You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomee.apache.org by AndreasN <a....@hotmail.de> on 2013/05/23 14:51:42 UTC

ApplicationComposer JUnit EJB Tests autoscanning issue and Hibernate

Hi,

I have some problems to get a basic setup with the ApplcationComposer
running, unfortunately without an option of use the persistence.xml, wherein
hibernate JPA is configured and does all the entity loading and
initialisation stuff automatically. 

I noticed and read somewhere that the responsibility of the persistence unit
is isolated in the ApplicationComposer and therefore all required entities
needs to setup here, of course all needed EJBs also. 
So I tried hard to resolve each dependency within our application
integration tests and added entities "by hand" without success and ended up
in using the reqular test environment with extreme long running startup time
of 15sec due automized EJB loading. Please do not ask me for specific error
messages, sometimes I got NullPointers, sometimes
IncompatibleClassChangeErrors, it varies in the amount of classes (Entites /
EJBs)  I loaded and thrown by Hibernate or OpenEJB....


The application I do testing consists of more than 100 EJBs and a couple of
hundred entities, for that the automized EJB loading is not really
applicable for building fast test cases where only a few EJBs are for
interest.

I read in the JIRA OPENEJB-1526, one suggestion of using the arquillian
adapter which should be intended for such cases, but I didn't find any
examples. 

The example were I build up my test case is based on this article: 

http://tomee.apache.org/examples-trunk/application-composer/

I have some questions: 

1.) In release 4.5.2 of OpenEJB core the Configuration and Module
annotations are marked as depreciated:

   import org.apache.openejb.junit.Configuration;
   import org.apache.openejb.junit.Module;

why? 

2.) Instead of the constructing the Persistence unit programmatically /
manually, it should be possible to let Hibernate (or other JPA Provider) do
that work - ergo loading the persistence.xml. 

Are there any planning or workarounds exist?

3.) It should be possible to pin down some EJBs for loading ergo do not load
all
 
I rely on an old article which reflect the same: 

http://www.marchwicki.pl/blog/2011/07/testing-ejb-applicatin-openejb-without-classpath-scanning/

and did read this tutorial: 

http://tomee.apache.org/application-discovery-via-the-classpath.html

4.) Does there are more complete JPA / EJB example for testing exist??


Hopefully someone can help!

Thank you for some comments, thoughts and ideas.



Kind regards,
Andreas


 




--
View this message in context: http://openejb.979440.n4.nabble.com/ApplicationComposer-JUnit-EJB-Tests-autoscanning-issue-and-Hibernate-tp4663182.html
Sent from the OpenEJB Dev mailing list archive at Nabble.com.

Re: ApplicationComposer JUnit EJB Tests autoscanning issue and Hibernate

Posted by AndreasN <a....@hotmail.de>.
There are too many mappings of nearly 500 entites for the session factory;
therefore I did fight for seconds ;-)

I'm relaxed for now by removing one structural biderectional mapping, I
break down the module application part with 30 entities to unit test, the
inititalisation takes just 2,5 secs, I'm very glad with that differentiated
setup.

Kind regards,
Andreas 



--
View this message in context: http://openejb.979440.n4.nabble.com/ApplicationComposer-JUnit-EJB-Tests-autoscanning-issue-and-Hibernate-tp4663182p4663246.html
Sent from the OpenEJB Dev mailing list archive at Nabble.com.

Re: ApplicationComposer JUnit EJB Tests autoscanning issue and Hibernate

Posted by Romain Manni-Bucau <rm...@gmail.com>.
did you try monitoring what was long? 10s for an application composer run
sounds like super long

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



2013/5/27 AndreasN <a....@hotmail.de>

> Works like a charm, the hibernate.query.startup_check property speeds up
> the
> startup time from 13sec to 10 sec.
>
> The other properties didn't have any impact.
>
>
>
>
> --
> View this message in context:
> http://openejb.979440.n4.nabble.com/ApplicationComposer-JUnit-EJB-Tests-autoscanning-issue-and-Hibernate-tp4663182p4663242.html
> Sent from the OpenEJB Dev mailing list archive at Nabble.com.
>

Re: ApplicationComposer JUnit EJB Tests autoscanning issue and Hibernate

Posted by AndreasN <a....@hotmail.de>.
Works like a charm, the hibernate.query.startup_check property speeds up the
startup time from 13sec to 10 sec. 

The other properties didn't have any impact.




--
View this message in context: http://openejb.979440.n4.nabble.com/ApplicationComposer-JUnit-EJB-Tests-autoscanning-issue-and-Hibernate-tp4663182p4663242.html
Sent from the OpenEJB Dev mailing list archive at Nabble.com.

Re: ApplicationComposer JUnit EJB Tests autoscanning issue and Hibernate

Posted by AndreasN <a....@hotmail.de>.
Hi,

I'll give it a try tomorrow !

Other options I found were hibernate specific, I guess the undocumented
option  "hibernate.query.startup_check" will bring the most boost during the
start up; I have hundreds of named queries...

Probably the mapping constraint checks could not skipped due the nature of a
consistent persistence factory. 

Other options, no clue if they would have any impact on the initialisation
part, I will test too:

hibernate.bytecode.provider=cglib|javassist
hibernate.bytecode.use_reflection_optimizer=true|false

https://hibernate.atlassian.net/browse/HHH-2193
hibernate.query.startup_check true/false

I think we are done, thank you!

Kind regards,
Andreas



--
View this message in context: http://openejb.979440.n4.nabble.com/ApplicationComposer-JUnit-EJB-Tests-autoscanning-issue-and-Hibernate-tp4663182p4663231.html
Sent from the OpenEJB Dev mailing list archive at Nabble.com.

Re: ApplicationComposer JUnit EJB Tests autoscanning issue and Hibernate

Posted by Romain Manni-Bucau <rm...@gmail.com>.
-Dopenejb.validation.skip=true
Le 24 mai 2013 19:03, "AndreasN" <a....@hotmail.de> a écrit :

> Did not work, tested two properties I guess intended for that. Let me know,
> please!
>
>
>
> --
> View this message in context:
> http://openejb.979440.n4.nabble.com/ApplicationComposer-JUnit-EJB-Tests-autoscanning-issue-and-Hibernate-tp4663182p4663212.html
> Sent from the OpenEJB Dev mailing list archive at Nabble.com.
>

Re: ApplicationComposer JUnit EJB Tests autoscanning issue and Hibernate

Posted by AndreasN <a....@hotmail.de>.
Did not work, tested two properties I guess intended for that. Let me know,
please!



--
View this message in context: http://openejb.979440.n4.nabble.com/ApplicationComposer-JUnit-EJB-Tests-autoscanning-issue-and-Hibernate-tp4663182p4663212.html
Sent from the OpenEJB Dev mailing list archive at Nabble.com.

Re: ApplicationComposer JUnit EJB Tests autoscanning issue and Hibernate

Posted by Romain Manni-Bucau <rm...@gmail.com>.
Dont recall it right now but validations can be skipped through a property
Le 24 mai 2013 18:12, "AndreasN" <a....@hotmail.de> a écrit :

> Hi,
>
> I got everything running in my test environment, without the needs of
> additional investigation in persistence.xml. There were entities missing
> and
> some missconfiguration in the persistenceunit leads to errors.
>
> In comparison with the normal setup I have 2 test cases and can save 4sec
> more to the specific ApplicationComposer approach. One annoying issue
> remains, the needs of hibernate to initialize each entity and a missing
> property to skip the validation of everything and let it do on demand
> during
> runtime. I would wish an existing option to speed up the load time.
>
> Nevertheless, the framework is great for testing and make my day :-)
>
> Thank you for assistance!
>
> Kind regards,
> Andreas
>
>
>
> --
> View this message in context:
> http://openejb.979440.n4.nabble.com/ApplicationComposer-JUnit-EJB-Tests-autoscanning-issue-and-Hibernate-tp4663182p4663210.html
> Sent from the OpenEJB Dev mailing list archive at Nabble.com.
>

Re: ApplicationComposer JUnit EJB Tests autoscanning issue and Hibernate

Posted by AndreasN <a....@hotmail.de>.
Hi,

I got everything running in my test environment, without the needs of
additional investigation in persistence.xml. There were entities missing and
some missconfiguration in the persistenceunit leads to errors.

In comparison with the normal setup I have 2 test cases and can save 4sec
more to the specific ApplicationComposer approach. One annoying issue
remains, the needs of hibernate to initialize each entity and a missing
property to skip the validation of everything and let it do on demand during
runtime. I would wish an existing option to speed up the load time. 

Nevertheless, the framework is great for testing and make my day :-)

Thank you for assistance!

Kind regards,
Andreas



--
View this message in context: http://openejb.979440.n4.nabble.com/ApplicationComposer-JUnit-EJB-Tests-autoscanning-issue-and-Hibernate-tp4663182p4663210.html
Sent from the OpenEJB Dev mailing list archive at Nabble.com.

Re: ApplicationComposer JUnit EJB Tests autoscanning issue and Hibernate

Posted by Romain Manni-Bucau <rm...@gmail.com>.
You'd need to use a persistencemodule with a configured rooturl. You can
use openejb scanning too.

That said this doesnt match appcomposer anymore because of this.
Le 23 mai 2013 19:40, "AndreasN" <a....@hotmail.de> a écrit :

> Hi,
>
> thank you for responding!
>
> Ok, I understand the outlined examples and the core concept of the
> ApplicationComposer. Nevertheless I would like / or I need the entity
> inititialisation through hibernate with auto-scanning entities and
> dependencies due I have no luck to do it by hand and hundreds of entities.
>
> The question remains how to force hibernate do that task; I got an
> exception
> from hibernate that it can't find the persistence.xml, independent from
> OpenEJB. For the "regular" Test setup without the ApplicationComposer
> hibernate take care  of all classes and there it works; only the long
> loading time for EJB deploying is a bit annoying here.
>
> Kind regards,
> Andreas
>
>
>
> --
> View this message in context:
> http://openejb.979440.n4.nabble.com/ApplicationComposer-JUnit-EJB-Tests-autoscanning-issue-and-Hibernate-tp4663182p4663189.html
> Sent from the OpenEJB Dev mailing list archive at Nabble.com.
>

Re: ApplicationComposer JUnit EJB Tests autoscanning issue and Hibernate

Posted by AndreasN <a....@hotmail.de>.
Hi,

thank you for responding!

Ok, I understand the outlined examples and the core concept of the
ApplicationComposer. Nevertheless I would like / or I need the entity
inititialisation through hibernate with auto-scanning entities and
dependencies due I have no luck to do it by hand and hundreds of entities. 

The question remains how to force hibernate do that task; I got an exception
from hibernate that it can't find the persistence.xml, independent from
OpenEJB. For the "regular" Test setup without the ApplicationComposer
hibernate take care  of all classes and there it works; only the long
loading time for EJB deploying is a bit annoying here.

Kind regards,
Andreas



--
View this message in context: http://openejb.979440.n4.nabble.com/ApplicationComposer-JUnit-EJB-Tests-autoscanning-issue-and-Hibernate-tp4663182p4663189.html
Sent from the OpenEJB Dev mailing list archive at Nabble.com.

Re: ApplicationComposer JUnit EJB Tests autoscanning issue and Hibernate

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

1)
http://svn.apache.org/repos/asf/tomee/tomee/trunk/server/openejb-cxf-rs/src/test/java/org/apache/openejb/server/cxf/rs/CdiInterceptorContextTest.java
uses
testing package annotations
2) you can use @Classes annotation to list classes to take into account for
the test on top of the module method or simply list classes in the @Module
method like in
http://svn.apache.org/repos/asf/tomee/tomee/trunk/container/openejb-core/src/test/java/org/apache/openejb/resource/jdbc/JtaFailOverRouterTest.java

about the persistence.xml you can unmarshal it from
JaxbPersistenceFactory.getPersistence(Persistence.class, url)

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



2013/5/23 AndreasN <a....@hotmail.de>

> Hi Romain,
>
> Do you have some examples for 1) ?
>
> How can load the persistence.xml and pass it through hibernate to let the
> initialisation do?
>
> add 3.) do you mean the manual EJB adding by:
>
>  @Module
>    public EjbJar beans() {
> ...
>  EjbJar ejbJar = new EjbJar("erp-beans");
>  ejbJar.addEnterpriseBean(new StatelessBean(clazzy));
> ...
> ??
>
>
>
> --
> View this message in context:
> http://openejb.979440.n4.nabble.com/ApplicationComposer-JUnit-EJB-Tests-autoscanning-issue-and-Hibernate-tp4663182p4663185.html
> Sent from the OpenEJB Dev mailing list archive at Nabble.com.
>

Re: ApplicationComposer JUnit EJB Tests autoscanning issue and Hibernate

Posted by AndreasN <a....@hotmail.de>.
Hi Romain,

Do you have some examples for 1) ?

How can load the persistence.xml and pass it through hibernate to let the
initialisation do?

add 3.) do you mean the manual EJB adding by:

 @Module
   public EjbJar beans() {
...
 EjbJar ejbJar = new EjbJar("erp-beans");
 ejbJar.addEnterpriseBean(new StatelessBean(clazzy));
...
??



--
View this message in context: http://openejb.979440.n4.nabble.com/ApplicationComposer-JUnit-EJB-Tests-autoscanning-issue-and-Hibernate-tp4663182p4663185.html
Sent from the OpenEJB Dev mailing list archive at Nabble.com.

Re: ApplicationComposer JUnit EJB Tests autoscanning issue and Hibernate

Posted by Romain Manni-Bucau <rm...@gmail.com>.
1) because was referencing junit and we support testng too (see testing
package)
2) you can lod the persistence.xml but you need to do it yourself
3) it is


PS: ApplicationComposer is not for integration testing, if you need so
maybe have a look to arquillian

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



2013/5/23 AndreasN <a....@hotmail.de>

> Hi,
>
> I have some problems to get a basic setup with the ApplcationComposer
> running, unfortunately without an option of use the persistence.xml,
> wherein
> hibernate JPA is configured and does all the entity loading and
> initialisation stuff automatically.
>
> I noticed and read somewhere that the responsibility of the persistence
> unit
> is isolated in the ApplicationComposer and therefore all required entities
> needs to setup here, of course all needed EJBs also.
> So I tried hard to resolve each dependency within our application
> integration tests and added entities "by hand" without success and ended up
> in using the reqular test environment with extreme long running startup
> time
> of 15sec due automized EJB loading. Please do not ask me for specific error
> messages, sometimes I got NullPointers, sometimes
> IncompatibleClassChangeErrors, it varies in the amount of classes (Entites
> /
> EJBs)  I loaded and thrown by Hibernate or OpenEJB....
>
>
> The application I do testing consists of more than 100 EJBs and a couple of
> hundred entities, for that the automized EJB loading is not really
> applicable for building fast test cases where only a few EJBs are for
> interest.
>
> I read in the JIRA OPENEJB-1526, one suggestion of using the arquillian
> adapter which should be intended for such cases, but I didn't find any
> examples.
>
> The example were I build up my test case is based on this article:
>
> http://tomee.apache.org/examples-trunk/application-composer/
>
> I have some questions:
>
> 1.) In release 4.5.2 of OpenEJB core the Configuration and Module
> annotations are marked as depreciated:
>
>    import org.apache.openejb.junit.Configuration;
>    import org.apache.openejb.junit.Module;
>
> why?
>
> 2.) Instead of the constructing the Persistence unit programmatically /
> manually, it should be possible to let Hibernate (or other JPA Provider) do
> that work - ergo loading the persistence.xml.
>
> Are there any planning or workarounds exist?
>
> 3.) It should be possible to pin down some EJBs for loading ergo do not
> load
> all
>
> I rely on an old article which reflect the same:
>
>
> http://www.marchwicki.pl/blog/2011/07/testing-ejb-applicatin-openejb-without-classpath-scanning/
>
> and did read this tutorial:
>
> http://tomee.apache.org/application-discovery-via-the-classpath.html
>
> 4.) Does there are more complete JPA / EJB example for testing exist??
>
>
> Hopefully someone can help!
>
> Thank you for some comments, thoughts and ideas.
>
>
>
> Kind regards,
> Andreas
>
>
>
>
>
>
>
> --
> View this message in context:
> http://openejb.979440.n4.nabble.com/ApplicationComposer-JUnit-EJB-Tests-autoscanning-issue-and-Hibernate-tp4663182.html
> Sent from the OpenEJB Dev mailing list archive at Nabble.com.
>