Announcement Announcement Module
Collapse
No announcement yet.
[Error] NameNotFoundException: jndi-lookup name is not associated with this context Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • [Error] NameNotFoundException: jndi-lookup name is not associated with this context

    Hi all,

    Trying to run the application into browser, the following error appears:

    javax.naming.NameNotFoundException: name hibernate/TFCappDS is not associated with this context
    I connect to data Source with JNDI lookup, my app server is VMware vFabric tc Server, and I'm using Hibernate as the ORM framwork.

    The fact is, I really don't know what name should I put as a jndi name.

    Furthermore, I read in some places that is necessary to define JNDI lookup name as a <resource> in server.xml file from Server directory, and then to reference JNDI from Server's web, in context.xml from the same directory. But I have no idea about how to create this server resource, or what values should I write considering my server and ORM cases (VMware vFabric tc Server, Hibernate)

    All my current code about JNDI and dataSource bean is this, at Spring xml file:

    Code:
    <jee:jndi-lookup id="dataSource"
    	jndi-name="hibernate/TFCappDS"
    	resource-ref="true"/>
    		
    <beans:bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
    	<beans:property	name="dataSource" ref="dataSource"/>
    	<beans:property name="packagesToScan" value="cat.tfcproject.springmvc.domain"/>
    	<beans:property	name="hibernateProperties">
    	        <beans:props>
    		        <beans:prop key="dialect">org.hibernate.dialect.HSQLDialect</beans:prop>
    	        </beans:props>
    	</beans:property>
    </beans:bean>
    
    
    	
    <beans:bean class="org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor" />
    	
    <beans:bean id="txManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
    	<beans:property name="sessionFactory" ref="sessionFactory"/> 
    </beans:bean>
    	
    <tx:annotation-driven transaction-manager="txManager"/>

    Someone know how to solve this?

  • #2
    Well, It still does not recognize jndi name as a part of this context,

    I'm working with postgres right now so I only changed the SessionFactory dialect parameter, in servlet-context.xml. No changes at the rest of the code, except I added the following resource, inside server.xml VMware tc Server file:

    Code:
    <GlobalNamingResources>
       	<Resource 	name="hibernate/TFCappDS"
       		auth="Container"
       		type="javax.sql.DataSource"
       		username="dbUsername"
       		password="dbPasswd"
       		driverClassName="org.postgresql.Driver"
       		url="jdbc:postgresql://localhost/TFCappDS"
       		maxActive="120"
       		maxIdle="5"
       		maxWait="5000"
       		initialSize="5"
       		poolPreparedStatements="true"
       		validationQuery="select 1" />	
    </GlobalNamingResources>
    But It still does not recognize jndi name as a part of this context.

    About this, I have two questions:

    Can someone tell me if I have the correct values of 'url' and 'driverClassName' parameters, considering postgres??

    Does Anyone know if there's something more to do, after editing servlet-context.xml and server.xml like this, to get JNDI-lookup name finally recognized? Or am I just simply wrong from de begining?


    Very grateful to everyone

    Comment

    Working...
    X