users@jersey.java.net

[Jersey] Re: Jersey Test Framework

From: Robertnac <robertnac_at_googlemail.com>
Date: Tue, 9 Aug 2011 13:53:14 +0200

I found this error. It Was a bit confused.

In the parent pom, I had wron dependency:

<dependency>
                <groupId>com.sun.jersey.jersey-test-framework</groupId>
                <artifactId>jersey-test-framework-grizzly2</artifactId>
                <version>${jersey.version}</version>
                <scope>test</scope>
</dependency>

Thanx for your help!

Robert


2011/8/9 Robertnac <robertnac_at_googlemail.com>:
> 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>
>>
>>
>