JPA Persistence loading issue - JBOSS 5
sri4985 Jun 11, 2013 4:16 AMHello Every One!!
I have two projects "ProjectA.war" and "ProjectB.war".
In both projects, i am using Oracle 11g, JPA2 with EclipseLink 2.4.2.
and i am using JBOSS 5.1.0 GA application server.
Both have different persistence.xml files with different persistence-unit names, different datasource files.
Here i am connecting same Oracle DB user for both projects.
My Problem is...
First i had deployed ProjectA.war in server. And it is working fine. and DB operations also working fine.
Now i am deploying the ProjectB.war in server besides of ProjectA.war.
So, when i am trying to perform the db operations on ProjectA.war then jboss is searching the POJO classes in ProjectB.war's persistenece.xml file with the help of ProjectB's persistence-unit name.
But actually it need to search in ProjectA.
So, what can i do?
My ProjectA.war Configurations as like below...
============ persistence.xml ================== <persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence persistence_2_0.xsd" version="2.0"> <persistence-unit name="Entity" transaction-type="RESOURCE_LOCAL"> <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider> <non-jta-data-source>java:/projectADS</non-jta-data-source> <class>env.model.authorization.IptUsersRoles</class> <class>env.model.defaults.IptUsergroups</class> <class>env.model.defaults.IptUsertype</class> <class>env.model.authorization.IptUsers</class> <properties> <property name="javax.persistence.jdbc.driver" value="oracle.jdbc.driver.OracleDriver" /> <property name="javax.persistence.jdbc.url" value="jdbc:oracle:thin:@x.x.x.x:1521:TEST" /> <property name="javax.persistence.jdbc.user" value="TEST" /> <property name="javax.persistence.jdbc.password" value="TEST" /> <property name="eclipselink.session.customizer" value="entity.jpa.JPAEclipseLinkSessionCustomizer"/> <property name="eclipselink.logging.level" value="FINEST"/> </properties> </persistence-unit> </persistence> ================= jboss-classloading.xml =================== <?xml version="1.0" encoding="UTF-8"?> <classloading xmlns="urn:jboss:classloading:1.0" name="ProjectA.war" domain="DefaultDomain" top-level-classloader="true" parent-domain="Ignored" export-all="NON_EMPTY" import-all="true" parent-first="false"> </classloading> ==================== jboss-web.xml ====================== <?xml version="1.0" encoding="UTF-8"?> <jboss-web> <resource-ref> <description>DB Connection</description> <res-ref-name>ProjectADS</res-ref-name> <res-type>javax.sql.DataSource</res-type> <jndi-name>java:/ProjectADS</jndi-name> <res-auth>Container</res-auth> </resource-ref> </jboss-web>
My ProjectB.war Configurations as like below...
============ persistence.xml ================== <?xml version="1.0" encoding="UTF-8"?> <persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence persistence_2_0.xsd" version="2.0"> <persistence-unit name="IportIBEntity" transaction-type="RESOURCE_LOCAL"> <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider> <non-jta-data-source>java:/ProjectBDS</non-jta-data-source> <class>env.model.IptRequestDataRecord</class> <class>env.model.IptResponseDataRecord</class> <properties> <property name="eclipselink.jdbc.driver" value="oracle.jdbc.driver.OracleDriver" /> <property name="eclipselink.jdbc.url" value="jdbc:oracle:thin:@x.x.x.x:1521:TEST" /> <property name="eclipselink.jdbc.user" value="TEST" /> <property name="eclipselink.jdbc.password" value="TEST" /> <property name="eclipselink.session.customizer" value="entity.jpa.JPAEclipseLinkSessionCustomizer" /> <property name="eclipselink.logging.level" value="FINEST" /> </properties> </persistence-unit> </persistence> ================= jboss-classloading.xml =================== <?xml version="1.0" encoding="UTF-8"?> <classloading xmlns="urn:jboss:classloading:1.0" name="ProjectB.war" domain="DefaultDomain" top-level-classloader="true" parent-domain="Ignored" export-all="NON_EMPTY" import-all="true" parent-first="false"> </classloading> ==================== jboss-web.xml ====================== <?xml version="1.0" encoding="UTF-8"?> <jboss-web> <resource-ref> <description>DB Connection</description> <res-ref-name>ProjectBDS</res-ref-name> <res-type>javax.sql.DataSource</res-type> <jndi-name>java:/ProjectBDS</jndi-name> <res-auth>Container</res-auth> </resource-ref> </jboss-web>
And the console error like below ....
13:26:34,068 INFO [IportIBEntity] finding IptUsers instance with property: userCode, value: ADMIN 13:26:34,709 SEVERE [IportIBEntity] find by property name failed java.lang.IllegalArgumentException: An exception occurred while creating a query in EntityManager: Exception Description: Problem compiling [select model from IptUsers model where model.userCode= :propertyValue]. [18, 26] The abstract schema type 'IptUsers' is unknown. [39, 53] The state field path 'model.userCode' cannot be resolved to a valid type. at org.eclipse.persistence.internal.jpa.EntityManagerImpl.createQuery(EntityManagerImpl.java:1512) at env.acegi.users.IptUsersDAO.findByProperty(IptUsersDAO.java:174) at env.acegi.users.IptUsersDAO.findByUserCode(IptUsersDAO.java:185) at env.acegi.security.AcegiAuthentication.loadUserByUsername(AcegiAuthentication.java:51) at org.acegisecurity.providers.dao.DaoAuthenticationProvider.retrieveUser(DaoAuthenticationProvider.java:99) at org.acegisecurity.providers.dao.AbstractUserDetailsAuthenticationProvider.authenticate(AbstractUserDetailsAuthenticationProvider.java:122) at org.acegisecurity.providers.ProviderManager.doAuthentication(ProviderManager.java:200) at org.acegisecurity.AbstractAuthenticationManager.authenticate(AbstractAuthenticationManager.java:47) at org.acegisecurity.ui.webapp.AuthenticationProcessingFilter.attemptAuthentication(AuthenticationProcessingFilter.java:74) at org.acegisecurity.ui.AbstractProcessingFilter.doFilter(AbstractProcessingFilter.java:252) at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275) at org.acegisecurity.ui.logout.LogoutFilter.doFilter(LogoutFilter.java:110) at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275) at org.acegisecurity.context.HttpSessionContextIntegrationFilter.doFilter(HttpSessionContextIntegrationFilter.java:249) at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275) at org.acegisecurity.concurrent.ConcurrentSessionFilter.doFilter(ConcurrentSessionFilter.java:95) at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275) at org.acegisecurity.util.FilterChainProxy.doFilter(FilterChainProxy.java:149) at org.acegisecurity.util.FilterToBeanProxy.doFilter(FilterToBeanProxy.java:98) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:235) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:190) at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:92) at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.process(SecurityContextEstablishmentValve.java:126) at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:70) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:330) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:829) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:598) at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447) at java.lang.Thread.run(Thread.java:662) Caused by: Exception [EclipseLink-0] (Eclipse Persistence Services - 2.4.2.v20130315-93567e3): org.eclipse.persistence.exceptions.JPQLException Exception Description: Problem compiling [select model from IptUsers model where model.userCode= :propertyValue]. [18, 26] The abstract schema type 'IptUsers' is unknown. [39, 53] The state field path 'model.userCode' cannot be resolved to a valid type. at org.eclipse.persistence.internal.jpa.jpql.HermesParser.buildException(HermesParser.java:150) at org.eclipse.persistence.internal.jpa.jpql.HermesParser.validate(HermesParser.java:339) at org.eclipse.persistence.internal.jpa.jpql.HermesParser.populateQueryImp(HermesParser.java:270) at org.eclipse.persistence.internal.jpa.jpql.HermesParser.buildQuery(HermesParser.java:157) at org.eclipse.persistence.internal.jpa.EJBQueryImpl.buildEJBQLDatabaseQuery(EJBQueryImpl.java:138) at org.eclipse.persistence.internal.jpa.EJBQueryImpl.buildEJBQLDatabaseQuery(EJBQueryImpl.java:112) at org.eclipse.persistence.internal.jpa.EJBQueryImpl.<init>(EJBQueryImpl.java:98) at org.eclipse.persistence.internal.jpa.EJBQueryImpl.<init>(EJBQueryImpl.java:82) at org.eclipse.persistence.internal.jpa.EntityManagerImpl.createQuery(EntityManagerImpl.java:1510) ... 38 more 13:26:34,711 ERROR [[default]] Servlet.service() for servlet default threw exception java.lang.IllegalArgumentException: An exception occurred while creating a query in EntityManager: Exception Description: Problem compiling [select model from IptUsers model where model.userCode= :propertyValue]. [18, 26] The abstract schema type 'IptUsers' is unknown. [39, 53] The state field path 'model.userCode' cannot be resolved to a valid type. at org.eclipse.persistence.internal.jpa.EntityManagerImpl.createQuery(EntityManagerImpl.java:1512) at env.acegi.users.IptUsersDAO.findByProperty(IptUsersDAO.java:174) at env.acegi.users.IptUsersDAO.findByUserCode(IptUsersDAO.java:185) at env.acegi.security.AcegiAuthentication.loadUserByUsername(AcegiAuthentication.java:51) at org.acegisecurity.providers.dao.DaoAuthenticationProvider.retrieveUser(DaoAuthenticationProvider.java:99) at org.acegisecurity.providers.dao.AbstractUserDetailsAuthenticationProvider.authenticate(AbstractUserDetailsAuthenticationProvider.java:122) at org.acegisecurity.providers.ProviderManager.doAuthentication(ProviderManager.java:200) at org.acegisecurity.AbstractAuthenticationManager.authenticate(AbstractAuthenticationManager.java:47) at org.acegisecurity.ui.webapp.AuthenticationProcessingFilter.attemptAuthentication(AuthenticationProcessingFilter.java:74) at org.acegisecurity.ui.AbstractProcessingFilter.doFilter(AbstractProcessingFilter.java:252) at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275) at org.acegisecurity.ui.logout.LogoutFilter.doFilter(LogoutFilter.java:110) at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275) at org.acegisecurity.context.HttpSessionContextIntegrationFilter.doFilter(HttpSessionContextIntegrationFilter.java:249) at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275) at org.acegisecurity.concurrent.ConcurrentSessionFilter.doFilter(ConcurrentSessionFilter.java:95) at org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275) at org.acegisecurity.util.FilterChainProxy.doFilter(FilterChainProxy.java:149) at org.acegisecurity.util.FilterToBeanProxy.doFilter(FilterToBeanProxy.java:98) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:235) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:190) at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:92) at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.process(SecurityContextEstablishmentValve.java:126) at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:70) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:330) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:829) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:598) at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447) at java.lang.Thread.run(Thread.java:662) Caused by: Exception [EclipseLink-0] (Eclipse Persistence Services - 2.4.2.v20130315-93567e3): org.eclipse.persistence.exceptions.JPQLException Exception Description: Problem compiling [select model from IptUsers model where model.userCode= :propertyValue]. [18, 26] The abstract schema type 'IptUsers' is unknown. [39, 53] The state field path 'model.userCode' cannot be resolved to a valid type. at org.eclipse.persistence.internal.jpa.jpql.HermesParser.buildException(HermesParser.java:150) at org.eclipse.persistence.internal.jpa.jpql.HermesParser.validate(HermesParser.java:339) at org.eclipse.persistence.internal.jpa.jpql.HermesParser.populateQueryImp(HermesParser.java:270) at org.eclipse.persistence.internal.jpa.jpql.HermesParser.buildQuery(HermesParser.java:157) at org.eclipse.persistence.internal.jpa.EJBQueryImpl.buildEJBQLDatabaseQuery(EJBQueryImpl.java:138) at org.eclipse.persistence.internal.jpa.EJBQueryImpl.buildEJBQLDatabaseQuery(EJBQueryImpl.java:112) at org.eclipse.persistence.internal.jpa.EJBQueryImpl.<init>(EJBQueryImpl.java:98) at org.eclipse.persistence.internal.jpa.EJBQueryImpl.<init>(EJBQueryImpl.java:82) at org.eclipse.persistence.internal.jpa.EntityManagerImpl.createQuery(EntityManagerImpl.java:1510) ... 38 more
In above error description....
"INFO [IportIBEntity] finding IptUsers instance with property: userCode, value: ADMIN"
here IportIBEntity is the persistence-unit of ProjectB.war, but IptUsers pojo have in ProjectA.war.
So, it is trying to search the pojo in ProjectB.war instead of ProjectA.war
Please help me to solve the problem....