3
votes

I just added JAX-RS web services to my project in MyEclipse and did my export/deploy to jboss 6/jdk 1.6, but I keep getting this error and I have no clue why it comes up. Here's the first few lines of this stack trace:

2011-05-03 21:33:46,716 INFO  [org.jboss.resteasy.integration.deployers.ResteasyIntegrationDeployer] (HDScanner) *** Adding JAX-RS resource classes: com.mycompany.CategoriesResource
2011-05-03 21:33:47,180 INFO  [org.jboss.web.tomcat.service.deployers.TomcatDeployment] (HDScanner) deploy, ctxPath=/mypath
2011-05-03 21:33:47,330 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[/mypath]] (HDScanner) Exception sending context initialized event to listener instance of class org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap: java.lang.RuntimeException: Unable to scan WEB-INF for JAX-RS annotations, you must manually register your classes/resources

Has anyone had trouble with this before? The project was created in MyEclipse with Struts and Web Service Capabilities if that helps. I honestly don't know what else I can try considering I just recently deployed a similar configuration without any problems.

Thanks!

Here is my web.xml

http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"> action org.apache.struts.action.ActionServlet config /WEB-INF/struts-config.xml debug 3 detail 3 0

<listener>
    <listener-class>org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap</listener-class>
</listener>
<servlet>
    <display-name>API</display-name>
    <servlet-name>API</servlet-name>
    <servlet-class>org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher</servlet-class>
    <load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
    <servlet-name>API</servlet-name>
    <url-pattern>/api/*</url-pattern>
</servlet-mapping>
<context-param>
    <param-name>resteasy.scan</param-name>
    <param-value>true</param-value>
</context-param>
<context-param>
    <param-name>resteasy.servlet.mapping.prefix</param-name>
    <param-value>/api</param-value>
</context-param>
<servlet-mapping>
    <servlet-name>action</servlet-name>
    <url-pattern>*.do</url-pattern>
</servlet-mapping>
<welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
</welcome-file-list>

<jsp-config>
    <taglib>
        <taglib-uri>http://struts.apache.org/tags-bean</taglib-uri>
        <taglib-location>/WEB-INF/struts-bean.tld</taglib-location>
    </taglib>
    <taglib>
        <taglib-uri>http://struts.apache.org/tags-html</taglib-uri>
        <taglib-location>/WEB-INF/struts-html.tld</taglib-location>
    </taglib>
    <taglib>
        <taglib-uri>http://struts.apache.org/tags-logic</taglib-uri>
        <taglib-location>/WEB-INF/struts-logic.tld</taglib-location>
    </taglib>
    <taglib>
        <taglib-uri>http://struts.apache.org/tags-tiles</taglib-uri>
        <taglib-location>/WEB-INF/struts-tiles.tld</taglib-location>
    </taglib>
    <taglib>
        <taglib-uri>http://struts.apache.org/tags-nested</taglib-uri>
        <taglib-location>/WEB-INF/struts-nested.tld</taglib-location>
    </taglib>
</jsp-config>

4
do you have correct configuration in your web.xml?fmucar
I'm pretty sure the web.xml is fine, but here it is just in case you can spot something wrong with it.Adrian Rodriguez
I have the same problem , did you manage to solve this?Yashar
It was so long ago. I really don't remember. However, I do remember just say f*** all this xml garbage and started the project again using typesafe idiomatic java ... just take all that config ... as much of it as you can and do it programmatically. It saved me tons of headaches.Adrian Rodriguez

4 Answers

1
votes

This means that RESTEasy received an IOException when trying to scan the WEB-INF directory. The first thing I would check is your file system permisions - can the user running the JBoss process read WEB-INF and all the files within it?

EDIT:

In response to your comment: Your classpath includes an entry that Scannotation doesn't understand. It looks like jndi://. Can you check the classpath and find out what this entry is?

1
votes

Resteasy should be the victim, too. The problem is at scannotation-1.0.3.jar.

DirectoryIteratorFactory factory = registry.get(url.getProtocol());
if (factory == null) throw new IOException("Unable to scan directory of protocol: " + url.getProtocol());
return factory.create(url, filter);

It seems when the url.getProtocol() returns "jdni", this problem happens. I'm still investigating what url will return protocol as jndi.

I deleted the scannotation-1.0.3.jar from my lib folder, and downloaded the source code, printed the bad url. It turned out to be: jndi:/localhost/Enoch2/WEB-INF/lib/.svn/

Then I tried to remove all .svn folders from the deployment. It works. find . -name .svn | xargs rm -Rf

0
votes

I faced the same issue when I moved my maven project from java 6 to java 8. The cause was some dependancy in my project was holding on to javassit 3.12 and it was not compatible with java 8. After I upgraded javassist to 3.20 it started working fine. So if you face this issue please check the javassist jar used and upgrade if needed.

0
votes

I have faced this issue recently.
javassist version was not supported with Java 8 changes. So I have excluded this jar from that dependency and added externally javassist dependency(with higer version).

LOG:
SEVERE: Exception sending context initialized event to listener instance of class [org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap]

java.lang.RuntimeException: Unable to scan WEB-INF for JAX-RS annotations, you must manually register your classes/resources

    at org.jboss.resteasy.plugins.server.servlet.ConfigurationBootstrap.createDeployment(ConfigurationBootstrap.java:177)

    at org.jboss.resteasy.plugins.server.servlet.ListenerBootstrap.createDeployment(ListenerBootstrap.java:32)

    at org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap.contextInitialized(ResteasyBootstrap.java:27)

My Solution:

Updated my pom.xml file

<dependency>
    <groupId>com.xyz</groupId>
    <artifactId>abc</artifactId>
    <version>${abc.version}</version>
    <exclusions>
        <exclusion>
            <groupId>javassist</groupId>
            <artifactId>javassist</artifactId>
        </exclusion>
    </exclusions>
</dependency>

and added dependency

<dependency>
    <groupId>org.javassist</groupId>
    <artifactId>javassist</artifactId>
    <version>3.18.2-GA</version>
</dependency>