Hi again,
I have additional comment to your question. Paul noticed you are using
EJB in your application. This unfortunately won't work with current
Jersey Test framework, because it is using Glassfish
3.0-Prelude-Embedded-b14 which doesn't support EJB yet. Testing EJB
would be possible when embedded GF v3.0+ will be integrated with Jersey
Test Framework (and that will happen after Jersey switches to SE 6).
Alternative for you is external test container - that means build your
application with -Dmaven.test.skip=true, deploy it and run
mvn test
-Djersey.test.containerFactory=com.sun.jersey.test.framework.spi.container.external.ExternalTestContainerFactory
-DJERSEY_HTTP_PORT=port# -DJERSEY_HOST_NAME=hostname
You might find more info about testing Jersey-based applications in our
user guide [1]
Regards,
Pavel
[1]
https://jersey.dev.java.net/source/browse/*checkout*/jersey/trunk/www/documentation/1.2-SNAPSHOT/user-guide.html?rev=3510#d4e1167
Pavel Bucek wrote:
> Hello Jay,
>
> looks like you don't have necessary jars on your classpath.
>
> I guess this is caused by not activating EmbeddedGF profile in
> jersey-test-framework (see [1]). You can do it by adding
> "-Dcontainer.type=EmbeddedGF" to command line when executing tests.
>
> Note that in Jersey 1.2 is breaking change in Jersey test framework
> described in User Guide [2].
>
> Regards,
> Pavel
>
>
> [1]
> http://download.java.net/maven/2/com/sun/jersey/jersey-test-framework/1.1.5.1/jersey-test-framework-1.1.5.1.pom
>
> [2]
> https://jersey.dev.java.net/source/browse/*checkout*/jersey/trunk/www/documentation/1.2-SNAPSHOT/user-guide.html?rev=3510#d4e1167
>
>
> Jay Wang wrote:
>>
>> Hi,
>>
>> I have a problem when I set the TestContainerFactory to
>> EmbeddedGlassfishTestContainerFactory in my test class. (using
>> jersey-test-framework-1.1.5.1.jar)
>>
>> Enclosed are source ans test files.
>>
>> I m using this method to set the TestContainerFactory :
>>
>> @Override
>> protected TestContainerFactory getTestContainerFactory() {
>> return new EmbeddedGlassFishTestContainerFactory();
>> }
>>
>> I got the exception like this:
>>
>> java.lang.NoClassDefFoundError: org/glassfish/embed/EmbeddedException
>> at
>> com.sun.jersey.test.framework.spi.container.embedded.glassfish.EmbeddedGlassFishTestContainerFactory.create(EmbeddedGlassFishTestContainerFactory.java:79)
>>
>> at
>> com.sun.jersey.test.framework.JerseyTest.getContainer(JerseyTest.java:301)
>>
>> at
>> com.sun.jersey.test.framework.JerseyTest.<init>(JerseyTest.java:176)
>> at
>> com.sample.resources.TestResourceContainerTest.<init>(TestResourceContainerTest.java:21)
>>
>> at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
>> Method)
>> at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown
>> Source)
>> at
>> sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown
>> Source)
>> at java.lang.reflect.Constructor.newInstance(Unknown Source)
>> at
>> org.junit.runners.BlockJUnit4ClassRunner.createTest(BlockJUnit4ClassRunner.java:171)
>>
>> at
>> org.junit.runners.BlockJUnit4ClassRunner$1.runReflectiveCall(BlockJUnit4ClassRunner.java:216)
>>
>> at
>> org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
>>
>> at
>> org.junit.runners.BlockJUnit4ClassRunner.methodBlock(BlockJUnit4ClassRunner.java:213)
>>
>> at
>> org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:73)
>>
>> at
>> org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:46)
>>
>> at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:180)
>> at org.junit.runners.ParentRunner.access$000(ParentRunner.java:41)
>> at org.junit.runners.ParentRunner$1.evaluate(ParentRunner.java:173)
>> at
>> org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
>>
>> at
>> org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
>>
>> at org.junit.runners.ParentRunner.run(ParentRunner.java:220)
>> at
>> org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:46)
>>
>> at
>> org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
>>
>> at
>> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
>>
>> at
>> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
>>
>> at
>> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
>>
>> at
>> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
>>
>> Caused by: java.lang.ClassNotFoundException:
>> org.glassfish.embed.EmbeddedException
>> at java.net.URLClassLoader$1.run(Unknown Source)
>> at java.security.AccessController.doPrivileged(Native Method)
>> at java.net.URLClassLoader.findClass(Unknown Source)
>> at java.lang.ClassLoader.loadClass(Unknown Source)
>> at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
>> at java.lang.ClassLoader.loadClass(Unknown Source)
>> at java.lang.ClassLoader.loadClassInternal(Unknown Source)
>> ... 26 more
>>
>> --
>> -------------------
>> /T
>> ------------------------------------------------------------------------
>>
>> ---------------------------------------------------------------------
>> 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
>