2012-08-09 2 views
0

Spring 3.0에서 지속성 공급자로 eclipselink를 사용하는 애플리케이션이 있습니다. 응용 프로그램이 Jetty 응용 프로그램 서버에서 제대로 작동하지만 웹 로직에 배포 할 때 오류가 발생합니다. 내가 web.xml에 태그를 선언 한weblogic + spring + eclipselink의 JNDI 문제

  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  

다음과 같이이 켜지지 세부

봄 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" /> 

특성 파일 이하이다

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

무엇이 잘못 되었습니까?

+0

weblogic 서버에서 데이터 소스가 정의되고 잘 작동합니까? – Luciano

+0

예. weblogic 서버에서 JNDI를 검사했는데 올바르게 작동합니다. –

+0

업데이트하기 만하면됩니다. persistence.xml의 이름을 다른 것으로 변경했는데 이것이 문제를 해결 한 것 같습니다. 정확한 이유는 모르겠지만. –

답변

0

그것은 왜냐하면 weblogicpersistence.xml 파일이 /META-INF 폴더에 할당를 자동으로 감지하고 미리로드 Persistence Unit 같은 자바 EE 컨테이너 (사용하여 구현 내장)하지만, 최대 절전 수준에서 설정 한 JPA 속성의 단서가 없습니다. 퍼시스턴스 유닛은 Spring으로 부트 스트래핑해야하므로 파일 이름을 다른 것으로 변경하면 문제가 해결됩니다.

관련 문제