Get OpenJPA jars loaded by tomcat

Hi
I have a spring mvc app which uses openjpa 2.1.1 as its persistence framework. It is developed as a Maven project in STS, and runs locally on vFaric TC Server (Tomcat 7).

When we first deployed the war to Websphere 8.5, we encountered classloader conflicts with the following 3 openjpa jars which were in our war file:

geronimo-jpa_2.0_spec-1.1.jar
geronimo-jta_1.1_spec-1.1.1.jar
validation-api-1.0.0.GA.jar

Removing these from the war and deferring to Websphere's bundled openjpa worked fine, so I changed the openjpa POM dependency scope from 'compile' to 'provided' (so that these jars would not be packaged into the war file).

Since Tomcat 7 is not JEE compliant, I placed the 3 jars in Tomcat\lib (also tried the vfabric-tc-server lib - which wraps tomcat), but the JPA classes were not visible by the app at startup (noclassdeffound exceptions in console).

I also tried adding the jars to the server classpath from 'launch configuration' within STS - no luck there either.

Is there a class loader order that needs to be set somewhere in Tomcat such that JPA loads before the app?

What I need is a build that will work when deployed to either Tomcat or Websphere.

Any help will be much appreciated.

Thanks
Jim
abladaptAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

girionisCommented:
Since Tomcat 7 is not JEE compliant, I placed the 3 jars in Tomcat\lib (also tried the vfabric-tc-server lib - which wraps tomcat), but the JPA classes were not visible by the app at startup (noclassdeffound exceptions in console).

Are you sure? By putting the jar files in the lib folder they should be available to both Tomcat internal classes and to all web applications. Are you sure that the NoClassDefFoundError is about the jpa files?
0
abladaptAuthor Commented:
Hi, Thanks for responding. You are correct. The NoClassDefFoundError was referring to a JPA class, but NOT one of those from the 3 jars I included. I ran mvn tree and found that the entire chain of JPA dependencies was:

openjpa-2.1.1.jar
commons-lang-2.4.jar
commons-collections-3.2.1.jar
geronimo-jta_1.1_spec-1.1.1.jar
geronimo-jpa_2.0_spec-1.1.jar

I also needed to add:

serp-1.12.0.jar

I originally included the validation-api-1.0.0.GA.jar in tomcat/lib as well because it had to be removed from the war to get websphere working, but placing this in tomcat/lib caused a "javax.validation.ValidationException: Unable to find default provider" so I took it out, meaning just the above 6 jars needed to be added.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
abladaptAuthor Commented:
Solved myself following guidance from girionis
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java App Servers

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.