java.lang.NoClassDefFoundError:javax / persistence / Persistence ... axis2和eclipselink

时间:2012-07-19 21:05:30

标签: netbeans eclipselink axis2

我想在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)         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)         在java.lang.reflect.Method.invoke(Method.java:597)         在org.apache.axis2.rpc.receivers.RPCUtil.invokeServiceClass(RPCUtil.java:194)         在org.apache.axis2.rpc.receivers.RPCInOnlyMessageReceiver.invokeBusinessLogic(RPCInOnlyMessageReceiver.java:63)         在org.apache.axis2.receivers.AbstractMessageReceiver.receive(AbstractMessageReceiver.java:114)         在org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:173)         在org.apache.axis2.transport.http.util.RESTUtil.invokeAxisEngine(RESTUtil.java:135)         在org.apache.axis2.transport.http.util.RESTUtil.processURLRequest(RESTUtil.java:130)         at 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.internalDoFilter(ApplicationFilterChain.java:290)         在org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)         at or or or or or or or or or or or or or or or or         在org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)         在org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)         在org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)         at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)         在org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)         at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)         在org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)         在org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)         在org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:849)         在org.apache.coyote.http11.Http11Protocol $ Http11ConnectionHandler.process(Http11Protocol.java:583)         在org.apache.tomcat.util.net.JIoEndpoint $ Worker.run(JIoEndpoint.java:454)         在java.lang.Thread.run(Thread.java:662) 引起:java.lang.ClassNotFoundException:未找到类:javax.persistence.Persistence         在org.apache.axis2.deployment.DeploymentClassLoader.findClass(DeploymentClassLoader.java:92)         at java.lang.ClassLoader.loadClass(ClassLoader.java:306)         在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,解决方案是添加到类路径中:hibernate-jpa-2.0-api-1.0.0.Final.jar,在此链接中{{3 }}

但我不知道EclipseLink的问题是什么我不知道我是否添加了其他库而且...非常感谢...

这是我的服务类

公共类LoginService {

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);

}

}

1 个答案:

答案 0 :(得分:1)

如果使用JPA 2.0,则需要javax.persistence_1.0.0.jar(如果仅使用JPA 1.0)或javax.persistence_2.0.4.v201112161009.jar中的javax.persistence类(jar可能会略微命名不同的是,这是与2.4里程碑一起发货的)。

这些将位于EclipseLink下载的jlib / jpa目录中。