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

发布于 2024-11-16 21:10:16 字数 3987 浏览 6 评论 0原文

我现在真的很绝望,因为我正在构建一个分为几个项目的小应用程序。有一个使用 Vaadin 的 Web 应用程序和一个 EJB 容器,该容器应该使用 JDODataNucleus 来完成持久性工作。这个hole项目是用Maven构建的,我很高兴现在有一个EAR存档。

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

但为什么?谁能告诉我吗?请!

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

java.lang.NoClassDefFoundError: javax/jdo/JDOHelper 在de.igeri.mmorpg.common.dao.JDOManager。(JDOManager.java:22) 在de.igeri.mmorpg.common.dao.JDOManager。(JDOManager.java:14) 在 de.igeri.mmorpg.common.dao.BuildingBeanFactory.getAvailable(BuildingBeanFactory.java:29) 在 de.igeri.mmorpg.ui.BuildingUiFactory.getAvailable(BuildingUiFactory.java:26) 在de.igeri.mmorpg.MmorpgApplication.createBuildingsPanel(MmorpgApplication.java:75) 在 de.igeri.mmorpg.MmorpgApplication.createBuildWindow(MmorpgApplication.java:58) 在 de.igeri.mmorpg.MmorpgApplication.createLayout(MmorpgApplication.java:44) 在 de.igeri.mmorpg.MmorpgApplication.init(MmorpgApplication.java:29) 在 com.vaadin.Application.start(Application.java:554) 在com.vaadin.terminal.gwt.server.AbstractApplicationServlet.startApplication(AbstractApplicationServlet.java:1182) 在 com.vaadin.terminal.gwt.server.AbstractApplicationServlet.service(AbstractApplicationServlet.java:466) 在 javax.servlet.http.HttpServlet.service(HttpServlet.java:848) 在 org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1534) 在org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:281) 在org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175) 在 org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655) 在org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595) 在 com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:98) 在 com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:91) 在 org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:162) 在 org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:326) 在 org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:227) 在 com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:228) 在 com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:822) 在 com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:719) 在 com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1013) 在 com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:225) 在 com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137) 在 com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104) 在 com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90) 在 com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79) 在com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54) 在 com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59) 在com.sun.grizzly.ContextTask.run(ContextTask.java:71) 在 com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532) 在 com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513) 在 java.lang.Thread.run(Thread.java:636) 引起原因:java.lang.ClassNotFoundException:javax.jdo.JDOHelper 在 com.sun.enterprise.loader.ASURLClassLoader.findClassData(ASURLClassLoader.java:808) 在 com.sun.enterprise.loader.ASURLClassLoader.findClass(ASURLClassLoader.java:696) 在 java.lang.ClassLoader.loadClass(ClassLoader.java:321) 在 java.lang.ClassLoader.loadClass(ClassLoader.java:266) ... 37 更多

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

殤城〤 2024-11-23 21:10:16

我的建议是将您的 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 目录中。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文