You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomee.apache.org by amber <am...@hotmail.fr> on 2014/04/15 13:22:34 UTC

OpenEJB testing REST services

hi, I'am trying to integrate the REST rest-xml-json exemple into my project
(http://www.apache.org/dyn/closer.cgi/tomee/tomee-1.6.0/examples-4.6.0-src.zip)

The exemple works fine into Eclipse and maven command line.

but as soon as I integrate the exemple in my project I have this error :

INFO - Cannot find the configuration file [conf/openejb.xml].  Will attempt
to create one for the beans deployed.
INFO - Configuring Service(id=Default Security Service,
type=SecurityService, provider-id=Default Security Service)
INFO - Configuring Service(id=Default Transaction Manager,
type=TransactionManager, provider-id=Default Transaction Manager)
INFO - Creating TransactionManager(id=Default Transaction Manager)
INFO - Creating SecurityService(id=Default Security Service)
INFO - Initializing network services
INFO - Creating ServerService(id=httpejbd)
INFO - Using 'print=true'
INFO - Using 'indent.xml=true'
INFO - Creating ServerService(id=cxf-rs)
GRAVE - Cannot instantiate the service class
org.apache.openejb.server.cxf.rs.CxfRSService. Received error:
java.lang.NoClassDefFoundError org/apache/cxf/common/logging/LogUtils
java.lang.NoClassDefFoundError: org/apache/cxf/common/logging/LogUtils
	at org.apache.cxf.BusFactory.<clinit>(BusFactory.java:71)
	at
org.apache.openejb.server.cxf.transport.util.CxfUtil.getDefaultBus(CxfUtil.java:76)
	at
org.apache.openejb.server.cxf.transport.util.CxfUtil.configureBus(CxfUtil.java:176)
	at org.apache.openejb.server.cxf.rs.CxfRSService.init(CxfRSService.java:54)
	at
org.apache.openejb.server.ServiceManager.initServer(ServiceManager.java:158)
	at
org.apache.openejb.server.ServiceManager.initServers(ServiceManager.java:88)
	at
org.apache.openejb.server.SimpleServiceManager.init(SimpleServiceManager.java:149)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at
org.apache.openejb.util.ServiceManagerProxy.invoke(ServiceManagerProxy.java:80)
	at
org.apache.openejb.util.ServiceManagerProxy.<init>(ServiceManagerProxy.java:66)
	at
org.apache.openejb.testing.ApplicationComposers.before(ApplicationComposers.java:512)
	at
org.apache.openejb.testing.ApplicationComposers.evaluate(ApplicationComposers.java:590)
	at
org.apache.openejb.junit.ApplicationComposer$DeployApplication.evaluate(ApplicationComposer.java:64)
	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)
	at
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)
	at
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
	at
org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
	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.apache.cxf.common.logging.LogUtils
	at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
	... 31 more


any hint ?



--
View this message in context: http://openejb.979440.n4.nabble.com/OpenEJB-testing-REST-services-tp4668791.html
Sent from the OpenEJB User mailing list archive at Nabble.com.

Re: OpenEJB testing REST services

Posted by Romain Manni-Bucau <rm...@gmail.com>.
Hi

to test a *war* arquillian is more adapted but if you just want to
reuse code it should work


Romain Manni-Bucau
Twitter: @rmannibucau
Blog: http://rmannibucau.wordpress.com/
LinkedIn: http://fr.linkedin.com/in/rmannibucau
Github: https://github.com/rmannibucau


2014-04-22 18:09 GMT+02:00 amber <am...@hotmail.fr>:
> Hi Romain,
>
> finally got it :) thank you for your advices
>
> I migrated from openEJB 4.5.2 to 4.6.0 (there was some problems with
> jboss-as-ejb-client-bom dependency, moved it, and now it's ok), and I
> changed the way to initiate openEJb to :
>
>
>
>
>
> Now I can have a Maven layer to test/junit my REST services above business
> services layer (EJB 3).
>
> Last question : if the RESt services are packaged into the presentation
> layer (WAR) may I test them the same way ? (even if it's a war?)
>
> thx!
>
>
>
>
> --
> View this message in context: http://openejb.979440.n4.nabble.com/OpenEJB-testing-REST-services-tp4668791p4668949.html
> Sent from the OpenEJB User mailing list archive at Nabble.com.

Re: OpenEJB testing REST services

Posted by amber <am...@hotmail.fr>.
Hi Romain,

finally got it :) thank you for your advices

I migrated from openEJB 4.5.2 to 4.6.0 (there was some problems with
jboss-as-ejb-client-bom dependency, moved it, and now it's ok), and I
changed the way to initiate openEJb to :





Now I can have a Maven layer to test/junit my REST services above business
services layer (EJB 3).

Last question : if the RESt services are packaged into the presentation
layer (WAR) may I test them the same way ? (even if it's a war?)

thx!




--
View this message in context: http://openejb.979440.n4.nabble.com/OpenEJB-testing-REST-services-tp4668791p4668949.html
Sent from the OpenEJB User mailing list archive at Nabble.com.

Re: OpenEJB testing REST services

Posted by Romain Manni-Bucau <rm...@gmail.com>.
*track it a bit (sorry)


Romain Manni-Bucau
Twitter: @rmannibucau
Blog: http://rmannibucau.wordpress.com/
LinkedIn: http://fr.linkedin.com/in/rmannibucau
Github: https://github.com/rmannibucau


2014-04-17 17:48 GMT+02:00 Romain Manni-Bucau <rm...@gmail.com>:
> a dep is missing somehow, openejb-cxf-ts and its deps maybe.
>
> maybe try using maven enforcer plugin (dependecy convergence rule) to
> track it a big
>
>
> Romain Manni-Bucau
> Twitter: @rmannibucau
> Blog: http://rmannibucau.wordpress.com/
> LinkedIn: http://fr.linkedin.com/in/rmannibucau
> Github: https://github.com/rmannibucau
>
>
> 2014-04-17 17:45 GMT+02:00 amber <am...@hotmail.fr>:
>> Romain I restart from the "openejb-examples-4.6.0\rest-on-ejb" sample which
>> is more near what I want (inject EJB into the REST layer) :
>>
>>
>>
>>
>>
>> Works fine as a single module,
>> Now when I integrate it  with our super-pom (as parent), there is conflicts
>> ..;
>> Caused by: java.lang.ClassNotFoundException:
>> org.apache.cxf.common.i18n.UncheckedException
>>
>>
>> just to find the bad dependencies :p
>>
>>
>>
>>
>> --
>> View this message in context: http://openejb.979440.n4.nabble.com/OpenEJB-testing-REST-services-tp4668791p4668880.html
>> Sent from the OpenEJB User mailing list archive at Nabble.com.

Re: OpenEJB testing REST services

Posted by Romain Manni-Bucau <rm...@gmail.com>.
a dep is missing somehow, openejb-cxf-ts and its deps maybe.

maybe try using maven enforcer plugin (dependecy convergence rule) to
track it a big


Romain Manni-Bucau
Twitter: @rmannibucau
Blog: http://rmannibucau.wordpress.com/
LinkedIn: http://fr.linkedin.com/in/rmannibucau
Github: https://github.com/rmannibucau


2014-04-17 17:45 GMT+02:00 amber <am...@hotmail.fr>:
> Romain I restart from the "openejb-examples-4.6.0\rest-on-ejb" sample which
> is more near what I want (inject EJB into the REST layer) :
>
>
>
>
>
> Works fine as a single module,
> Now when I integrate it  with our super-pom (as parent), there is conflicts
> ..;
> Caused by: java.lang.ClassNotFoundException:
> org.apache.cxf.common.i18n.UncheckedException
>
>
> just to find the bad dependencies :p
>
>
>
>
> --
> View this message in context: http://openejb.979440.n4.nabble.com/OpenEJB-testing-REST-services-tp4668791p4668880.html
> Sent from the OpenEJB User mailing list archive at Nabble.com.

Re: OpenEJB testing REST services

Posted by amber <am...@hotmail.fr>.
Romain I restart from the "openejb-examples-4.6.0\rest-on-ejb" sample which
is more near what I want (inject EJB into the REST layer) :





Works fine as a single module,
Now when I integrate it  with our super-pom (as parent), there is conflicts
..;
Caused by: java.lang.ClassNotFoundException:
org.apache.cxf.common.i18n.UncheckedException 


just to find the bad dependencies :p




--
View this message in context: http://openejb.979440.n4.nabble.com/OpenEJB-testing-REST-services-tp4668791p4668880.html
Sent from the OpenEJB User mailing list archive at Nabble.com.

Re: OpenEJB testing REST services

Posted by Romain Manni-Bucau <rm...@gmail.com>.
not sure I get it properly, basically I would just expect a cleanup of
dependencies to run cleanly on trunk


Romain Manni-Bucau
Twitter: @rmannibucau
Blog: http://rmannibucau.wordpress.com/
LinkedIn: http://fr.linkedin.com/in/rmannibucau
Github: https://github.com/rmannibucau


2014-04-17 10:19 GMT+02:00 amber <am...@hotmail.fr>:
> the use case I reach from the sample I sended would be to change  the code
> from the "GreetingService" to :
>
>
>
>
>
>
>
> --
> View this message in context: http://openejb.979440.n4.nabble.com/OpenEJB-testing-REST-services-tp4668791p4668845.html
> Sent from the OpenEJB User mailing list archive at Nabble.com.

Re: OpenEJB testing REST services

Posted by amber <am...@hotmail.fr>.
the use case I reach from the sample I sended would be to change  the code
from the "GreetingService" to :







--
View this message in context: http://openejb.979440.n4.nabble.com/OpenEJB-testing-REST-services-tp4668791p4668845.html
Sent from the OpenEJB User mailing list archive at Nabble.com.

Re: OpenEJB testing REST services

Posted by Romain Manni-Bucau <rm...@gmail.com>.
Your use case is valid and close to what we do in cxf-rs module for
tests. Not sure why we didn't get this side effect too.

Maybe try today's snapshot, it should work


Romain Manni-Bucau
Twitter: @rmannibucau
Blog: http://rmannibucau.wordpress.com/
LinkedIn: http://fr.linkedin.com/in/rmannibucau
Github: https://github.com/rmannibucau


2014-04-17 9:08 GMT+02:00 amber <am...@hotmail.fr>:
> Ok , I sould remove this dependency so.
>
>
> About mixing, what I want to do is a layer with REST services (and their
> tests) that uses a business layer (EJB 3) :
>
> @Path("foorest")
> @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
> @Consumes({ "application/xml", "application/json" })
> @Stateless
> public class FooRest {
>
>   @EJB
>   private Foo foo;
>
> ...
> }
>
>
> I don't find a sample to do that (there is rest-on-ejb but it use lookup).
>
> thx for your patience Romain ^^
>
>
>
>
>
> --
> View this message in context: http://openejb.979440.n4.nabble.com/OpenEJB-testing-REST-services-tp4668791p4668839.html
> Sent from the OpenEJB User mailing list archive at Nabble.com.

Re: OpenEJB testing REST services

Posted by amber <am...@hotmail.fr>.
Ok , I sould remove this dependency so.


About mixing, what I want to do is a layer with REST services (and their
tests) that uses a business layer (EJB 3) :

@Path("foorest")
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Consumes({ "application/xml", "application/json" })
@Stateless
public class FooRest {

  @EJB 
  private Foo foo;

...
}


I don't find a sample to do that (there is rest-on-ejb but it use lookup).

thx for your patience Romain ^^

 



--
View this message in context: http://openejb.979440.n4.nabble.com/OpenEJB-testing-REST-services-tp4668791p4668839.html
Sent from the OpenEJB User mailing list archive at Nabble.com.

Re: OpenEJB testing REST services

Posted by Romain Manni-Bucau <rm...@gmail.com>.
javax:javaee-api 6 is not correct bytecode IIRC, more or less API to
implement but not to run (and tests need runtime ;)).

It has been fixed with EE 7 API jar btw. That said you use javaee-api
from openejb so don't mix both.

About LocalInitialContextFactory you mix sthg (surely not clear).
Using new InitialContext to boot the container (old openejb way) it
was mandatory but using EJBContainer API it is not, the API does it
for you (more or less)


Romain Manni-Bucau
Twitter: @rmannibucau
Blog: http://rmannibucau.wordpress.com/
LinkedIn: http://fr.linkedin.com/in/rmannibucau
Github: https://github.com/rmannibucau


2014-04-17 8:29 GMT+02:00 amber <am...@hotmail.fr>:
> Hi romain,
>
> javax.javaee-api is jee 6 api, why is it wrong ?
>
>
> p.put(Context.INITIAL_CONTEXT_FACTORY,"org.apache.openejb.client.LocalInitialContextFactory");
> is present in almost all samples  ???
>
> Glad you find the  problem ^^
>
>
>
> --
> View this message in context: http://openejb.979440.n4.nabble.com/OpenEJB-testing-REST-services-tp4668791p4668835.html
> Sent from the OpenEJB User mailing list archive at Nabble.com.

Re: OpenEJB testing REST services

Posted by amber <am...@hotmail.fr>.
Hi romain,

javax.javaee-api is jee 6 api, why is it wrong ?


p.put(Context.INITIAL_CONTEXT_FACTORY,"org.apache.openejb.client.LocalInitialContextFactory"); 
is present in almost all samples  ???

Glad you find the  problem ^^



--
View this message in context: http://openejb.979440.n4.nabble.com/OpenEJB-testing-REST-services-tp4668791p4668835.html
Sent from the OpenEJB User mailing list archive at Nabble.com.

Re: OpenEJB testing REST services

Posted by Romain Manni-Bucau <rm...@gmail.com>.
first you don't need:

 p.put(Context.INITIAL_CONTEXT_FACTORY,"org.apache.openejb.client.LocalInitialContextFactory");

and

// context.close();

in abstracttest


then your dependency are crappy so you have some wrong dependencies
making everything failing (some javax.javaee)

I got your test almost running on trunk (didnt test with 4.5) but
either using only WebApp or using only EJBContainer.

I think I identified the issue using both in your case (weird we do it
on trunk without issue). Should be fixed tomorrow on trunk



Romain Manni-Bucau
Twitter: @rmannibucau
Blog: http://rmannibucau.wordpress.com/
LinkedIn: http://fr.linkedin.com/in/rmannibucau
Github: https://github.com/rmannibucau


2014-04-16 17:02 GMT+02:00 amber <am...@hotmail.fr>:
> sorry I missed the attached zip (I have added new tests)
>
> rest-xml-json.zip
> <http://openejb.979440.n4.nabble.com/file/n4668826/rest-xml-json.zip>
>
>
>
>
>
> --
> View this message in context: http://openejb.979440.n4.nabble.com/OpenEJB-testing-REST-services-tp4668791p4668826.html
> Sent from the OpenEJB User mailing list archive at Nabble.com.

Re: OpenEJB testing REST services

Posted by amber <am...@hotmail.fr>.
sorry I missed the attached zip (I have added new tests)

rest-xml-json.zip
<http://openejb.979440.n4.nabble.com/file/n4668826/rest-xml-json.zip>  





--
View this message in context: http://openejb.979440.n4.nabble.com/OpenEJB-testing-REST-services-tp4668791p4668826.html
Sent from the OpenEJB User mailing list archive at Nabble.com.

Re: OpenEJB testing REST services

Posted by Romain Manni-Bucau <rm...@gmail.com>.
don't get you, there is a single test, no?


Romain Manni-Bucau
Twitter: @rmannibucau
Blog: http://rmannibucau.wordpress.com/
LinkedIn: http://fr.linkedin.com/in/rmannibucau
Github: https://github.com/rmannibucau


2014-04-16 16:06 GMT+02:00 amber <am...@hotmail.fr>:
> Hi Romain,
>
> they are not...
>
> I made a sample from the "rest-xml-json" exemple (from the zip) :
>
> *1)* works fine from Maven command line
>
> *2)* fail into Eclipse Kepler/Jdk1.6 (run as Junit Test on folder
> src/test/java)
>
>
> *3)* work into Eclipse if you run each test alone...
>
> Maybe the cycle for openEjb is not good, but was working well until our
> tests with REST
>
>
>
>
>
>
>
> --
> View this message in context: http://openejb.979440.n4.nabble.com/OpenEJB-testing-REST-services-tp4668791p4668822.html
> Sent from the OpenEJB User mailing list archive at Nabble.com.

Re: OpenEJB testing REST services

Posted by amber <am...@hotmail.fr>.
Hi Romain, 

they are not...

I made a sample from the "rest-xml-json" exemple (from the zip) : 

*1)* works fine from Maven command line

*2)* fail into Eclipse Kepler/Jdk1.6 (run as Junit Test on folder
src/test/java)


*3)* work into Eclipse if you run each test alone...

Maybe the cycle for openEjb is not good, but was working well until our
tests with REST







--
View this message in context: http://openejb.979440.n4.nabble.com/OpenEJB-testing-REST-services-tp4668791p4668822.html
Sent from the OpenEJB User mailing list archive at Nabble.com.

Re: OpenEJB testing REST services

Posted by Romain Manni-Bucau <rm...@gmail.com>.
examples are taken from this link so should be the same


Romain Manni-Bucau
Twitter: @rmannibucau
Blog: http://rmannibucau.wordpress.com/
LinkedIn: http://fr.linkedin.com/in/rmannibucau
Github: https://github.com/rmannibucau


2014-04-16 10:38 GMT+02:00 amber <am...@hotmail.fr>:
> it's not easy to extract a sample form the whole solution :(
>
> Anyway our goal is to test REST service located in the Web Maven module
> (war) so I guess we should go head with the tomee sample ( link
> <http://svn.apache.org/repos/asf/tomee/tomee/trunk/examples/rest-example/>
> )?
>
> Just to be sure : we are talking about the sample from the
> examples-4.6.0-src.zip
> (http://www.apache.org/dyn/closer.cgi/tomee/tomee-1.6.0/examples-4.6.0-src.zip)
> and not the one from this link
> http://svn.apache.org/repos/asf/tomee/tomee/trunk/examples/rest-example/
>
>
>
>
>
> --
> View this message in context: http://openejb.979440.n4.nabble.com/OpenEJB-testing-REST-services-tp4668791p4668818.html
> Sent from the OpenEJB User mailing list archive at Nabble.com.

Re: OpenEJB testing REST services

Posted by amber <am...@hotmail.fr>.
it's not easy to extract a sample form the whole solution :(

Anyway our goal is to test REST service located in the Web Maven module
(war) so I guess we should go head with the tomee sample ( link
<http://svn.apache.org/repos/asf/tomee/tomee/trunk/examples/rest-example/> 
)?

Just to be sure : we are talking about the sample from the
examples-4.6.0-src.zip
(http://www.apache.org/dyn/closer.cgi/tomee/tomee-1.6.0/examples-4.6.0-src.zip)
and not the one from this link
http://svn.apache.org/repos/asf/tomee/tomee/trunk/examples/rest-example/





--
View this message in context: http://openejb.979440.n4.nabble.com/OpenEJB-testing-REST-services-tp4668791p4668818.html
Sent from the OpenEJB User mailing list archive at Nabble.com.

Re: OpenEJB testing REST services

Posted by Romain Manni-Bucau <rm...@gmail.com>.
ok,

this example uses ApplicationComposer for testing which handles
correctly lifecycle. you can normally get the context injected using
AppResource  annotation IIRC.

the best to go ahread would be a sample showing your issue I think
Romain Manni-Bucau
Twitter: @rmannibucau
Blog: http://rmannibucau.wordpress.com/
LinkedIn: http://fr.linkedin.com/in/rmannibucau
Github: https://github.com/rmannibucau



2014-04-15 18:24 GMT+02:00 amber <am...@hotmail.fr>:
> I don't understand : If i follow the sample "rest-xml-json"  I need to use
> openejb-cxf-rs to test REST services ?
>
> note : getContext() is only a getter on the Context object.
>
>
>
>
>
>
> Romain Manni-Bucau wrote
>> right jboss deps will bring comons-logging and potentially some
>> overrides of cxf (pretty sure). If you don't need openejb jaxrs
>> integration remove openejb-cxf-rs dependency. WHat's getContext?
>> ejbcontainer.getCOntext()? can be jboss EJBContainer maybe depending
>> your deps.
>> Romain Manni-Bucau
>> Twitter: @rmannibucau
>> Blog: http://rmannibucau.wordpress.com/
>> LinkedIn: http://fr.linkedin.com/in/rmannibucau
>> Github: https://github.com/rmannibucau
>>
>>
>>
>> 2014-04-15 15:52 GMT+02:00 amber &lt;
>
>> amber63@
>
>> &gt;:
>>> Hi Romain,
>>>
>>> how to check every JAR ?? (you talk about
>>> https://cxf.apache.org/docs/debugging-and-logging.html)
>>>
>>> Anyway I'v tried to put this file put same error.
>>>
>>>
>>> Also, I've tried to put my own pom settings content into the sample to
>>> identify which dependency cause the error : I've isolated the
>>> "boss-as-ejb-client-bom" dependency as source of errors....
>>>
>>> Now, into the sample, if I set it into  a
>> <dependencyManagement>
>>  section I
>>> got the error :
>>>
>>>
>>> If I move it into the
>> <dependecies>
>>  section all is fine...
>>>
>>>
>>> And now if I remove the jboss client bom from my entreprise solution
>>> where
>>> I've integrate the sample "rest-xml-json" :
>>> - running junit from Eclipse works fine onto the rest-xml-json test
>>> - running junit from Eclipse on each other tests works fine
>>> - running the whole unit tests (include the rest-xml-json) give me random
>>> errors :
>>>
>>>
>>>
>>> The code where the null is the initialisation of openEJB :
>>>
>>>
>>>
>>> The others tests uses OpnEJB to test EJBs, may be it 's interfering with
>>> jax
>>> rs tests ? I 'am using jdk 1.6 (so Jersey REST)
>>>
>>> thx!
>>>
>>>
>>>
>>> --
>>> View this message in context:
>>> http://openejb.979440.n4.nabble.com/OpenEJB-testing-REST-services-tp4668791p4668796.html
>>> Sent from the OpenEJB User mailing list archive at Nabble.com.
>
>
>
>
>
> --
> View this message in context: http://openejb.979440.n4.nabble.com/OpenEJB-testing-REST-services-tp4668791p4668800.html
> Sent from the OpenEJB User mailing list archive at Nabble.com.

Re: OpenEJB testing REST services

Posted by amber <am...@hotmail.fr>.
I don't understand : If i follow the sample "rest-xml-json"  I need to use
openejb-cxf-rs to test REST services ?

note : getContext() is only a getter on the Context object.






Romain Manni-Bucau wrote
> right jboss deps will bring comons-logging and potentially some
> overrides of cxf (pretty sure). If you don't need openejb jaxrs
> integration remove openejb-cxf-rs dependency. WHat's getContext?
> ejbcontainer.getCOntext()? can be jboss EJBContainer maybe depending
> your deps.
> Romain Manni-Bucau
> Twitter: @rmannibucau
> Blog: http://rmannibucau.wordpress.com/
> LinkedIn: http://fr.linkedin.com/in/rmannibucau
> Github: https://github.com/rmannibucau
> 
> 
> 
> 2014-04-15 15:52 GMT+02:00 amber &lt;

> amber63@

> &gt;:
>> Hi Romain,
>>
>> how to check every JAR ?? (you talk about
>> https://cxf.apache.org/docs/debugging-and-logging.html)
>>
>> Anyway I'v tried to put this file put same error.
>>
>>
>> Also, I've tried to put my own pom settings content into the sample to
>> identify which dependency cause the error : I've isolated the
>> "boss-as-ejb-client-bom" dependency as source of errors....
>>
>> Now, into the sample, if I set it into  a 
> <dependencyManagement>
>  section I
>> got the error :
>>
>>
>> If I move it into the  
> <dependecies>
>  section all is fine...
>>
>>
>> And now if I remove the jboss client bom from my entreprise solution 
>> where
>> I've integrate the sample "rest-xml-json" :
>> - running junit from Eclipse works fine onto the rest-xml-json test
>> - running junit from Eclipse on each other tests works fine
>> - running the whole unit tests (include the rest-xml-json) give me random
>> errors :
>>
>>
>>
>> The code where the null is the initialisation of openEJB :
>>
>>
>>
>> The others tests uses OpnEJB to test EJBs, may be it 's interfering with
>> jax
>> rs tests ? I 'am using jdk 1.6 (so Jersey REST)
>>
>> thx!
>>
>>
>>
>> --
>> View this message in context:
>> http://openejb.979440.n4.nabble.com/OpenEJB-testing-REST-services-tp4668791p4668796.html
>> Sent from the OpenEJB User mailing list archive at Nabble.com.





--
View this message in context: http://openejb.979440.n4.nabble.com/OpenEJB-testing-REST-services-tp4668791p4668800.html
Sent from the OpenEJB User mailing list archive at Nabble.com.

Re: OpenEJB testing REST services

Posted by Romain Manni-Bucau <rm...@gmail.com>.
right jboss deps will bring comons-logging and potentially some
overrides of cxf (pretty sure). If you don't need openejb jaxrs
integration remove openejb-cxf-rs dependency. WHat's getContext?
ejbcontainer.getCOntext()? can be jboss EJBContainer maybe depending
your deps.
Romain Manni-Bucau
Twitter: @rmannibucau
Blog: http://rmannibucau.wordpress.com/
LinkedIn: http://fr.linkedin.com/in/rmannibucau
Github: https://github.com/rmannibucau



2014-04-15 15:52 GMT+02:00 amber <am...@hotmail.fr>:
> Hi Romain,
>
> how to check every JAR ?? (you talk about
> https://cxf.apache.org/docs/debugging-and-logging.html)
>
> Anyway I'v tried to put this file put same error.
>
>
> Also, I've tried to put my own pom settings content into the sample to
> identify which dependency cause the error : I've isolated the
> "boss-as-ejb-client-bom" dependency as source of errors....
>
> Now, into the sample, if I set it into  a <dependencyManagement> section I
> got the error :
>
>
> If I move it into the  <dependecies> section all is fine...
>
>
> And now if I remove the jboss client bom from my entreprise solution  where
> I've integrate the sample "rest-xml-json" :
> - running junit from Eclipse works fine onto the rest-xml-json test
> - running junit from Eclipse on each other tests works fine
> - running the whole unit tests (include the rest-xml-json) give me random
> errors :
>
>
>
> The code where the null is the initialisation of openEJB :
>
>
>
> The others tests uses OpnEJB to test EJBs, may be it 's interfering with jax
> rs tests ? I 'am using jdk 1.6 (so Jersey REST)
>
> thx!
>
>
>
> --
> View this message in context: http://openejb.979440.n4.nabble.com/OpenEJB-testing-REST-services-tp4668791p4668796.html
> Sent from the OpenEJB User mailing list archive at Nabble.com.

Re: OpenEJB testing REST services

Posted by Romain Manni-Bucau <rm...@gmail.com>.
well actually I think it is linked to your setup. Closing container is
important but using both works well on our build on I used it a lot
for business projects. That said if a test doesnt handle correctly its
lifecycle you can get unpredictable behavior when running next one
(two start will just make the second one reuse old context for
instance)
Romain Manni-Bucau
Twitter: @rmannibucau
Blog: http://rmannibucau.wordpress.com/
LinkedIn: http://fr.linkedin.com/in/rmannibucau
Github: https://github.com/rmannibucau



2014-04-15 18:06 GMT+02:00 amber <am...@hotmail.fr>:
> For the null, error, we have to explicit close the ejbcontainer :
>
> init :
> ...
> ejbcontainer = EJBContainer.createEJBContainer(p);
> ...
>
> @AfterClass
>         public static void stop() {
>                 if (context != null) {
>                         context.close();
>                         ejbcontainer.close();
>                 }
>         }
>
> works fine on one module Maven, but on another still some tests failure only
> with eclipse (ok with Maven)...
>
> Working with both openEJb embedd and jaxrs seems .. not easy ?
>
>
>
>
>
>
>
> --
> View this message in context: http://openejb.979440.n4.nabble.com/OpenEJB-testing-REST-services-tp4668791p4668798.html
> Sent from the OpenEJB User mailing list archive at Nabble.com.

Re: OpenEJB testing REST services

Posted by amber <am...@hotmail.fr>.
For the null, error, we have to explicit close the ejbcontainer :

init :
...
ejbcontainer = EJBContainer.createEJBContainer(p);
...

@AfterClass
	public static void stop() {
		if (context != null) {
			context.close();
			ejbcontainer.close();
		}
	}

works fine on one module Maven, but on another still some tests failure only
with eclipse (ok with Maven)...

Working with both openEJb embedd and jaxrs seems .. not easy ?







--
View this message in context: http://openejb.979440.n4.nabble.com/OpenEJB-testing-REST-services-tp4668791p4668798.html
Sent from the OpenEJB User mailing list archive at Nabble.com.

Re: OpenEJB testing REST services

Posted by amber <am...@hotmail.fr>.
Hi Romain,

how to check every JAR ?? (you talk about
https://cxf.apache.org/docs/debugging-and-logging.html) 

Anyway I'v tried to put this file put same error.


Also, I've tried to put my own pom settings content into the sample to
identify which dependency cause the error : I've isolated the
"boss-as-ejb-client-bom" dependency as source of errors....

Now, into the sample, if I set it into  a <dependencyManagement> section I
got the error :


If I move it into the  <dependecies> section all is fine...


And now if I remove the jboss client bom from my entreprise solution  where
I've integrate the sample "rest-xml-json" :
- running junit from Eclipse works fine onto the rest-xml-json test
- running junit from Eclipse on each other tests works fine
- running the whole unit tests (include the rest-xml-json) give me random
errors :



The code where the null is the initialisation of openEJB :

	

The others tests uses OpnEJB to test EJBs, may be it 's interfering with jax
rs tests ? I 'am using jdk 1.6 (so Jersey REST)

thx!



--
View this message in context: http://openejb.979440.n4.nabble.com/OpenEJB-testing-REST-services-tp4668791p4668796.html
Sent from the OpenEJB User mailing list archive at Nabble.com.

Re: OpenEJB testing REST services

Posted by Romain Manni-Bucau <rm...@gmail.com>.
do you have at classpath a jar containing META-INF/cxf/org.apache.cxf.Logger ?
Romain Manni-Bucau
Twitter: @rmannibucau
Blog: http://rmannibucau.wordpress.com/
LinkedIn: http://fr.linkedin.com/in/rmannibucau
Github: https://github.com/rmannibucau



2014-04-15 13:22 GMT+02:00 amber <am...@hotmail.fr>:
> hi, I'am trying to integrate the REST rest-xml-json exemple into my project
> (http://www.apache.org/dyn/closer.cgi/tomee/tomee-1.6.0/examples-4.6.0-src.zip)
>
> The exemple works fine into Eclipse and maven command line.
>
> but as soon as I integrate the exemple in my project I have this error :
>
> INFO - Cannot find the configuration file [conf/openejb.xml].  Will attempt
> to create one for the beans deployed.
> INFO - Configuring Service(id=Default Security Service,
> type=SecurityService, provider-id=Default Security Service)
> INFO - Configuring Service(id=Default Transaction Manager,
> type=TransactionManager, provider-id=Default Transaction Manager)
> INFO - Creating TransactionManager(id=Default Transaction Manager)
> INFO - Creating SecurityService(id=Default Security Service)
> INFO - Initializing network services
> INFO - Creating ServerService(id=httpejbd)
> INFO - Using 'print=true'
> INFO - Using 'indent.xml=true'
> INFO - Creating ServerService(id=cxf-rs)
> GRAVE - Cannot instantiate the service class
> org.apache.openejb.server.cxf.rs.CxfRSService. Received error:
> java.lang.NoClassDefFoundError org/apache/cxf/common/logging/LogUtils
> java.lang.NoClassDefFoundError: org/apache/cxf/common/logging/LogUtils
>         at org.apache.cxf.BusFactory.<clinit>(BusFactory.java:71)
>         at
> org.apache.openejb.server.cxf.transport.util.CxfUtil.getDefaultBus(CxfUtil.java:76)
>         at
> org.apache.openejb.server.cxf.transport.util.CxfUtil.configureBus(CxfUtil.java:176)
>         at org.apache.openejb.server.cxf.rs.CxfRSService.init(CxfRSService.java:54)
>         at
> org.apache.openejb.server.ServiceManager.initServer(ServiceManager.java:158)
>         at
> org.apache.openejb.server.ServiceManager.initServers(ServiceManager.java:88)
>         at
> org.apache.openejb.server.SimpleServiceManager.init(SimpleServiceManager.java:149)
>         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>         at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>         at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>         at java.lang.reflect.Method.invoke(Method.java:597)
>         at
> org.apache.openejb.util.ServiceManagerProxy.invoke(ServiceManagerProxy.java:80)
>         at
> org.apache.openejb.util.ServiceManagerProxy.<init>(ServiceManagerProxy.java:66)
>         at
> org.apache.openejb.testing.ApplicationComposers.before(ApplicationComposers.java:512)
>         at
> org.apache.openejb.testing.ApplicationComposers.evaluate(ApplicationComposers.java:590)
>         at
> org.apache.openejb.junit.ApplicationComposer$DeployApplication.evaluate(ApplicationComposer.java:64)
>         at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)
>         at
> org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)
>         at
> org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)
>         at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
>         at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
>         at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
>         at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
>         at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
>         at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
>         at
> org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
>         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.apache.cxf.common.logging.LogUtils
>         at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
>         at java.security.AccessController.doPrivileged(Native Method)
>         at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
>         at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
>         at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
>         at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
>         ... 31 more
>
>
> any hint ?
>
>
>
> --
> View this message in context: http://openejb.979440.n4.nabble.com/OpenEJB-testing-REST-services-tp4668791.html
> Sent from the OpenEJB User mailing list archive at Nabble.com.

Re: OpenEJB testing REST services

Posted by Romain Manni-Bucau <rm...@gmail.com>.
our default is JUL which should be provided (slf4j-jdk14) but here it
is overriden somehow by commons logging.
-Dorg.apache.cxf.Logger=org.apache.cxf.common.logging.Slf4jLogger can
help but really shouldn't
Romain Manni-Bucau
Twitter: @rmannibucau
Blog: http://rmannibucau.wordpress.com/
LinkedIn: http://fr.linkedin.com/in/rmannibucau
Github: https://github.com/rmannibucau



2014-04-15 15:36 GMT+02:00 agumbrecht <ag...@tomitribe.com>:
> I think I may have seen this before due to a missing log4j dependency? You
> could try adding that to you pom.
>
> Andy.
>
>
>
> -----
>     --
>     Andy Gumbrecht
>
>     http://www.tomitribe.com | agumbrecht@tomitribe.com | https://twitter.com/AndyGeeDe
>
>     Tomitribe treibt TomEE! | http://tomee.apache.org
> --
> View this message in context: http://openejb.979440.n4.nabble.com/OpenEJB-testing-REST-services-tp4668791p4668794.html
> Sent from the OpenEJB User mailing list archive at Nabble.com.

Re: OpenEJB testing REST services

Posted by agumbrecht <ag...@tomitribe.com>.
I think I may have seen this before due to a missing log4j dependency? You
could try adding that to you pom.

Andy.



-----
    -- 
    Andy Gumbrecht

    http://www.tomitribe.com | agumbrecht@tomitribe.com | https://twitter.com/AndyGeeDe

    Tomitribe treibt TomEE! | http://tomee.apache.org
--
View this message in context: http://openejb.979440.n4.nabble.com/OpenEJB-testing-REST-services-tp4668791p4668794.html
Sent from the OpenEJB User mailing list archive at Nabble.com.