How to deploy a JDO based EAR file on GlassFish?
I'm really desperate right now, because I'm building a little application that is split up into several projects. There is a web application that uses Vaadin and an EJB container that should do the persistance stuff with JDO and DataNucleus. The hole project is build with Maven and I'm happy now that there comes out an EAR archive.
The content of the EAR file looks right to me. There are all dependency JARs in it, even duplicated inside the containing WAR file. It deploys without any error to the GlassFish server, but when I call the URL I get an ClassNotFoundException
for the javax.jdo.JDOHelper
class. The JAR jdo-api-3.0.jar
exists, but GlassFish isn't able to locate it.
But why? Can anyone tell me? Please!
...and the stack trace... ;) The de.igeri.mmorpg.*
stuff ist my project. But I think, you already guessed it.
java.lang.NoClassDefFoundError: javax/jdo/JDOHelper
at de.igeri.mmorpg.common.dao.JDOManager.(JDOManager.java:22)
at de.igeri.mmorpg.common.dao.JDOManager.(JDOManager.java:14)
at de.igeri.mmorpg.common.dao.BuildingBeanFactory.getAvailable(BuildingBeanFactory.java:29)
at de.igeri.mmorpg.ui.BuildingUiFactory.getAvailable(BuildingUiFactory.java:26)
at de.igeri.mmorpg.MmorpgApplication.createBuildingsPanel(MmorpgApplication.java:75)
at de.igeri.mmorpg.MmorpgApplication.createBuildWindow(MmorpgApplication.java:58)
at de.igeri.mmorpg.MmorpgApplication.createLayout(MmorpgApplication.java:44)
at de.igeri.mmorpg.MmorpgApplication.init(MmorpgApplication.java:29)
at com.vaadin.Application.start(Application.java:554)
at com.vaadin.terminal.gwt.server.AbstractApplicationServlet.startApplication(AbstractApplicationServlet.java:1182)
at com.vaadin.terminal.gwt.server.AbstractApplicationServlet.service(AbstractApplicationServlet.java:466)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:848)
at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1534)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:281)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595)
at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:98)
at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:91)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:162)
at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:326)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:227)
at com.sun.enterpr开发者_StackOverflow社区ise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:228)
at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:822)
at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:719)
at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1013)
at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:225)
at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
at java.lang.Thread.run(Thread.java:636)
Caused by: java.lang.ClassNotFoundException: javax.jdo.JDOHelper
at com.sun.enterprise.loader.ASURLClassLoader.findClassData(ASURLClassLoader.java:808)
at com.sun.enterprise.loader.ASURLClassLoader.findClass(ASURLClassLoader.java:696)
at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
... 37 more
My suggestion is add your jdo api and datanucleus libs to your app server as a module then in maven you can add dependencies as
and add datanucleus maven plugin like this :
<plugin>
<groupId>org.datanucleus</groupId>
<artifactId>datanucleus-maven-plugin</artifactId>
<version>4.0.2</version>
<configuration>
<!-- <log4jConfiguration>src/main/resources/log4j.properties</log4jConfiguration> -->
<!-- this usefull if you dont want to get too long command error -->
<verbose>false</verbose>
</configuration>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>enhance</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
then the most important part you must add your dependency to datanucleus in your manifest file!!! i'm pretty sure that in your case this was the problem.
In WildFly you can do it like this:
<plugin>
<groupId>org.wildfly.plugins</groupId>
<artifactId>wildfly-maven-plugin</artifactId>
<version>${version.wildfly.maven.plugin}</version>
<inherited>true</inherited>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
</manifest>
<addMavenDescriptor>false</addMavenDescriptor>
<manifestEntries>
<Dependencies>deployment.datanucleus-jdo-jca-5.0.0-m1.rar,
javax.jdo</Dependencies>
</manifestEntries>
</archive>
</configuration>
</plugin>
If you are not using jca adapter clearly you can delete that part. Or you can set maven to add your resources such as deployment descriptors or manifest file to your package INF directory.
精彩评论