RESTEasy Unable to scan WEB-INF for JAX-RS annotations ?

Question

Developing REST service, with file upload function with resteasy, after added resteasy multipart dependency, following strange error message prompt during the application start up?

P.S Using resteasy-jaxrs and resteasy-multipart version 2.2.1.GA.


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.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
	at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
Caused by: java.io.EOFException: Unexpected end of ZLIB input stream
	at java.util.zip.InflaterInputStream.fill(InflaterInputStream.java:223)
	at java.util.zip.InflaterInputStream.read(InflaterInputStream.java:141)
	at java.util.zip.ZipInputStream.read(ZipInputStream.java:146)
	//...
	at org.scannotation.AnnotationDB.scanClass(AnnotationDB.java:343)
	at org.scannotation.AnnotationDB.scanArchives(AnnotationDB.java:326)
	at org.jboss.resteasy.plugins.server.servlet.ConfigurationBootstrap
        .createDeployment(ConfigurationBootstrap.java:163)
	... 17 more
09 Julai 2011 1:52:13 PM org.apache.catalina.core.StandardContext listenerStop
SEVERE: Exception sending context destroyed event to listener instance of class 
org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap
java.lang.NullPointerException
	at org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap.contextDestroyed...

Solution

Not sure what is the root caused of it, two solutions :

1. Downgrade Version

Downgrade “resteasy-multipart-provider” to version 2.2.0.GA get the problem solved.


		<dependency>
			<groupId>org.jboss.resteasy</groupId>
			<artifactId>resteasy-jaxrs</artifactId>
			<version>2.2.1.GA</version>
		</dependency>

		<dependency>
			<groupId>org.jboss.resteasy</groupId>
			<artifactId>resteasy-multipart-provider</artifactId>
			<version>2.2.0.GA</version>
		</dependency>

2. Register RESTEasy Manually

Disable RESTEasy auto service scanning mode, and register it manually. Not sure why, but it works.

File : web.xml


       <!-- disabled auto scan mode
       <context-param>
		<param-name>resteasy.scan</param-name>
		<param-value>true</param-value>
	</context-param>
         -->
	<context-param>
		<param-name>resteasy.resources</param-name>
		<param-value>your REST service</param-value>
	</context-param>

About the Author

author image
mkyong
Founder of Mkyong.com, love Java and open source stuff. Follow him on Twitter, or befriend him on Facebook or Google Plus. If you like my tutorials, consider make a donation to these charities.

Comments

avatar
6 Comment threads
1 Thread replies
0 Followers
 
Most reacted comment
Hottest comment thread
3 Comment authors
elgselgsJAX-RS TUTORIALS | BUYWORKSELLKirantejJAX-RS Tutorial Recent comment authors
newest oldest most voted
elgselgs
Guest
elgselgs

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/

elgselgs
Guest
elgselgs

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.

trackback
JAX-RS TUTORIALS | BUYWORKSELL

[…] RESTEasy Unable to scan WEB-INF for JAX-RS annotations, Unexpected end of ZLIB input stream […]

Kiran
Guest
Kiran

I am using javassist-3.6.0.GA.jar, resteasy-jaxb-provider-1.2.GA.jar, resteasy-jaxrs-1.2.GA.jar & scannotation-1.0.2.jar and while deploying i am getting the below error; any thoughts?

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:160)
	at org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap.contextInitialized(ResteasyBootstrap.java:27)
	at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3854)
	at org.apache.catalina.core.StandardContext.start(StandardContext.java:4352)
	at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:752)
	at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:732)
	at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:553)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)

This same webservice was working fine till yesterday; i just built once again with my app level code changes, it started cribbing now…

Kiran
Guest
Kiran

I cracked it, its nothing to do with any jar file version or other. I have extracted a jar file (myjar.jar) in my library folder for verification into myjar folder and without deleting it i started building the war file.

So when war file is built, in the web-inf/lib/myjar folder is empty and class loading was happening from the empty folder instead of myjar.jar; so the above error came.

Now i removed the extracted folder and rebuilt the war file which lead to successful deployment and testing.

Silly thing but killed my 8hrs of time and sleepless night :)

tej
Guest
tej

I resolved by adding
scannotation-1.0.2.jar
javassist-3.14.0-GA.jar

trackback
JAX-RS Tutorial

[…] with Spring framework.Common Error MessagesSome common error messages in JAX-RS development.RESTEasy Unable to scan WEB-INF for JAX-RS annotations, Unexpected end of ZLIB input streamClassNotFoundException : org.jboss.resteasy.plugins.providers.multipart.MultipartInputRESTEasy […]