Mapping of logical resource-name to absolute jndi-name for data source

Hi,
I am using SJS AS 8.1. I do a lookup for datasource using logical name specified in ejb-jar.xml using resource-ref element as below :
<resource-ref>
        <res-ref-name>jdbc/db-resource</res-ref-name>
        <res-type>javax.sql.DataSource</res-type>
        <res-auth>Container</res-auth>
        <res-sharing-scope>Shareable</res-sharing-scope>
</resource-ref>jdbc/db-resource is mapped to absolute jndi name 'jdbc/jndi-db-resource' in sun-ejb-jar.xml as below :
<resource-ref>
        <res-ref-name>jdbc/db-resource</res-ref-name>
        <jndi-name>jdbc/jndi-db-resource</jndi-name>
</resource-ref>I have configued data source using admin GUI with JNDI name jdbc/jndi-db-resource. When I do a look up of datasource as below :
initalContext.lookup("jdbc/db-resource"); from the EJB I get NameNotFoundException. How do I configure logical datasource name using admin GUI ?
Thanks,
Manisha.

Hi Manisha,
When doing a lookup of standard j2ee connection factories like jms or jdbc "java:comp/env" need to be prefixed.
initalContext.lookup("jdbc/db-resource");
need to be
initalContext.lookup("java:comp/env/jdbc/db-resource");
For more information :
http://docs.sun.com/source/819-0079/dgjndi.html#wp24616
Thanks,
-Jagadish

Similar Messages

  • Could take the same JNDI-names for both tags: jndi-name and local-jndi-name

    Hello!
    I try to design the weblogic-ejb-jar.xml descriptor and I ask myself, if I could
    take the same JNDI-names for both tags:
    <jndi-name> and <local-jndi-name> ?
    Could you give me and advice if this is ok?
    Thanks

    if you have two separate interfaces, you cant bind them to the same jndi
    name. you will have a local home that extends EJBLocalHome and a remote
    home called EJBHome. also you need to know which one you are looking up
    so you can cast it properly, and use it property (remote interfaces need
    PortableRemoteObject, remote parameters are passed by value, ...)
    joern kirch wrote:
    Hello!
    I try to design the weblogic-ejb-jar.xml descriptor and I ask myself, if I could
    take the same JNDI-names for both tags:
    <jndi-name> and <local-jndi-name> ?
    Could you give me and advice if this is ok?
    Thanks

  • ODBC call SQLDriverConnect for data source Server name failed: [ . Notify Customer Support.

    Need help !
    While running DS job through designer we are getting below error:
    ODBC call <SQLDriverConnect> for data source <SErver name> failed: <[>. Notify Customer Support.
    Additional notes:
    1. Source and Target datastore are getting connected properly as i have imported table's definition using it.
    2. Source and target data store pointing to SQL server 2008 R2 express edition DB (64 bit).
    3. It seems like server machine has both 32bit and 64bit drivers installed on it. Please refer attached driverdetails.jpg file for more details.
    Thanks

    Hi did you referred this :
    ODBC call <SQLDriverConnect> for data source <MyComputer\SQLServer2008R2> failed: <[Microsoft][ODBC SQL Server Driver][DBNETLIB]SQL Server does not exist or access denied.>. Notify Customer Support.

  • Problem using JDBC (JNDI) DataSource and data-sources.xml w/ OC4J

    I have a JClient application developed in JDev X. It works fine when using a JDBC URL for the connection (which then writes the connection into the BC4J.xcfg files, one for each application module). However, I would like the app to retrieve the data source from the server's data-sources.xml file. However, when, on the configurations tab of the application module I set the connection type to JDBC DataSource, and give it the JNDI name, it does not work, either with the embedded OC4J or the stand-alone OC4J. Any suggestions???
    In the stand alone OC4J I verified that the data source exists (using java -jar admin.jar ormi://nemethzoltan3 admin welcome -application adatklinika -testDataSource -location jdbc/adatklinikaCoreDS) ... so the data source is defined in the data-sources.xml. Of course the error I get is JBO-30003.
    If I just try to "test" the data source in Jdeveloper (using the context menu of the app module, and setting it to use the adatklinikaCoreDS) I get a JNDI error: unable to lookup data source and at level 3 a "javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial". I checked, the data source is defined under tools->embedded OC4J properties->data sources.
    If I try to run the main form, simply nothing happens.
    Please help!!!

    Ok, figured out why running from jdeveloper wasn't working: the embedded OC4J server wasn't started (start it by running an html page from your project or something...and make sure you don't have a stand-alone oc4j running). AND more importantly it didn't have the library "embedded oc4j client" library included (project properties -> profiles -> development -> libraries)...which is needed for whatever reason.
    Now to try and get it working with the stand-alone OC4J...

  • Table for Data source and Transfer rule mapping

    Hi all,
    Do we have any table where in we can know the different transfer rules(for different source systems) assigned to the same Data source.
    thanks and regards,
    Rk.

    thank you all,
    the table RSDS does not have 3.x data sources, it has only 7.0 Data sources also it does not have the field mapping.
    RSOSFIELDMAP and RSTSRULES have the field mapping of the datasources, do we have any similiar tables for 7.0 Datasources.
    regards,
    RK

  • Mapping between the info cube fields and fields in the data source in sap r

    In Bi7.0 in which database did the mapping between the Infocube objects and the datasource object will be store Here i have used the r3 system

    Hi,
    Chk table RSOSFIELDMAP.
    Regards,
    Gunjan.

  • Treasury - Cash Management 0TR-CM-1 logic for Data Source

    Hi all,
    I am trying to understand how the value of the DATA_SOURC field in the extract structure FTI_BIW_CM in DS 0TR-CM-1 is populated. This value propagates to the InfoProvider (0TRCM_RC1) and standard content queries have a hard-coded restriction to a value of '2' The DS is returning values of 1 and 2 and I need to understand the implications of the two values. The help pages don't provide this information.
    Any help is greatly appreciated.

    Hi,
    Extractor 0TR_CM_1 reads from table FDSB and FDSR. Not sure what could be
    the reason for this code to avoid zero values. Please check with application
    colleagues if zero values are allowed for this field in ECC system.
    Thanks,
    Vimal

  • JNDI name for resource adapters

    When I look up a connection factory via the initial context, which JNDI name should I be using? How do I know which namespace my JCA resource adapter is in?
    I have registered the standalone JCA resource adapter via the command
    C:\OraHome_2\dcm\bin>dcmctl deployApplication -f my.rar -a my_jca
    Can I access it like this from my EJB?
    Context initialContext = new InitialContext();
    jcaConnectionFactory = (ConnectionFactory)initialContext.lookup("my_jca");
    or does it have to be java:comp/env?
    The default oc4j-ra.xml that was generated by dcmctl looks like this:
    <?xml version="1.0"?>
    <!DOCTYPE oc4j-connector-factories PUBLIC "-//Oracle//DTD Oracle Connector 9.04//EN" "http://xmlns.oracle.com/ias/dtds/oc4j-connector-factories-9_04.dtd">
    <oc4j-connector-factories>
    <connector-factory location="" connector-name="my_jca">
    </connector-factory>
    </oc4j-connector-factories>

    What is the correct way of looking up a resource adapter from another resource adpater? The JNDI name of my resource adapter is "StorageFactory" and I am doing a lookup like:
              Context ctx = new InitialContext();
              ctx.lookup("StorageFactory")
              Is this a correct way to lookup?

  • EJB Refs ( coded name and JNDI name )

    Hi
    I am just starting to develop EJBs . I can't get to work the EJB refs as expected . In a session bean I have a lookup for an Entity bean . Both beans are in separate JAR files , but in the same ear .
    The lookup from session bean to entity bean only works when
    the coded name in EJB ref is defined exactly the same as JNDI name for enity bean , also the name in lookup method must be the same in session bean .
    To my surprise , the JNDI name for the target EJB , defined in EJB ref for session bean , does not mater at all . Even if I change it to a non existant name , the bean lookup works .
    Theoritacally I understand that EJB ref is there to provide a mapping between the name of bean mentioned in code to the actual JNDI name of another bean , at the time of deployment .
    The above is happening in J2EE 1.4 envoirment .
    Please let me know , what am I doing here that is wrong .
    ( All examples and tutorials , usually give coded name same as JNDI name ) .
    Thanks
    Tarun

    Hi Tarun,
    The ejb-ref-name lives in a different namespace than the global JNDI names. Any names of ejb-refs, ejb-local-refs, resource-refs, etc. are scoped within a particular component's private namespace. All environment references are accessed via the java:comp/env namespace at runtime. So, if your ejb-ref-name(a.k.a "coded name") is ejb/foo in the deployment descriptor, you would access it from the code as follows :
    initialContext.lookup("java:comp/env/ejb/foo");
    This way, neither the standard deployment descriptor nor the code has any dependency on the global JNDI name. That's a good thing since the decision about which target EJB should be linked to is often not made until deployment time rather than development time. Furthermore, it means if you want to change the linking you can always do it without recompiling your code.
    As for the global JNDI names, the first thing to note is that they are completely vendor-specific. That's why they don't appear in the standard deployment descriptor. In the J2EE SDK, each EJB that exposes a Remote view is assigned a global JNDI name in sun-ejb-jar.xml. This JNDI name is assigned from the global namespace of the application server. There's nothing stopping it from also being "ejb/foo", but it refers to a different thing than the "ejb/foo" above.
    Now we have an ejb-ref called ejb/foo and an ejb whose JNDI name is ejb/foo, but we haven't linked the two. When it comes to linking, you have two choices:
    1. If the target ejb is in the same .ear as the client component, you can use the ejb-link mechanism. This allows you to specify the target ejb by referring to its ejb-name. Since ejb-name is only guaranteed to be unique within an ejb-jar, the syntax allows for you to give the uri of the containing ejb-jar, followed by #, followed by ejb-name.
    2. Alternatively, you can specify the global JNDI name of the target ejb using sun-ejb-jar.xml Note that this will work whether the target ejb is in the same .ear or not. However, it's the only option if the target ejb is in a different .ear. In this case, you would create an ejb-ref entry for the client component within the sun-ejb-jar.xml. e.g. :
    <ejb>
    <ejb-name>MyClientBean</ejb-name>
    <ejb-ref>
    <ejb-ref-name>ejb/foo</ejb-ref-name>
    <jndi-name>ejb/foo</jndi-name>
    </ejb-ref>
    </ejb>
    Again, it's just a coincidence that both names happen to be ejb/foo. They refer to different things.
    When you do a global lookup from your code, initialContext.lookup('ejb/foo"), it will work in some environments because you're simply bypassing the level of indirection provided by your component environment and going straight to the global namespace. This is non-portable and not a good idea, since you've now tightly coupled the name of the target ejb to your client component. That means if it changes you need to recompile your code. Hope this helps.
    --ken

  • Of Coded name and JNDI name...

    I'm confused as to what is the relationship between a coded name and a JNDI name?
    What exactly is a coded name and for JNDI name it seems like some kind of URL to identify resources, machines, databases, EJBs etc.
    What's the difference between them and how are they related to each other?
    Why do we seem to map coded name to JNDI name?

    See the tutorial on jndi for how it works/is used etc.
    http://java.sun.com/products/jndi/tutorial
    You may find this link also useful:
    ftp://ftp.javasoft.com/docs/j2se1.3/jndi.pdf

  • Weblogic 12c ignores jndi-name definition. Why ?

    Hi all!
    I have a Stateless Bean which has a custom JNDI name defined in weblogic-ejb-jar.xml
    <weblogic-enterprise-bean>
    <ejb-name>CompanySFSB</ejb-name>
    <stateless-session-descriptor>
    <business-interface-jndi-name-map>
    <business-remote>model.logic.Company</business-remote>
    <jndi-name>ejb/Company</jndi-name>
    </business-interface-jndi-name-map>
    </stateless-session-descriptor>
    </weblogic-enterprise-bean>
    </weblogic-ejb-jar>
    However looking at the JNDI tree the bean is stored as "WLSEARWLSEJB_jarCompanySFSB_Company"
    Therefore injecting the EJB as
    @EJB(name = "CompanySFSB", mappedName = "ejb/Company")
    Is there a way to store the EJB with the JNDI declared in weblogic-ejb-jar.xml ? or by using an annotation in the EJB ?
    Thanks
    Frank

    Hi Frank,
    Try this option in your startup script.
    -Dweblogic.jndi.retainenvironment=true
    Regards,
    Kal

  • Crystal Reports XI and Sun One 6.1 web server SP 5 Error finding JNDI name

    I am trying to create a Crystal Reports XI report in a JSP using Sun One 6.1 Web server sp 5.
    At this point I am getting the error �Error finding JNDI name� on Sun One
    The application will run on Netbeans/Tomcat
    I have done the following:
    I edited CRConfig.xml
    <?xml version="1.0" encoding="utf-8"?>
    <CrystalReportEngine-configuration>

    <DataDriverCommon>
         <JavaDir>C:\Program Files\Java\j2re1.4.2_10\bin</JavaDir>
    <Classpath>C:\oracle\product\10.2.0\client_1\jdbc\lib\ojdbc14.jar;�</Classpath>

    <JDBC>
         <CacheRowSetSize>100</CacheRowSetSize>
         <JDBCURL>jdbc:oracle:thin:@10.10.10.10:1521:dev</JDBCURL>
         <JDBCClassName>oracle.jdbc.driver.OracleDriver</JDBCClassName>
         <JDBCUserName>lab_ro</JDBCUserName>
         <JNDIURL></JNDIURL>

    </JDBC>
    I created a report using JDBC (JNDI) connection and have the JNDI Connection set to the name of DATA.
    The report works just fine in Crystal Reports.
    Then in Netbeans I created an application and it runs in the Tomcat part of Netbeans
    In context.xml I have:
    <Context path="/BOEnterpriseTest3">
    <Resource name="jdbc/dev" auth="Container" type="javax.sql.DataSource"
    driverClassName="oracle.jdbc.driver.OracleDriver" url="jdbc:oracle:thin:@10.10.10.10:1521:dev"
    username="theuserid" password="thepassword" maxActive="20" maxIdle="10" maxWait="-1"/>
    </Context>
    In web.xml I have
    <web-app>
    <context-param>
    <param-name>crystal_image_uri</param-name>
    <param-value>crystalreportviewers11</param-value>
    </context-param>

    <taglib>
    <taglib-uri>/crystal-tags-reportviewer.tld</taglib-uri>
    <taglib-location>/WEB-INF/crystal-tags-reportviewer.tld</taglib-location>
    </taglib>
    <resource-ref>
    <description>jdbc:oracle:thin:@10.10.10.10:1521:dev</description>
    <res-ref-name>jdbc/dev10g</res-ref-name>
    <res-type>javax.sql.DataSource</res-type>
    <res-auth>Application</res-auth>
    <res-sharing-scope>Shareable</res-sharing-scope>
    </resource-ref>
    <resource-ref>
    <description>jdbc:oracle:thin:@10.10.10.10:1521:dev</description>
    <res-ref-name>Data</res-ref-name>
    <res-type>javax.sql.DataSource</res-type>
    <res-auth>Application</res-auth>
    <res-sharing-scope>Shareable</res-sharing-scope>
    </resource-ref>
    </web-app>
    in web-inf\sun-web.xml I have
    <sun-web-app>
    <resource-ref>
    <res-ref-name>jdbc/dev10g</res-ref-name>
    <jndi-name>Data</jndi-name>
    </resource-ref>
    </sun-web-app>
    I have copied all of Common Files\Business Objects\3.0\java\lib and Common Files\Business Objects\3.0\java\lib\external to the lib folder
    I have copied crystalreportviewers11 to the root of my web application
    I have tried to load the JNDI information and display the report
    <%@page pageEncoding="UTF-8"
    import="com.crystaldecisions.reports.reportengineinterface.*,
    com.crystaldecisions.report.web.viewer.*,
    javax.naming.*,
    javax.sql.*,
    java.sql.*"%>
    <%
    InitialContext initContext = new InitialContext();
    DataSource source = (DataSource) initContext.lookup("java:comp/env/jdbc/dev10g");
    Context initCtx = new InitialContext();
    Context envCtx = (Context) initCtx.lookup("java:comp/env");
    try{
         // Look up our data source
    DataSource ds = (DataSource)initCtx.lookup("Data");
    out.println("found ds under jdbc/Data");
    catch ( NamingException e ){
    // Look up our data source
    DataSource ds = (DataSource) initContext.lookup("java:comp/env/jdbc/dev10g");
    initCtx.bind("Data", ds);     
    out.println("found ds under java:com/env:jdbc/Data - bound into root initial context for Crystal to find");
    %>
    <%
    //Use the relative path to the report; the physical or full qualified URL cannot be used.
    String reportName = "useridincluded.rpt";
    //Database username and password
    String userName = "theuserid";
    String password = "thepassword";
    //check to see if the Report Source Session Variable already exist
    Object reportSource = session.getAttribute("Report1");
    // Create a new ConnectionInfos and ConnectionInfo object
    com.crystaldecisions.sdk.occa.report.data.ConnectionInfos connectionInfos = new com.crystaldecisions.sdk.occa.report.data.ConnectionInfos();
    com.crystaldecisions.sdk.occa.report.data.ConnectionInfo connectionInfo = new com.crystaldecisions.sdk.occa.report.data.ConnectionInfo();
    //Set username and password for the report's database
    connectionInfo.setUserName(userName);
    connectionInfo.setPassword(password);
    //Add object to collection
    connectionInfos.add(connectionInfo);
    //---------- Create a ReportClientDocument -------------
    com.crystaldecisions.reports.sdk.ReportClientDocument reportClientDocument = new com.crystaldecisions.reports.sdk.ReportClientDocument();
    //---------- Set the path to the location of the report soruce -------------
    //Open report.
    reportClientDocument.open(reportName, 0);
    //Get the report source
    reportSource = reportClientDocument.getReportSource();
    //---------- Create the viewer and render the report -------------
    //create the CrystalReportViewer object
    com.crystaldecisions.report.web.viewer.CrystalReportViewer crystalReportViewer = new com.crystaldecisions.report.web.viewer.CrystalReportViewer();
    //set the reportsource property of the viewer
    crystalReportViewer.setReportSource(reportSource);
    //set the DB logon into the viewer
    crystalReportViewer.setDatabaseLogonInfos(connectionInfos);
    //set viewer attributes
    crystalReportViewer.setOwnPage(true);
    crystalReportViewer.setOwnForm(true);
    crystalReportViewer.refresh();
    //set the CrystalReportViewer print mode
    //crystalReportViewer.setPrintMode(com.crystaldecisions.report.web.viewer.CrPrintMode.ACTIVEX);
    crystalReportViewer.setPrintMode(com.crystaldecisions.report.web.viewer.CrPrintMode.PDF);
    //process the report
    crystalReportViewer.processHttpRequest(request, response, getServletConfig().getServletContext(), null);
    %>
    On the Sun One Web server
    On the Java Tab
    JDBC Connection Pools
    Pool Name = dev10g
    Class name = oracle.jdbc.pool.OracleDataSource
    User id = theuserid
    url = 10.10.10.10
    password=thepassword
    JDBC Resources
    JNDI Name=dev10g
    Pool = dev10g
    I get the error finding JNDI name � how do I tell Sun One where the JNDI is to make Crystal Reports work?

    I tried the following to test the JNDI
    I am trying to do JNDI in Sun One Web server 6.1 sp 5 but I seem to be missing an important part. I get two different errors based on the JSP code, �Cannot retrieve data source: javax.naming.NamingException: Cannot create resource instance� or �Cannot retrieve data source: javax.naming.NamingException: Cannot create resource instance�.
    Context.xml:
    <?xml version="1.0" encoding="UTF-8"?>
    <Context path="/BOTest">
      <Resource name="jdbc/dev10g" auth="Container" type="javax.sql.DataSource"
    driverClassName="oracle.jdbc.driver.OracleDriver" url="jdbc:oracle:thin:@10.10.10.10:1521:dev10g"
    username="userid" password="password" maxActive="20" maxIdle="10" maxWait="-1"/>
      <Resource name="Data" auth="Container" type="javax.sql.DataSource"
    driverClassName="oracle.jdbc.driver.OracleDriver" url="jdbc:oracle:thin:@10.10.10.10:1521:dev10g"
    username="userid" password="password" maxActive="20" maxIdle="10" maxWait="-1"/>
    </Context>Sun-one.xml:
    <sun-web-app>
    <context-root>BOTest</context-root>
    <resource-ref>
    <res-ref-name>jdbc/dev10g</res-ref-name>
    <jndi-name>jdbc/dev10g</jndi-name>
    </resource-ref>
    </sun-web-app>web.xml:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE web-app
        PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
        "http://java.sun.com/dtd/web-app_2_3.dtd">
    <web-app>
        <session-config>
            <session-timeout>
                30
            </session-timeout>
        </session-config>
        <welcome-file-list>
         <welcome-file>
                index.jsp
            </welcome-file>
        </welcome-file-list>
        <resource-ref>
            <description>jdbc:oracle:thin:@10.10.10.10:1521:dev10g</description>
            <res-ref-name>jdbc/dev10g</res-ref-name>
            <res-type>javax.sql.DataSource</res-type>
            <res-auth>Application</res-auth>
            <res-sharing-scope>Shareable</res-sharing-scope>
        </resource-ref>
        <resource-ref>
            <description>jdbc:oracle:thin:@10.10.10.10:1521:dev10g</description>
            <res-ref-name>Data</res-ref-name>
            <res-type>javax.sql.DataSource</res-type>
            <res-auth>Application</res-auth>
            <res-sharing-scope>Shareable</res-sharing-scope>
        </resource-ref>
    </web-app>server.xml has:
    <RESOURCES>
    - <JDBCCONNECTIONPOOL name="dev10g" datasourceclassname="oracle.jdbc.pool.OracleDataSource" steadypoolsize="8" maxpoolsize="32" poolresizequantity="2" idletimeout="300" maxwaittime="60000" connectionvalidationrequired="off" connectionvalidationmethod="auto-commit" validationtablename="" failallconnections="off" transactionisolationlevel="read-uncommitted" isolationlevelguaranteed="off">
      <PROPERTY name="URL" value="jdbc:oracle:thin:@10.45.3.197:1521:dev10g" />
      <PROPERTY name="User" value="lab_ro" />
      <PROPERTY name="Password" value="0asphalt1" />
      </JDBCCONNECTIONPOOL>
      <JDBCRESOURCE jndiname="jdbc/dev10g" poolname="dev10g" enabled="on" />
      <JDBCRESOURCE jndiname="Data" poolname="dev10g" enabled="on" />
    - <JDBCCONNECTIONPOOL name="Data" datasourceclassname="oracle.jdbc.pool.OracleDataSource" steadypoolsize="8" maxpoolsize="32" poolresizequantity="2" idletimeout="300" maxwaittime="60000" connectionvalidationrequired="off" connectionvalidationmethod="auto-commit" validationtablename="" failallconnections="off" transactionisolationlevel="read-uncommitted" isolationlevelguaranteed="off">
      <PROPERTY name="User" value="lab_ro" />
      <PROPERTY name="URL" value="jdbc:oracle:thin:@10.45.3.197:1521:dev10g" />
      <PROPERTY name="Password" value="0asphalt1" />
      </JDBCCONNECTIONPOOL>
      <JDBCRESOURCE jndiname="jdbc/Data" poolname="Data" enabled="on" />
      <JDBCRESOURCE jndiname="dev10g" poolname="dev10g" enabled="on" />
      </RESOURCES>I am getting the following error: �Cannot retrieve data source: javax.naming.NamingException: Cannot create resource instance�
    With the following code:
    <%@page
       import="java.io.*,
               javax.sql.*,
               javax.naming.*,
               java.sql.*,
               java.util.*"%>
    <%
    Context init;
    Context ctx;
    DataSource datasource;
    Connection con;
    try
    init = new InitialContext();
    Context envCtx = (Context) init.lookup("java:comp/env");
    datasource = (DataSource)  envCtx.lookup("jdbc/dev10g");
    catch(NamingException ex)
        out.print("Cannot retrieve data source: " + ex.toString(true));
        return;
    try
        con = datasource.getConnection();
    catch (Exception e)
      out.print("Cannot retrieve connection: " + e.toString());
      return;
    try
        PreparedStatement pstmt = con.prepareStatement("SELECT PROJNO FROM MATERIALSLAB.VW_ASPHALTHEADERINFO");
        ResultSet results = pstmt.executeQuery();
        while (results.next())
        out.println(results.getString(1));
    catch(Exception ex)
    out.print("Got connection, can't execute query: " + ex.toString());
    return;
    %>I get the following error: Cannot retrieve data source: javax.naming.NamingException: Cannot create resource instance
    With the following code:
    <%@page
       import="java.io.*,
               javax.sql.*,
               javax.naming.*,
               java.sql.*,
               java.util.*"%>
    <%
    Context init;
    Context ctx;
    DataSource datasource;
    Connection con;
    try
        init = new InitialContext();
        ctx = (Context) init.lookup("java:comp/env");
        datasource = (DataSource) ctx.lookup("jdbc/dev10g");
    catch(NamingException ex)
        out.print("Cannot retrieve data source: " + ex.toString(true));
        return;
    try
        con = datasource.getConnection();
    catch (Exception e)
      out.print("Cannot retrieve connection: " + e.toString());
      return;
    try
        PreparedStatement pstmt = con.prepareStatement("SELECT PROJNO FROM MATERIALSLAB.VW_ASPHALTHEADERINFO");
        ResultSet results = pstmt.executeQuery();
        while (results.next())
        out.println(results.getString(1));
    catch(Exception ex)
    out.print("Got connection, can't execute query: " + ex.toString());
    return;
    %>

  • Problem in setting up jndi name in servlet

    hi,
    I am using netbeans6.8, glassfishv3 with mysql5.1. I set up a new jdbc Resource & connection pool by using the glassifsh admin console, and associated the connection pool with jdbc resource
    when i ping the status of the connection pool , it is success.
    Following is the lines added from my config.xml file in glassfish domain
    <jdbc-resource pool-name="knockknock_poool" description="For connecting with knockknock for testing" jndi-name="jdbc/knockknock" />
    <jdbc-connection-pool datasource-classname="com.mysql.jdbc.jdbc2.optional.MysqlDataSource" max-pool-size="250" res-type="javax.sql.DataSource" steady-pool-size="32" description="pool for contains connection to connect with knockknock" name="knockknock_poool" non-transactional-connections="true" ping="true">
    <property description="jdbcname" name="URL" value="jdbc:mysql://localhost:3306/knockknock" />
    <property description="knockknock" name="databaseName" value="knockknock" />
    <property description="knockknock" name="datasourceName" value="knockknock" />
    <property description="tcp" name="networkProtocol" value="tcp" />
    <property description="admin" name="password" value="admin" />
    <property description="3306" name="portNumber" value="3306" />
    <property description="localhost" name="serverName" value="192.168.2.36" />
    <property description="root" name="user" value="root" />
    </jdbc-connection-pool>
    My DB name is knockknock & jndi name of datasource is jdbc/knockknock and ping status is true
    when i try to make a datasource lookup from my servlet i am getting the following exception
    javax.naming.NamingException: Lookup failed for 'jdbc/knockknock' in SerialContext [Root exception is javax.naming.NameNotFoundException: knockknock not found]
    at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:442)
    at javax.naming.InitialContext.lookup(InitialContext.java:392)
    at javax.naming.InitialContext.lookup(InitialContext.java:392)
    at knockingvideopackage.NewRegistration.init(NewRegistration.java:50)
    at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1428)
    at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:1073)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:187)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:188)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:641)
    at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:97)
    at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:85)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:185)
    at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:332)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:233)
    at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:165)
    at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:791)
    at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:693)
    at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:954)
    at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:170)
    at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:135)
    at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:102)
    at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:88)
    at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:76)
    at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:53)
    at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:57)
    at com.sun.grizzly.ContextTask.run(ContextTask.java:69)
    at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:330)
    at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:309)
    at java.lang.Thread.run(Thread.java:619)
    Caused by: javax.naming.NameNotFoundException: knockknock not found
    at com.sun.enterprise.naming.impl.TransientContext.doLookup(TransientContext.java:197)
    at com.sun.enterprise.naming.impl.TransientContext.lookup(TransientContext.java:168)
    at com.sun.enterprise.naming.impl.TransientContext.lookup(TransientContext.java:172)
    at com.sun.enterprise.naming.impl.SerialContextProviderImpl.lookup(SerialContextProviderImpl.java:58)
    at com.sun.enterprise.naming.impl.LocalSerialContextProviderImpl.lookup(LocalSerialContextProviderImpl.java:101)
    at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:430)
    ... 28 more
    and my servlet code is
    @Override
    public void init(ServletConfig config)
    try {
    InitialContext ctx = new InitialContext();
    // ctx.bind("java:comp/env/jdbc/knockknock", ctx);
    if(ctx == null )
    try {
    throw new Exception("Boom - No Context");
    } catch (Exception ex) {
    Logger.getLogger(NewRegistration.class.getName()).log(Level.SEVERE, null, ex);
    DataSource ds = (DataSource)ctx.lookup("java:comp/env/jdbc/knockknock");
    try {
    con = ds.getConnection();
    } catch (SQLException ex) {
    Logger.getLogger(NewRegistration.class.getName()).log(Level.SEVERE, null, ex);
    } catch (NamingException ex) {
    Logger.getLogger(NewRegistration.class.getName()).log(Level.SEVERE, null, ex);
    i believe that what i am doing is correct from this document of mysql
    http://dev.mysql.com/doc/refman/5.1/en/connector-j-usagenotes-j2ee.html
    But i cannot understand what is the problem. any help is appreciated
    thanks

    Hello there.
    Here's the ServiceLocator and delegates I am using....
    // LoginDelegate.as
    package com.myproj.products.business {
         import com.myproj.products.vo.LoginVO;
         import mx.rpc.IResponder;
         import com.adobe.cairngorm.business.ServiceLocator;
         public class LoginDelegate {
              // anything that implements the IResponder interface can act as a responder
              private var responder:IResponder;
              private var service:Object;
              public function LoginDelegate(responder:IResponder) {
                   this.responder = responder;
                   this.service = ServiceLocator.getInstance().getRemoteObject("loginService");
              public function login(loginAttempt:LoginVO):void {
                   // Call the method of service that resides on server
                   var call:Object = service.login(loginAttempt);
                   // Send the response to responder
                   call.addResponder(responder);
    // com/myproj/products/business/Services.mxml
    <?xml version="1.0" encoding="utf-8"?>
    <cairngorm:ServiceLocator
         xmlns:mx="http://www.adobe.com/2006/mxml"
            xmlns:cairngorm="com.adobe.cairngorm.business.*">
         <!-- Login Service -->
         <mx:RemoteObject
              id="loginService"
              destination="zend"
              source="LoginService"
              showBusyCursor="true">
              <mx:method name="doLogin" />
         </mx:RemoteObject>
    </cairngorm:ServiceLocator>
    With kind regards
    ShiVik

  • WLS10.3.1 : How to overload the jndi name of a stateless EJB

    Hi,
    I am trying to overload the jndi name of a stateless bean defined in an application by using a weblogic-ejb-jar.xml descriptor file.
    This does not work.
    The ear contains a jar that have a weblogic-ejb-jar.xml file in its META-INF directory. The file is :
    <?xml version="1.0" encoding="UTF-8"?>
    <weblogic-ejb-jar
    xmlns="http://www.bea.com/ns/weblogic/90" xmlns:j2ee="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.bea.com/ns/weblogic/90 http://www.bea.com/ns/weblogic/90/weblogic-ejb-jar.xsd">
    <weblogic-enterprise-bean>
    <ejb-name>HelloWorldBean</ejb-name>
    <enable-call-by-reference>true</enable-call-by-reference>
    <jndi-name>TOTO</jndi-name>
    </weblogic-enterprise-bean>
    </weblogic-ejb-jar>
    This is the code of my bean :
    package test;
    import javax.ejb.Local;
    import javax.ejb.Remote;
    import javax.ejb.Stateless;
    @Stateless( name = "HelloWorldBean", mappedName="HWBean")
    @Local( IHelloWorldLocal.class)
    @Remote( IHelloWorldRemote.class)
    public class HelloWorldBean implements IHelloWorldLocal, IHelloWorldRemote
    public void sayHello(String name) {
    System.out.println( "Hello " + name + "!!!!");
    The bean implements the following interfaces :
    package test;
    public interface IHelloWorldRemote extends IHelloWorld {
    package test;
    public interface IHelloWorldLocal extends IHelloWorld {
    package test;
    public interface IHelloWorld {
    public void sayHello( String name);
    When i browse the JNDI tree, i see the bean registered with the mapped name attribute (HWBean#test.IHelloWorldRemote) but i don't see any bean registered with the name provided by the weblogic-ejb-jar.xml (TOTO)
    My standalone client can't perform a lookup using the JNDI name 'TOTO' but reaches the bean when using 'HWBean#test.IHelloWorldRemote'
    It seem's that the overload of the Jndi name using the weblogic-ejb-jar file descriptor doesn't work.
    Can you help me to solve the problem.
    Thanks.

    Thank you, my sample works fine with the following weblogic-ejb-jar.xml :
    <?xml version="1.0" encoding="UTF-8"?>
    <weblogic-ejb-jar xmlns="http://www.bea.com/ns/weblogic/10.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.bea.com/ns/weblogic/10.0 http://www.bea.com/ns/weblogic/10.0/weblogic-ejb-jar.xsd">
    <weblogic-enterprise-bean>
    <ejb-name>HelloWorldBean</ejb-name>
    <enable-call-by-reference>true</enable-call-by-reference>
    <stateless-session-descriptor>
    <business-interface-jndi-name-map>
    <business-remote>test.IHelloWorldRemote</business-remote>
    <jndi-name>TOTO</jndi-name>
    </business-interface-jndi-name-map>
    </stateless-session-descriptor>
    </weblogic-enterprise-bean>
    </weblogic-ejb-jar>

  • Jndi-name in  Message Driven Bean

    Hi
    I have successfully created the ejb jar file for deployment using sun one studio . I created the message driven bean and I right clicked on the ejb and used the customize option to set the bean properties . But my problem is that the jndi-name in the <ejb> tags takes the value jms/(ejbname) instead of jms/(queuename) . I am attaching the xml file with this . Can any one tell how to set the jndi-name to queue value using studio
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE sun-ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Sun ONE Application Server 7.0 EJB 2.0//EN" "http://www.sun.com/software/sunone/appserver/dtds/sun-ejb-jar_2_0-0.dtd">
    <sun-ejb-jar>
    <enterprise-beans>
    <name>ejb</name>
    <ejb>
    <ejb-name>Suneesh</ejb-name>
    <jndi-name>jms/Suneesh</jndi-name> <resource-ref>
    <res-ref-name>QueueConnectionFactory</res-ref-name>
    <jndi-name>jms/QueueConnectionFactory</jndi-name>
    </resource-ref>
    <resource-env-ref>
    <resource-env-ref-name>TestQueue</resource-env-ref-name>
    <jndi-name>jms/TestQueue</jndi-name>
    </resource-env-ref>
    <pass-by-reference>false</pass-by-reference>
    </ejb>
    <ejb>
    <ejb-name>Suneesh1</ejb-name>
    <jndi-name>jms/Suneesh1</jndi-name>
    <resource-ref>
    <res-ref-name>QueueConnectionFactory</res-ref-name>
    <jndi-name>jms/QueueConnectionFactory</jndi-name>
    </resource-ref>
    <resource-env-ref>
    <resource-env-ref-name>TestQueue1</resource-env-ref-name>
    <jndi-name>jms/TestQueue1</jndi-name>
    </resource-env-ref>
    <pass-by-reference>false</pass-by-reference>
    </ejb>
    </enterprise-beans>
    </sun-ejb-jar>

    Hi Bhagya,
    Thanks for your response. I think from EJB container we can call Local EJBs with the full JNDI name. The session facade bean which is being called is a remote bean. From the session facade bean I am calling a local stateless session bean for database access. I am getting the reference of the local EJB from my session facade bean with full JNDI name "java:comp/env/ejb/EJBJNDIName". It is working fine with out any problem. My servicelocator is able to provide me the reference of the local EJB from the session facade remote bean with Full JNDI name. I am only having this problem calling from the MDB. I am really not sure whether what is causing it?
    Thanks
    Amit

Maybe you are looking for

  • Why isn't the Searh box working??

    No matter what I type into the search box, I don't get ANY results.  Is it broke?

  • Time modified when importing uploaded images from Gallery

    I'm a fire investigator and several of us use cameras to document a scene. We share the images using mobile.me Gallery. I posted this question nearly a year ago but the problem persists. "We use the 24 hour clock setting on all our cameras as opposed

  • SAP Interactive Forms Configuration

    Hi All, I have installed SAP NetWeaver 2004s Java Trial Version on my local machine and I would like to explore more on the SAP Interactive Forms tutorials. Can someone tell me what are the basic configurations I need to perform to execute the web dy

  • Can't watch any video on my Curve 8530!

    I've looked around recently to try to find an answer to why my BlackBerry Curve 8530 will not play videos, and nothing I've read seems to work. When try to play a YouTube video, one of the following 3 errors occurs: 1) "The device media processor is

  • How can I undo the last firefox update? I've had nothing but problems since!

    Ever since I updated to firefox 3.6.10 firefox keeps freezing on me as well as doing all kinds of weird things making it just about impossible to browse or post on the web. So how do I get back to the older version???