我在 Spring 3.0 中有一个使用 eclipselink 作为持久性提供程序的应用程序。该应用程序在 Jetty 应用服务器中运行良好,但在 weblogic 中部署时出现错误。必要的细节如下
春天的xml文件
<context:property-placeholder location="classpath:jdbc.properties"
ignore-unresolvable="true" />
<jee:jndi-lookup id="jndiDataSource" jndi-name="${jndi.name}"
resource-ref="true" />
<bean id="pum"
class="org.springframework.orm.jpa.persistenceunit.DefaultPersistenceUnitManager">
<property name="persistenceXmlLocations">
<list>
<value>classpath*:META-INF/persistence.xml</value>
</list>
</property>
<property name="defaultDataSource" ref="jndiDataSource" />
</bean>
<bean id="entityManagerFactory"
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="persistenceUnitName" value="my-persistence" />
<property name="persistenceUnitManager" ref="pum" />
<property name="jpaDialect" ref="jpaDialect" />
<property name="jpaVendorAdapter" ref="jpaAdapter" />
<property name="loadTimeWeaver" ref="loadTimeWeaver" />
</bean>
<bean id="jpaAdapter"
class="org.springframework.orm.jpa.vendor.EclipseLinkJpaVendorAdapter"
p:databasePlatform="${toplink.database.platform}" p:showSql="true" />
<bean id="jpaDialect"
class="org.springframework.orm.jpa.vendor.EclipseLinkJpaDialect" />
属性文件如下
jdbc.driverClassName=org.postgresql.Driver
jdbc.url=jdbc:postgresql://localhost:5432/myDB
jdbc.username=***
jdbc.password=***
jndi.name=jndi/myDBjndi
jndi.resourceRef=true
jndi.enabled=true
hibernate.database.platform=org.hibernate.dialect.PostgreSQLDialect
toplink.database.platform=org.eclipse.persistence.platform.database.PostgreSQLPlatform
我在 web.xml 中声明了一个标签
<resource-ref>
<descriptionMy DataSource Reference</description>
<res-ref-name>jndi/myDBjndi</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
以上在 Jetty 中有效,但在 Weblogic 10.3.4 中我得到以下异常
####<Aug 9, 2012 6:19:46 PM CST> <Info> <EclipseLink> <AdminServer> <[ACTIVE] ExecuteThread: '5' for queue: 'weblogic.kernel.Default (self-tuning)'> <<anonymous>> <> <f637fb3f44bc7f84:-2787ac98:1390ae3403e:-8000-000000000000001e> <1344507586988> <BEA-2005000> <2012-08-09 18:19:46.988--ServerSession(57821834)--Connection(55507026)--connecting(DatabaseLogin(
platform=>PostgreSQLPlatform
user name=> ""
datasource URL=> "null"))>
####<Aug 9, 2012 6:19:47 PM CST> <Alert> <EclipseLink> <AdminServer> < [ACTIVE] ExecuteThread: '5' for queue: 'weblogic.kernel.Default (self-tuning)'> <<anonymous>> <> <f637fb3f44bc7f84:-2787ac98:1390ae3403e:-8000-000000000000001e> <1344507587003> <BEA-2005000> <2012-08-09 18:19:47.003--ServerSession(57821834)--Local Exception Stack:
Exception [EclipseLink-4021] (Eclipse Persistence Services - 2.3.2.v20111125-r10461):
org.eclipse.persistence.exceptions.DatabaseException
Exception Description: Unable to acquire a connection from driver [null], user [null] and URL [null]. Verify that you have set the expected driver class and URL. Check your login, persistence.xml or sessions.xml resource. The jdbc.driver property should be set to a class that is compatible with your database platform
at org.eclipse.persistence.exceptions.DatabaseException.unableToAcquireConnectionFromDriverException(DatabaseException.java:376)
at org.eclipse.persistence.sessions.DefaultConnector.connect(DefaultConnector.java:91)
at org.eclipse.persistence.sessions.DatasourceLogin.connectToDatasource(DatasourceLogin.java:162)
at org.eclipse.persistence.internal.databaseaccess.DatasourceAccessor.connectInternal(DatasourceAccessor.java:330)
at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.connectInternal(DatabaseAccessor.java:293)
知道我在做什么错吗?