4

目前我在 glassfish 4 上部署 .ear 文件时遇到问题。这有一个 JPA 应用程序,我正在使用 EJB 启动会话模块来测试它。当我在本地 glassfish 服务器上部署此应用程序时,出现以下错误。

“java.lang.NoClassDefFoundError:javax/persistence/EntityManager”。

我已确保将所有必需的库包含到类路径中。谁能帮我确定是什么问题?

以下是完整的错误日志:

2013-11-05T15:08:31.330-0500] [glassfish 4.0] [INFO] [] [javax.enterprise.system.tools.deployment.common] [tid: _ThreadID=32 _ThreadName=admin-listener(1)] [timeMillis: 1383682111330] [levelValue: 800] [[
  visiting unvisited references]]

[2013-11-05T15:08:31.500-0500] [glassfish 4.0] [INFO] [] [javax.enterprise.system.tools.deployment.common] [tid: _ThreadID=32 _ThreadName=admin-listener(1)] [timeMillis: 1383682111500] [levelValue: 800] [[
  visiting unvisited references]]

[2013-11-05T15:08:31.505-0500] [glassfish 4.0] [SEVERE] [] [global] [tid: _ThreadID=32 _ThreadName=admin-listener(1)] [timeMillis: 1383682111505] [levelValue: 1000] [[
  Class [ javax/persistence/EntityManager ] not found. Error while loading [ class edu.stevens.cs548.clinic.domain.PatientDAO ]]]

[2013-11-05T15:08:31.505-0500] [glassfish 4.0] [SEVERE] [] [global] [tid: _ThreadID=32 _ThreadName=admin-listener(1)] [timeMillis: 1383682111505] [levelValue: 1000] [[
  Class [ javax/persistence/EntityManager ] not found. Error while loading [ class edu.stevens.cs548.clinic.domain.ProviderDAO ]]]

[2013-11-05T15:08:31.594-0500] [glassfish 4.0] [INFO] [] [org.eclipse.persistence.session.file:/users/ganu/ec2/glassfish4/glassfish/domains/domain1/eclipseApps/Clinic/lib/ClinicDomain_1.jar/_ClinicDomain_1] [tid: _ThreadID=32 _ThreadName=admin-listener(1)] [timeMillis: 1383682111594] [levelValue: 800] [[
  EclipseLink, version: Eclipse Persistence Services - 2.5.0.v20130507-3faac2b]]

[2013-11-05T15:08:31.601-0500] [glassfish 4.0] [INFO] [] [org.eclipse.persistence.session.file:/users/ganu/ec2/glassfish4/glassfish/domains/domain1/eclipseApps/Clinic/lib/ClinicDomain_1.jar/_ClinicDomain_1.connection] [tid: _ThreadID=32 _ThreadName=admin-listener(1)] [timeMillis: 1383682111601] [levelValue: 800] [[
  file:/users/ganu/ec2/glassfish4/glassfish/domains/domain1/eclipseApps/Clinic/lib/ClinicDomain_1.jar/_ClinicDomain_1 login successful]]

[2013-11-05T15:08:31.605-0500] [glassfish 4.0] [WARNING] [] [org.eclipse.persistence.default] [tid: _ThreadID=32 _ThreadName=admin-listener(1)] [timeMillis: 1383682111605] [levelValue: 900] [[
  The collection of metamodel types is empty. Model classes may not have been found during entity search for Java SE and some Java EE container managed persistence units.  Please verify that your entity classes are referenced in persistence.xml using either <class> elements or a global <exclude-unlisted-classes>false</exclude-unlisted-classes> element]]

[2013-11-05T15:08:31.606-0500] [glassfish 4.0] [WARNING] [] [javax.org.glassfish.persistence.org.glassfish.persistence.common] [tid: _ThreadID=32 _ThreadName=admin-listener(1)] [timeMillis: 1383682111606] [levelValue: 900] [[
  Cannot create tables for application Clinic. The expected DDL file default_ClinicDomain_1_createDDL.jdbc is not available.]]

[2013-11-05T15:08:31.614-0500] [glassfish 4.0] [INFO] [ejb.portable_jndi_names] [javax.enterprise.system.container.ejb.com.sun.ejb.containers] [tid: _ThreadID=32 _ThreadName=admin-listener(1)] [timeMillis: 1383682111614] [levelValue: 800] [[
  EJB5181:Portable JNDI names for EJB Test: [java:global/Clinic/ClinicTest/Test!edu.stevens.cs548.clinic.test.Test, java:global/Clinic/ClinicTest/Test]]]

[2013-11-05T15:08:31.836-0500] [glassfish 4.0] [INFO] [] [edu.stevens.cs548.clinic.test.Test] [tid: _ThreadID=32 _ThreadName=admin-listener(1)] [timeMillis: 1383682111836] [levelValue: 800] [[
  Initializing the user database.#######]]

[2013-11-05T15:08:31.837-0500] [glassfish 4.0] [INFO] [] [edu.stevens.cs548.clinic.test.Test] [tid: _ThreadID=32 _ThreadName=admin-listener(1)] [timeMillis: 1383682111837] [levelValue: 800] [[
  Creating provider enrtity.######]]

[2013-11-05T15:08:31.837-0500] [glassfish 4.0] [INFO] [] [edu.stevens.cs548.clinic.test.Test] [tid: _ThreadID=32 _ThreadName=admin-listener(1)] [timeMillis: 1383682111837] [levelValue: 800] [[
  Created provider enrtity.######]]

[2013-11-05T15:08:31.839-0500] [glassfish 4.0] [SEVERE] [] [javax.enterprise.system.tools.deployment.common] [tid: _ThreadID=32 _ThreadName=admin-listener(1)] [timeMillis: 1383682111839] [levelValue: 1000] [[
  Exception while invoking class org.glassfish.ejb.startup.EjbApplication start method
javax.ejb.EJBException: javax.ejb.CreateException: Initialization failed for Singleton Test
    at com.sun.ejb.containers.AbstractSingletonContainer$SingletonContextFactory.create(AbstractSingletonContainer.java:656)
    at com.sun.ejb.containers.AbstractSingletonContainer.instantiateSingletonInstance(AbstractSingletonContainer.java:396)
    at org.glassfish.ejb.startup.SingletonLifeCycleManager.initializeSingleton(SingletonLifeCycleManager.java:219)
    at org.glassfish.ejb.startup.SingletonLifeCycleManager.initializeSingleton(SingletonLifeCycleManager.java:180)
    at org.glassfish.ejb.startup.SingletonLifeCycleManager.doStartup(SingletonLifeCycleManager.java:158)
    at org.glassfish.ejb.startup.EjbApplication.start(EjbApplication.java:166)
    at org.glassfish.internal.data.EngineRef.start(EngineRef.java:122)
    at org.glassfish.internal.data.ModuleInfo.start(ModuleInfo.java:291)
    at org.glassfish.internal.data.ApplicationInfo.start(ApplicationInfo.java:352)
    at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:497)
    at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:219)
    at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:491)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.java:527)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.java:523)
    at java.security.AccessController.doPrivileged(Native Method)
    at javax.security.auth.Subject.doAs(Subject.java:356)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$2.execute(CommandRunnerImpl.java:522)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:546)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1423)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1500(CommandRunnerImpl.java:108)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1762)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1674)
    at com.sun.enterprise.v3.admin.AdminAdapter.doCommand(AdminAdapter.java:534)
    at com.sun.enterprise.v3.admin.AdminAdapter.onMissingResource(AdminAdapter.java:224)
    at org.glassfish.grizzly.http.server.StaticHttpHandler.service(StaticHttpHandler.java:297)
    at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:246)
    at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:191)
    at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:168)
    at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:189)
    at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:288)
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:206)
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:136)
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:114)
    at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
    at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:838)
    at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:113)
    at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:115)
    at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:55)
    at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:135)
    at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:564)
    at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:544)
    at java.lang.Thread.run(Thread.java:724)
Caused by: javax.ejb.CreateException: Initialization failed for Singleton Test
    at com.sun.ejb.containers.AbstractSingletonContainer.createSingletonEJB(AbstractSingletonContainer.java:483)
    at com.sun.ejb.containers.AbstractSingletonContainer.access$000(AbstractSingletonContainer.java:81)
    at com.sun.ejb.containers.AbstractSingletonContainer$SingletonContextFactory.create(AbstractSingletonContainer.java:654)
    ... 42 more
Caused by: java.lang.Exception: java.lang.NoClassDefFoundError: javax/persistence/EntityManager
    at com.sun.ejb.containers.interceptors.CallbackInvocationContext.proceed(CallbackInvocationContext.java:209)
    at org.jboss.weld.ejb.AbstractEJBRequestScopeActivationInterceptor.aroundInvoke(AbstractEJBRequestScopeActivationInterceptor.java:55)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at com.sun.ejb.containers.interceptors.CallbackInterceptor.intercept(InterceptorManager.java:986)
    at com.sun.ejb.containers.interceptors.CallbackChainImpl.invokeNext(CallbackChainImpl.java:72)
    at com.sun.ejb.containers.interceptors.CallbackInvocationContext.proceed(CallbackInvocationContext.java:205)
    at com.sun.ejb.containers.interceptors.SystemInterceptorProxy.doCall(SystemInterceptorProxy.java:163)
    at com.sun.ejb.containers.interceptors.SystemInterceptorProxy.init(SystemInterceptorProxy.java:125)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at com.sun.ejb.containers.interceptors.CallbackInterceptor.intercept(InterceptorManager.java:986)
    at com.sun.ejb.containers.interceptors.CallbackChainImpl.invokeNext(CallbackChainImpl.java:72)
    at com.sun.ejb.containers.interceptors.InterceptorManager.intercept(InterceptorManager.java:412)
    at com.sun.ejb.containers.interceptors.InterceptorManager.intercept(InterceptorManager.java:375)
    at com.sun.ejb.containers.BaseContainer.intercept(BaseContainer.java:1949)
    at com.sun.ejb.containers.AbstractSingletonContainer.createSingletonEJB(AbstractSingletonContainer.java:475)
    ... 44 more
Caused by: java.lang.NoClassDefFoundError: javax/persistence/EntityManager
    at edu.stevens.cs548.clinic.domain.ProviderDAO.addProvider(ProviderDAO.java:72)
    at edu.stevens.cs548.clinic.test.Test.init(Test.java:66)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at com.sun.ejb.containers.interceptors.BeanCallbackInterceptor.intercept(InterceptorManager.java:1035)
    at com.sun.ejb.containers.interceptors.CallbackChainImpl.invokeNext(CallbackChainImpl.java:72)
    at com.sun.ejb.containers.interceptors.CallbackInvocationContext.proceed(CallbackInvocationContext.java:205)
    ... 64 more
4

1 回答 1

5

Get the javaee.jar file and include it in your project classpath.

http://mvnrepository.com/artifact/javax/javaee-api

Or

you can directly download from the below link

http://www.java2s.com/Code/Jar/j/Downloadjavaeeapi70jar.htm

The javax.persistence.Entity is a class inside the J2EE SDK library “javaee.jar“, you are missing this jar file in your project class-path.

于 2014-02-08T09:42:55.043 回答