我已经将我的pom文件配置为使用maven-embedded-glassfish-plugin。实际上,这是生成项目的jersey-webapp工件。 pom的插件部分如下: -
org.glassfish 行家-嵌入与GlassFish插件 $ {} glassfish.version 嵌入式的GlassFish /Users/vdevigere/Projects/ShoppingSite/shoppingsite-ws/target/${project.build.finalName}.war 测试 真正 8080 com.sun.jersey 新泽西州的servlet $ {} jersey.version 的javax.servlet 的javax.servlet-API 3.0.1
当我做一个mvn embedded-glassfish:run我得到一个stacktrace通知我找不到javax.ejb.Stateless。堆栈跟踪在
之下EVERE:调用类com.sun.enterprise.web.WebApplication start方法时出现异常 java.lang.Exception:java.lang.IllegalStateException:ContainerBase.addChild:start:org.apache.catalina.LifecycleException:org.apache.catalina.LifecycleException:java.lang.NoClassDefFoundError:javax / ejb / Stateless 在com.sun.enterprise.web.WebApplication.start(WebApplication.java:138) 在org.glassfish.internal.data.EngineRef.start(EngineRef.java:130) 在org.glassfish.internal.data.ModuleInfo.start(ModuleInfo.java:269) 在org.glassfish.internal.data.ApplicationInfo.start(ApplicationInfo.java:294) 在com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:462) 在com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:240) 在org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:382) at com.sun.enterprise.v3.admin.CommandRunnerImpl $ 1.execute(CommandRunnerImpl.java:355) 在com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:370) 在com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1064) 在com.sun.enterprise.v3.admin.CommandRunnerImpl.access $ 1200(CommandRunnerImpl.java:96) at com.sun.enterprise.v3.admin.CommandRunnerImpl $ ExecutionContext.execute(CommandRunnerImpl.java:1244) at com.sun.enterprise.v3.admin.CommandRunnerImpl $ ExecutionContext.execute(CommandRunnerImpl.java:1232) 在com.sun.enterprise.admin.cli.embeddable.DeployerImpl.deploy(DeployerImpl.java:129) 在com.sun.enterprise.admin.cli.embeddable.DeployerImpl.deploy(DeployerImpl.java:105) 在org.glassfish.maven.PluginUtil.doDeploy(PluginUtil.java:106) 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.glassfish.maven.AbstractDeployMojo.doDeploy(AbstractDeployMojo.java:239) 在org.glassfish.maven.RunMojo.execute(RunMojo.java:68) 在org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:490) at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:694) 在org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeStandaloneGoal(DefaultLifecycleExecutor.java:569) 在org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:539) 在org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:387) 在org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:348) 在org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:180) 在org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:328) 在org.apache.maven.DefaultMaven.execute(DefaultMaven.java:138) 在org.apache.maven.cli.MavenCli.main(MavenCli.java:362) 在org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:60) 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.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315) 在org.codehaus.classworlds.Launcher.launch(Launcher.java:255) 在org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430) 在org.codehaus.classworlds.Launcher.main(Launcher.java:375)
我已经确认javax.ejb.Stateless是glassfish-embedded-web的一部分,它作为测试范围依赖项包含在内。
org.glassfish.extras 与GlassFish嵌入式网络 $ {} glassfish.version 测试
我最终知道为什么这不起作用。我能够将应用程序部署到实际的glassfish应用程序服务器。
答案 0 :(得分:1)
要解决此问题,您需要将以下附加依赖项添加到pom.xml中maven-embedded-glassfish-plugin依赖项下的依赖项列表中:
<dependency>
<groupId>org.glassfish</groupId>
<artifactId>javax.ejb</artifactId>
<version>${glassfish.version}</version>
</dependency>