Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] EclipseLink cannot acquire datasource in JBoss 5.0

Yang,
    Hi, you may be experiencing a common configuration issue with application servers that are based on the Catalina (Tomcat) servlet container where the lookupType must be STRING_LOOKUP.
    However that usually emits the exception (sic "throught") javax.naming.NamingException: This context must be accessed throught a java: URL"
    I see you are correctly setting the target-server property so you are getting the costomized JBossPlatform that uses the jndi lookup "java:/TransactionManager" for the JTATransactionManager.
    Hibernate may default to STRING_LOOKUP as the lookupType because it normally runs in JBoss which is Catalina based.

    See the following EclipseLink on JBoss tutorial where we describe configuring the eclipselink.session.customizer so that the lookupType on ideally both JTA and non-JTA datasource connectors are changed from " COMPOSITE_NAME_LOOKUP" to "STRING_LOOKUP".

http://wiki.eclipse.org/EclipseLink/Examples/JPA/JBoss_Web_Tutorial#Session_Customizer

The following page describes the use of JNDIConnector.STRING_LOOKUP in general for all Catalina based servers.
http://wiki.eclipse.org/EclipseLink/Examples/JPA/Tomcat_Web_Tutorial#Session_Customizer

    Also verify that the *-ds.xml config files are setup using the following section as a guide.
http://wiki.eclipse.org/EclipseLink/Examples/JPA/JBoss_Web_Tutorial#JNDI_JTA.2Fnon-JTA_Server_DataSource_Setup

    thank you
    /michael



Yang, Daoqi (D.) wrote:
EclipseLink cannot acquire datasource in JBoss 5.0

Hi,
I am using EclipseLink 1.0.2 inside JBoss 5.0. The datasource is configured correctly as I am able to manually look up the datasource:

InitialContext ctx = New InitialContect();
DataSource ds = (DataSource) ctx.lookup(“java:jpaTestJtaDS”);

However, when I put the datasource inside persistence.xml as in

<persistence-unit name="jpaTestJtaPU" transaction-type="JTA">
  <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
  <jta-data-source>java:jpaTestJtaDS</jta-data-source>
  <properties>
     <property name="eclipselink.target-server" value="JBoss" />
    <property name="eclipselink.target-database" value="Derby" />
  </properties>

I run into the following exception. Any suggestion is greatly appreciated.

Exception Description: Cannot acquire data source [java:jpaTestJtaDS].
Internal Exception:
javax.naming.InvalidNameException: Not a compound name: jpaTestJtaDS
at javax.naming.CompoundName.addAll(Unknown Source)
at org.jnp.interfaces.NamingContext.composeName(NamingContext.java:1064)
at org.jnp.interfaces.NamingContext.getAbsoluteName(NamingContext.java:1777)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:704)
at javax.naming.InitialContext.lookup(Unknown Source)
at org.eclipse.persistence.sessions.JNDIConnector.connect(JNDIConnector.java:117)
at org.eclipse.persistence.sessions.JNDIConnector.connect(JNDIConnector.java:94)
at org.eclipse.persistence.sessions.DatasourceLogin.connectToDatasource
   (DatasourceLogin.java:164)
at org.eclipse.persistence.internal.databaseaccess.DatasourceAccessor.connectInternal
   (DatasourceAccessor.java:324)
at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.connectInternal
   (DatabaseAccessor.java:264)
at org.eclipse.persistence.internal.databaseaccess.DatasourceAccessor.connect
   (DatasourceAccessor.java:407)
at org.eclipse.persistence.sessions.server.ConnectionPool.buildConnection
   (ConnectionPool.java:130)
at org.eclipse.persistence.sessions.server.ExternalConnectionPool.startUp
   (ExternalConnectionPool.java:110)
at org.eclipse.persistence.sessions.server.ServerSession.connect
   (ServerSession.java:500)
at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.login
   (DatabaseSessionImpl.java:606)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryProvider.login
   (EntityManagerFactoryProvider.java:211)
at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy
   (EntityManagerSetupImpl.java:246)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.getServerSession
   (EntityManagerFactoryImpl.java:69)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManagerImpl
   (EntityManagerFactoryImpl.java:118)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManagerImpl
   (EntityManagerFactoryImpl.java:112)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManager
   (EntityManagerFactoryImpl.java:100)

The datasource is set in a file called “derbydb-ds.xml” as
  <xa-datasource>
       <jndi-name>jpaTestJtaDS</jndi-name>
       <use-java-context>true</use-java-context>

When I swithc to use Hibernate JPA, the same configuration works.

Regards,
Daoqi  Yang
Application Technology Architect
Ford Java Center of Excellence, E1F001 iTek
dyang11@xxxxxxxx, 313-206-3960


_______________________________________________ eclipselink-users mailing list eclipselink-users@xxxxxxxxxxx https://dev.eclipse.org/mailman/listinfo/eclipselink-users


Back to the top