dev@jersey.java.net

Re: Resource Class discovery at deployment time.

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Thu, 04 Oct 2007 14:08:47 +0200

Jakub Podlesak wrote:
> Hi Frank,
>
> I have tried the [ResourceClassLoader] and it gives me the following
> when using parameter 1 (for 2,3 is does not work either):

Are you executing the task "test-hello-world" in the build.xml ?

Note that for 2 and 3 the classes were compiled using SE 6 so if you are
using SE 5 you will get a class loading error.

Paul.

> --cuthere--
> init:
> deps-jar:
> compile:
> run:
> Exception in thread "main" java.lang.RuntimeException: java.lang.ClassNotFoundException: com.sun.ws.rest.samples.helloworld.resources.HelloWorldResource
> at com.sun.ws.rest.deployer.ASMResourceClassScanner.scan(ASMResourceClassScanner.java:76)
> at com.sun.ws.rest.deployer.Test.testHelloWorld(Test.java:61)
> at com.sun.ws.rest.deployer.Test.main(Test.java:37)
> Caused by: java.lang.ClassNotFoundException: com.sun.ws.rest.samples.helloworld.resources.HelloWorldResource
> at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
> at java.security.AccessController.doPrivileged(Native Method)
> at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
> HelloWorld --------------------------------------
> at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
> at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
> at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
> at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
> at java.lang.Class.forName0(Native Method)
> at java.lang.Class.forName(Class.java:164)
> at com.sun.ws.rest.deployer.ASMResourceClassScanner.analyze(ASMResourceClassScanner.java:87)
> at com.sun.ws.rest.deployer.ASMResourceClassScanner.indexJar(ASMResourceClassScanner.java:132)
> at com.sun.ws.rest.deployer.ASMResourceClassScanner.indexDir(ASMResourceClassScanner.java:114)
> at com.sun.ws.rest.deployer.ASMResourceClassScanner.index(ASMResourceClassScanner.java:97)
> at com.sun.ws.rest.deployer.ASMResourceClassScanner.scan(ASMResourceClassScanner.java:68)
> ... 2 more
> Java Result: 1
> BUILD SUCCESSFUL (total time: 0 seconds)
> --cuthere--
>
> Any idea what could be wrong?
>
> Thanks a lot!
>
> ~Jakub
>
> On Wed, Oct 03, 2007 at 06:12:42PM -0500, Frank Martínez wrote:
>> Hi Paul,
>>
>>>> I have developed a Resource class scanner in my old project. It uses
>>>> asm (bycode manipulation library) to scan WEB-INF/classes and
>>>> WEB-INF/lib jars on a servlet init or a listener. The advantage of
>>>> this approach is that resources are discovered at deployment time. Do
>>>> you think it would be useful in jersey?
>>>>
>>> Definitely! I have wanted to look into this (see an email i sent to
>>> the dev list talking about this). I think it has general
>>> applicability for non-servlet deployments as well. It may mean we can
>>> simplify the abstract resource model implementations. This is the
>>> type of thing that WebBeans is doing, plus it means we can pick up
>>> other components like EntityProviders using a WebBeans like technique
>>> we have semi-specified.
>>>
>> Here is a proof of concept (attached)
>> look at the Test class (It is not a JUnit test).
>> The important method is ResourceClassScanner.scan( ... ).
>>
>> Important note: This implementation does not load not matching
>> classes. It uses ASM (objectweb library) to parse .class files without
>> loading it into the VM.
>>
>> Regards,
>>
>> --
>> Frank D. Martínez M.
>> Asimov Technologies Ltda.
>> Blog: http://www.ibstaff.net/fmartinez/
>
>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe_at_jersey.dev.java.net
>> For additional commands, e-mail: dev-help_at_jersey.dev.java.net
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: dev-help_at_jersey.dev.java.net
>

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