[SEAM] 请教 Jboss 连接两个数据源的配置问题,各位高手多多指教,

mojinp 2010-09-03
目前边学边做一些东西,seam 4.2.2 +jboss 2.2.0, 需要连接两个数据源,一个是在oracle, 另一个是SqlServer2000,我就把相应的数据库驱动放到deploy的lib中,其他的都没有变,按seam默认的。

下面是我几个重要文件的配置:
(1)components.xml

<web:hot-deploy-filter url-pattern="*.seam" />
<persistence:entity-manager-factory
name="entityManagerFactory" persistence-unit-name="dataCenter" />
<persistence:managed-persistence-context
auto-create="true" entity-manager-factory="#{entityManagerFactory}"
name="entityManager" />
<persistence:entity-manager-factory
name="entityManagerFactoryjwglxt" persistence-unit-name="jwglxt" />
<persistence:managed-persistence-context
auto-create="true" entity-manager-factory="#{entityManagerFactoryjwglxt}"
name="entityManagerjwglxt" />
<drools:rule-base name="securityRules">
<drools:rule-files>
<value>/security.drl</value>
</drools:rule-files>
</drools:rule-base>
<security:rule-based-permission-resolver
security-rules="#{securityRules}" />
<security:identity authenticate-method="#{authenticator.authenticate}"
remember-me="true" />
<event type="org.jboss.seam.security.notLoggedIn">
<action execute="#{redirect.captureCurrentView}" />
</event>
<event type="org.jboss.seam.security.loginSuccessful">
<action execute="#{redirect.returnToCapturedView}" />
</event>
<mail:mail-session host="localhost" port="25" />
<!--
For use with jBPM pageflow or process management <bpm:jbpm>
<bpm:process-definitions></bpm:process-definitions>
<bpm:pageflow-definitions></bpm:pageflow-definitions> </bpm:jbpm>
-->
</components>
(2) persistence.xml

<persistence-unit name="dataCenter" transaction-type="JTA">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>java:/dataCenterDatasource</jta-data-source>
<class>org.domain.datacenter.entity.Studentsfromjwc</class>
<class>org.domain.datacenter.entity.Department</class>
<class>org.domain.datacenter.entity.Xueke</class>
<class>yaweiinfo.usermanage.entity.Users</class>
<class>yaweiinfo.usermanage.entity.Roles</class>
<class>yaweiinfo.usermanage.entity.RoleAssign</class>
<class>yaweiinfo.usermanage.entity.Privilegelist</class>
<class>yaweiinfo.usermanage.entity.PrivilegeAssign</class>
<class>org.domain.datacenter.entity.Achievementsfromjwc</class>
<class>org.domain.datacenter.entity.Classesfromjwc</class>
<class>org.domain.datacenter.entity.Classroomsfromjwc</class>
<class>org.domain.datacenter.entity.Coursesfromjwc</class>
<class>org.domain.datacenter.entity.Specialtysfromjwc</class>
<exclude-unlisted-classes>true</exclude-unlisted-classes>
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.Oracle10gDialect" />
<property name="hibernate.hbm2ddl.auto" value="create" />
<property name="hibernate.show_sql" value="false" />
<property name="hibernate.format_sql" value="false" />
<!--
Only relevant if Seam is loading the persistence unit (Java SE
bootstrap)
-->
<property name="hibernate.transaction.manager_lookup_class"
value="org.hibernate.transaction.JBossTransactionManagerLookup" />
</properties>
</persistence-unit>

<persistence-unit name="jwglxt" transaction-type="JTA">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>java:/jwglxtDatasource</jta-data-source>
<exclude-unlisted-classes>true</exclude-unlisted-classes>
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.SQLServerDialect" />
<property name="hibernate.hbm2ddl.auto" value="validate" />
<property name="hibernate.show_sql" value="false" />
<property name="hibernate.format_sql" value="false" />
<!--
Only relevant if Seam is loading the persistence unit (Java SE
bootstrap)
-->
<property name="hibernate.transaction.manager_lookup_class"
value="org.hibernate.transaction.JBossTransactionManagerLookup" />
</properties>
</persistence-unit>
</persistence>

(3)datacenter-ds.xml

<datasources>

<local-tx-datasource>
<jndi-name>dataCenterDatasource</jndi-name>
<use-java-context>true</use-java-context>
<connection-url>jdbc:oracle:thin:@a.b.c.d:1521:aaa</connection-url>
<driver-class>oracle.jdbc.OracleDriver</driver-class>
<user-name>8888</user-name>
<password>8888</password>
</local-tx-datasource>

<local-tx-datasource>
<jndi-name>jwglxtDatasource</jndi-name>
<connection-url>jdbc:sqlserver://a.b.c.e:5001;DatabaseName=bbbb</connection-url>
<driver-class>com.microsoft.sqlserver.jdbc.SQLServerDriver</driver-class>
<user-name>9999</user-name>
<password>9999</password>
<metadata>
<type-mapping>MS SQLSERVER2000</type-mapping>
</metadata>
</local-tx-datasource>

(4)启动jboss时老是有下面的错误:
Exception sending context initialized event to listener instance of class org.jboss.seam.servlet.SeamListener
org.jboss.seam.InstantiationException: Could not instantiate Seam component: entityManagerFactory

No identifier specified for entity: org.domain.datacenter.entity.Achievementsfromjwc
at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:252)

Error listenerStart
17:34:24,156 ERROR [StandardContext] Context [/dataCenter] startup failed due to previous errors

Could not start deployment: file:/D:/ProgramFiles/jboss-4.2.2.GA/server/default/deploy/dataCenter.war/


请教各位是什么原因呢 ,谢谢咯,我折腾了一天了还没找到原因,是数据库配置有问题还是什么呢 》
Global site tag (gtag.js) - Google Analytics