JBoss EJB 客户端处理程序缺少参数
JBoss EJB Client handler missing argument
我正在尝试通过以下方式设置新的 InitialContext
(我认为这是非常标准的):
private static InitialContext getInitialContext() throws NamingException {
InitialContext context = null;
try {
Properties properties = new Properties();
properties.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");
properties.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory");
properties.put(Context.PROVIDER_URL, "remote://localhost:4447");
properties.put(Context.SECURITY_PRINCIPAL, "username");
properties.put(Context.SECURITY_CREDENTIALS, "password");
context = new InitialContext(properties);
System.out.println("\n\tGot initial Context: " + context);
}
catch (Exception e) {
e.printStackTrace();
}
return context;
}
public static void sendMessage(RoboticsParameters object_msg) throws Exception {
InitialContext context = getInitialContext();
// other code
}
代码 "fails" 在使用属性创建 new InitialContext
的那一行,我得到了 java.lang.NullPointerException
。我怀疑我错过了一个论点。这是堆栈跟踪:
WARN: EJB client integration will not be available due to a problem setting up the EJB client handler java.lang.NullPointerException
at org.jboss.naming.remote.client.InitialContextFactory.<clinit>(InitialContextFactory.java:118)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:348)
at com.sun.naming.internal.VersionHelper12.loadClass(VersionHelper12.java:72)
at com.sun.naming.internal.VersionHelper12.loadClass(VersionHelper12.java:61)
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:672)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:313)
at javax.naming.InitialContext.init(InitialContext.java:244)
at javax.naming.InitialContext.<init>(InitialContext.java:216)
有什么建议吗?
我是 运行 JBoss EAP 6.4 并使用 EJB 3。我在 class 路径中有 jboss-client.jar
。
我检查了源代码:
jboss-remote-naming/src/main/java/org/jboss/naming/remote/client/InitialContextFactory.java
并找到了日志消息的来源:
public class InitialContextFactory implements javax.naming.spi.InitialContextFactory {
// code
private static final String REMOTE_NAMING_EJB_CLIENT_HANDLER_CLASS_NAME = "org.jboss.naming.remote.client.ejb.RemoteNamingStoreEJBClientHandler";
// code
try {
klass = classLoader.loadClass(REMOTE_NAMING_EJB_CLIENT_HANDLER_CLASS_NAME);
method = klass.getMethod("setupEJBClientContext", new Class<?>[] {Properties.class, List.class});
} catch (Throwable t) {
logger.warn("EJB client integration will not be available due to a problem setting up the EJB client handler", t);
}
// other code
}
class org.jboss.naming.remote.client.ejb.RemoteNamingStoreEJBClientHandler
在我添加到 class 路径的 jar 中,但由于某些原因加载 class 时出现问题。
然后我在 [jboss_home]/bin/client
文件夹中偶然发现了这个 README-EJB-JMS.txt
小文件,其中包含以下内容:
“Maven 用户不应使用此 jar,而应改用以下 BOM 依赖项
<dependencies>
<dependency>
<groupId>org.jboss.as</groupId>
<artifactId>jboss-as-ejb-client-bom</artifactId>
<type>pom</type>
</dependency>
<dependency>
<groupId>org.jboss.as</groupId>
<artifactId>jboss-as-jms-client-bom</artifactId>
<type>pom</type>
</dependency>
</dependencies>
这是因为maven和shaded jar一起使用很有可能造成class版本冲突,这就是为什么
我们不会将此 jar 发布到 maven 存储库。"
所以,我添加了 maven 依赖项,而不是将 jar 放在我的 class 路径中,瞧!有效!
我正在尝试通过以下方式设置新的 InitialContext
(我认为这是非常标准的):
private static InitialContext getInitialContext() throws NamingException {
InitialContext context = null;
try {
Properties properties = new Properties();
properties.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");
properties.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory");
properties.put(Context.PROVIDER_URL, "remote://localhost:4447");
properties.put(Context.SECURITY_PRINCIPAL, "username");
properties.put(Context.SECURITY_CREDENTIALS, "password");
context = new InitialContext(properties);
System.out.println("\n\tGot initial Context: " + context);
}
catch (Exception e) {
e.printStackTrace();
}
return context;
}
public static void sendMessage(RoboticsParameters object_msg) throws Exception {
InitialContext context = getInitialContext();
// other code
}
代码 "fails" 在使用属性创建 new InitialContext
的那一行,我得到了 java.lang.NullPointerException
。我怀疑我错过了一个论点。这是堆栈跟踪:
WARN: EJB client integration will not be available due to a problem setting up the EJB client handler java.lang.NullPointerException
at org.jboss.naming.remote.client.InitialContextFactory.<clinit>(InitialContextFactory.java:118)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:348)
at com.sun.naming.internal.VersionHelper12.loadClass(VersionHelper12.java:72)
at com.sun.naming.internal.VersionHelper12.loadClass(VersionHelper12.java:61)
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:672)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:313)
at javax.naming.InitialContext.init(InitialContext.java:244)
at javax.naming.InitialContext.<init>(InitialContext.java:216)
有什么建议吗?
我是 运行 JBoss EAP 6.4 并使用 EJB 3。我在 class 路径中有 jboss-client.jar
。
我检查了源代码:
jboss-remote-naming/src/main/java/org/jboss/naming/remote/client/InitialContextFactory.java
并找到了日志消息的来源:
public class InitialContextFactory implements javax.naming.spi.InitialContextFactory {
// code
private static final String REMOTE_NAMING_EJB_CLIENT_HANDLER_CLASS_NAME = "org.jboss.naming.remote.client.ejb.RemoteNamingStoreEJBClientHandler";
// code
try {
klass = classLoader.loadClass(REMOTE_NAMING_EJB_CLIENT_HANDLER_CLASS_NAME);
method = klass.getMethod("setupEJBClientContext", new Class<?>[] {Properties.class, List.class});
} catch (Throwable t) {
logger.warn("EJB client integration will not be available due to a problem setting up the EJB client handler", t);
}
// other code
}
class org.jboss.naming.remote.client.ejb.RemoteNamingStoreEJBClientHandler
在我添加到 class 路径的 jar 中,但由于某些原因加载 class 时出现问题。
然后我在 [jboss_home]/bin/client
文件夹中偶然发现了这个 README-EJB-JMS.txt
小文件,其中包含以下内容:
“Maven 用户不应使用此 jar,而应改用以下 BOM 依赖项
<dependencies>
<dependency>
<groupId>org.jboss.as</groupId>
<artifactId>jboss-as-ejb-client-bom</artifactId>
<type>pom</type>
</dependency>
<dependency>
<groupId>org.jboss.as</groupId>
<artifactId>jboss-as-jms-client-bom</artifactId>
<type>pom</type>
</dependency>
</dependencies>
这是因为maven和shaded jar一起使用很有可能造成class版本冲突,这就是为什么 我们不会将此 jar 发布到 maven 存储库。"
所以,我添加了 maven 依赖项,而不是将 jar 放在我的 class 路径中,瞧!有效!