Announcement Announcement Module
Collapse
No announcement yet.
weblogic + JNDI - unable to lookup datasource Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • weblogic + JNDI - unable to lookup datasource

    Hi,

    I am getting the following message when trying to lookup datasource:

    -----------------------------------------------------------------------------------
    org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'dataSource' defined in class path resource [com/package/name/commonBeanDefinition.xml]: Initialization of bean failed; nested exception is javax.naming.NameNotFoundException: While trying to look up /env/comp/datasource/ds in /app/ejb/testspring.jar#beanservicemdb.
    -----------------------------------------------------------------------------------


    bean definition:
    -----------------------------------------------------------------------------------
    ...
    <bean id="dsJndiTemplate" class="org.springframework.jndi.JndiTemplate">
    <property name="environment">
    <props>
    <prop key="java.naming.provider.url">t3://localhost:7001</prop>
    <prop key="java.naming.factory.initial">weblogic.jndi.WL InitialContextFactory</prop>
    </props>
    </property>
    </bean>


    <bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryB ean">
    <property name="jndiName">
    <value>datasource/ds</value>
    </property>
    <property name="resourceRef">
    <value>true</value>
    </property>
    <property name="jndiTemplate">
    <ref local="dsJndiTemplate"/>
    </property>

    </bean>
    ...

    -----------------------------------------------------------------------------------

    I also tried adding jndi-name setting in weblogic-ejb-jar with no luck:
    -----------------------------------------------------------------------------------
    <weblogic-enterprise-bean>
    ..
    <jndi-name>datasource/ds</jndi-name>
    ..
    </weblogic-enterprise-bean>

    -----------------------------------------------------------------------------------


    JNDI Name:datasource/ds - defined in weblogic console

    What am I missing? I am using weblogic 8.1 sp4, jdk 1.4.2

    Thanks,
    Mark.

  • #2
    Hi,

    <bean id="Datasource"
    class="org.springframework.jndi.JndiObjectFactoryB ean">
    <property name="jndiName">
    <value>projectSolomonDataSource</value>
    </property>
    </bean>

    This what i did, without the resourceRef = true. I did previous to put the resourceRef = true and i faced the problem you mention.

    Try to take out that.

    Comment


    • #3
      Thanks, it worked.

      Comment


      • #4
        Accessing Weblogic Data Source from Spring

        <bean id="dsJndiTemplate" class="org.springframework.jndi.JndiTemplate">
        <property name="environment">
        <props>
        <prop key="java.naming.provider.url">t3://server1:7002,server2:7003</prop>
        <prop key="java.naming.factory.initial">weblogic.jndi.WL InitialContextFactory</prop>
        <prop key="java.naming.security.principal">weblogic</prop>
        <prop key="java.naming.security.credentials">weblogic</prop>
        </props>
        </property>
        </bean>

        <bean id="TODatasource" class="org.springframework.jndi.JndiObjectFactoryB ean">
        <property name="jndiTemplate">
        <ref local="dsJndiTemplate"/>
        </property>
        <property name="jndiName">
        <value>Weblogic.DataSource.JNDIName</value>
        </property>
        </bean>

        Java Code to access the DATASOURCE

        javax.sql.DataSource dataSource = (DataSource)ComponentHelper.getInstance().lookup(T ODatasource);

        conn = dataSource.getConnection();


        Thanx
        Sumit

        Comment


        • #5
          Sumit, where is your question? Do I suggest correctly that the code you posted does not work? If so, a description might be helpful.

          Besides that, the difference between your case and the original one is, that the original poster accesses the DS from within the container, while you seem trying to access it from outside. As far as I know, DataSources are not accessible outside the container. But to be sure please consult the WebLogic reference.

          Regards,
          Andreas

          Comment

          Working...
          X