0

我想在 netbeans 中部署axis2 web 服务,我在netbeans 中安装了插件axis2。我也使用 EclipseLink 2.0 连接数据库。当我在我创建的主类中使用时,我的连接成功。但是,当我尝试通过右键单击服务在 netbeans 中测试我的 Web 服务时,会抛出此异常:

[错误] javax/persistence/Persistence java.lang.NoClassDefFoundError: javax/persistence/Persistence at db.util.ManageConnection.getStatsEntityManagerFactory(ManageConnection.java:33) at services.LoginService.loginService(LoginService.java:31) at sun。 reflect.NativeMethodAccessorImpl.invoke0(Native Method) 在 sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) 在 sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 在 java.lang.reflect.Method.invoke( Method.java:597) at org.apache.axis2.rpc.receivers.RPCUtil.invokeServiceClass(RPCUtil.java:194) at org.apache.axis2.rpc.receivers.RPCInOnlyMessageReceiver.invokeBusinessLogic(RPCInOnlyMessageReceiver.java:63) at org .apache.axis2.receivers.AbstractMessageReceiver。在 org.apache.axis2.transport.http.util.RESTUtil.invokeAxisEngine(RESTUtil.java:135) 的 org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:173) 接收(AbstractMessageReceiver.java:114)在 org.apache.axis2.transport.http.util.RESTUtil.processURLRequest(RESTUtil.java:130) 在 org.apache.axis2.transport.http.AxisServlet$RestRequestProcessor.processURLRequest(AxisServlet.java:825) 在 org.apache .axis2.transport.http.AxisServlet.doGet(AxisServlet.java:271) 在 javax.servlet.http.HttpServlet.service(HttpServlet.java:617) 在 javax.servlet.http.HttpServlet.service(HttpServlet.java:717 ) 在 org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java: org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)206) 在 org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) 在 org.apache.catalina 的 org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:390) .core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) 在 org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233) 在 org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191 ) 在 org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) 在 org.apache.catalina.core.StandardEngineValve 的 org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)。在 org.apache.catalina.connector.CoyoteAdapter.service 调用(StandardEngineValve.java:109)(CoyoteAdapter.java:293) 在 org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583) 在 org.apache.tomcat.util 的 org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:849) .net.JIoEndpoint$Worker.run(JIoEndpoint.java:454) at java.lang.Thread.run(Thread.java:662) 原因:java.lang.ClassNotFoundException: Class Not found : javax.persistence.Persistence at org .apache.axis2.deployment.DeploymentClassLoader.findClass(DeploymentClassLoader.java:92) at java.lang.ClassLoader.loadClass(ClassLoader.java:306) at org.apache.axis2.deployment.DeploymentClassLoader.loadClass(DeploymentClassLoader.java:273 ) 在 java.lang.ClassLoader.loadClass(ClassLoader.java:247) ... 还有 31 个 [错误] org.apache.axis2.AxisFault: javax/persistence/Persistenceorg.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583) 在 org.apache.tomcat.util.net.JIoEndpoint$ 的 apache.coyote.http11.Http11Processor.process(Http11Processor.java:849) java.lang.Thread.run(Thread.java:662) 的 Worker.run(JIoEndpoint.java:454) 原因:java.lang.ClassNotFoundException:找不到类:org.apache.axis2 的 javax.persistence.Persistence。 deployment.DeploymentClassLoader.findClass(DeploymentClassLoader.java:92) 在 java.lang.ClassLoader.loadClass(ClassLoader.java:306) 在 org.apache.axis2.deployment.DeploymentClassLoader.loadClass(DeploymentClassLoader.java:273) 在 java.lang .ClassLoader.loadClass(ClassLoader.java:247) ... 还有 31 个 [错误] org.apache.axis2.AxisFault: javax/persistence/Persistenceorg.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583) 在 org.apache.tomcat.util.net.JIoEndpoint$ 的 apache.coyote.http11.Http11Processor.process(Http11Processor.java:849) java.lang.Thread.run(Thread.java:662) 的 Worker.run(JIoEndpoint.java:454) 原因:java.lang.ClassNotFoundException:找不到类:org.apache.axis2 的 javax.persistence.Persistence。 deployment.DeploymentClassLoader.findClass(DeploymentClassLoader.java:92) 在 java.lang.ClassLoader.loadClass(ClassLoader.java:306) 在 org.apache.axis2.deployment.DeploymentClassLoader.loadClass(DeploymentClassLoader.java:273) 在 java.lang .ClassLoader.loadClass(ClassLoader.java:247) ... 还有 31 个 [错误] org.apache.axis2.AxisFault: javax/persistence/Persistence在 org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint. java:454) at java.lang.Thread.run(Thread.java:662) 原因:java.lang.ClassNotFoundException:找不到类:org.apache.axis2.deployment.DeploymentClassLoader.findClass( DeploymentClassLoader.java:92) 在 java.lang.ClassLoader.loadClass(ClassLoader.java:306) 在 org.apache.axis2.deployment.DeploymentClassLoader.loadClass(DeploymentClassLoader.java:273) 在 java.lang.ClassLoader.loadClass(ClassLoader .java:247) ... 还有 31 个 [错误] org.apache.axis2.AxisFault: javax/persistence/Persistence在 org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint. java:454) at java.lang.Thread.run(Thread.java:662) 原因:java.lang.ClassNotFoundException:找不到类:org.apache.axis2.deployment.DeploymentClassLoader.findClass( DeploymentClassLoader.java:92) 在 java.lang.ClassLoader.loadClass(ClassLoader.java:306) 在 org.apache.axis2.deployment.DeploymentClassLoader.loadClass(DeploymentClassLoader.java:273) 在 java.lang.ClassLoader.loadClass(ClassLoader .java:247) ... 还有 31 个 [错误] org.apache.axis2.AxisFault: javax/persistence/Persistencecoyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583) at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:454) at java.lang.Thread.run(Thread. java:662) 原因:java.lang.ClassNotFoundException: 类未找到:javax.persistence.Persistence at org.apache.axis2.deployment.DeploymentClassLoader.findClass(DeploymentClassLoader.java:92) at java.lang.ClassLoader.loadClass( ClassLoader.java:306) at org.apache.axis2.deployment.DeploymentClassLoader.loadClass(DeploymentClassLoader.java:273) at java.lang.ClassLoader.loadClass(ClassLoader.java:247) ... 还有 31 个 [错误] org. apache.axis2.AxisFault:javax/persistence/Persistencecoyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583) at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:454) at java.lang.Thread.run(Thread. java:662) 原因:java.lang.ClassNotFoundException: 类未找到:javax.persistence.Persistence at org.apache.axis2.deployment.DeploymentClassLoader.findClass(DeploymentClassLoader.java:92) at java.lang.ClassLoader.loadClass( ClassLoader.java:306) at org.apache.axis2.deployment.DeploymentClassLoader.loadClass(DeploymentClassLoader.java:273) at java.lang.ClassLoader.loadClass(ClassLoader.java:247) ... 还有 31 个 [错误] org. apache.axis2.AxisFault:javax/persistence/Persistencejava.lang.Thread.run(Thread.java:662) 处的 JioEndpoint$Worker.run(JIoEndpoint.java:454) 原因:java.lang.ClassNotFoundException:找不到类:org.apache 处的 javax.persistence.Persistence。 axis2.deployment.DeploymentClassLoader.findClass(DeploymentClassLoader.java:92) 在 java.lang.ClassLoader.loadClass(ClassLoader.java:306) 在 org.apache.axis2.deployment.DeploymentClassLoader.loadClass(DeploymentClassLoader.java:273) 在 java .lang.ClassLoader.loadClass(ClassLoader.java:247) ... 还有 31 个 [错误] org.apache.axis2.AxisFault: javax/persistence/Persistencejava.lang.Thread.run(Thread.java:662) 处的 JioEndpoint$Worker.run(JIoEndpoint.java:454) 原因:java.lang.ClassNotFoundException:找不到类:org.apache 处的 javax.persistence.Persistence。 axis2.deployment.DeploymentClassLoader.findClass(DeploymentClassLoader.java:92) 在 java.lang.ClassLoader.loadClass(ClassLoader.java:306) 在 org.apache.axis2.deployment.DeploymentClassLoader.loadClass(DeploymentClassLoader.java:273) 在 java .lang.ClassLoader.loadClass(ClassLoader.java:247) ... 还有 31 个 [错误] org.apache.axis2.AxisFault: javax/persistence/PersistencefindClass(DeploymentClassLoader.java:92) at java.lang.ClassLoader.loadClass(ClassLoader.java:306) at org.apache.axis2.deployment.DeploymentClassLoader.loadClass(DeploymentClassLoader.java:273) at java.lang.ClassLoader.loadClass (ClassLoader.java:247) ... 还有 31 个 [错误] org.apache.axis2.AxisFault: javax/persistence/PersistencefindClass(DeploymentClassLoader.java:92) at java.lang.ClassLoader.loadClass(ClassLoader.java:306) at org.apache.axis2.deployment.DeploymentClassLoader.loadClass(DeploymentClassLoader.java:273) at java.lang.ClassLoader.loadClass (ClassLoader.java:247) ... 还有 31 个 [错误] org.apache.axis2.AxisFault: javax/persistence/Persistence

我可以部署其他不包含与 eclipselink (entityManager...) 的连接的服务。

我在其他论坛中发现了同样的问题,但他们使用的是休眠,解决方案是添加到类路径中:hibernate-jpa-2.0-api-1.0.0.Final.jar,在这个链接http://www。 coderanch.com/t/513512/ORM/databases/Error-java-lang-NoClassDefFoundError-javax

但我不知道 EclipseLink 有什么问题我不知道我是否添加其他库以及在哪里.. 非常感谢...

这是我的服务班

公共类登录服务 {

EntityManagerFactory emf = ManageConnection.
    getStatsEntityManagerFactory(PersistenceConfiguration.
    getPERSISTENCE_UNIT_NAME());

public String prubaServicioWeb(String nombre) {
    return nombre + " Welcome";

}

public void loginService(String whatever) {

    BankJpaController bankController = new
    BankJpaController(emf);
    Bank bank = new Bank();
    bank.setId(null);
    bank.setBankCode("BNSJ");
    bank.setName("Bank of America");
    bankController.create(bank);

}

}

4

1 回答 1

1

您需要 javax.persistence_1.0.0.jar(如果仅使用 JPA 1.0)或 javax.persistence_2.0.4.v201112161009.jar(如果使用 JPA 2.0)中的 javax.persistence 类(jar 的名称可能略有不同,这是 2.4 里程碑附带的东西)。

These will be in the jlib/jpa directory of your EclipseLink download.

于 2012-07-20T16:17:39.360 回答