Results 1 to 5 of 5

Thread: weblogic + JNDI - unable to lookup datasource

  1. #1
    Join Date
    May 2005
    Posts
    2

    Default 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. #2
    Join Date
    May 2005
    Location
    Singapore
    Posts
    4

    Default

    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.
    Hadi Muchtar

  3. #3
    Join Date
    May 2005
    Posts
    2

    Default

    Thanks, it worked.

  4. #4

    Default 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

  5. #5
    Join Date
    Aug 2004
    Posts
    2,715

    Default

    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

Similar Threads

  1. Replies: 13
    Last Post: Feb 5th, 2010, 12:31 AM
  2. Beandoc crashing (on its samples!)
    By aaime in forum Container
    Replies: 17
    Last Post: Oct 7th, 2005, 07:21 AM
  3. JNDI DataSource lookup outside of JBoss
    By cpmcda01 in forum Data
    Replies: 4
    Last Post: Jun 15th, 2005, 03:56 PM
  4. Replies: 1
    Last Post: Feb 12th, 2005, 07:30 AM
  5. Ignoring missing Jndi DataSource within IDE?
    By Bill Pearce in forum Container
    Replies: 2
    Last Post: Oct 27th, 2004, 09:06 AM

Posting Permissions

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