users@jersey.java.net

[Jersey] Re: Jersey Test Framework

From: Pavel Bucek <pavel.bucek_at_oracle.com>
Date: Tue, 09 Aug 2011 13:50:53 +0200

seems like you don't have all binaries on classpath. you should be able
to run your test via maven (it should be doable even in eclipse).

fyi, you can obtain list of needed dependencies via mvn
dependency:tree.. and for jersey-test-framework-grizlly2 version
1.9-SNAPSHOT it returns:

[INFO]
com.sun.jersey.jersey-test-framework:jersey-test-framework-grizzly2:jar:1.9-SNAPSHOT
[INFO] +-
com.sun.jersey.jersey-test-framework:jersey-test-framework-core:jar:1.9-SNAPSHOT:compile
[INFO] | +- org.glassfish:javax.servlet:jar:3.0:compile
[INFO] | +- junit:junit:jar:4.8.2:compile
[INFO] | +- com.sun.jersey:jersey-server:jar:1.9-SNAPSHOT:compile
[INFO] | | +- asm:asm:jar:3.1:compile
[INFO] | | \- com.sun.jersey:jersey-core:jar:1.9-SNAPSHOT:compile
[INFO] | \- com.sun.jersey:jersey-client:jar:1.9-SNAPSHOT:compile
[INFO] \- com.sun.jersey:jersey-grizzly2:jar:1.9-SNAPSHOT:compile
[INFO] +- org.glassfish.grizzly:grizzly-http:jar:2.1.1:compile
[INFO] | \- org.glassfish.grizzly:grizzly-framework:jar:2.1.1:compile
[INFO] | \- org.glassfish.gmbal:gmbal-api-only:jar:3.0.0-b023:compile
[INFO] | \-
org.glassfish.external:management-api:jar:3.0.0-b012:compile
[INFO] +- org.glassfish.grizzly:grizzly-http-server:jar:2.1.1:compile
[INFO] | \- org.glassfish.grizzly:grizzly-rcm:jar:2.1.1:compile
[INFO] \- org.glassfish.grizzly:grizzly-http-servlet:jar:2.1.1:compile
[INFO] \-
org.glassfish.grizzly:grizzly-framework:jar:tests:2.1.1:compile

exception you mentioned is thrown because you do have
grizzly-http-server on classpath (HttpHandler class is there) but you
don't have grizzly-framework and Grizzly class is from that module).

Regards,
Pavel


On 8/9/11 1:08 PM, Robertnac wrote:
> Hello,
>
> I understand it not, it is the same error. The StackTrace is:
>
> java.lang.NoClassDefFoundError: org.glassfish.grizzly.Grizzly
> at org.glassfish.grizzly.http.server.HttpHandler.<clinit>(HttpHandler.java:73)
> at java.lang.J9VMInternals.initializeImpl(Native Method)
> at java.lang.J9VMInternals.initialize(J9VMInternals.java:200)
> at java.lang.J9VMInternals.initialize(J9VMInternals.java:167)
> at com.sun.jersey.test.framework.spi.container.grizzly2.web.GrizzlyWebTestContainerFactory$GrizzlyWebTestContainer.instantiateGrizzlyWebServer(GrizzlyWebTestContainerFactory.java:163)
> at com.sun.jersey.test.framework.spi.container.grizzly2.web.GrizzlyWebTestContainerFactory$GrizzlyWebTestContainer.<init>(GrizzlyWebTestContainerFactory.java:129)
> at com.sun.jersey.test.framework.spi.container.grizzly2.web.GrizzlyWebTestContainerFactory$GrizzlyWebTestContainer.<init>(GrizzlyWebTestContainerFactory.java:86)
> at com.sun.jersey.test.framework.spi.container.grizzly2.web.GrizzlyWebTestContainerFactory.create(GrizzlyWebTestContainerFactory.java:79)
> at com.sun.jersey.test.framework.JerseyTest.getContainer(JerseyTest.java:342)
> at com.sun.jersey.test.framework.JerseyTest.<init>(JerseyTest.java:217)
> at com.sun.jersey.test.framework.JerseyTest.<init>(JerseyTest.java:235)
> at de.lvm.helloworld.resources.properties.TestPropertyResource.<init>(TestPropertyResource.java:19)
> at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
> at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:44)
> at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
> at java.lang.reflect.Constructor.newInstance(Constructor.java:516)
> at org.junit.runners.BlockJUnit4ClassRunner.createTest(BlockJUnit4ClassRunner.java:209)
> at org.junit.runners.BlockJUnit4ClassRunner$1.runReflectiveCall(BlockJUnit4ClassRunner.java:258)
> at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
> at org.junit.runners.BlockJUnit4ClassRunner.methodBlock(BlockJUnit4ClassRunner.java:255)
> at org.junit.runners.BlockJUnit4ClassRunner.runNotIgnored(BlockJUnit4ClassRunner.java:79)
> at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:71)
> at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49)
> at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
> at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
> at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
> at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
> at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
> at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
> at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:45)
> at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
> at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
> at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
> at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
> at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
> Caused by: java.lang.ClassNotFoundException: org.glassfish.grizzly.Grizzly
> at java.net.URLClassLoader.findClass(URLClassLoader.java:423)
> at java.lang.ClassLoader.loadClass(ClassLoader.java:653)
> at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:346)
> at java.lang.ClassLoader.loadClass(ClassLoader.java:619)
> ... 35 more
>
>
> I do the test in Eclipse JUnitTestEnvironment.
>
> Grizzly, we use only in tests. Productively we use WebSphere
>
> I try to change the execution environment to java 1.6.
>
> Any idea?
>
> Robert
>
> 2011/8/9 Pavel Bucek<pavel.bucek_at_oracle.com>:
>>
>> On 8/9/11 11:01 AM, Robertnac wrote:
>>> Hi Pavel,
>>>
>>> thanks for the reply. I have already any snippets from your samples.It
>>> worked very well,..... until now :-(
>>>
>>> If I use the following dependencies, I get the same error.
>> really the same error? (CNFE for org.glassfish.grizzly.Grizzly? It does not
>> make much sense, it should be included in your classpath by now.
>>
>> how are you executing your tests? "mvn test" ... ? Or .. can you share
>> minimal testcase for issue you are having? I could probably sort it out
>> faster..
>>> <dependency>
>>>
>>> <groupId>com.sun.jersey.jersey-test-framework</groupId>
>>>
>>> <artifactId>jersey-test-framework-grizzly2</artifactId>
>>> <version>${jersey.version}</version>
>>> <scope>test</scope>
>>> </dependency>
>>>
>>> <dependency>
>>>
>>> <groupId>com.sun.jersey.jersey-test-framework</groupId>
>>>
>>> <artifactId>jersey-test-framework-grizzly2</artifactId>
>>> <version>${jersey.version}</version>
>>> <scope>test</scope>
>>> </dependency>
>>>
>>> But that aside, I want to use conscious grizzly, because I do not want
>>> to use servlet api 3.0.
>> are you using Grizzly somewhere in the runtime or just for testing?
>>> According
>>> http://jersey.java.net/nonav/documentation/latest/test-framework.html
>>> would need to go
>>>
>>> Any idea? The test run with java 1.6, but the project is compiled with
>>> 1.5. Is that bad?
>> it shouldn't be a problem..
>>
>>
>>> Regards,
>>>
>>> Robert
>>>
>>> 2011/8/9 Pavel Bucek<pavel.bucek_at_oracle.com>:
>>>> <dependency> <groupId>com.sun.jersey.jersey-test-framework</
>>>> groupId> <artifactId>jersey-test-framework-grizzly2</artifactId>
>>>> <version>${jersey.version}</version> <scope>test</scope> </dependency>
>>