users@jersey.java.net

Re: null pointer in resources scan

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Tue, 29 Jan 2008 16:50:43 +0100

guilhem legal wrote:
> I still continue to think this is a problem of JDK5/6.
> in fact just before this exception I get an other exception :
>

Ah! yes, although i usually see:

   Exception in thread "main" java.lang.UnsupportedClassVersionError: Bad
   version number in .class file

in such cases. I notice from the stack trace that there is some JAXB
work going on.

Good luck!
Paul.

> GRAVE: "Servlet.service()" pour la servlet ServletAdaptor a généré une
> exception
> java.lang.ClassFormatError: Illegal class modifiers in class
> net/seagis/wcs/package-info: 0x1600
> at java.lang.ClassLoader.defineClass1(Native Method)
> at java.lang.ClassLoader.defineClass(Unknown Source)
> at java.security.SecureClassLoader.defineClass(Unknown Source)
> at
> org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:1817)
>
> at
> org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:872)
>
> at
> org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1325)
>
> at
> org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1204)
>
> at java.lang.ClassLoader.loadClassInternal(Unknown Source)
> at java.lang.Class.forName0(Native Method)
> at java.lang.Class.forName(Unknown Source)
> at java.lang.Package.getPackageInfo(Unknown Source)
> at java.lang.Package.getAnnotation(Unknown Source)
> at
> com.sun.xml.bind.v2.model.annotation.RuntimeInlineAnnotationReader.getPackageAnnotation(RuntimeInlineAnnotationReader.java:125)
>
>
> which i know is throw when you use a 1.6 compiled app in an environement
> 1.5
>
> i continue to investigate where this come from
> Guilhem Legal
>
> Paul Sandoz a écrit :
>> Hi Guilhem,
>>
>> I don't think it is a JER 5/6 version issue. An exception is being
>> thrown because a URL with a 'file' protocol (scheme) is assumed to be
>> a directory and it is not in this case. Jersey converts this
>> file-based URL to a file then does File.listFiles() which returns
>> null. Definitely a bug.
>>
>> I managed to reproduce the same exception but i am not sure if that is
>> the same problem you are having. What i did was create a file, say
>> called 'junk', in a package, say 'mypackage', then set the package
>> name to search for in the web.xml as follows:
>>
>> <init-param>
>> <param-name>com.sun.ws.rest.config.property.packages</param-name>
>> <param-value>mypackage.junk</param-value>
>> </init-param>
>>
>>
>> For the the package name you used:
>>
>> net.seagis.coverage.wms
>>
>> is 'wms' a file in the package "net.seagis.coverage" ?
> net.seagis.coverage.wms is a package containing two resources classes.
>>
>> If not i am not sure what is going on. Would it be possible to execute
>> the following code somewhere in your web app by including an
>> additional a basic servlet:
>>
>> public static void printPackageUrls(String... packages) throws
>> Exception {
>> ClassLoader cl = Thread.currentThread().getContextClassLoader();
>> for (String p : packages) {
>> String fileP = p.replace('.', '/');
>> Enumeration<URL> urls = cl.getResources(fileP);
>> while (urls.hasMoreElements()) {
>> System.out.println(" URI: " + urls.nextElement());
>> System.out.println("file p: " + fileP);
>> System.out.println(new File(fileP).isDirectory());
>> }
>> }
>> }
>>
>> where you pass the packages you configure in the web.xml ?
>>
>> Thanks,
>> Paul.
>>
>> guilhem legal wrote:
>>> hi!
>>>
>>> I have a little issue with the maven plugin of netbeans, when i build
>>> my project with maven command line all work fine.
>>> But when i build my jersey WS with the netbeans maven plugin and try
>>> to deploy it with NB i get the folowing error :
>>>
>>> javax.servlet.ServletException:
>>> java.lang.reflect.InvocationTargetException
>>>
>>> com.sun.ws.rest.spi.container.servlet.ServletContainer.createResourceConfig(ServletContainer.java:172)
>>>
>>>
>>> com.sun.ws.rest.spi.container.servlet.ServletContainer.init(ServletContainer.java:104)
>>>
>>>
>>> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
>>>
>>>
>>> org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:263)
>>>
>>>
>>> org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
>>>
>>>
>>> org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:584)
>>>
>>>
>>> org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
>>> java.lang.Thread.run(Thread.java:595)
>>>
>>> java.lang.reflect.InvocationTargetException
>>> sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
>>> Method)
>>>
>>> sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
>>>
>>>
>>> sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
>>>
>>> java.lang.reflect.Constructor.newInstance(Constructor.java:494)
>>>
>>> com.sun.ws.rest.spi.container.servlet.ServletContainer.createResourceConfig(ServletContainer.java:168)
>>>
>>>
>>> com.sun.ws.rest.spi.container.servlet.ServletContainer.init(ServletContainer.java:104)
>>>
>>>
>>> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
>>>
>>>
>>> org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:263)
>>>
>>>
>>> org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
>>>
>>>
>>> org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:584)
>>>
>>>
>>> org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
>>> java.lang.Thread.run(Thread.java:595)
>>>
>>> java.lang.NullPointerException
>>>
>>> com.sun.ws.rest.impl.container.config.ResourceClassScanner.indexDir(ResourceClassScanner.java:149)
>>>
>>>
>>> com.sun.ws.rest.impl.container.config.ResourceClassScanner.index(ResourceClassScanner.java:135)
>>>
>>>
>>> com.sun.ws.rest.impl.container.config.ResourceClassScanner.scan(ResourceClassScanner.java:97)
>>>
>>>
>>> com.sun.ws.rest.api.core.PackagesResourceConfig.init(PackagesResourceConfig.java:88)
>>>
>>>
>>> com.sun.ws.rest.api.core.PackagesResourceConfig.<init>(PackagesResourceConfig.java:64)
>>>
>>>
>>> com.sun.ws.rest.api.core.PackagesResourceConfig.<init>(PackagesResourceConfig.java:72)
>>>
>>> sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
>>> Method)
>>>
>>> sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
>>>
>>>
>>> sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
>>>
>>> java.lang.reflect.Constructor.newInstance(Constructor.java:494)
>>>
>>> com.sun.ws.rest.spi.container.servlet.ServletContainer.createResourceConfig(ServletContainer.java:168)
>>>
>>>
>>> com.sun.ws.rest.spi.container.servlet.ServletContainer.init(ServletContainer.java:104)
>>>
>>>
>>> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
>>>
>>>
>>> org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:263)
>>>
>>>
>>> org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
>>>
>>>
>>> org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:584)
>>>
>>>
>>> org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
>>> java.lang.Thread.run(Thread.java:595)
>>>
>>> I see in the log the scan starting :
>>>
>>> INFO: Scanning for root resource classes in the packages:
>>> net.seagis.coverage.wms
>>>
>>> but it never find the resources.
>>>
>>> any idea what this happen? (i'm using tomcat 6 with JDK5, I have
>>> maybe a problem with JDK6/5 compilation)
>>>
>>> Guilhem Legal
>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
>>> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>

-- 
| ? + ? = To question
----------------\
    Paul Sandoz
         x38109
+33-4-76188109