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

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

  • 'Class Cast Exception' while invoking a EJB from a Servlet

              Hi,
              I am working on J2EE applications.I am using Webgain studio and weblogic server.I
              got a problem while invoking EJB from the servlet.
              While calling an EJB from the servlet, it is giving that "Class Cast Exception".This
              is because, the remote home reference is not able to type casted to the"Home Interface"
              of the EJB, even if I type casted explicitly. It is creating the context and able
              to identify the EJB with the JNDI name.
              Could please help me in solving this problem.I am pasting the code here.
              Thanks in advance,
              Dharma
              public void doGet(HttpServletRequest req, HttpServletResponse resp)
                   throws ServletException, IOException
                        resp.setContentType("text/html");
                        PrintWriter out = new PrintWriter(resp.getOutputStream());
              try
              Context context=getInitialContext();
              Object reference=context.lookup("ArlProjContractorAppletSession");
              ArlProjContractorAppletSessionHome home=(ArlProjContractorAppletSessionHome)PortableRemoteObject.narrow(reference,ArlProjContractorAppletSessionHome.class);
              //Exception is occuring in the above statement. It is unable
              //to cast to the home interface          
                        ArlProjContractorAppletSession the_ejb=null;
              try
              the_ejb=home.create();
              System.out.println("the_ejb = " + the_ejb.toString());
              catch(Exception e)
              e.printStackTrace();
              catch(Exception e)
              e.printStackTrace();
                        // to do: code goes here.
                        out.println("<HTML>");
                        out.println("<HEAD><TITLE>Contractor TimeTracker</TITLE></HEAD>");
                        out.println("<BODY>");
                        // to do: your HTML goes here.
                        out.println("</BODY>");
                        out.println("</HTML>");
                        out.close();
              

              I came across this kind of problem once. My problem went away after I upgraded
              from 5.1 SP6 to 5.1 SP8.
              "Dharma" <[email protected]> wrote:
              >
              >Hi,
              >
              >I am working on J2EE applications.I am using Webgain studio and weblogic
              >server.I
              >got a problem while invoking EJB from the servlet.
              >
              >While calling an EJB from the servlet, it is giving that "Class Cast
              >Exception".This
              >is because, the remote home reference is not able to type casted to the"Home
              >Interface"
              >of the EJB, even if I type casted explicitly. It is creating the context
              >and able
              >to identify the EJB with the JNDI name.
              >
              >Could please help me in solving this problem.I am pasting the code here.
              >
              >Thanks in advance,
              >Dharma
              >
              >
              >public void doGet(HttpServletRequest req, HttpServletResponse resp)
              >     throws ServletException, IOException
              >     {
              >          resp.setContentType("text/html");
              >          PrintWriter out = new PrintWriter(resp.getOutputStream());
              >
              > try
              > {
              >
              > Context context=getInitialContext();
              >
              > Object reference=context.lookup("ArlProjContractorAppletSession");
              >
              > ArlProjContractorAppletSessionHome home=(ArlProjContractorAppletSessionHome)PortableRemoteObject.narrow(reference,ArlProjContractorAppletSessionHome.class);
              >
              >//Exception is occuring in the above statement. It is unable
              >//to cast to the home interface          
              >
              >          ArlProjContractorAppletSession the_ejb=null;
              >
              > try
              > {
              > the_ejb=home.create();
              >
              > System.out.println("the_ejb = " + the_ejb.toString());
              >
              > }
              > catch(Exception e)
              > {
              > e.printStackTrace();
              > }
              > }
              > catch(Exception e)
              > {
              > e.printStackTrace();
              > }
              >          // to do: code goes here.
              >
              >          out.println("<HTML>");
              >          out.println("<HEAD><TITLE>Contractor TimeTracker</TITLE></HEAD>");
              >          out.println("<BODY>");
              >
              >          // to do: your HTML goes here.
              >
              >          out.println("</BODY>");
              >          out.println("</HTML>");
              >          out.close();
              >     }
              >
              >
              >
              >
              >
              

  • [Fwd: Security problem accessing MBeanServer from a servlet]

    Reposting to Security and Servlet newsgroups.
    -------- Original Message --------
    Subject: Security problem accessing MBeanServer from a servlet
    Date: 10 Feb 2004 13:02:09 -0800
    From: Alain <[email protected]>
    Reply-To: Alain <[email protected]>
    Organization: BEA NEWS SITE
    Newsgroups: weblogic.developer.interest.management
    Hi,
    I am trying to understand how WLS 7.0 secures a call to an MBean. Got
    the following
    scenario:
    - I am in a servlet context
    - I have created and registered an MBean with the WLS MBeanServer. Fine
    so far
    - Within the same call I can retrieve the MBean attributes. Fine so far
    - I keep the MBeanServer reference in an object global to the servlet
    context
    The problem:
    - When I do another request and try to use the cached MBeanServer
    instance to
    access the MBean, I get the following error:
    weblogic.management.NoAccessRuntimeException: Access not allowed for
    subject:
    principals=[], on ResourceType ...
    Any idea?
    Alain

    PaulF <paulf@reply_in_newsgroup.com> wrote:
    On 10 Feb 2004 13:02:09 -0800, Alain <[email protected]> wrote:
    Hi,
    I am trying to understand how WLS 7.0 secures a call to an MBean. Got
    the following
    scenario:
    - I am in a servlet context
    - I have created and registered an MBean with the WLS MBeanServer.Fine
    so far
    - Within the same call I can retrieve the MBean attributes. Fine sofar
    - I keep the MBeanServer reference in an object global to the servlet
    context
    The problem:
    - When I do another request and try to use the cached MBeanServer
    instance to
    access the MBean, I get the following error:
    weblogic.management.NoAccessRuntimeException: Access not allowed for
    subject:
    principals=[], on ResourceType ...
    Any idea?
    AlainWhat ResourceType are you trying to access. From the Exception you're
    trying to access it as an Anonymous user (principals=[]) and evidently
    you're attempting to access something that is protected. I can't tell
    what
    from the snippet you've included.
    Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/
    Thanks Paul for your reply.
    You are right. I can access my custom MBeans if I am authenticated for example
    as an Administrator. My problem is that I want any application to access this
    MBean authenticated or not. I am trying to find how I could grant permission to
    this MBean to everyone. Still searching.
    Thanks.

  • 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-

  • 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

  • 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.

  • 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

  • Security problem accessing MBeanServer from a servlet

    Hi,
    I am trying to understand how WLS 7.0 secures a call to an MBean. Got the following
    scenario:
    - I am in a servlet context
    - I have created and registered an MBean with the WLS MBeanServer. Fine so far
    - Within the same call I can retrieve the MBean attributes. Fine so far
    - I keep the MBeanServer reference in an object global to the servlet context
    The problem:
    - When I do another request and try to use the cached MBeanServer instance to
    access the MBean, I get the following error:
    weblogic.management.NoAccessRuntimeException: Access not allowed for subject:
    principals=[], on ResourceType ...
    Any idea?
    Alain

    PaulF <paulf@reply_in_newsgroup.com> wrote:
    On 10 Feb 2004 13:02:09 -0800, Alain <[email protected]> wrote:
    Hi,
    I am trying to understand how WLS 7.0 secures a call to an MBean. Got
    the following
    scenario:
    - I am in a servlet context
    - I have created and registered an MBean with the WLS MBeanServer.Fine
    so far
    - Within the same call I can retrieve the MBean attributes. Fine sofar
    - I keep the MBeanServer reference in an object global to the servlet
    context
    The problem:
    - When I do another request and try to use the cached MBeanServer
    instance to
    access the MBean, I get the following error:
    weblogic.management.NoAccessRuntimeException: Access not allowed for
    subject:
    principals=[], on ResourceType ...
    Any idea?
    AlainWhat ResourceType are you trying to access. From the Exception you're
    trying to access it as an Anonymous user (principals=[]) and evidently
    you're attempting to access something that is protected. I can't tell
    what
    from the snippet you've included.
    Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/
    Thanks Paul for your reply.
    You are right. I can access my custom MBeans if I am authenticated for example
    as an Administrator. My problem is that I want any application to access this
    MBean authenticated or not. I am trying to find how I could grant permission to
    this MBean to everyone. Still searching.
    Thanks.

  • 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..

  • 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.

  • Accessing an ejb from a servlet gives resource not allowed exception

    hi friends,
    i deployed a bean in weblogic server calling from within a servlet. this bean is used to retrieve a database connection and returns to the servlet. i have done all the resource references lookups everything and also the bean is deployed successfully, but when i run the servlet i didn't get even the println messages. it gives resource not allowed message.
    here is the deployment descriptor is correct ? if anything wrong or missed, please mention and try to give me the solution.
    web.xml
    <web-app>
    <servlet>
    <servlet-name>TestConnection</servlet-name>
    <display-name>TestConnection</display-name>
    <servlet-class>tms.com.ejb.TestConnection</servlet-class>
    </servlet>
    <servlet-mapping>
    <servlet-name>TestConnection</servlet-name>
    <url-pattern>TestConnection</url-pattern>
    </servlet-mapping>
    <resource-ref>
    <res-ref-name>tmsPool</res-ref-name>
    <res-type>javax.sql.DataSource</res-type>
    <res-auth>Container</res-auth>
    </resource-ref>
    <env-entry>
    <env-entry-name>tmsDataSource</env-entry-name>
    <env-entry-value>tmsPool</env-entry-value>
    <env-entry-type>java.lang.String</env-entry-type>
    </env-entry>
    <env-entry>
    <env-entry-name>TMS_DBConnectionBean</env-entry-name>
    <env-entry-value>java:comp/env/ejb/TMS_DBConnectionBean</env-entry-value>
    <env-entry-type>java.lang.String</env-entry-type>
    </env-entry>
    <ejb-ref>
    <ejb-ref-name>ejb/TMS_DBConnectionBean</ejb-ref-name>
    <ejb-ref-type>Session</ejb-ref-type>
    <home>tms.com.ejb.TMS_DBConnectionHome</home>
    <remote>tms.com.ejb.TMS_DBConnection</remote>
    <ejb-link>TMS_DBConnectionBean</ejb-link>
    </ejb-ref>
    </web-app>
    Ejb jar is
    <enterprise-beans>
    <session>
    <display-name>ConnectionBean</display-name>
    <ejb-name>TMS_DBConnectionBean</ejb-name>
    <home>tms.com.ejb.TMS_DBConnectionHome</home>
    <remote>tms.com.ejb.TMS_DBConnection</remote>
    <ejb-class>tms.com.ejb.TMS_DBConnectionBean</ejb-class>
    <session-type>Stateless</session-type>
    <transaction-type>Container</transaction-type>
    <env-entry>
    <env-entry-name>tmsDataSource</env-entry-name>
    <env-entry-type>java.lang.String</env-entry-type>
    <env-entry-value>tmsPool</env-entry-value>
    </env-entry>
    <security-identity>
    <description></description>
    <use-caller-identity></use-caller-identity>
    </security-identity>
    <resource-ref>
    <res-ref-name>tmsPool</res-ref-name>
    <res-type>javax.sql.DataSource</res-type>
    <res-auth>Container</res-auth>
    <!--<res-sharing-scope>Shareable</res-sharing-scope>-->
    </resource-ref>
    </session>
    </enterprise-beans>
    <weblogic-ejb-jar>
    weblogic ejb jar file is the following content.
    <weblogic-enterprise-bean>
    <ejb-name>TMS_DBConnectionBean</ejb-name>
    <stateless-session-descriptor>
    <pool>
         <max-beans-in-free-pool>1</max-beans-in-free-pool>
    </pool>
    </stateless-session-descriptor>
    <jndi-name>TMS_DBConnectionBean</jndi-name>
    </weblogic-enterprise-bean>
    thanx in advance..

    hi
    i tried the same but still i'm getting the same problem, the value i mentioned in the servlet lookup is java:comp/env/TMS_DBConnectionBean.
    then the value returned by the lookup would be java:comp/env/ejb/TMS_DBConnectionBean. right. Anyway i tried the same as u mentioned. that same problem resource not allowed is displayed in the browser. is there any other alternative to solve this?
    thanks

  • Unable to access EJB from servlet

    Hi,
    I have in service method my servlet code.
    Hashtable env = new Hashtable();
                        env.put(Context.INITIAL_CONTEXT_FACTORY, "com.evermind.server.ApplicationInitialContextFactory");
                        env.put(Context.PROVIDER_URL, "ormi://localhost/hello");
                        env.put(Context.SECURITY_PRINCIPAL, "admin");
                        env.put(Context.SECURITY_CREDENTIALS, "mypwd");
                        Context ctx = new InitialContext(env);
              Object obj = ctx.lookup("HelloName");
                        HelloHome home = (HelloHome) javax.rmi.PortableRemoteObject.narrow(obj, HelloHome.class);
                        Hello hello = home.create();
    this is how i have orion-ejb-jar.xml
         <enterprise-beans>
              <session-deployment name="Hello" location="HelloName" >
              </session-deployment>
         </enterprise-beans>
         ejb-jar.xml
              <session>
                   <ejb-name>Hello</ejb-name>
                   <home>examples.HelloHome</home>
                   <remote>examples.Hello</remote>
                   <local-home>examples.HelloLocalHome</local-home>
                   <local>examples.HelloLocal</local>
                   <ejb-class>examples.HelloBean</ejb-class>
                   <session-type>Stateless</session-type>
                   <transaction-type>Container</transaction-type>
              </session>
    When i access the servlet i get this error.
    javax.naming.NameNotFoundException: HelloName not found
         at com.evermind.server.rmi.RMIContext.lookup(RMIContext.java:149)
         at com.evermind.server.ApplicationContext.lookup(ApplicationContext.java:217)
         at com.evermind.server.ApplicationContext.lookup(ApplicationContext.java:88)
         at javax.naming.InitialContext.lookup(InitialContext.java:345)
         at examples.HelloServlet.service(Unknown Source)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:772)
         at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:317)
         at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:782)
         at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:270)
         at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:112)
         at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:186)
         at java.lang.Thread.run(Thread.java:479)
    Is location attribute in orion-ejb-jar.xml used to specify JNDI name? Can i get the JNDI tree showing the name mappings in oc4j? How do i correct this error?
    Ravi

    Ravi --
    The most portable and standards oriented solution is to define an ejb-ref in the web.xml for the servlet, and then look up the name using the formal EJB UNC model.
    web.xml:
    <ejb-ref>
    <ejb-ref-name>ejb/AppSessionFacadeHome</ejb-ref-name>
    <ejb-ref-type>Session</ejb-ref-type>
    <home>faqapp.ejb.AppSessionFacadeHome</home>
    <remote>faqapp.ejb.AppSessionFacade</remote>
    </ejb-ref>
    servlet lookup
    InitialContext ctx = new InitialContext();
    Object homeObject = ctx.lookup("java:comp/env/ejb/AppSessionFacadeHome");
    EJBHome ejbHome = (EJBHome)
    portableRemoteObject.narrow (homeObject, AppSessionFacadeHome.class);
    cheers
    -steve-

  • How can I call EJB from JSP/Servlets in iWS?

    Hi!!
    My JSP/Servlets are on iWS, and I deploy EJB on iAS.
    In this case, I don't know how JSP/Servlet call EJb on iAS.
    I'd like to know how I can set JNDI name in JSP/Servlet on iWS.
    I will thank you if you give me a simple example source using JSP/Servlet
    and EJB.
    Thanks in advance!!!
    - Park-

    Park,
    Why Are you running your JSP/Servlets in iWS instead of iAS? For whatever
    reason,
    look at the Converter sample from iAS. You will be doing RMI/IIOP in this
    case and the sample explains in detail what to do.
    hth,
    -robert
    "SungHyun, Park" <[email protected]> wrote in message
    news:9jpfmt$[email protected]..
    Hi!!
    My JSP/Servlets are on iWS, and I deploy EJB on iAS.
    In this case, I don't know how JSP/Servlet call EJb on iAS.
    I'd like to know how I can set JNDI name in JSP/Servlet on iWS.
    I will thank you if you give me a simple example source using JSP/Servlet
    and EJB.
    Thanks in advance!!!
    - Park-

  • 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]

Maybe you are looking for

  • Inutilização de NFe com erro de validação

    Srs. Gostaria de tirar uma duvida mais "funcional" do processo de uma nfe, que seria a seguinte, caso uma NFE esteja com erro de validação no GRC, se o erro e o status voltou para o ERP e na j1bnfe ela esta com status 8, eu poderia solicitar a inutil

  • AIR Badge with in flash site

    Hello, need some advice / help. I currently have a flash site and I have an AIR app. I need to use the badge within my flash site. Does anyone know if there is anyway of using the AIR Badge within the .swf or will I need to create a normal .html page

  • Templates and Dynamic Memory Allocation Templates

    Hi , I was reading a detailed article about templates and I came across the following paragraph template<class T, size_t N> class Stack T data[N]; // Fixed capacity is N size_t count; public: void push(const T& t); };"You must provide a compile-time

  • Import Windoze OL2000 PST mail into Mac OSx MS Entourage2004 or Osx Mail

    Anyone aware of any Mac based scripts/conversion utilities that will convert within the following caveats/parameters?: * Must run on OSx 10.4.10+ Intel C2D - (Yes I'm aware of Windoze based options to say re-export PST to CSV/Tab delim formats etc as

  • SOS: Problem with how to unlock or activate my iPhone4S

    I bought my 4S in Austrilia a couple of days ago. Full price 799!!!AUD, then, for some personal reason, I had to go to china with it unwrapped. To be honest , I want to give it to one of my friend as a gift. However, when I got here, I inserted local