aspose file tools*
The moose likes Spring and the fly likes Create and update operations in ROO are causing exception after deploying on weblogic Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "Create and update operations in ROO are causing exception after deploying on weblogic " Watch "Create and update operations in ROO are causing exception after deploying on weblogic " New topic
Forums: Spring BEA/Weblogic
Author

Create and update operations in ROO are causing exception after deploying on weblogic

sajjad ahmad
Ranch Hand

Joined: Jan 23, 2003
Posts: 78
I am trying to deploy a roo 1.2.1 spring mvc,jpa2.0 application on weblogic.All the select queries are working fine after deployment but if I try to update a record or create a new record I get below exception

Caused by: java.lang.ClassCastException: org.eclipse.persistence.jpa.PersistenceProvider cannot be cast to javax.persistence.spi.PersistenceProvider


I have mentioned in my persistance.xml file provider as org.hibernate.ejb.HibernatePersistence , still webllogic 10.3.3 is trying to load org.eclipse.persistence.jpa.PersistenceProvider.

Please guide me what I am doing wrong here





Bill Gorder
Bartender

Joined: Mar 07, 2010
Posts: 1649
    
    7

You apparently have 2 copies of the javax.persistence library on the classpath. You either need to scope the one in your application to provided or configure your applications servers classloader to use the one in your application if it exists before using its own.

The one looks like it comes out of eclipselink. If you are using hibernate I am not sure where that is coming from.


[How To Ask Questions][Read before you PM me]
sajjad ahmad
Ranch Hand

Joined: Jan 23, 2003
Posts: 78
Bill Gorder wrote:You apparently have 2 copies of the javax.persistence library on the classpath. You either need to scope the one in your application to provided or configure your applications servers classloader to use the one in your application if it exists before using its own.

The one looks like it comes out of eclipselink. If you are using hibernate I am not sure where that is coming from.


I can't configure the application classloader because that is not in my control and doing so can also create problems with other JPA1.0 applications deployed on the same server , however I have used package preferences in the weblogic.xml file like below



and have also mentioned the JPA provider in my persistence.xml file like below


Still I am getting the exception mentioned earlier , I am really out of clues here , what could I be possibly doing wrong here.
sajjad ahmad
Ranch Hand

Joined: Jan 23, 2003
Posts: 78
Now I am thinking to try another Package preference in weblogic.xml which is

<wls:package-name>*.PersistenceProvider</wls:package-name>

Since the only JPA jar I have in my application lib folder is hibernate-jpa-2.0-api , which has PersistenceProvider under the same package I am hoping this should solve the problem , however I will be able to try it tomoroow and will update you regardign the progress.

Thanks for your help.
sajjad ahmad
Ranch Hand

Joined: Jan 23, 2003
Posts: 78
Unfortunately it didn't work , now I am stuck with the project :S.
On another blog I posted teh details of what I did to get the web applicaiton deployed on production

http://middlewaremagic.com/weblogic/?p=6725

but den even after defining package preferences I am still getting all other exceptions .
Bill Gorder
Bartender

Joined: Mar 07, 2010
Posts: 1649
    
    7

Well I think we have identified the problem and it is not with Spring but is a class loading issue in whatever version of Weblogic you are using. I will add this to our Weblogic forum as well to see if anyone there can help you with this further. I would do a maven dependency tree on your application code just to make sure that there are not two conflicting versions in your applications dependencies. Some times this can happen when Maven pulls in transitive dependencies and it will require you to add some excludes to certain dependencies. If you can run this command post the output of it and I can have a look at it.
sajjad ahmad
Ranch Hand

Joined: Jan 23, 2003
Posts: 78
Thanks for your efforts

I tried to run below maven command on my project and got below information , I have no idea what this means

"mvn dependency:tree"

[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building DrillingBestPractices 0.1.0.BUILD-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-dependency-plugin:2.1:tree (default-cli) @ DrillingBestPractice
s ---
[INFO] mycompany.dbprillingBestPractices:war:0.1.0.BUILD-SNAPSHOT
[INFO] +- junit:junit:jar:4.10:test
[INFO] | \- org.hamcrest:hamcrest-core:jar:1.1:test
[INFO] +- log4j:log4j:jar:1.2.16:compile
[INFO] +- org.slf4j:slf4j-api:jar:1.6.4:compile
[INFO] +- org.slf4j:jcl-over-slf4j:jar:1.6.4:compile
[INFO] +- org.slf4j:slf4j-log4j12:jar:1.6.4:compile
[INFO] +- org.aspectj:aspectjrt:jar:1.6.12:compile
[INFO] +- org.aspectj:aspectjweaver:jar:1.6.12:compile
[INFO] +- javax.servlet:servlet-api:jar:2.5:provided (scope not updated to compi
le)
[INFO] +- net.sf.flexjson:flexjson:jar:2.1:compile
[INFO] +- org.apache.commons:commons-lang3:jar:3.1:compile
[INFO] +- org.springframework.roorg.springframework.roo.annotations:jar:1.2.1.
RELEASE:provided
[INFO] | \- commons-io:commons-io:jar:2.1:provided
[INFO] +- org.springframework:spring-core:jar:3.1.0.RELEASE:compile
[INFO] | \- org.springframework:spring-asm:jar:3.1.0.RELEASE:compile
[INFO] +- org.springframework:spring-test:jar:3.1.0.RELEASE:test (scope not upda
ted to compile)
[INFO] +- org.springframework:spring-context:jar:3.1.0.RELEASE:compile
[INFO] | +- org.springframework:spring-beans:jar:3.1.0.RELEASE:compile
[INFO] | \- org.springframework:spring-expression:jar:3.1.0.RELEASE:compile
[INFO] +- org.springframework:spring-aop:jar:3.1.0.RELEASE:compile
[INFO] | \- aopalliance:aopalliance:jar:1.0:compile
[INFO] +- org.springframework:spring-aspects:jar:3.1.0.RELEASE:compile
[INFO] | \- org.springframework:spring-context-support:jar:3.1.0.RELEASE:compil
e
[INFO] +- org.hibernate:hibernate-core:jar:3.6.9.Final:compile
[INFO] | +- antlr:antlr:jar:2.7.6:compile
[INFO] | +- commons-collections:commons-collections:jar:3.1:compile
[INFO] | +- dom4j:dom4j:jar:1.6.1:compile
[INFO] | \- org.hibernate:hibernate-commons-annotations:jar:3.2.0.Final:compile

[INFO] +- org.hibernate:hibernate-entitymanager:jar:3.6.9.Final:compile
[INFO] | \- javassist:javassist:jar:3.12.0.GA:compile
[INFO] +- org.hibernate.javax.persistence:hibernate-jpa-2.0-api:jar:1.0.1.Final:
compile
[INFO] +- org.hibernate:hibernate-validator:jar:4.2.0.Final:compile
[INFO] +- javax.validation:validation-api:jar:1.0.0.GA:compile
[INFO] +- cglib:cglib-nodep:jar:2.2.2:compile
[INFO] +- javax.transaction:jta:jar:1.1:compile
[INFO] +- org.springframework:spring-jdbc:jar:3.1.0.RELEASE:compile
[INFO] | \- org.springframework:spring-tx:jar:3.1.0.RELEASE:compile
[INFO] +- org.springframework:spring-orm:jar:3.1.0.RELEASE:compile
[INFO] +- commons-pool:commons-pool:jar:1.5.6:compile
[INFO] +- commons-dbcp:commons-dbcp:jar:1.3:compile
[INFO] +- org.springframework:spring-webmvc:jar:3.1.0.RELEASE:compile
[INFO] | \- org.springframework:spring-web:jar:3.1.0.RELEASE:compile
[INFO] +- org.springframework.webflow:spring-js-resources:jar:2.2.1.RELEASE:comp
ile
[INFO] +- commons-digester:commons-digester:jar:2.1:compile
[INFO] | \- commons-beanutils:commons-beanutils:jar:1.8.3:compile
[INFO] +- commons-fileupload:commons-fileupload:jar:1.2.2:compile
[INFO] +- javax.servlet.jsp.jstl:jstl-api:jar:1.2:compile
[INFO] +- org.glassfish.web:jstl-impl:jar:1.2:compile
[INFO] +- javax.el:el-api:jar:1.0:provided
[INFO] +- joda-time:joda-time:jar:1.6:compile
[INFO] +- javax.servlet.jsp:jsp-api:jar:2.1:provided (scope not updated to compi
le)
[INFO] +- commons-codec:commons-codec:jar:1.5:compile
[INFO] +- org.apache.tiles:tiles-jsp:jar:2.2.2:compile
[INFO] | +- org.apache.tiles:tiles-servlet:jar:2.2.2:compile
[INFO] | | \- org.apache.tiles:tiles-core:jar:2.2.2:compile
[INFO] | \- org.apache.tiles:tiles-template:jar:2.2.2:compile
[INFO] | \- org.apache.tiles:tiles-api:jar:2.2.2:compile
[INFO] +- org.springframework.security:spring-security-core:jar:3.1.0.RELEASE:co
mpile
[INFO] | \- org.springframework.security:spring-security-crypto:jar:3.1.0.RELEA
SE:compile
[INFO] +- org.springframework.security:spring-security-config:jar:3.1.0.RELEASE:
compile
[INFO] +- org.springframework.security:spring-security-web:jar:3.1.0.RELEASE:com
pile
[INFO] +- org.springframework.security:spring-security-taglibs:jar:3.1.0.RELEASE
:compile
[INFO] | \- org.springframework.security:spring-security-acl:jar:3.1.0.RELEASE:
compile
[INFO] \- com.oraclejdbc6:jar:11.2.0:compile
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.997s
[INFO] Finished at: Fri Nov 23 22:51:28 AST 2012
[INFO] Final Memory: 12M/222M
[INFO] ------------------------------------------------------------------------
sajjad ahmad
Ranch Hand

Joined: Jan 23, 2003
Posts: 78
I finally figured a workaround for this problem , and now JPA2.0 application is running fine on Weblogic10.3.3 server.

I found out that the problem was actully relted to hibernate validator , In my JPA method code I had a "@Valid" annotation along with the object I was getting , I was trying to use hibernate validator to validate the object before persisting it , there I was getting all these exceptions.
To get my application running on server I had to remove those @valid annotations from my JPA code and now everything is working fine. But now I am relying on page level validation which in my case is good enough.
However the ideal solution would be to find a compatable hibernat validator jar and keep the @valid annotations in your project for the sake of better validation.
For now this solution is working for me , ASA I get time I will try to find the hibernate validator jar which can work with this version on server we have and will love to have server side validation as well.
I hope this workaround will save some days of someone out there .

Please note that in order to run your JPA2.0 application on weblogic10.3.3 which is JPA1.0 compliant you will have to rename your persistence.xml to something like foo.xml and mentione the name of this xml file in your applicationContext.xml as (I am using Spring here )



rename the persistenceUnit and dataSource according to the beans you have defined in your application

and you will have to define package exclusions in your weblogic.xml file as



I invested few days to resolve the problem , and sharing the solution hoping it might benefit someone someday cheers.
sajjad ahmad
Ranch Hand

Joined: Jan 23, 2003
Posts: 78
Please find all the other details on my below blog post

http://javaiscoool.blogspot.com/2012/12/deploy-jpa20-application-on-weblogic1033.html
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Create and update operations in ROO are causing exception after deploying on weblogic