RESTEAsy WADL生成器包含在我们的应用程序中,引用How to generate wadl file for resteasy in jboss。 在JBoss EAP 6.4中完成的部署是成功的。但是在访问WADL生成URL http://host:8080/rest-serviceapp/application.xml时,它会生成以下错误 -
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上都有此版本。
我还必须在pom中排除resteasy-jaxrs库,否则我的战争中会包含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>
此外,如果您使用的版本不是JBoss中已安装的resteasy库的版本,则这些resteasy库(resteasy-jaxrs ...)将作为resteasy-wadl库的依赖项第二次安装。这些重复的库似乎会引起很多冲突。