Accessing EJB from Console App.

I have deployed in EJB with JNDI name "greeter" in Sun Java� System Application Server Platform Edition 8.
Then i am trying to access EJB using a console app (given below).
import javax.ejb.*;
import javax.rmi.*;
import java.util.*;
import javax.naming.*;
public class Client
public static void main(String args[])
Greeter myGreeterBean;
GreeterHome myGreeterHome;
Greeter myGreeterRemote;
Context context = null;
try
context = new javax.naming.InitialContext();
catch (Exception e)
System.out.println( "Unable To Get Initial Context");
return;
System.out.println("Got Context...");
try {
String JNDIName = "greeter";
Object objref = context.lookup(JNDIName);
System.out.println("Got Access To Object");
myGreeterHome =(GreeterHome) PortableRemoteObject.narrow(objref,
GreeterHome.class);
myGreeterRemote = myGreeterHome.create();
String theMessage = myGreeterRemote.getGreeting();
System.out.println(theMessage);
catch(Exception ex) { System.out.println( ex.getMessage()); }
} // end of main
} // end of Client
But, while i am running this program i am getting the following error:
Got Context...
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 don't know where i am wrong. Any idea about it ?
Thank you,
P.Srikanth.

This is what you need to modify :)
Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY, "<<your
initial context factory>>");
env.put(Context.PROVIDER_URL, "<<JNDI provider
URL>>");
// Check documentation for exact Strings to be set.
// Pass the environment parameters to
InitialContext.
Context context = new InitialContext(env);
Angel
No this is not correct. Lookups in SUN AS works a bit differently.

Similar Messages

  • Access EJB from Servlet that in different archive?

    <font class="mediumtxt">package kyro.ejb.session;
    import javax.ejb.*;
    import javax.persistence.EntityManager;
    import javax.persistence.PersistenceContext;
    @Stateless(name="StandAlone")
    @Remote(StandAlone.class)
    public class StandAloneBean
    implements StandAlone, StandAloneLocal
    public StandAloneBean() {
    public String sayHello() {     
    return "sayHello";
    I want to access ejb from servlet that .war and .jar not in single .ear. I want to try that just with annotation not xml descriptor cause is easy to understand for me. I use Glassfish. But i can't lookup that ejb. How can i lookup that ejb with jndi? Can't you give me example of servlet to access that? I not use JNDI.properties, are that caused i can't access my ejb? I just thing .war and.jar in one server, are i have to used JNDI.properties. can you explain how to use JNDI.properties in servlet or separate file?
    </font>

    But i can't lookup that ejb. How are you trying and what exception is occurring?
    How can i lookup that ejb with jndi? [https://glassfish.dev.java.net/javaee5/ejb/EJB_FAQ.html|https://glassfish.dev.java.net/javaee5/ejb/EJB_FAQ.html]
    m

  • Issue in accessing EJB from plain java

    Hi,
    I am new to OAS. I am using OAS 10.1.2.
    I want to access EJB which runs inside OAS, through a plain java program which runs from outside the OAS environment (standalone java program).
    I am confused on what to use. RMIInitialContextFactory or ApplicationClientInitialContextFactory for the context in the java program.
    what should be the provide URL ?
    java.naming.provider.url","ormi://hostname:18140/
    is it "ormi" or something else? what is the port number should i use. there are many ports in this OAS. i see that in the console("Ports") link.
    also let me know what should i mention in the EJB xml descriptor.
    Is this lookup to be done by retrieving from jndi?
    pls help.
    Thanks,
    Sukumar
    with this confusion i developed an EJB with the following details
    ejb-jar.xml
    <ejb-ref>
         <ejb-ref-name>ejb/testDetails</ejb-ref-name>
         <ejb-ref-type>Entity</ejb-ref-type>
    <home>com.xxx.xxx.testDetailsHome</home>
    <remote>com.xxx.xxx.testDetails</remote>
         </ejb-ref>
    orion-ejb-jar.xml
    <entity-deployment name="ejb/testDetails" location="ejb/testDetails"
    Client Java program
    public class testDetailsClient
    public static void main(String [] args)
    testDetailsClient testDetailsClient = new testDetailsClient();
    try
    Context context =getInitialContext();
    testDetailsHome testDetailsHome = (testDetailsHome)PortableRemoteObject.narrow(context.lookup("java:comp/env/ejb/testDetails"), testDetailsHome.class);
    testDetails testDetails;
    catch(Throwable ex)
    ex.printStackTrace();
    private static Context getInitialContext() throws NamingException
    Hashtable env = new Hashtable();
    env.put("java.naming.factory.initial","com.evermind.server.rmi.RMIInitialContextFactory");
    //env.put("java.naming.factory.initial","com.evermind.server.ApplicationClientInitialContextFactory");
    env.put("java.naming.provider.url","ormi://host_name:18140/"); //23791 18140
    env.put(Context.SECURITY_PRINCIPAL, "ias_admin");
    env.put(Context.SECURITY_CREDENTIALS, "abc123");
    InitialContext context = new InitialContext(env);
    return context;
    if i execute this, it says
    javax.naming.NameNotFoundException: java:comp/env/ejb/testDetails not found
    18140 is Application Server Control RMI port.
    if i run the same code with ApplicationClientInitialContextFactory, it throws exception saying
    java.lang.InstantiationException: No location specified and no suitable instance of the type 'com.testdetails.testDetails' found for the ejb-ref ejb/testDetails
         at com.evermind.server.administration.ApplicationResourceFinder.getEJBHome(ApplicationResourceFinder.java:268)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:324)
         at com.evermind.server.rmi.RMICallHandler.run(RMICallHandler.java:124)
         at com.evermind.server.rmi.RMICallHandler.run(RMICallHandler.java:48)
         at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:192)
         at java.lang.Thread.run(Thread.java:534)
    javax.naming.NamingException: Error reading application-client descriptor: No location specified and no suitable instance of the type 'com.testdetails.testDetails' found for the ejb-ref ejb/testDetails
         at com.evermind.server.ApplicationClientInitialContextFactory.getInitialContext(ApplicationClientInitialContextFactory.java:161)
         at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:662)
         at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:243)
         at javax.naming.InitialContext.init(InitialContext.java:219)
         at javax.naming.InitialContext.<init>(InitialContext.java:195)
         at com.testdetails.testDetailsClient.getInitialContext(testDetailsClient.java:89)
         at com.testdetails.testDetailsClient.main(testDetailsClient.java:20)
    pls help

    Hi,
    you do not have to package your EJB and PAR together! You can deploy them separately and then reference the J2EE Application from your PAR or vice versa to access it.
    For instance you can access the EJB from your PAR as described here:
    http://help.sap.com/saphelp_nw2004s/helpdata/en/42/9ddf20bb211d72e10000000a1553f6/frameset.htm
    Or you can access a Portal application from J2EE like described here:
    http://help.sap.com/saphelp_nw2004s/helpdata/en/42/9ddd0cbb211d72e10000000a1553f6/frameset.htm
    Even if you package your PAR in to the same EAR with your EJB they will result in two different containers on the J2EE Engine and you will have to reference them as described in the link above to access the functionality of one component from the other.
    Best regards,
    Stefan Brauneis

  • Help me which JNDIFactory to use to access EJB from a java class of JAR

    I am confused in understanding the different JNDI factories
    RMIInitialContextFactory, ApplicationInitialContextFactory and ApplicationClientInitialContextFactory
    And the different namespaces like global, container local and component local.
    Especially is there any relationship between the JNDI factories and the namespaces?
    Or are they related to the deployment descriptors.
    Because in application specific deployment descriptors (orion-ejb-jar.xml), we just map the JNDI location with the object (or its reference from ejb-jar.xml). We dont specify it can be accessed from this factory or that.
    Shall we access an EJB from using any JNDI factory?
    Specifically, I am stuck with what Factory to use to access an EJB from a Java class in a library (jar). The JAR is packaged with the EAR which contains the EJB Jar that I am trying to access.
    THANK YOU

    Ed,
    As Robin said, I think you need code similar to this:
    Context c = new InitialContext();
    Object o = c.lookup("java:comp/env/Name");where Name is the name of your EJB as it appears in the "ejb-jar.xml"
    deployment descriptor XML file.
    Good Luck,
    Avi.

  • Accessing EJBs from a servlet

    Hi everyone,
    I deployed my EJB component in an Oracle 8.1.7 database and I try to access it from a servlet.
    If I run my servlet from JDeveloper 3.2 (Web-to-Go), it all works fine. If I run my servlet from JRun 3.01 or from Tomcat 3.2.1, I get the following exception:
    javax.naming.NoInitialContextException: Need to specify class name in environmen
    t or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
    at java.lang.Throwable.fillInStackTrace(Native Method)
    at java.lang.Throwable.fillInStackTrace(Compiled Code)
    at java.lang.Throwable.<init>(Compiled Code)
    at java.lang.Exception.<init>(Compiled Code)
    at javax.naming.NamingException.<init>(NamingException.java:104)
    at javax.naming.NoInitialContextException.<init>(NoInitialContextException.java:58)
    at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:649)
    at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:242)
    at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:279)
    at javax.naming.InitialContext.lookup(InitialContext.java:349)
    at com.cognicase.framework.base.U0003.AbstractORB.getBean(AbstractORB.java:285)
    at com.cognicase.framework.base.U0003.AbstractORB.getBean(Compiled Code)
    at com.cognicase.demo.U2007BL.U2007WP_Users.lookupBean(U2007WP_Users.java:60)
    at com.cognicase.framework.is.U0103.AbstractBeanWrapper.beforeBeanCall(AbstractBeanWrapper.java:121)
    at com.cognicase.demo.U2007BL.U2007WP_Users.valideUser(U2007WP_Users.java:77)
    at com.cognicase.demo.U2000WB.U2000MW_WorkSpace.CallEjb(Compiled Code)
    at com.cognicase.demo.U2000WB.U2000MW_WorkSpace.doValidateLogin(Compiled Code)
    at com.cognicase.demo.U2000WB.U2000MW_WorkSpace.processService(U2000MW_WorkSpace.java:98)
    at Demo_0100_01.service(Demo_0100_01.java:128)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    at org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:404)
    at org.apache.tomcat.core.Handler.service(Compiled Code)
    at org.apache.tomcat.core.ServletWrapper.service(Compiled Code)
    at org.apache.tomcat.core.ContextManager.internalService(Compiled Code)
    at org.apache.tomcat.core.ContextManager.service(Compiled Code)
    at org.apache.tomcat.service.connector.Ajp13ConnectionHandler.processConnection(Compiled Code)
    at org.apache.tomcat.service.TcpWorkerThread.runIt(Compiled Code)
    at org.apache.tomcat.util.ThreadPool$ControlRunnable.run(Compiled Code)
    at java.lang.Thread.run(Compiled Code)
    If I add my servlet classes, aurora_client.jar, mts.jar, vbjapp.jar and vbjorb.jar files to the CLASSPATH, it works fine.
    The behavior is the same in JRun and Tomcat.
    I don't like this solution since I have to make the CLASSPATH point to my application classes at the web server level instead of at the application context level.
    Has anyone been able to solve this problem?
    Thanks for your help.
    null

    Yes, I did. Actually, if I run my servlet in JDeveloper (Web-to-Go), it all works fine. I also extracted the code that calls the EJB from the servlet and I tested it in a small Java application, and it also works fine.
    Things stop to work when I deploy my servlet in JRun or in Tomcat.
    It appears that my code is correct, but the environment I try to run it is not, and I can't figure out what's wrong.
    Can anyone help me?
    <BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by Sandeep Desai ([email protected]):
    Have you provided the environmental settings in the servlet.
    It should be :
    import oracle.aurora.jndi.sess_iiop.ServiceCtx;
    env.put(Context.URL_PKG_PREFIXES, "oracle.aurora.jndi");
    env.put(Context.SECURITY_PRINCIPAL, username);
    env.put(Context.SECURITY_CREDENTIALS, password);
    env.put(Context.SECURITY_AUTHENTICATION, ServiceCtx.NON_SSL_LOGIN);
    InitialContext ctx = new InitialContext(env);
    Object obj = ctx.lookup("test/EJBHome");
    HomeObject home = PortableRemoteObject.narrow(
    obj,"HomeObject.class");
    RemoteObject remote = home.create();
    This should make it work!!
    <HR></BLOCKQUOTE>
    null

  • Pass Principal to EJB from external app

    Hello,
    I have spent half a day with glassfish v2 trying to find what seems to be trivial information: how do I pass a caller's principal, so that it could be retrieved from EJBContext inside container (by ctx.getCallerPrincipal()).
    I know that at least servlet container delegates it behind the scenes. But I need to do this manually from external java app, for ex., from junit tests. Without passing a principal, I am calling EJB without a problem by looking up the initial context with these params:
    env.setProperty("java.naming.factory.initial", com.sun.enterprise.naming.SerialInitContextFactory");
    env.setProperty("org.omg.CORBA.ORBInitialHost", "hostname");
    env.setProperty("org.omg.CORBA.ORBInitialPort", "port");
    env.setProperty(Context.PROVIDER_URL, "url");
    I assumed that adding these line will solve the problem:
    env.setProperty(Context.SECURITY_PRINCIPAL, "uname");
    env.setProperty(Context.SECURITY_CREDENTIALS, "passw");
    Hawever, with these settings the caller's pincipal name inside container is ANONYMOUS.
    Can anyone help me out with this?
    Thank you!

    Hi,
    of course I did. I guess there is no problem in doing all kind of stuff with app client container. However, the question is, how it is possible to delegate user's principal from external app, like JUNIT test runner?
    There is simply no damn information about this! =(
    Anyone, please?

  • Accessing EJBs from a Web project

    Hi,
    I am getting the error: "com.sap.engine.services.jndi.persistent.exceptions.NameNotFoundException: Path to object does not exist at java:comp, the whole lookup name is java:comp/env/ejb/UserInfoServer." when I try to access the session bean from my web project.  I have followed the instructions explicitly in http://help.sap.com/saphelp_nw04s/helpdata/en/55/29ed5eff965448941c0b42f01b9804/frameset.htm and also tried every other combination I can think of for configuring the references in both the EJB project & the web project (both in the same ear).  I do have a jndi name in the visual administrator for localebjs/sap.com/myEar/UserInfoServer.  Does anyone have any ideas?
    Thanks & merry Christmas/Happy New year to all the SDN folks!

    I've managed to get around the problem for the time being by using "/localejbs/provider/application/beanName" - bypassing (I think) the whole JNDI issue -  this is OK for now, but it's obviously not a long term fix. 
    Previously, I had used the default & so did not enter anything in the ejb-j2ee-engine.xml, and so my ejb's showed up nicely in the Visual Administrator JNDI Registry under the localejbs tab as you would expect. The problem appears to be in the Web project - The key is that the error is "Path to object not found" rather than "Name not found".  It seems to me that it knows what it is looking for & that it is valid, but doesn't know how to get there! Note that the EJB project is in the same EAR. The only reference to "Path" that I can find is in the help doc above where it says "If the name of the target enterprise bean is not unique in the enterprise application scope, you can enter the path to the JAR file that contains the bean...".  I've gone through the Car Rental Application pdf (I can't find the download that contains the entire application) & followed the instructions there explicitly for referencing ejbs from the web..

  • Security exception while trying to access EJB from stand alone client

    Hi!, I am trying a sample EJB application to R&D some security related issues. I want to access EJB through a web application as well as a stand-alone client. I have set approriate <method-permission> in EJB deployment descriptor. I am using users.properties/roles.properties file for authentication mechanism. I am using JBoss 3.2.
    - On the web application side I am using BASIC authentication and the servlet is able to access the EJB OK, as long as I am using a login/password that has access to the EJB.
    - Now I am trying to access the EJB using a stand alone Java class. These are the things I have tried till now:
    =>Created a InitialContext with appropriate principal, credentials and tried getting a reference to EJB home interface. That resulted in security exception.
    =>Logged into a LoginContext by using appropriate JBossSX classes and then tried getting a EJB home interface. Again security exception.
    Now I am not sure what to do. I read at some places about client side container but not sure what that is. Does anyone has any ideas to try? Is there any other way I can make a swing application and a web application authenticate to EJB container?
    Also can anyone point me to any documentation that gives some idea about how the security credentials gets propagated from web application/standalone client to EJB container?

    It would be better if you can post your code...and DD that way we can help you better

  • Readouts from Console.app

    How can i know from Console logs, if & when special events related to my mini occurred?
    e.g. if i want to know when a power failure took place, (& i'm not at home, or power failed in the night), I don't think there is any specific logging of this in console. What wording in console's log can lead me to say with 90% confidence that power had failed?

    There would not be any specific log entry. You could figure out when by the difference between the time on a clock that isn't affected by the outage and the time on a clock that would have stopped when the outage occurred. If the computer is set to restart after an outage, then there is a console.log entry when the restart occurs.

  • I am trying to access files from an app on my phone.

    Every time I select "apps" in itunes, it stops and gives me a window that iTunes has stopped working and windows is looking for a solution to the problem.
    I can access and manipulate everything else on my phone, except for the apps that are installed.

    No, I have the music I want to move from the laptop to the phone selected. Then I go under file, devices, and try to click sync but it is not available to click.

  • Problems in accessing EJB from stand-alone client

    Hi,
    I am trying to access a EJB deployed in RI from a stand-alone client. When I run it, I got this exception:
    Exception in thread "main" java.rmi.AccessException: CORBA NO_PERMISSION 9998 Ma
    ybe; nested exception is:
    org.omg.CORBA.NO_PERMISSION: minor code: 9998 completed: Maybe
    org.omg.CORBA.NO_PERMISSION: minor code: 9998 completed: Maybe
    at java.lang.Class.newInstance0(Native Method)
    at java.lang.Class.newInstance(Unknown Source)
    at com.sun.corba.ee.internal.iiop.messages.ReplyMessage_1_2.getSystemExc
    eption(ReplyMessage_1_2.java:93)
    at com.sun.corba.ee.internal.iiop.ClientResponseImpl.getSystemException(
    ClientResponseImpl.java:108)
    at com.sun.corba.ee.internal.POA.GenericPOAClientSC.invoke(GenericPOACli
    entSC.java:136)
    at org.omg.CORBA.portable.ObjectImpl._invoke(Unknown Source)
    at TheBeanRemoteStub.test(Unknown Source)
    at Client.main(Client.java:19)
    The following is the code of the client:
    System.setProperty(Context.SECURITY_PRINCIPAL, "achong");
    System.setProperty(Context.SECURITY_CREDENTIALS, "achong");
    Context context = new InitialContext(System.getProperties());
    Object object = PortableRemoteObject.narrow(context.lookup("MyBean"), TheBeanHome.class);
    TheBeanHome home = (TheBeanHome) object;
    I have set "support client choice" while deploying the bean, and set which roles can access which methods. Any idea? Is my code is incorrect?

    I have the same problem like you.
    If you solve it, please give me a hint.
    Thank you very much!
    [email protected]

  • Error Accessing EJB from remote application - is it supported in 101202?

    We are running Oracle App Server 10.1.2.0.2, There is a containers created on midtier server called OC4J_TEST .
    We have two applications, one has EJB and another one has JSP.JSP has following code
    Hashtable env = new Hashtable();
    env.put(Context.INITIAL_CONTEXT_FACTORY, "com.evermind.server.rmi.RMIInitialContextFactory");
    env.put(Context.SECURITY_PRINCIPAL, "ias_admin");
    env.put(Context.SECURITY_CREDENTIALS, "welcome1");
    String pURL="opmn:ormi://localhost:12401:OC4J_TEST/";
    env.put(Context.PROVIDER_URL,pURL );
    env.put("dedicated.connection","true");
    Context context = null;
    sampleejb Sampleejb;
    String mess = "Initial message, if you see that is because EJB has not been properly called";
    mess = mess + " "+pURL;
    try
    // Create InitialContext
    context = new InitialContext(env);
    // Lookup Home interface
    sampleejbHome SampleejbHome = (sampleejbHome)PortableRemoteObject.narrow(context.lookup("sampleejb"), sampleejbHome.class);
    // Create the bean and the remote interface
    Sampleejb = SampleejbHome.create();
    mess = Sampleejb.hello("Middle Tier JSP EJB Client");
    // Destroy the Bean Instance
    catch(Throwable ex)
    ex.printStackTrace();
    When I run this code we get following exception:
    08/10/15 16:21:35 javax.naming.NameNotFoundException: ejbserverapp/sampleejb not found
    08/10/15 16:21:35 at com.evermind.server.rmi.RMIContext.lookup(RMIContext.java:165)
    08/10/15 16:21:35 at javax.naming.InitialContext.lookup(InitialContext.java:347)
    08/10/15 16:21:35 at JspsampleejbClient.jspService(_JspsampleejbClient.java:76)
    08/10/15 16:21:35 at com.orionserver.http.OrionHttpJspPage.service(OrionHttpJspPage.java:56)
    08/10/15 16:21:35 at oracle.jsp.runtimev2.JspPageTable.compileAndServe(JspPageTable.java:575)
    08/10/15 16:21:35 at oracle.jsp.runtimev2.JspPageTable.service(JspPageTable.java:311)
    08/10/15 16:21:35 at oracle.jsp.runtimev2.JspServlet.internalService(JspServlet.java:498)
    08/10/15 16:21:35 at oracle.jsp.runtimev2.JspServlet.service(JspServlet.java:402)
    08/10/15 16:21:35 at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    08/10/15 16:21:35 at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:835)
    08/10/15 16:21:35 at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:341)
    08/10/15 16:21:35 at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:816)
    08/10/15 16:21:35 at com.evermind.server.http.AJPRequestHandler.run(AJPRequestHandler.java:231)
    08/10/15 16:21:35 at com.evermind.server.http.AJPRequestHandler.run(AJPRequestHandler.java:136)
    08/10/15 16:21:35 at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:192)
    08/10/15 16:21:35 at java.lang.Thread.run(Thread.java:534)
    What we really want is to have webapp with JSP running on one server and EJB running on another server. Need some help.
    Thanks in advance.
    Manoj
    Edited by: Manoj Desai on Oct 16, 2008 11:01 AM

    This connection string does not look correct to me:
    String pURL="opmn:ormi://localhost:12401:OC4J_TEST/";
    As you have it, you are specifying the OC4J RMI port to connect to, in conjunction with the ORMI lookup handler.
    The correct form for this string should be using the OPMN request port:
    String pURL="opmn:ormi://localhost:6003:OC4J_TEST/";
    The6003 value comes from the request port that OPMN is using on the target application server instance you need to connect to -- you can observe this port by looking at the $ORACLE_HOME/opmn/conf/opmn.xml file and look for this element:
    <port local="6101" remote="6202" request="6003"/>
    Use whatever port is specified there in your connect string.
    -steve-

  • Problem accessing ejb from servlet

    Hi,
    I'm aving a problem accessing a stateful session bean from a servlet. I'm using a jndi lookup to do it because I need that a client has its own bean reference...
    My code into the service method is:
    InitialContext ctx;
    try {
    ctx = new InitialContext();
    carrelloService = (CarrelloLocal)ctx.lookup("java:comp/env/ejb/Carrello");
    and I have a reference to EJB into web.xml:
    <ejb-local-ref>
    <ejb-ref-name>ejb/Carrello</ejb-ref-name>
    <ejb-ref-type>Session</ejb-ref-type>
    <local-home></local-home>
    <local>carrello.model.CarrelloLocal</local>
    </ejb-local-ref>
    If I use @EJB annotation to inject the servlet, it works fine.
    Instead using jndi lookup throws a NamingException because it doesn't find java:comp/env/ejb/Carrello entry.
    Any idea about the problem?

    Here's something simple that I have that works:
    <p> </p>
    SimpleBean
    <p> </p>
    @Stateless(name="SimpleBean")
    public class SimpleBeanBean implements SimpleBeanLocal {
    <p> </p>
    web.xml; -- note I use a whacko ejb-ref-name just to make it obvious where I'm using it.
    <p> </p>
        <ejb-local-ref>
            <ejb-ref-name>ejb_mapping_doodad/SimpleBean</ejb-ref-name>
            <ejb-ref-type>Session</ejb-ref-type>
            <local>sab.otn681398.ejb.SimpleBeanLocal</local>
        </ejb-local-ref><p> </p>
    servlet:
    <p> </p>
    package sab.otn681398.web;
    import java.io.IOException;
    import java.io.PrintWriter;
    import javax.naming.InitialContext;
    import javax.naming.NamingException;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import sab.otn681398.ejb.SimpleBeanLocal;
    public class TestServlet extends HttpServlet  {
        private static final String CONTENT_TYPE = "text/html; charset=windows-1252";
        private static final String SIMPLE_BEAN_JNDI = "ejb_mapping_doodad/ASimpleBean";
        private final boolean USEENC = true;
        private SimpleBeanLocal simple = null;
        public void init(ServletConfig config) throws ServletException {
            super.init(config);
        public void doGet(HttpServletRequest request,
                          HttpServletResponse response) throws ServletException, IOException {
            response.setContentType(CONTENT_TYPE);
            PrintWriter out = response.getWriter();
             try {
                if(simple==null) {
                    simple = createSimple();
            } catch(NamingException ne) {
                throw new ServletException("Error in looking up the EJB", ne);
            out.println("<html>");
            out.println("<head><title>TestServlet</title></head>");
            out.println("<body>");
            out.printf("&lt;p&gt;The %s bean has been hit: %s times&lt;/p&gt;", simple, simple.getHitCount());
            out.println("</body></html>");
            out.close();
        private SimpleBeanLocal createSimple() throws NamingException {
          return (USEENC==true? createSimpleViaENC(): createSimpleViaName());
        private SimpleBeanLocal createSimpleViaENC() throws NamingException {
            InitialContext ic = new InitialContext();
            SimpleBeanLocal simple = (SimpleBeanLocal)ic.lookup("java:comp/env/" + SIMPLE_BEAN_JNDI);
            return simple;
        private SimpleBeanLocal createSimpleViaName() throws NamingException {
            InitialContext ic = new InitialContext();
            SimpleBeanLocal simple = (SimpleBeanLocal)ic.lookup(SIMPLE_BEAN_JNDI);
            return simple;
    }<p> </p>
    -steve-

  • TS3297 Cannot access iTunes from Music App 4S

    I cannot access the "store" from my music app on my 4S. From any of the screens a can push the button that says "store", the button does change shade to indicate it is being pushed, but nothing happens. No error message, nothing. I've updated the iOS, I've restarted the app. I've restarted the phone. 3G on, Wifi on, My apple ID works. I can use home sharing and write on this forum. I just cant access the store. I just moved to India, but I have bought music from iTunes on my iMac and MacBook pro. No problem. Thanks for your answers.

    Is iTunes endlessly saying "Accessing iTunes Store"? Or is something a bit different going on?

  • Problems Accessing EJB from Client

    Hello All,
    I have deployed my first EJB in my JBoss App server and thats fine. However when I try and run the simple client that I have written to access this I get the following error:
    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 have tried Debugging the app and cant understand where/why this error is occurring? Any ideas and suggestions would be appreciated...The code I am using in the client is below:
    Context c = new InitialContext();
          Object o = c.lookup("HelloWorldEJB");
          HelloWorldHome hw = (HelloWorldHome)PortableRemoteObject.narrow (o, HelloWorldHome.class);
          HelloWorld hello = hw.create();
          System.out.println ("Result is: " + hello.hello());
          hello.remove();

    Hi!
    I do not know if you have got the solution for your problem....
    I am also struggling around with similar issue
    Here is how i tried
    Properties prop = System.getProperties();
    prop.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
    prop.put(Context.PROVIDER_URL, "localhost");
    prop.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces" );
    Context ctx = new InitialContext(prop);
    System.out.println("looking up ejb");
    Object obj = ctx.lookup("ejb/test");
    DO NOT forget to put jbossall-client.jar and jnpserver.jar in your classpath .
    This way at least you get the solution of the problem you are facing now.....
    Good Luck
    Alok

Maybe you are looking for

  • Login issue in 11.5.10.2

    Getting below error while login in oracle.apps.fnd.framework.OAException: java.lang.NullPointerException      at oracle.apps.fnd.framework.OAException.wrapperException(OAException.java:891)      at oracle.apps.fnd.framework.webui.OAWebBeanHelper.proc

  • Breaking one track into several fluidly

    I did a live recording all into one instrument track using the internal microphone on my Macbook. It sounds great, but I'm wanting to produce a CD from it and track each song individually. My problem, when I segment the show with garageband and then

  • ACR Plugins not working and Bridge won't view cr2 files

    Hey there.. I've been using Photoshop/Bridge/ ACR for 7 years now but from memory I have had this issue before when installing. My laptop just got a new hard drive and fan and I've had to reinstall everything. I downloaded 3 different ACR plugins and

  • Query to get the following criteria

    Hi all I've the following tables rec ,pay ,cact ,isumand the relation between them is isum.invid=rec.INVID_ARREC isum.invid=pay.invid_arpay cact.arpayid_cb=pay.arpayid cact.arrecid_cb=rec.arrecidi need to get the o/p of BAL , SUM(TAMT) , SUM(VAL) whi

  • Intermedia help needed

    hi, We are using Oracle 8i (8.1.6) and use intermedia to index certain columns. We been facing a peculiar problem over the past few days wherein search queries based on intermedia indexes crap out on singular words but come back fine on the plurals f