使用 client-ejb jar 查找远程 ejb
我将应用程序打包为 .ear 文件,其中包含 ejb 模块。有无状态会话 bean 实现远程接口。类似这样的:
package my.package.ext.impl;
[...]
@Stateless(name = "MyPropertiesHandler", mappedName = "ejb/MyPropertiesHandler")
public class PropertiesHandler implements PropertiesHandlerRemote {
[...]
}
还有这样的:
package my.package.ext;
[...]
@Remote
public interface PropertiesHandlerRemote {
[...]
}
还生成了 client-ejb jar,里面有业务远程接口和其他一些东西。
此 client-ejb jar 作为 Maven 依赖项附加到其他应用程序。
我尝试从此应用程序查找 PropertiesHandler 服务:
PropertiesHandlerRemote propertiesHandler = InitialContext.doLookup(
"ejb/MyPropertiesHandler#my.package.ext.PropertiesHandlerRemote");
此时我收到以下错误:
java.lang.NoClassDefFoundError: my/package/ext/PropertiesHandlerRemote
at [...]
at sun.reflect.GeneratedMethodAccessor633.invoke(Unknown Source)
Truncated. see log file for complete stacktrace
Caused By: java.lang.ClassNotFoundException: my.package.ext.PropertiesHandlerRemote
at weblogic.utils.classloaders.GenericClassLoader.findLocalClass(GenericClassLoader.java:297)
at weblogic.utils.classloaders.GenericClassLoader.findClass(GenericClassLoader.java:270)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
at weblogic.utils.classloaders.GenericClassLoader.loadClass(GenericClassLoader.java:179)
Truncated. see log file for complete stacktrace
我在 Weblogic 10.x 上运行它,如上所示。
有什么想法出错了吗?
I have application packed as an .ear file with ejb module inside. There is stateless session bean implementing remote interface. Something like this:
package my.package.ext.impl;
[...]
@Stateless(name = "MyPropertiesHandler", mappedName = "ejb/MyPropertiesHandler")
public class PropertiesHandler implements PropertiesHandlerRemote {
[...]
}
and this:
package my.package.ext;
[...]
@Remote
public interface PropertiesHandlerRemote {
[...]
}
There's also client-ejb jar generated, there are business remote interface and some other stuff inside.
This client-ejb jar is attached to other application as a Maven dependency.
I try to look-up PropertiesHandler service from this application:
PropertiesHandlerRemote propertiesHandler = InitialContext.doLookup(
"ejb/MyPropertiesHandler#my.package.ext.PropertiesHandlerRemote");
At this moment I get following error:
java.lang.NoClassDefFoundError: my/package/ext/PropertiesHandlerRemote
at [...]
at sun.reflect.GeneratedMethodAccessor633.invoke(Unknown Source)
Truncated. see log file for complete stacktrace
Caused By: java.lang.ClassNotFoundException: my.package.ext.PropertiesHandlerRemote
at weblogic.utils.classloaders.GenericClassLoader.findLocalClass(GenericClassLoader.java:297)
at weblogic.utils.classloaders.GenericClassLoader.findClass(GenericClassLoader.java:270)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
at weblogic.utils.classloaders.GenericClassLoader.loadClass(GenericClassLoader.java:179)
Truncated. see log file for complete stacktrace
I run it on Weblogic 10.x as you can see above.
Any ideas that's going wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
问题在于 client-ejb jar 打包在 Ear 文件的根目录中,而不是包含其他依赖项的 /lib 文件夹中。
解决方案是在您所在项目的 pom 中使用
client
标记而不是ejb-client
想要使用您的 client-ejb jar 文件。这里也讨论了这个问题:http://jira.codehaus.org/browse/MEAR-85< /a>
奇怪的是,这是我第一次遇到这样的问题,以前的
ejb-client
标签工作得很好。The problem was that the client-ejb jar was packed in the root of an ear file, not in the /lib folder with other dependencies.
The solution is to use
<classifier>client</classifier>
tag instead of<type>ejb-client</type>
in the pom of the project where you want to use your client-ejb jar file.This problem is also discussed here: http://jira.codehaus.org/browse/MEAR-85
Strange that this is the first time I met such problem, previously
<type>ejb-client</type>
tag worked perfect.由于您有
NoClassDefFoundError
,这并不意味着您的PropertiesHandlerRemote
类未找到,而是您的实现使用的某些内容 - 所以也许您还有其他不存在的依赖项客户端的类路径?Since you have a
NoClassDefFoundError
, it does not mean yourPropertiesHandlerRemote
class is not found, but something which is used by your implementation - so maybe you have further dependencies which are not in the client's classpath?