2

「ProjectA.war」と「ProjectB.war」の 2 つのプロジェクトがあります。

両方のプロジェクトで、私は Oracle 11g、JPA2 と EclipseLink 2.4.2 を使用しています。JBOSS 5.1.0 GA アプリケーション サーバーを使用しています。

両方とも、異なる永続ユニット名、異なるデータソース ファイルを持つ異なる persistence.xml ファイルを持っています。ここでは、両方のプロジェクトに同じ Oracle DB ユーザーを接続しています。

私の問題は...まず、ProjectA.warをサーバーにデプロイしました。そして、それはうまく機能しています。およびDB操作も正常に機能しています。

今、私は ProjectA.war のほかに ProjectB.war をサーバーにデプロイしています。したがって、ProjectA.war で db 操作を実行しようとすると、jboss は ProjectB の永続ユニット名を使用して、ProjectB.war の persistenece.xml ファイル内の POJO クラスを検索します。しかし、実際には ProjectA で検索する必要があります。

それで、なにかお手伝いできますか?

以下のような私の ProjectA.war 構成...

============ 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>

以下のような私の ProjectB.war 構成...

============ 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>

そして、以下のようなコンソールエラー....

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

上記のエラーの説明では....

"INFO  [IportIBEntity] finding IptUsers instance with property: userCode, value: ADMIN"

ここで IportIBEntity は ProjectB.war の永続化ユニットですが、IptUsers pojo は ProjectA.war にあります。そのため、ProjectA.war ではなく ProjectB.war で pojo を検索しようとしています。

私も以下のリンクをたどりましたが、進歩はありません

JBoss5 の JBoss Web クラスローダー

問題を解決するのを手伝ってください....

4

0 に答える 0