Results 1 to 7 of 7

Thread: JBoss + Spring 2.5.2 + Hibernate javax.naming.NameNotFoundException: OracleDS not bou

  1. #1
    Join Date
    Apr 2008
    Posts
    13

    Default JBoss + Spring 2.5.2 + Hibernate javax.naming.NameNotFoundException: OracleDS not bou

    Hi everyone,

    I have a problem using the following combination of frameworks:
    Spring 2.5.2
    Hibernate 3.2.5
    JPA
    I've tried Tomcat 4.0.4, 4.0.5 and 4.2.2.

    The problem is due a NameNotFoundException when using a jndi provided datasource. It all works fine with a jdbc direct connection configuration. I've tried all possibilities but no success.

    Here is my configuration:

    String config:
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    
    <beans xmlns="http://www.springframework.org/schema/beans"
    	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    	xmlns:p="http://www.springframework.org/schema/p"
    	xmlns:aop="http://www.springframework.org/schema/aop"
    	xmlns:context="http://www.springframework.org/schema/context"
    	xmlns:jee="http://www.springframework.org/schema/jee"
    	xmlns:tx="http://www.springframework.org/schema/tx"
    	xsi:schemaLocation="
    			http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
    			http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
    			http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
    			http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-2.5.xsd
    			http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd ">
    	<!-- Datasource: s'usa directament per desenvolupar en Tomcat.
    		En test real s'ha d'usar el datasource del servidor d'aplicacions
    	-->
    	<!--  <bean id="dataSource"
    		class="org.springframework.jdbc.datasource.DriverManagerDataSource">
    		<property name="driverClassName"
    		value="oracle.jdbc.driver.OracleDriver" />
    		<property name="url"
    		value="jdbc:oracle:thin:@uxorades:1521:orades" />
    		<property name="username" value="dtmweb00" />
    		<property name="password" value="zdtmweb00" />
    		</bean> 
    	-->
    <!-- 
    	<jee:jndi-lookup id="dataSource" jndi-name="OracleDS" cache="true"
    		resource-ref="true" lookup-on-startup="false"
    		expected-type="javax.sql.DataSource" />
    -->
    	<bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
    		<property name="jndiName"><value>OracleDS</value></property>
            <property name="resourceRef"><value>true</value></property>
    	</bean>
    
    	<bean
    		class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor" />
    
    	<!-- Definició de la Persistence Unit Manager per a JPA -->
    	<bean id="persistenceUnitManager"
    		class="org.springframework.orm.jpa.persistenceunit.DefaultPersistenceUnitManager">
    		 <property name="persistenceXmlLocations">
    		<list>
    			<value>classpath:/META-INF/persistence.xml</value>
    		</list>
    		</property>
    	</bean>
    
    	<!-- Configuració de la EntityManager Factory -->
    	<!-- Es configura per a usar Hibernate com a implementació de la JPA -->
    	<bean id="entityManagerFactory"
    		class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
    	  	<property name="dataSource" ref="dataSource" />
    		<property name="jpaVendorAdapter">
    			<bean
    				class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
    				<property name="database" value="ORACLE" />
    				<property name="generateDdl" value="false" />
    				<property name="databasePlatform"
    					value="org.hibernate.dialect.Oracle10gDialect" />
    				<property name="showSql" value="true" />
    			</bean>
    		</property>
    		<property name="jpaPropertyMap">
    			<map>
    				<entry key="hibernate.show_sql" value="false" />
    				<entry key="hibernate.format_sql" value="true" />
    				<entry key="hibernate.connection.driver_class"
    					value="oracle.jdbc.driver.OracleDriver" />
    			</map>
    		</property>
    		<property name="persistenceUnitManager"
    			ref="persistenceUnitManager" />
    	</bean>
    
    
    
    	<!-- <property name="userTransactionName"><value>UserTransaction</value></property> -->
    
    	<!-- Definició de Transaction Manager -->
    	<bean id="transactionManager"
    		class="org.springframework.orm.jpa.JpaTransactionManager">
    		<property name="entityManagerFactory"
    			ref="entityManagerFactory" />
    	</bean>
    
    	<tx:annotation-driven transaction-manager="transactionManager" />
    
    	<!--  Generic DAO to use from BOs -->
    	<bean id="universalDao"
    		class="net.tmb.framework.services.persistence.impl.UniversalDAOImpl">
    	</bean>
    
    
    </beans>
    My persistence.xml:
    Code:
    <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 
    	http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
    	version="1.0">
    	<persistence-unit name="persistenceUnit"
    		transaction-type="RESOURCE_LOCAL" >
    		<non-jta-data-source>OracleDS</non-jta-data-source>
    		<properties>
    			<property name="hibernate.show_sql" value="false" />
    			<property name="hibernate.format_sql" value="false" />
    			<property name="hibernate.connection.driver_class"
    				value="oracle.jdbc.driver.OracleDriver" />
    			<property name="hibernate.dialect"
    				value="org.hibernate.dialect.Oracle10gDialect" />
    			<property name="hibernate.hbm2ddl.auto" value="false" />
    		</properties>
    	</persistence-unit>
    </persistence>


    Any help please??
    Thanks a lot.

  2. #2
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,625

    Default

    Your datasource name should read something like 'java:jdbc/OracleDS' however it depends on your settings in JBoss.
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

  3. #3
    Join Date
    Apr 2008
    Posts
    13

    Default

    Marten,
    My jboss datasource config is:
    Code:
    <datasources>
      <local-tx-datasource>
        <jndi-name>jndi-name</jndi-name>
        <connection-url>jdbc:oracle:thin:@uxorades:1521:orades</connection-url>
        <driver-class>oracle.jdbc.driver.OracleDriver</driver-class>
        <user-name>dtmweb00</user-name>
        <password>zdtmweb00</password>
     
        <min-pool-size>5</min-pool-size>
        <max-pool-size>20</max-pool-size>
    
        <!-- Uses the pingDatabase method to check a connection is still valid before handing it out from the pool -->
        <!-- valid-connection-checker-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleValidConnectionChecker</valid-connection-checker-class-name -->
        <!-- Checks the Oracle error codes and messages for fatal errors -->
        <exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleExceptionSorter</exception-sorter-class-name>
            <!-- sql to call on an existing pooled connection when it is obtained from pool - the OracleValidConnectionChecker is prefered -->
            <check-valid-connection-sql>select * from dual</check-valid-connection-sql>
    
          <!-- corresponding type-mapping in the standardjbosscmp-jdbc.xml (optional) -->
          <metadata>
             <type-mapping>Oracle10</type-mapping>
          </metadata>
      </local-tx-datasource>
    </datasources>
    Thank you

  4. #4
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,625

    Default

    Code:
    <jndi-name>jndi-name</jndi-name>
    Where as you query OracleDS....
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

  5. #5
    Join Date
    Apr 2008
    Posts
    13

    Default

    Excuse me, actually is:
    <jndi-name>OracleDS</jndi-name>

  6. #6
    Join Date
    Apr 2008
    Posts
    13

    Default

    No success with Jetty neither.

    Any help?

  7. #7
    Join Date
    Apr 2008
    Posts
    13

    Default Final Solution

    I've found that the cause of the problema was the library: jboss-commons-core-2.0.4.jar.
    In JBoss 4.0.5 there's no conflict but with others versions there is.

    Removing this library and all it's dependencies solved the problem.

    Bye

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •