2010-12-20 29 views
1

我試圖構建一個使用休眠數據訪問的restful web服務。我正在使用Maven構建,並且必須在JBossAS5.1上進行部署 - 未來可能會使用EAP5.x。獲取RestEASY,HIbernate,Maven和JBossAS5.1可以很好地播放

RestEASY很好,但我遇到了Hibernate問題,只要我將hibernate依賴關係添加到pom.xml中,WAR部署結束後就會立即崩潰。

我對Java和Maven非常滿意,但是對於JavaEE而言,除了簡單的JSP之外,它是新手。

pom.xml中提取:

 <repositories> 
      <repository> 
       <id>jboss</id> 
       <name>jboss repo</name> 
       <url>http://repository.jboss.org/nexus/content/groups/public/</url> 
      </repository> 
     </repositories> 

    <dependencies> 
     <!-- hibernate --> 
    <dependency> 
     <groupId>org.hibernate</groupId> 
     <artifactId>hibernate-core</artifactId> 
     <version>3.5.6-Final</version> 
     <exclusions> 
      <exclusion> 
       <groupId>org.slf4j</groupId> 
       <artifactId>slf4j-api</artifactId> 
      </exclusion> 
     </exclusions>   

    </dependency> 
     <dependency> 
      <groupId>javax.persistence</groupId> 
      <artifactId>persistence-api</artifactId> 
      <version>1.0</version> 
     </dependency> 

     <dependency> 
      <groupId>org.jboss.resteasy</groupId> 
      <artifactId>resteasy-jaxrs</artifactId> 
      <version>2.0.0.GA</version> 
      <exclusions> 
       <exclusion> 
        <groupId>com.sun.xml.bind</groupId> 
        <artifactId>jaxb-impl</artifactId> 
       </exclusion> 
       <exclusion> 
        <groupId>org.slf4j</groupId> 
        <artifactId>slf4j-api</artifactId> 
       </exclusion> 
       <exclusion> 
        <groupId>org.slf4j</groupId> 
        <artifactId>slf4j-simple</artifactId> 
       </exclusion> 
       <exclusion> 
        <groupId>org.slf4j</groupId> 
        <artifactId>jcl-over-slf4j</artifactId> 
       </exclusion> 
      </exclusions> 
     </dependency> 
     <dependency> 
      <groupId>org.jboss.resteasy</groupId> 
      <artifactId>resteasy-jaxb-provider</artifactId> 
      <version>2.0.0.GA</version> 
      <exclusions> 
       <exclusion> 
        <groupId>com.sun.xml.bind</groupId> 
        <artifactId>jaxb-impl</artifactId> 
       </exclusion> 
      </exclusions> 
     </dependency> 

    <build> 
    <finalName>hedgehog-rest</finalName> 
    <plugins> 
     <plugin> 
     <groupId>org.apache.maven.plugins</groupId> 
     <artifactId>maven-compiler-plugin</artifactId> 
      <configuration> 
       <source>1.6</source> 
       <target>1.6</target> 
      </configuration> 
     </plugin> 
    </plugins> 
    </build> 
</project> 

的web.xml:

<web-app> 
    <display-name>Archetype Created Web Application</display-name> 
    <context-param> 
     <param-name>resteasy.scan</param-name> 
     <param-value>true</param-value> 
    </context-param> 
    <listener> 
     <listener-class>org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap</listener-class> 
    </listener> 
    <servlet> 
     <servlet-name>Resteasy</servlet-name> 
     <servlet-class>org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher</servlet-class> 
    </servlet> 
    <servlet-mapping> 
     <servlet-name>Resteasy</servlet-name> 
     <url-pattern>/*</url-pattern> 
    </servlet-mapping> 
</web-app> 

我刪除了我所有的代碼,除了這個類:

@Path("/echo") 
public class Echo 
{ 
    @GET 
    @Produces("text/*") 
    @Path("/{message}") 
    public Response echoService(@PathParam("message") String message) 
    { 
     return Response.status(200).entity(message).build(); 
    } 
} 

以下錯誤日誌的開頭:

20:37:05,848 INFO [TomcatDeployment] deploy, ctxPath=/hedgehog-rest 
20:37:06,956 INFO [ConfigurationBootstrap] Adding scanned resource: com.ecs.hedgehog.Echo 
20:37:07,057 ERROR [[/hedgehog-rest]] Exception sending context initialized event to listener instance of class org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap 
java.lang.RuntimeException: java.lang.RuntimeException: Unable to instantiate MessageBodyReader 
    at org.jboss.resteasy.plugins.providers.RegisterBuiltin.register(RegisterBuiltin.java:36) 
    at org.jboss.resteasy.spi.ResteasyDeployment.start(ResteasyDeployment.java:171) 
    at org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap.contextInitialized(ResteasyBootstrap.java:28) 
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3910) 
+0

嗯,似乎工作正常提供添加到休眠依賴...試驗 – Dana 2010-12-20 11:39:53

回答

相關問題