如何在GlassFish上部署基于JDO的EAR文件?

时间:2011-06-21 17:04:54

标签: maven glassfish jdo ear

我现在非常绝望,因为我正在构建一个分成几个项目的小应用程序。有一个使用 Vaadin 的Web应用程序和一个EJB容器,它应该使用 JDO DataNucleus 执行持久性操作。这个洞项目是用Maven构建的,现在我很高兴出现了一个EAR档案。

EAR文件的内容对我来说是正确的。其中包含所有依赖项JAR,甚至在包含WAR文件中重复。它在没有任何错误的情况下部署到 GlassFish 服务器,但是当我调用URL时,我得到了ClassNotFoundException类的javax.jdo.JDOHelper。 JAR jdo-api-3.0.jar存在,但GlassFish无法找到它。

但为什么呢?有人能告诉我吗?请!

...和堆栈跟踪...;)de.igeri.mmorpg.*的东西是我的项目。但我想,你已经猜到了。

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.enterprise.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

1 个答案:

答案 0 :(得分:0)

我的建议是将您的jdo api和datanucleus库添加到您的应用服务器作为模块然后在maven中您可以添加依赖项

并添加datanucleus maven插件,如下所示:

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

然后最重要的部分你必须在清单文件中添加你对datanucleus的依赖!!!我很确定在你的情况下这是问题所在。

在WildFly中你可以这样做:

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

如果您没有清楚地使用jca适配器,则可以删除该部分。 或者,您可以将maven设置为将部署描述符或清单文件等资源添加到包INF目录中。