gpt4 book ai didi

java - 创建 Activity RAR 时出错 + 在 JAVA 中找不到 ResourceAdapterImpl 类

转载 作者:行者123 更新时间:2023-12-03 23:14:53 24 4
gpt4 key购买 nike

我已经用 Glassfish V 4.0 和 postgre sql 分别作为服务器和数据库创建了一个 EJB 包。 Glassfish 和 postgre 是远程安装的。

我已经创建了一个连接池和JNDI

如果需要更多详细信息,请告诉我

当我运行我的类文件时,出现以下错误

Dec 17, 2013 10:47:16 AM com.sun.enterprise.connectors.ActiveRAFactory   
createActiveResourceAdapter

SEVERE: RAR6001 : Class Not found : com.sun.gjc.spi.ResourceAdapterImpl
Dec 17, 2013 10:47:16 AM com.sun.enterprise.connectors.ActiveRAFactory
createActiveResourceAdapter
SEVERE:
com.sun.appserv.connectors.internal.api.ConnectorRuntimeException: Error in creating
active RAR
at com.sun.enterprise.connectors.ActiveRAFactory.createActiveResourceAdapter(ActiveRAFactory.java:111)
at com.sun.enterprise.connectors.service.ResourceAdapterAdminServiceImpl.createActiveResourceAdapter(ResourceAdapterAdminServiceImpl.java:210)
at com.sun.enterprise.connectors.ConnectorRuntime.createActiveResourceAdapter(ConnectorRuntime.java:427)
at com.sun.enterprise.resource.naming.ConnectorObjectFactory.getObjectInstance(ConnectorObjectFactory.java:107)
at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:321)
at com.sun.enterprise.naming.impl.SerialContext.getObjectInstance(SerialContext.java:527)
at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:487)
at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:438)
at javax.naming.InitialContext.lookup(InitialContext.java:411)
at sg.edu.astar.taxi360.dao.impl.DBConnection.<clinit>(DBConnection.java:24)
at sg.edu.astar.taxi360.dao.dummy.main(dummy.java:22)

Caused by: java.lang.ClassNotFoundException: com.sun.gjc.spi.ResourceAdapterImpl
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at com.sun.enterprise.connectors.ActiveRAFactory.createActiveResourceAdapter(ActiveRAFactory.java:102)
... 10 more

我的类文件有main方法

public static void main(String args[])
{
dummy p = new dummy();
PreparedStatement stmt = null;
String sql="";
try(Connection connection = DBConnection.getConnection();)
{
sql = "INSERT INTO databasename.request (requestId)" +
"VALUES (?)";
stmt = connection.prepareStatement(sql);
stmt.setString(1, "1324");
stmt.executeQuery();
}
catch(Exception ex){

}
}

DBConnection 类文件包含以下详细信息

public class DBConnection {
private static DataSource ds;
static {
try {
InitialContext ctx = new InitialContext();
ds = (DataSource) ctx.lookup("jdbc/databasename");
} catch (NamingException ex) {
Logger.getLogger(DBConnection.class.getName()).log(Level.SEVERE,null,ex);
}
}


public static Connection getConnection() {
Connection connection = null;
try {
connection = ds.getConnection();

} catch (SQLException ex) {
Logger.getLogger(DBConnection.class.getName()).log(Level.SEVERE, null, ex);
}
return connection;
}
}

提前致谢

最佳答案

我通过将 glassfish-embedded-all 添加到我的 pom.xml 解决了这个问题:

<dependency>
<groupId>org.glassfish.main.extras</groupId>
<artifactId>glassfish-embedded-all</artifactId>
<version>3.1.2.2</version>
</dependency>

关于java - 创建 Activity RAR 时出错 + 在 JAVA 中找不到 ResourceAdapterImpl 类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20625157/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com