使用 Hibernate 在 Weblogic 10.3 上部署 Web 服务时出现 ClassNotFoundException
我有一个使用 EJB 实现 JWS Web 服务的项目,如下所示:
@Stateless
@Remote(WebServiceTest.class)
@WebService(
serviceName="TestService",
name="TestName"
)
public class WebServiceTestImpl implements WebServiceTest {
@Override
@WebMethod(operationName="hello")
public String hello() {
return "Hello World!";
}
}
我使用一个简单的 EAR 项目在 WebLogic 10.3 上完美地部署和测试了该服务。现在我需要在我的项目中使用 Hibernate,所以根据以前的经验,我知道我必须从 Hibernate 使用 Antrl,而不是从容器,所以我在 EAR 项目中创建一个 weblogic-application.xml:
<?xml version="1.0" encoding="UTF-8"?>
<wls:weblogic-application ...>
<wls:prefer-application-packages>
<wls:package-name>antlr.*</wls:package-name>
</wls:prefer-application-packages>
</wls:weblogic-application>
现在,当我部署 EAR 时我收到此错误:
Unable to deploy EJB: WebServiceTestImpl from test-1.0.0-SNAPSHOT.jar:
***** ASSERTION FAILED *****
at weblogic.ejb.container.deployer.EJBModule.prepare(EJBModule.java:467)
at weblogic.application.internal.flow.ModuleListenerInvoker.prepare(ModuleListenerInvoker.java:199)
at weblogic.application.internal.flow.DeploymentCallbackFlow$1.next(DeploymentCallbackFlow.java:507)
at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:41)
at weblogic.application.internal.flow.DeploymentCallbackFlow.prepare(DeploymentCallbackFlow.java:149)
Truncated. see log file for complete stacktrace
Caused By: java.lang.ClassNotFoundException: test.WebServiceTestImpl_zd33dy_WSOImpl
at weblogic.utils.classloaders.GenericClassLoader.findLocalClass(GenericClassLoader.java:280)
at weblogic.utils.classloaders.GenericClassLoader.findClass(GenericClassLoader.java:253)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
at weblogic.utils.classloaders.GenericClassLoader.loadClass(GenericClassLoader.java:177)
Truncated. see log file for complete stacktrace
我该如何解决这个问题?如果我不将 Antlr 放入 wls:prefer-application-packages Hibernate 将无法工作,如果我将其放入,我将无法部署 Web 服务...
I have a project with a EJB implementing a JWS Webservice, like this:
@Stateless
@Remote(WebServiceTest.class)
@WebService(
serviceName="TestService",
name="TestName"
)
public class WebServiceTestImpl implements WebServiceTest {
@Override
@WebMethod(operationName="hello")
public String hello() {
return "Hello World!";
}
}
I deploy and test this perfectly on WebLogic 10.3 using a simple EAR project. Now I need to use Hibernate on my project, so from previous experiences I know that I have to use Antrl from Hibernate and not from the container, so I create a weblogic-application.xml in the EAR project:
<?xml version="1.0" encoding="UTF-8"?>
<wls:weblogic-application ...>
<wls:prefer-application-packages>
<wls:package-name>antlr.*</wls:package-name>
</wls:prefer-application-packages>
</wls:weblogic-application>
Now when I deploy the EAR I get this error:
Unable to deploy EJB: WebServiceTestImpl from test-1.0.0-SNAPSHOT.jar:
***** ASSERTION FAILED *****
at weblogic.ejb.container.deployer.EJBModule.prepare(EJBModule.java:467)
at weblogic.application.internal.flow.ModuleListenerInvoker.prepare(ModuleListenerInvoker.java:199)
at weblogic.application.internal.flow.DeploymentCallbackFlow$1.next(DeploymentCallbackFlow.java:507)
at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:41)
at weblogic.application.internal.flow.DeploymentCallbackFlow.prepare(DeploymentCallbackFlow.java:149)
Truncated. see log file for complete stacktrace
Caused By: java.lang.ClassNotFoundException: test.WebServiceTestImpl_zd33dy_WSOImpl
at weblogic.utils.classloaders.GenericClassLoader.findLocalClass(GenericClassLoader.java:280)
at weblogic.utils.classloaders.GenericClassLoader.findClass(GenericClassLoader.java:253)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
at weblogic.utils.classloaders.GenericClassLoader.loadClass(GenericClassLoader.java:177)
Truncated. see log file for complete stacktrace
How can I solve this? If I don't put Antlr in wls:prefer-application-packages Hibernate will not work, and if I put it I cannot deploy the webservice...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
即使您进行了新的/更新的部署,Weblogic 也会以某种方式保留 EJB 的预编译版本。
这对我来说适用于 wls 10.3.5:
在您的域的服务器目录中(例如,在我的情况下为/home/myUser/apps/bea/domains/myDomain/servers/AdminServer)有一个子文件夹“cache/EJBCompilerCache”。停止您的 weblogic 实例并删除该子文件夹的内容。重新启动 weblogic 一切都会正常:-)
Weblogic somehow keeps precompiled versions of EJBs even though you do a new/update deployment.
this works for me with wls 10.3.5:
within the server directory of your domain (e.g. in my case /home/myUser/apps/bea/domains/myDomain/servers/AdminServer) there is a subfolder "cache/EJBCompilerCache". Stop your weblogic instance and remove the contents of this subfolder. Restart weblogic and everything will work :-)
我不确定这是否是同一个错误,但 Weblogic 10.3.0-2 中有一个已知错误,在将 JaxWS 与 EJB v 2.x 一起使用时会导致出现问题。但是,当我将 @WebService 注释放在 Weblogic 10.3.1 上的 EJB v 3.0 上时,我遇到了几乎相同的错误。该错误正在加载看起来像是 Weblogic 创建的假定生成的本地存根的内容,并且它发生在 Weblogic 10.3.0、10.3.1、10.3.2 和 10.3.3 上。 (是的,我真的把它们都部署好了;)
I'm not sure if this is the same bug, but there is a known bug in Weblogic 10.3.0-2 that causes a problem when using JaxWS with an EJB v 2.x. But I'm getting a near identical error when I put the @WebService annotation on an EJB v 3.0 on Weblogic 10.3.1. The error is loading what looks like the supposedly generated local stubs that Weblogic creates, and its happening on Weblogic 10.3.0, 10.3.1, 10.3.2, and 10.3.3. (yes, I really have them all deployed ;)
我在部署会话 bean 然后尝试将其转换为 Web 服务时遇到了这个问题。 WebLogic 似乎以某种方式缓存会话 bean。
对此有几种解决方案:
- 重命名 slsb。
- 注释@Stateless和@Remote注释,部署应用程序,取消注释注释,再次重新部署。
- 反弹 WebLogic。
I had this problem deploying session bean and then trying to convert it to web service. WebLogic seems to cache session beans somehow.
There are several solution to this:
- Rename slsb.
- Comment @Stateless and @Remote annotations, deploy application, uncomment annotations, redeploy again.
- Bounce WebLogic.