Multiple JNDI names for EJB?

If I'm deploying a webapp that references an EJB, do I have to use the same JNDI
name that is configured in the EJB descriptor?
Why can't I reference the EJB using a seperate name (as in some J2EE examples)?
Thanks,
Darren

darren <[email protected]> wrote:
If I use a new JNDI name, rather than the one defined in weblogic-ejb-jar.xml,
it does not show up in the JNDI tree.
Does the JNDI name referenced in weblogic.xml need to be the same as that defined
in weblogic-ejb-jar.xml? No. ejb-ref mechanism allows you to map an actual ejb jndi name to one used by your
application - so, in theory, system administrator can change jndi names without
touching your application code. You do not see it in the global JNDI tree because
this mapping exists only in the context of your application.
<[email protected]> wrote:
That's what ejb-ref in web.xml is for - you can create an ejb-ref in
web.xml
and map it to an actual jndi name in weblogic.xml ejb-reference-description.
Darren <[email protected]> wrote:
If I'm deploying a webapp that references an EJB, do I have to usethe same JNDI
name that is configured in the EJB descriptor?
Why can't I reference the EJB using a seperate name (as in some J2EEexamples)?
Thanks,
Darren--
Dimitri
Dimitri

Similar Messages

  • Specify JNDI Name For EJB Module

    Hi folks, please I need to know how I can specify the Jndi name for an ejb module I am creating in netbeans 5.0, to be accessed by a web application.
    If this can be done using the sun java system application server 9 admin consle (just as for JDBC Resources), i'll also like to know how.
    Thanks.

    Thanks Jay. I went through the links, it seems that if you have the JNDI name set in the weblogic-ejb-jar.xml, there is no need to set the same in the weblogic admin console. I am using ejb 2.x version. Particularly if you get the WLInitialContextFactory in your code , then there is no need to set the JNDI name in the JNDI tree in weblogic admin console.
    Like:-
    Context ctx = null;
    java.sql.Connection conn = null;
    Hashtable<String,String> ht = new Hashtable<String,String>();
    ht.put(Context.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.WLInitialContextFactory");
    ht.put(Context.PROVIDER_URL,"t3://localhost:7001");
    This will take care of JNDI tree, hence there is no need to set the JNDI name explictly in the weblogic admin console.
    Please correct me if i am wrong. Whether for datasource also whether we can do the same, by setting the resource-ref with datasource in the ejb-jar.xml and not set anything in weblogic admin console? Thanks.

  • Looking up JNDI names for local client

    Sir,
    I have been trying to look up JNDI name for the local home interface in the client program.But I got only "javax.naming.NoInitialContextException".I want information about to give a JNDI name for EJB and its details.
    Thanking you.
    Yours,
    R K Ramesh

    It sounds like you are not specifying the right URL or username/credentials to get an initial context.
    A typical example would be something like this:
    Properties p = new Properties();
    p.put(Context.INITIAL_CONTEXT_FACTORY,
    "weblogic.jndi.WLInitialContextFactory");
    p.put(Context.PROVIDER_URL, "t3://server:port");
    InitialContext ic = new InitialContext(p);
    (You can also use a properties file or system prpoerties to specify these.)
    -- Rob
    WLS Blog http://dev2dev.bea.com/blog/rwoollen/

  • WLST - Creating Multiple JNDI Names

    Running into an issue while creating multiple JNDI Names using WLST.
    The script does create the JNDI Names in the following format:
    value1, value2
    What I want is:
    value1
    value2
    How do i add a return or next line to the script.
    Script Segment:
    for ds in dataSourceList:
    poolName = props.getProperty('DataSource.' + ds +'.PoolName')
    if poolName != None:
    if props.getProperty('MultiPool.' + poolName + '.poolList') == None:
    targetList = props.getProperty('DataSource.' + ds + '.targets').split(',')
    dsJNDIName = props.getProperty('DataSource.' + ds +'.JNDIName')
    createSinglePoolDS(poolName, ds, dsJNDIName, targetList)
    else:
    createMultiPoolDS(ds)
    else:
    print 'DataSource ' + ds + ' is not configured correctly'
    Property:
    DataSources=DataSoruce
    DataSource.jdbc/catalog.targets=Target
    DataSource.jdbc/catalog.JNDIName=Value1,Value2
    DataSource.jdbc/catalog.PoolName=Poolname
    DataSource.jdbc/catalog.TX=TX
    Any help is appreciated.

    Senthil,
    I changed my weblogic-ejb-jar.xml to have two entries point to one bean:
    <weblogic-ejb-jar>
    <weblogic-enterprise-bean>
    <ejb-name>ejb.MyBean</ejb-name>
    <caching-descriptor>
    <max-beans-in-free-pool>1000</max-beans-in-free-pool>
    </caching-descriptor>
    <jndi-name>MyBeanHome1</jndi-name>
    </weblogic-enterprise-bean>
    <weblogic-enterprise-bean>
    <ejb-name>ejb.MyBean</ejb-name>
    <caching-descriptor>
    <max-beans-in-free-pool>1000</max-beans-in-free-pool>
    </caching-descriptor>
    <jndi-name>MyBeanHome2</jndi-name>
    </weblogic-enterprise-bean>
    </weblogic-ejb-jar>
    When I call ctx.lookup(), it can find "MyBeanHome2", but not "MyBeanHome1".
    Am I doing anything wrong?
    Senthil Kumar S wrote:
    I think u can do that using EJb references in weblogic.jar.xml file.
    U define multiple refs and link it to a single JNDI name
    Catherine Wen wrote:
    Does anyone know is it possible to have multiple JNDI names mapping to
    one instance of object in JNDI tree? For example, when I do JNDI lookup
    for the following JNDI names
    ejb.mybeanHome1
    ejb.mybeanHome2
    ejb.mybeanHome
    they will all return me an instance of MybeanHome.
    Thanks!

  • JNDI name for TransactionManager?

    What is the JNDI name for TransactionManager on Oracle9ias? I thought
    it was "java:comp/UserTransaction" but everytime I try to get the
    TransactionManager I get a javax.naming.NamingTransaction, root exception is java.lang.NullPointerException. Any help would be appreciated. :-)
    TransactionManager trans = null;
    String name = null;
    try {
    InitialContext ctx = new javax.naming.InitialContext();
    name = "java:comp/UserTransaction";
    trans = (TransactionManager) ctx.lookup( name );
    out.println("<p>*** class of TransactionManager is: " + trans);
    trans.begin();

    Srini,
    You mention EJB client -> is the EJB an entity bean? Is it BMT or CMT? If its an entity bean with CMT then you cannot (and should not) be starting the transactions. If however this is BMT then you can use a Sesssion Bean to start and commit the transaction.
    I have a feeling that you are using a remote client to access the EJB and then would like to start and commit a transaction. I would like to point out that this kind of transaction demarcation is not supported in OC4J. Here is quote from the OC4J documentation:
    "Client-side transaction demarcation is not supported in the application client container: OC4J does not support client-side transaction demarcation. This form of transaction demarcation is not required by the J2EE specification, and is not recommended for performance and latency reasons."
    I would recommend that you start using SLSB instead of remote clients.
    Hope this helps.
    Deepak

  • 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

  • CORBA Name for EJB

    I'm trying to use an EJB from a C++ CORBA client.
    The JNDI Name is ejb.SumSessionRemoteHome.
    I cannot resolve this name with my C++ client (Orbacus 4.2). When I use a "lsns" utility I don't see "ejb.SumSessionRemoteHome". I do see things like this: SecondApplicationSumProject_jarSumSession_EO.
    Is there something special I need to do to bootstrap the name into the naming service? The EJB tests fine with a WebService Project Test .jws.
    Thanks
    Russ

    Russell Krayer <[email protected]> writes:
    I'm trying to use an EJB from a C++ CORBA client.
    The JNDI Name is ejb.SumSessionRemoteHome.
    I cannot resolve this name with my C++ client(Orbacus 4.2). When I use a "lsns" utility I don't
    see "ejb.SumSessionRemoteHome". I do see things like
    this: SecondApplicationSumProject_jarSumSession_EO.
    Is there something special I need to do tobootstrap the name into the naming service? The EJB
    tests fine with a WebService Project Test .jws.
    The name should be the same as that which you used to
    deploy. Do you
    see the ejb context? "." is interpreted as a contet
    separator.
    andy
    -- Yes, I see an ejb context and a weblogic context. But, I was able to finally get "ejb.SumSessionRemoteHome" to resolve after discovering a coding error on my part. I resolved the name and invoked methods on my bean although I don't see that name with my lsns utility.
    Thanks for the reply.
    Russ

  • Help needed on allocating a JNDI name for MYSQL on Glassfish

    Hi,
    I am trying to invoke my database (MYSQL) through a JNDI lookup on GlassFish Server. I copied the MySQL connector into the GLASSFISH_HOME/lib directory and went into Admin console (http://localhost:8080/login.jsf) to create a ConnectionPool. After this, I am not sure what I should do, inorder to associate a "jdbc/mysql" JNDI name for this pool. Can anybody point me to what has to be done?
    Thank you.

    Figured it. After you've setup your pool, you need to go to Resources -> JDBC -> JDBC Resources and then create an new mapping of the pool that you've just created to some name (ex: "java/mysql"); This should integrated Glassy with Mysql
    Thanks.

  • Deploytool: Can't specify a JNDI name for RA

    Using j2eesdk1.4_beta2, it appears there is no way to specify a JNDI name for a Resource Adapter. Is there a default name I can use to look up my RA if I don't specify a name? The Deploy Tool help describes some tabbed panes appear to be missing from the appication. Is there a way to work around this problem until the final release comes out?

    Headache!... That's what is expecting you in the DeployTool.
    The deploytool generates invalid deployment descriptors for Resource Adaptors.
    As you mentioned, it doesn't allow you to select a ResourceAdaptor implementation. In my case, I'm using my own Connection and ConnectionFactory and it didn't allow me to choose an implementation class for either interface neither.
    I solved these problems by downloading XMLSpy and using the XML Schema to fill-in the gaps in the ra.xml descriptor. There I had also to include other mandatory elements that where not written by the deployTool, like: <display-name>
    <vendor-name>
    <eis-type>
    <resourceadapter-version>
    Regarding to the <<null>> error, it has to deal with an invalid sun-ra.xml. It's either empty or it's missing a mandatory element. I used again XML Spy here to give a JNDI to my adaptor.
    I thought I was through it but I still can't deploy on the server. When I try, I get the following error:
    <[INFO][j2eesdk1.4_beta2][][][12][javax.enterprise.system.tools.admin][03.november.2003 22:16:22:351 CET][ADM5604:Processing config change [Domain:add to xpath=/domain/applications
    childXPath = /domain/applications/connector-module[@name='SimpleRAR1']]]>
    <[INFO][j2eesdk1.4_beta2][][][12][javax.enterprise.system.tools.admin][03.november.2003 22:16:23:302 CET][ADM1041:Sent the event to instance:[ModuleDeployEvent -- deploy connector/SimpleRAR1]]>
    org.w3c.dom.DOMException: NAMESPACE_ERR: An attempt is made to create or change an object in a way which is incorrect with regard to namespaces.
    [.... 200 lines stack trace ....]
    <[WARNING][j2eesdk1.4_beta2][][][12][javax.enterprise.system.tools.admin][03.november.2003 22:16:24:043 CET][ADM5603:Event listener error [null]]>
    So far I haven't found a way to get solve this one. The <NAMESPACE_ERR> makes me think about the infamous 'locale' error of the deploytool, but I included the JVM parameters [USER_LANG=en,USER_REGION=US,USER_COUNTRY=US] in the server startup and it didn't change anything.
    If you get further than that, please let me know.
    -regards,
    Gerard.

  • Dynamic JNDI name for database adapter in BPEL

    Hi All,
    I am having some major issues trying to make the JNDI location for the database adapter dynamic (10.1.3.4). I already went through the followin link, but that didnt work for me: http://www.oracle.com/technology/pub/articles/bpel_cookbook/carey.html
    The below example works, but only the first run. Second time around the first runs JNDI value gets retained and connects to that database.
    This is what worked atleast the first time.
    I parameterized the JNDI with a variable defined in the partnerlink definition in the bpel.xml
    In Bpel. xml
    <partnerLinkBinding name="updatetbl">
    <property name="wsdlLocation">updatetbl.wsdl</property>
    <property name="CONN">eis/DB/na</property>
    <property name="retryInterval">60</property>
    </partnerLinkBinding>
    In the updatetbl.wsdl file
    <service name="updatetbl">
    <port name="updatetbl_pt" binding="tns:updatetbl_binding">
    <jca:address location="$CONN"/>
    </port>
    </service>
    At run time I change the partnerlink CONN variable in embedded Java.
    try
    Element targetAdapterElement =(Element)getVariableData("Invoke_getFromTbl_OutputVariable","getFromTblOutputCollection","/ns2:getFromTblOutputCollection/ns2:getFromTblOutput/ns2:SRC_JNDI");
    getLocator().lookupProcess("JndiIssueTest").getDescriptor().getPartnerLinkBindings().getPartnerLinkBinding ("updatetbl").setPropertyValue ("CONN",targetAdapterElement.getTextContent());
    ("updatetbl").getPropertyValue ("CONN"));
    catch(Exception ex)
    addAuditTrailEntry("Error is " + ex);
    This works fine the first time, but the second time I run it to look at a different CONN value, it somehow still connects using the first runs value!
    If I redeploy or clear the WSDL cache, it works. But we plan to run it multiple times from several environment so manually or programatically clearing WSDL is not the right solution.
    Can someone tell me what is the standard process of doing this so it works everytime?
    Thanks,
    Shaf

    Shaf,
    Please refer the mail thread for details. If you want I can send you(send me your email id) the sample BPEL process which uses Dynamic JNDI.
    Re: How to externalize JNDI name (setting JNDI name dynamically)
    Thanks,
    Sen

  • 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

  • JNDI-name and ejb-name

    Hi,
    I know 'ejb-name' should be the name used in ejb-jar.xml. what should be JNDI-name?
    can I assign it to "xyz" or there is some strict rule? Is there any relation betn
    'ejb-name' and 'JNDI-name'
    Thanks a lot.
    Vishal

    Vishal,
         ejb-name - name of the ejb
         jndi-name- name by which remote components identify a particular bean.
    it's name is unique. for naming policies
    http://java.sun.com/products/jndi/tutorial/beyond/misc/policy.html
    /Venki..
    vishal patel wrote:
    Hi,
    I know 'ejb-name' should be the name used in ejb-jar.xml. what should be JNDI-name?
    can I assign it to "xyz" or there is some strict rule? Is there any relation betn
    'ejb-name' and 'JNDI-name'
    Thanks a lot.
    Vishal

  • JAVA client JNDI lookup for EJB session in cluster in WLS 5.1

    The documentation says :
              to obtain a Context for JNDI lookup do the following :
              Hashtable ht = new Hashtable();
              ht.put(Context.INITIAL_CONTEXT_FACTORY,
              "weblogic.jndi.WLInitialContextFactory");
              ht.put(Context.PROVIDER_URL, "t3://mycluster:7001");
              try {
              Context ctx = new InitialContext(ht);
              // Do the client's work
              catch (NamingException ne) {
              // A failure occurred
              finally {
              try {ctx.close();}
              catch (Exception e) {
              // a failure occurred
              where "mycluster" is the DNS name of my cluster. My DNS server (Windows 200
              DNS server) use round robin
              to call alernatively all the wls server node in "mycluster" and it's OK. The
              two servers of my cluster
              are called alternatively for my EJB session stateless.
              Now I unplug one of the two nodes of my cluster and the remaining server is
              called only 2 times
              and not after.
              Questions :
              -is the load balancing between the nodes of mycluster only rely on DNS or
              is there an internal
              mecanism in EJB sub to try one server then an other ?
              - do I need to obtain a new reference on JNDI Context for each call ?
              Thank's a lot.
              Farid Bellameche.
              

              I too have the same problem. My scenario is :
              I have the web tier architecture away from cluster. All ejbs are in cluster
              running in two seperate machines. We have a factory class running in
              webtier(we use servlet in this tier) which obtains home interface only once
              and stores it for future reference. When ever we need the remoteobject stub,
              we ask the factory class and which in turn uses the stored home interface to
              get the same.
              In the webtier, I list all the servers in the cluster as a part of url as
              mentioned by you.
              I started the web tier as well as Object tier cluster. I could see the
              request coming in both the machines in the cluster for the ejb. But When I
              bring one the server in the cluster,
              1. Web tier throws an exception saying that it could not connect
              to server using t3.
              2. The other machine which is running the server, also says
              'failed to create socket to : -32323234324 sever name
              using protocol t3.
              It looks like I am able to get load balance. But I am not able to get the
              fail over to be working.
              In the weblogic-ejb-jar.xml, I added the following.
              <clustering-descriptor>
              <home-is-clusterable>true</home-is-clusterable>
              <home-load-algorithm>round-robin</home-load-algorithm>
              </clustering-descriptor>
              I compiled and added the .jar file. So the jar file now has replica aware
              stubs.
              Could any one of you help me for why the fail over is not working?
              Suersh
              "Giri Alwar" <[email protected]> wrote in message
              news:[email protected]...
              > Farid,
              > (1) Yes, the stub has the logic to perform load-balancing and
              fail-over.
              > (2) In almost all cases, no. You can get the context once, store it
              and
              > use it thereafter. Please refer to
              > http://www.weblogic.com/docs51/cluster/concepts.html#1025061 for more
              info.
              >
              > A couple of notes on your situation. From what you are describing, your
              > Windows DNS server is setup to serve only one IP from the cluster (using
              > round-robin) as opposed to a list of all IP's in the cluster. Hence, the
              > initial context you obtain is tied to a single server in the cluster (the
              > one returned by the DNS). The weblogic implementation on the client side
              has
              > no idea of the existence of the other servers in the cluster. This is not
              a
              > cluster aware context. To obtain a cluster aware context, either list all
              > the IP's in the URL like t3://server1,server2,server3:7001 or have
              > "mycluster" return a list of all servers in the cluster.
              >
              > Giri
              >
              >
              > "Farid Bellameche" <[email protected]> wrote in message
              > news:[email protected]...
              > > The documentation says :
              > >
              > > to obtain a Context for JNDI lookup do the following :
              > > Hashtable ht = new Hashtable();
              > > ht.put(Context.INITIAL_CONTEXT_FACTORY,
              > > "weblogic.jndi.WLInitialContextFactory");
              > > ht.put(Context.PROVIDER_URL, "t3://mycluster:7001");
              > > try {
              > > Context ctx = new InitialContext(ht);
              > > // Do the client's work
              > > }
              > > catch (NamingException ne) {
              > > // A failure occurred
              > > }
              > > finally {
              > > try {ctx.close();}
              > > catch (Exception e) {
              > > // a failure occurred
              > > }
              > > }
              > >
              > > where "mycluster" is the DNS name of my cluster. My DNS server (Windows
              > 200
              > > DNS server) use round robin
              > > to call alernatively all the wls server node in "mycluster" and it's OK.
              > The
              > > two servers of my cluster
              > > are called alternatively for my EJB session stateless.
              > > Now I unplug one of the two nodes of my cluster and the remaining server
              > is
              > > called only 2 times
              > > and not after.
              > >
              > > Questions :
              > > -is the load balancing between the nodes of mycluster only rely on DNS
              > or
              > > is there an internal
              > > mecanism in EJB sub to try one server then an other ?
              > >
              > > - do I need to obtain a new reference on JNDI Context for each call ?
              > >
              > >
              > > Thank's a lot.
              > >
              > > Farid Bellameche.
              > >
              > >
              > >
              > >
              >
              >
              

  • JNDI name for a JMB is not replicatet to other servers in the cluster

    Hi,
              wl6.1sp7, two server cluster
              When I look at the JNDI Tree for a server I can't find JNDI names of JMB's from the other server in the cluster.
              I get an exception when trying to send to a destinaton on the other server. (Unable to resolve 'xlink.jms.service.report.biztalk-lab.Report' Resolved: 'xlink.jms.service.report' Unresolved:'biztalk-lab')
              Setting are same as explained in this thread...
              http://forums.bea.com/bea/thread.jspa?threadID=600003492&tstart=0
              And JNDINameReplicated is set to true....
              Why is the JNDI names not replicated?
              <JMSQueue JNDIName="xlink.jms.service.report.biztalk-lab.Report"
              JNDINameReplicated="true" Name="Report" StoreEnabled="default"/>
              This is the DD of a JMB:
              <weblogic-ejb-jar>
              <weblogic-enterprise-bean>
              <ejb-name>xlink.jms.service.report.biztalk-lab.Report</ejb-name>
              <message-driven-descriptor>
              <pool>
              <max-beans-in-free-pool>3</max-beans-in-free-pool>
              <initial-beans-in-free-pool>1</initial-beans-in-free-pool>
              </pool>
              <destination-jndi-name>xlink.jms.service.report.biztalk-lab.Report</destination-jndi-name>
              <connection-factory-jndi-name>xlink.jms.factory.commerceFactory</connection-factory-jndi-name>
              </message-driven-descriptor>
              <jndi-name>xlink.jms.service.report.biztalk-lab.Report</jndi-name>
              </weblogic-enterprise-bean>
              </weblogic-ejb-jar>
              ~b

    1. yes
              <JMSConnectionFactory AllowCloseInOnMessage="false"
              DefaultDeliveryMode="Persistent" DefaultPriority="4"
              DefaultTimeToLive="0"
              JNDIName="xlink.jms.factory.commerceFactory"
              MessagesMaximum="10" Name="xlink.jms.factory.commerceFactory"
              OverrunPolicy="KeepOld" Targets="bluej,biztalk-lab,devtestCluster"/>
              2. No I am just using the jndi name of the queue.
              This is an example of how I send a message:
                   Context ctx = new InitialContext();
              QueueConnectionFactory qconFactory;
              QueueConnection qcon;
              QueueSession qsession;
              QueueSender qsender;
              Queue queue;
              ObjectMessage msg;
              qconFactory = (QueueConnectionFactory) ctx.lookup("xlink.jms.factory.commerceFactory");
              qcon = qconFactory.createQueueConnection();
              qsession = qcon.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
              queue = (Queue) ctx.lookup("xlink.jms.queue.biztalk-lab.OrdrspImport");
              qsender = qsession.createSender(queue);
              msg = qsession.createObjectMessage(reportExecutorContainer);
              qcon.start();
              qsender.send(msg);
              qsender.close();
              qsession.close();
              qcon.close();
              3. I don't know those setting (wl 6.1sp7)

  • Format of the JNDI name for lookup in DataSource

    Hi
    a) I have made a datasource in Weblogic 10.3 called SQL and its JNDI name as jdbc/SQLDS.
    The driver was BEA'S Type 4 Driver for MS SQL Server
    Now I am trying to lookup the datasource through an application. I have used the following
    lines of code:
    InitialContext context = new InitialContext();
    DataSource ds = context.lookup("jdbc/SQLDS");
    Connection conn = ds.getConnection();
    The Application was a success.
    I saw in some articles that you can refer to the datasource by even java:comp/env/jdbc/SQLDS,
    instead of just jdbc/SQLDS. I tried both ways and I was able to run the application.
    b) Then I made another datasource in Weblogic 10.3 called SQL1 and its JNDI name as jdbc/SQL1.
    The driver was MS SQL Server Type 4 Driver for versions 2000, 2005
    Now I am trying to lookup the datasource through an application. I have used the following
    lines of code:
    InitialContext context = new InitialContext();
    DataSource ds = context.lookup("jdbc/SQL1");
    Connection conn = ds.getConnection();
    The Application was a success.
    I saw in some articles that you can refer to the datasource by even java:comp/env/jdbc/SQL1,
    instead of just jdbc/SQL1. I tried the first way and it didnt work. It gave me a NullPointerException
    at the line Connection conn = ds.getConnection();
    c)Then I made a 3rd datasource in Weblogic 10.3 called SQL2 and its JNDI name as jdbc/SQL2DS.
    The driver was MS SQL Server Type 4 Driver for versions 2000, 2005
    Now I am trying to lookup the datasource through an application. I have used the following
    lines of code:
    InitialContext context = new InitialContext();
    DataSource ds = context.lookup("jdbc/SQL2DS");
    Connection conn = ds.getConnection();
    The Application was a success.
    I saw in some articles that you can refer to the datasource by even java:comp/env/jdbc/SQL2DS,
    instead of just jdbc/SQL2DS. I tried the first way and it didnt work. Again, it gave me a NullPointerException
    at the line Connection conn = ds.getConnection();
    I was confused why the 2nd and 3rd way didnt work . Is it becaue I used Microsoft's MS SQL Server Type 4 Driver?
    I have added the jar file in the WEBLOGIC_CLASSPATH. Why is it not recognising java:comp/env/jdbc/SQL2DS ?
    I would be grateful if somebody could give me ideas on this...
    Thanks
    Neeti

    To use application scoped or indirect JNDI lookups (i.e. java:comp/env/...) you usually need to define a &lt;resource-ref&gt; entry in your deployment descriptor(s). Not sure what type of application you are using to test (web-app, EJB,) but for java:comp/env/ lookups to work, you need to define resource references. The fact that your first test succeeded is somewhat strange. Without the resource reference definitions, I would have expected your JNDI lookups to fail with a NamingException instead of the lookup returning NULL for the datasource.
    Assuming you are doing your test from a web-app, you need to add &lt;resource-ref&gt; definitions to your web.xml file similar to the following:
    &lt;resource-ref&gt;
    &lt;res-ref-name&gt;*jdbc/SQL2DS*&lt;/res-ref-name&gt;
    &lt;res-type&gt;java.sql.DataSource&lt;/res-type&gt;
    &lt;res-auth&gt;Container&lt;/res-auth&gt;
    &lt;/resource-ref&gt;
    and then add &lt;reference-descriptor&gt; definitions to your weblogic.xml file similar to the following:
    &lt;reference-descriptor&gt;
    &lt;resource-description&gt;
    &lt;res-ref-name&gt;*jdbc/SQL2DS*&lt;/res-ref-name&gt;
    &lt;jndi-name&gt;*jdbc/SQL2DS*&lt;/jndi-name&gt;
    &lt;/resource-description&gt;
    &lt;/reference-descriptor&gt;
    Once you do these steps your lookup("java:comp/env/jdbc/SQL2DS") should function properly from within your web-app.

Maybe you are looking for

  • Pages 5.2 PDF Exporting Issues

    Ever since I upgraded to OS X and Pages 5.2, the system will no longer allow me to export a Pages doc to PDF into certain folders. I keep getting a message that says "The document "xyz name of doc" could not be exported as "xyz name of doc". I have t

  • Safari dosen't work

    Here is the crash report: Process: Safari [192] Path: /Applications/Safari.app/Contents/MacOS/Safari Identifier: com.apple.Safari Version: 4.0.4 (5531.21.10) Build Info: WebBrowser-55312110~1 Code Type: PPC (Translated) Parent Process: launchd [72] I

  • A helpful forum but im still confused about x3100 graphics and leopard

    am i and maybe a few the exception? i find iTunes ( visulaizer - stops / jerky and then plays ) & Photobooth ( video backgrounds - choppy video / slow ) to run poorly even with 4 gb Ram on a new SR-MB. But i dont see many other complaints by other ow

  • Ctxload can't find a file in the current directory

    I am trying to load a thesaurus file using ctxload. The file is in the current directory. I can use a text editor to modify it. But ctxload always complains that "file not found." Why?

  • HT1338 safari 5.1.7 on lion 10.7.4 does not load

    safari 5.1.7 on lion 10.7.4 does not load, install neither does silverlight, I can't fix it. I have deleted from library internet plugins, I have uninstalled it reinstalled it does not work. Everything works great in firefox but i prefer safari. Why