Announcement Announcement Module
Collapse
No announcement yet.
JNDI DataSource Lookups and Glassfish Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • JNDI DataSource Lookups and Glassfish

    I'm trying to deploy an app (EJB3) to Glassfish, and I'm having trouble with the JNDI lookup, so I'm hoping someone here can help me (I'll probably cross-post this question to the GF forum).

    In the constructor for my stateless session bean, I grab the Spring context, then retrieve the JdbcTemplate and set that on my bean (which extends JdbcDaoSupport). Here's my applicationContext.xml
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">

    <beans>
    <bean id="brandNameProductDataSource" class="org.springframework.jndi.JndiObjectFactoryB ean">
    <!-- <property name="resourceRef"><value>true</value></property> -->
    <property name="jndiName"><value>java:comp/env/jdbc/ItemMap</value></property>
    </bean>
    <bean id="brandNameProductJdbcExceptionTranslator" class="org.springframework.jdbc.support.SQLErrorCo deSQLExceptionTranslator">
    <property name="dataSource">
    <ref bean="brandNameProductDataSource"/>
    </property>
    </bean>
    <bean id="brandNameProductJdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate" >
    <property name="dataSource">
    <ref bean="brandNameProductDataSource" />
    </property>
    <property name="exceptionTranslator">
    <ref bean="brandNameProductJdbcExceptionTranslator"/>
    </property>
    </bean>
    </beans>
    Some notes on the definition for brandNameProductDataSource. The bean deploys and runs great un JBoss 4 if I uncomment the resourceRef line, and change the JNDI name to java:jdbc/ItemMap. On Glassfish, however, I get errors like this:

    Caused by: org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'brandNameProductDataSource' defined in class path resource [applicationContext.xml]: Initialization of bean failed; nested exception is javax.naming.NamingException: invocation exception
    For the JNDI name, I've tried every combination I can think of
    • jdbc/ItemMap
    • java:jdbc/ItemMap
    • java:comp/env/jdbc/ItemMap

    All to no avail. Has anyone run across a similar scenario and had any luck? Thanks!

    jason
Working...
X