2016-11-24 109 views
1

RESTEAsy WADL生成器包含在我們的應用程序How to generate wadl file for resteasy in jboss中。 在JBoss EAP 6.4中完成的部署成功。但在訪問WADL生成URL http://host:8080/rest-serviceapp/application.xml,它產生以下錯誤 -使用RESTEasy wadl生成器生成的Nullpointerexception

java.lang.NullPointerException 
org.jboss.resteasy.wadl.ResteasyWadlWriter.getStringWriter(ResteasyWadlWriter.java:36) 
org.jboss.resteasy.wadl.ResteasyWadlWriter.getBytes(ResteasyWadlWriter.java:26) 
org.jboss.resteasy.wadl.ResteasyWadlServletWriter.writeWadl(ResteasyWadlServletWriter.java:32) 
org.jboss.resteasy.wadl.ResteasyWadlServletWriter.writeWadl(ResteasyWadlServletWriter.java:45) 
org.jboss.resteasy.wadl.ResteasyWadlServlet.service(ResteasyWadlServlet.java:55) 
javax.servlet.http.HttpServlet.service(HttpServlet.java:847) 

我們使用的web.xml文件是 -

<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee 
    http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" 
    version="3.1"> 

<display-name>Restapp_Service</display-name> 

<context-param> 
    <param-name>resteasy.servlet.mapping.prefix</param-name> 
    <param-value>/resteasy</param-value> 
</context-param> 
<context-param> 
    <param-name>resteasy.scan</param-name> 
    <param-value>true</param-value> 
</context-param> 
<context-param> 
    <param-name>resteasy.scan.providers</param-name> 
    <param-value>true</param-value> 
</context-param> 
<context-param> 
    <param-name>resteasy.scan.resources</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> 
    <servlet-name>RESTEasy WADL</servlet-name> 
    <servlet-class>org.jboss.resteasy.wadl.ResteasyWadlServlet</servlet-class> 
</servlet> 

<servlet-mapping> 
    <servlet-name>Resteasy</servlet-name> 
    <url-pattern>/resteasy/*</url-pattern> 
</servlet-mapping> 

<servlet-mapping> 
    <servlet-name>RESTEasy WADL</servlet-name> 
    <url-pattern>/application.xml</url-pattern> 
</servlet-mapping> 

<welcome-file-list> 
    <welcome-file>index.html</welcome-file> 
</welcome-file-list>  

的RestEasy的-WADL依賴是 -

<dependency> 
     <groupId>org.jboss.resteasy</groupId> 
     <artifactId>resteasy-wadl</artifactId> 
     <version>3.1.0</version> 
    </dependency> 

REST服務comsumes /產生JSON。 爲什麼WADL/xml代以nullpointer異常結束?我們正在犯的錯誤是什麼?

+0

您是否解決了您的問題? –

回答

0

我對Wildfly 10.1.0有同樣的問題。

我使用resteasy-wadl 3.0.19修復了它,因爲所有其他resteasy庫在Wildfly 10.1.0上都有此版本。

我也不得不排除RestEasy的-JAXRS庫中的POM,否則RestEasy的-JAXRS庫被列入我的戰爭,導致了問題:

<!-- https://mvnrepository.com/artifact/org.jboss.resteasy/resteasy-wadl --> 
    <dependency> 
     <groupId>org.jboss.resteasy</groupId> 
     <artifactId>resteasy-wadl</artifactId> 
     <version>3.0.19.Final</version> 
     <exclusions> 
      <exclusion> 
       <groupId>org.jboss.resteasy</groupId> 
       <artifactId>resteasy-jaxrs</artifactId> 
      </exclusion> 
     </exclusions> 
    </dependency> 

此外,如果使用其他版本比版本的resteasy庫已經安裝在你的JBoss中,這些resteasy庫(resteasy-jaxrs ...)將作爲resteasy-wadl庫的依賴被第二次安裝。這些重複的庫似乎會導致很多衝突。