2014-02-19 67 views
0

我在net beans中運行web服務時遇到了這個異常我錯過了什麼?我試圖使用mvn和stuff命令部署web服務,但仍然是一個例外。 Java中的新手。幫助高度讚賞。Jersey 2.0(Jax-RS 2.0)在Glassfish 3.1.2上運行時使用Maven拋出異常的Rest服務Web服務?

的web.xml

 <web-app xmlns="http://java.sun.com/xml/ns/javaee" 
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
     xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" 
     version="3.0"> 
    <servlet> 
     <servlet-name>async-app</servlet-name> 
     <servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class> 
     <init-param> 
      <param-name>javax.ws.rs.Application</param-name> 
      <param-value>org.glassfish.jersey.examples.server.async.AsyncJaxrsApplication</param-value> 
     </init-param> 
     <load-on-startup>1</load-on-startup> 
     <async-supported>true</async-supported> 
    </servlet> 
    <servlet-mapping> 
     <servlet-name>async-app</servlet-name> 
     <url-pattern>/*</url-pattern> 
    </servlet-mapping> 
</web-app> 

的pom.xml

 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 
    <modelVersion>4.0.0</modelVersion> 
- <parent> 
    <groupId>org.glassfish.jersey.examples</groupId> 
    <artifactId>server-async-standalone</artifactId> 
    <version>2.0</version> 
    </parent> 
    <artifactId>server-async-standalone-webapp</artifactId> 
    <packaging>war</packaging> 
    <name>jersey-examples-server-async-standalone-webapp</name> 
    <description>Standalone Jersey JAX-RS asynchronous server-side processing example web application.</description> 
- <dependencies> 
- <dependency> 
    <groupId>org.glassfish.jersey.containers</groupId> 
    <artifactId>jersey-container-servlet</artifactId> 
    <scope>provided</scope> 
    </dependency> 
    </dependencies> 
- <profiles> 
- <profile> 
    <id>examples-source-zip</id> 
- <!-- do not create source zip bundles 
    --> 
- <build> 
- <plugins> 
- <plugin> 
    <groupId>org.apache.maven.plugins</groupId> 
    <artifactId>maven-assembly-plugin</artifactId> 
- <configuration> 
    <skipAssembly>true</skipAssembly> 
    </configuration> 
    </plugin> 
    </plugins> 
    </build> 
    </profile> 
    </profiles> 
    </project> 

異常消息: -

[#|2014-02-19T15:01:10.928+0530|SEVERE|glassfish3.1.2|javax.enterprise.system.tools.admin.org.glassfish.deployment.admin|_ThreadID=73;_ThreadName=Thread-2;|Exception while invoking class com.sun.enterprise.web.WebApplication start method 
java.lang.Exception: java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: org.apache.catalina.LifecycleException: java.lang.NoClassDefFoundError: com/google/common/collect/Lists 
    at com.sun.enterprise.web.WebApplication.start(WebApplication.java:138) 
    at org.glassfish.internal.data.EngineRef.start(EngineRef.java:130) 
    at org.glassfish.internal.data.ModuleInfo.start(ModuleInfo.java:269) 
    at org.glassfish.internal.data.ApplicationInfo.start(ApplicationInfo.java:301) 
    at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:461) 
    at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:240) 
    at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:389) 
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$1.execute(CommandRunnerImpl.java:348) 
    at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:363) 
    at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1085) 
    at com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1200(CommandRunnerImpl.java:95) 
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1291) 
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1259) 
    at com.sun.enterprise.v3.admin.AdminAdapter.doCommand(AdminAdapter.java:461) 
    at com.sun.enterprise.v3.admin.AdminAdapter.service(AdminAdapter.java:212) 
    at com.sun.grizzly.tcp.http11.GrizzlyAdapter.service(GrizzlyAdapter.java:179) 
    at com.sun.enterprise.v3.server.HK2Dispatcher.dispath(HK2Dispatcher.java:117) 
    at com.sun.enterprise.v3.services.impl.ContainerMapper$Hk2DispatcherCallable.call(ContainerMapper.java:354) 
    at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:195) 
    at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:849) 
    at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:746) 
    at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1045) 
    at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:228) 
    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:722) 
|#] 

[#|2014-02-19T15:01:10.928+0530|SEVERE|glassfish3.1.2|javax.enterprise.system.core.com.sun.enterprise.v3.server|_ThreadID=73;_ThreadName=Thread-2;|Exception while loading the app|#] 

[#|2014-02-19T15:01:10.977+0530|SEVERE|glassfish3.1.2|javax.enterprise.system.tools.admin.org.glassfish.deployment.admin|_ThreadID=73;_ThreadName=Thread-2;|Exception while loading the app : java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: org.apache.catalina.LifecycleException: java.lang.NoClassDefFoundError: com/google/common/collect/Lists|#] 
+0

我碰到了同樣的問題來了,它看起來像GF 3.1.X不與新澤西2.x兼容。此條目確認http://jersey.576304.n2.nabble.com/jersey-2-x-on-glassfish-3-1-x-td7581312.html – botchniaque

回答

0

你缺少com/google/common/collect/Lists所以我想部署戰錯過了罐子。你在你的pom.xml中有什麼?

+0

我已編輯該問題並添加了pom文件代碼,請檢查。感謝您的考慮 – Rahul

+0

您的'pom.xml'包含對'org.glassfish.jersey.containers:jersey-container-servlet'的依賴,但沒有特定的版本。你的mvn構建中採用了哪一個?您確定它與要部署的Glassfish版本兼容嗎?除此之外(我不是Glassfish的專家),你的項目中的'guava'庫怎麼樣?它是傳遞性的依賴關係還是? –

+0

似乎火箭科學對我來說,我已經下載了jersey-examples-2.0-all,並且正在測試一個適合我需要的異步Restfull Webservice的例子。我只是將該示例導入netbeans並嘗試運行。但是,因爲我是新手在Java面臨提到的問題。我有什麼選擇? – Rahul

0

解決了它。我已將netbeans 7.2.1的所有內容升級到7.4 jdk 1.7 jre7。 glassfish 4.0 tomcat 7.0.41.0,它的工作原理。

0

真正這裏的問題是,Glassfish的3不兼容新澤西州2

如果你想使用澤西2,你必須使用Glassfish的4