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

Similar Messages

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

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

  • 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

  • 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

  • Very Urgent !!! Exception in looking up Local EJB from Servlet in WSAD 5.1

    Hi,
    I have a servlet and a local EJB. The servlet and EJB are deployed on same application server but in different J2EE applications i.e. different EAR files.
    When I lookup an EJB with remote interfaces from servlet everything works fine. But when I try to lookup EJB with local interfaces from
    Servlet I get following Exception.
    Exception Stack: -
    ========================================================
    avax.naming.NameNotFoundException: Context: localhost/nodes/localhost/servers/server1, name: TestLocalHome: First component in name TestLocalHome not found. Root exception is org.omg.CosNaming.NamingContextPackage.NotFound: IDL:omg.org/CosNaming/NamingContext/NotFound:1.0
    [12/8/05 14:14:05:047 IST] 7debf35b SystemErr R      at com.ibm.ws.naming.ipcos.WsnOptimizedNamingImpl.do_resolve_complete_info(WsnOptimizedNamingImpl.java:968)
    [12/8/05 14:14:05:047 IST] 7debf35b SystemErr R      at com.ibm.ws.naming.cosbase.WsnOptimizedNamingImplBase.resolve_complete_info(WsnOptimizedNamingImplBase.java:1399)
    [12/8/05 14:14:05:047 IST] 7debf35b SystemErr R      at com.ibm.WsnOptimizedNaming._NamingContextStub.resolve_complete_info(Unknown Source)
    [12/8/05 14:14:05:047 IST] 7debf35b SystemErr R      at com.ibm.ws.naming.jndicos.CNContextImpl.cosResolve(CNContextImpl.java:3491)
    [12/8/05 14:14:05:047 IST] 7debf35b SystemErr R      at com.ibm.ws.naming.jndicos.CNContextImpl.doLookup(CNContextImpl.java:1519)
    [12/8/05 14:14:05:047 IST] 7debf35b SystemErr R      at com.ibm.ws.naming.jndicos.CNContextImpl.doLookup(CNContextImpl.java:1480)
    [12/8/05 14:14:05:047 IST] 7debf35b SystemErr R      at com.ibm.ws.naming.jndicos.CNContextImpl.lookupExt(CNContextImpl.java:1187)
    [12/8/05 14:14:05:047 IST] 7debf35b SystemErr R      at com.ibm.ws.naming.jndicos.CNContextImpl.lookup(CNContextImpl.java:1067)
    [12/8/05 14:14:05:047 IST] 7debf35b SystemErr R      at com.ibm.ws.naming.util.WsnInitCtx.lookup(WsnInitCtx.java:132)
    [12/8/05 14:14:05:047 IST] 7debf35b SystemErr R      at javax.naming.InitialContext.lookup(InitialContext.java:360)
    [12/8/05 14:14:05:047 IST] 7debf35b SystemErr R      at org.apache.jsp._DomainClient._jspService(_DomainClient.java:95)
    [12/8/05 14:14:05:047 IST] 7debf35b SystemErr R      at com.ibm.ws.webcontainer.jsp.runtime.HttpJspBase.service(HttpJspBase.java:89)
    [12/8/05 14:14:05:047 IST] 7debf35b SystemErr R      at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    [12/8/05 14:14:05:047 IST] 7debf35b SystemErr R      at com.ibm.ws.webcontainer.jsp.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:344)
    [12/8/05 14:14:05:047 IST] 7debf35b SystemErr R      at com.ibm.ws.webcontainer.jsp.servlet.JspServlet.serviceJspFile(JspServlet.java:669)
    [12/8/05 14:14:05:047 IST] 7debf35b SystemErr R      at com.ibm.ws.webcontainer.jsp.servlet.JspServlet.service(JspServlet.java:767)
    [12/8/05 14:14:05:047 IST] 7debf35b SystemErr R      at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    [12/8/05 14:14:05:047 IST] 7debf35b SystemErr R      at com.ibm.ws.webcontainer.servlet.StrictServletInstance.doService(StrictServletInstance.java:110)
    [12/8/05 14:14:05:047 IST] 7debf35b SystemErr R      at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet._service(StrictLifecycleServlet.java:174)
    [12/8/05 14:14:05:047 IST] 7debf35b SystemErr R      at com.ibm.ws.webcontainer.servlet.IdleServletState.service(StrictLifecycleServlet.java:313)
    [12/8/05 14:14:05:047 IST] 7debf35b SystemErr R      at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet.service(StrictLifecycleServlet.java:116)
    [12/8/05 14:14:05:047 IST] 7debf35b SystemErr R      at com.ibm.ws.webcontainer.servlet.ServletInstance.service(ServletInstance.java:283)
    [12/8/05 14:14:05:047 IST] 7debf35b SystemErr R      at com.ibm.ws.webcontainer.servlet.ValidServletReferenceState.dispatch(ValidServletReferenceState.java:42)
    [12/8/05 14:14:05:047 IST] 7debf35b SystemErr R      at com.ibm.ws.webcontainer.servlet.ServletInstanceReference.dispatch(ServletInstanceReference.java:40)
    [12/8/05 14:14:05:047 IST] 7debf35b SystemErr R      at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.handleWebAppDispatch(WebAppRequestDispatcher.java:983)
    [12/8/05 14:14:05:047 IST] 7debf35b SystemErr R      at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.dispatch(WebAppRequestDispatcher.java:564)
    [12/8/05 14:14:05:062 IST] 7debf35b SystemErr R      at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.forward(WebAppRequestDispatcher.java:200)
    [12/8/05 14:14:05:062 IST] 7debf35b SystemErr R      at com.ibm.ws.webcontainer.srt.WebAppInvoker.doForward(WebAppInvoker.java:119)
    [12/8/05 14:14:05:062 IST] 7debf35b SystemErr R      at com.ibm.ws.webcontainer.srt.WebAppInvoker.handleInvocationHook(WebAppInvoker.java:276)
    [12/8/05 14:14:05:062 IST] 7debf35b SystemErr R      at com.ibm.ws.webcontainer.cache.invocation.CachedInvocation.handleInvocation(CachedInvocation.java:71)
    [12/8/05 14:14:05:062 IST] 7debf35b SystemErr R      at com.ibm.ws.webcontainer.srp.ServletRequestProcessor.dispatchByURI(ServletRequestProcessor.java:182)
    [12/8/05 14:14:05:062 IST] 7debf35b SystemErr R      at com.ibm.ws.webcontainer.oselistener.OSEListenerDispatcher.service(OSEListener.java:334)
    [12/8/05 14:14:05:062 IST] 7debf35b SystemErr R      at com.ibm.ws.webcontainer.http.HttpConnection.handleRequest(HttpConnection.java:56)
    [12/8/05 14:14:05:062 IST] 7debf35b SystemErr R      at com.ibm.ws.http.HttpConnection.readAndHandleRequest(HttpConnection.java:618)
    [12/8/05 14:14:05:062 IST] 7debf35b SystemErr R      at com.ibm.ws.http.HttpConnection.run(HttpConnection.java:439)
    [12/8/05 14:14:05:062 IST] 7debf35b SystemErr R      at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:672)
    ========================================================
    Please help asap.
    Regds
    VJ.

    The ejb spec only defines local ejb access within the same application. It's possible some app servers support access from a different application but it wouldn't be portable, nor would it work within the J2EE SDK or Sun Java System App Servers. To access a local ejb from a web component or ejb , define an ejb-local-ref in the client component's standard .xml file (web.xml or ejb-jar.xml) and use the ejb-link element to specify the ejb-name of the target ejb.
    --ken                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Loading remote EJB from servlet using jakarta and openejb

    I am trying to create an environment where I use
    openejb as my EJB container, and JAKARTA Tomcat
    as my
    Servlet/JSP container. However,
    i'm having a problem in lookingup my remote EJB from my
    jakarta application.
    That exact code works perfectly if I run it standalone. I
    am using the same JRE. Jakarta has also loaded the
    openejb-0.8.3.jar and openejb_client-0.8.3.jar
    What I dont understand is why jakarta
    would behave differently than command-line java when I
    am
    running in the same JRE on a single machine.
    Any help would be much appreciated.

    Several fairly major improvements have been maid in OpenEJB specifically for the Tomcat people. For one, the whole way you integrate them has completely been rewritten. Now all you have to do is copy a openejb_loader-0.9.1.war into the Tomcat webapps directory and change an init-param in it. Pretty straight forward. OpenEJB 0.8.3 won't work with Tomcat in the same VM, however OpenEJB 0.9.0 and up have been totally revamped in all things related to classloading so that it can co-exist with Tomcats unique classloading architecture.
    O'Reilly just published an article detailing the ins and outs of the integration, it's a pretty good read:
    http://www.onjava.com/pub/a/onjava/2003/02/12/ejb_tomcat.html

  • 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

  • Calling ejbs from servlets without using web apps.

    i am trying to instantiate and ejb from a servlet but it gives me the
              following error. the configuration and code that generated this error is
              attached below.
              oddly enough the same chunk of code works fine in a stand alone client if
              j2ee.jar;weblogic\classes and weblogicaux.jar are included in the classpath.
              any help would be appreciated.
              peter
              -8787844: in servlet.Webmedx.init
              -8787844: null
              java.lang.ClassCastException
              at
              com.sun.corba.ee.internal.javax.rmi.PortableRemoteObject.narrow(Porta
              bleRemoteObject.java:296)
              at
              javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:137)
              at webmedx.servlet.Webmedx.init(Webmedx.java:23)
              at javax.servlet.GenericServlet.init(GenericServlet.java:258)
              at
              weblogic.servlet.internal.ServletStubImpl.createServlet(ServletStubIm
              pl.java:474)
              at
              weblogic.servlet.internal.ServletStubImpl.createInstances(ServletStub
              Impl.java, Compiled Code)
              at
              weblogic.servlet.internal.ServletStubImpl.prepareServlet(ServletStubI
              mpl.java:422)
              at
              weblogic.servlet.internal.ServletStubImpl.getServlet(ServletStubImpl.
              java:187)
              at
              weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubIm
              pl.java:118)
              at
              weblogic.servlet.internal.ServletContextImpl.invokeServlet(ServletCon
              textImpl.java:760)
              at
              weblogic.servlet.internal.ServletContextImpl.invokeServlet(ServletCon
              textImpl.java:707)
              at
              weblogic.servlet.internal.ServletContextManager.invokeServlet(Servlet
              ContextManager.java:251)
              at
              weblogic.socket.MuxableSocketHTTP.invokeServlet(MuxableSocketHTTP.jav
              a:369)
              at
              weblogic.socket.MuxableSocketHTTP.execute(MuxableSocketHTTP.java:269)
              at weblogic.kernel.ExecuteThread.run(ExecuteThread.java, Compiled
              Code)
              configuration:
              WebLogic startup settings are presently:
              CLASSPATH Prefix
              \weblogic\lib\weblogic510sp5boot.jar;\j2ee\lib\j2ee.jar;\web
              logic\lib\servlet.jar;\weblogic\lib\jaxp.jar;\weblogic\lib\parser.jar
              CLASSPATH
              \weblogic\lib\weblogic510sp5boot.jar;\j2ee\lib\j2ee.jar;\web
              logic\lib\servlet.jar;\weblogic\lib\jaxp.jar;\weblogic\lib\parser.jar;\weblo
              gic\
              jre1_2\lib\tools.jar;\weblogic\jre1_2\jre\lib\rt.jar;\weblogic\jre1_2\jre\li
              b\i1
              8n.jar;C:\weblogic\license;C:\weblogic\classes\boot;C:\weblogic\classes;C:\w
              eblo
              gic\lib\weblogicaux.jar;C:\weblogic\eval\cloudscape\lib\cloudscape.jar
              JAVA_HOME \weblogic\jre1_2
              WEBLOGIC_LICENSEDIR C:\weblogic\license
              WEBLOGIC_HOME C:\weblogic
              system properties:
              java.security.manager
              java.security.policy=\weblogic\weblogic.policy
              weblogic.system.home=\weblogic
              java.compiler=symcjit
              weblogic.class.path=\weblogic\lib\weblogic510sp5.jar;\weblog
              ic\license;\weblogic\classes;\weblogic\lib\weblogicaux.jar
              INITIAL_HEAP 64 MB
              MAX_HEAP 64 MB
              SERVERCLASSPATH
              \weblogic\lib\weblogic510sp5boot.jar;\j2ee\lib\j2ee.jar;\web
              logic\lib\servlet.jar;\weblogic\lib\jaxp.jar;\weblogic\lib\parser.jar;\weblo
              gic\
              jre1_2\jre\lib\rt.jar;\weblogic\jre1_2\jre\lib\i18n.jar;C:\weblogic\classes\
              boot
              ;C:\weblogic\eval\cloudscape\lib\cloudscape.jar
              Type "wlconfig -help" for program usage.
              code:
              public void init() throws ServletException{
              try{
              Log.debug("in servlet.Webmedx.init");
              Properties h = new Properties();
              h.put(Context.INITIAL_CONTEXT_FACTORY,
              "weblogic.jndi.WLInitialContextFactory");
              h.put(Context.PROVIDER_URL, "t3://localhost:7001");
              Context initial = new InitialContext(h);
              Object objref = initial.lookup("webmedx/pool");
              webmedxpoolhome =
              (WebmedxPoolHome)PortableRemoteObject.narrow(objref,WebmedxPoolHome.class);
              }catch(Exception ex){
              Log.error(ex);
              

    The problem before was that you were trying to load the same class from
              2 different class paths. The ClassCastException is very un-intuitive in this
              case.
              Peter Ghosh wrote:
              > however, when i added it to the classpath prefix (not the
              > weblogic.classpath) it seemed to do the trick. very odd.
              > thanks,
              > peter
              >
              > "Peter Ghosh" <[email protected]> wrote in message
              > news:[email protected]...
              > > i tried that but no luck. any other suggestions?
              > > peter
              > >
              > > "Ohad Shany" <[email protected]> wrote in message
              > > news:[email protected]...
              > > > Is your EJB classes on the servlet classpath?
              > > > (weblogic.httpd.servlet.classpath property)
              > > >
              > > > I had some strange casting problem when my EJB classes was on the
              > servlet
              > > > classpath
              > > > and it was gone when i moved them to the weblogic.class.path . Worth a
              > > try.
              > > >
              > > > OHAD
              > > >
              > > > Peter Ghosh wrote:
              > > >
              > > > > i am trying to instantiate and ejb from a servlet but it gives me the
              > > > > following error. the configuration and code that generated this error
              > is
              > > > > attached below.
              > > > > oddly enough the same chunk of code works fine in a stand alone client
              > > if
              > > > > j2ee.jar;weblogic\classes and weblogicaux.jar are included in the
              > > classpath.
              > > > > any help would be appreciated.
              > > > > peter
              > > > >
              > > > > -8787844: in servlet.Webmedx.init
              > > > > -8787844: null
              > > > > java.lang.ClassCastException
              > > > > at
              > > > > com.sun.corba.ee.internal.javax.rmi.PortableRemoteObject.narrow(Porta
              > > > > bleRemoteObject.java:296)
              > > > > at
              > > > > javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:137)
              > > > > at webmedx.servlet.Webmedx.init(Webmedx.java:23)
              > > > > at javax.servlet.GenericServlet.init(GenericServlet.java:258)
              > > > > at
              > > > > weblogic.servlet.internal.ServletStubImpl.createServlet(ServletStubIm
              > > > > pl.java:474)
              > > > > at
              > > > > weblogic.servlet.internal.ServletStubImpl.createInstances(ServletStub
              > > > > Impl.java, Compiled Code)
              > > > > at
              > > > > weblogic.servlet.internal.ServletStubImpl.prepareServlet(ServletStubI
              > > > > mpl.java:422)
              > > > > at
              > > > > weblogic.servlet.internal.ServletStubImpl.getServlet(ServletStubImpl.
              > > > > java:187)
              > > > > at
              > > > > weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubIm
              > > > > pl.java:118)
              > > > > at
              > > > > weblogic.servlet.internal.ServletContextImpl.invokeServlet(ServletCon
              > > > > textImpl.java:760)
              > > > > at
              > > > > weblogic.servlet.internal.ServletContextImpl.invokeServlet(ServletCon
              > > > > textImpl.java:707)
              > > > > at
              > > > > weblogic.servlet.internal.ServletContextManager.invokeServlet(Servlet
              > > > > ContextManager.java:251)
              > > > > at
              > > > > weblogic.socket.MuxableSocketHTTP.invokeServlet(MuxableSocketHTTP.jav
              > > > > a:369)
              > > > > at
              > > > > weblogic.socket.MuxableSocketHTTP.execute(MuxableSocketHTTP.java:269)
              > > > >
              > > > > at weblogic.kernel.ExecuteThread.run(ExecuteThread.java, Compiled
              > > > > Code)
              > > > >
              > > > > configuration:
              > > > >
              > > > > WebLogic startup settings are presently:
              > > > >
              > > > > CLASSPATH Prefix
              > > > > \weblogic\lib\weblogic510sp5boot.jar;\j2ee\lib\j2ee.jar;\web
              > > > > logic\lib\servlet.jar;\weblogic\lib\jaxp.jar;\weblogic\lib\parser.jar
              > > > > CLASSPATH
              > > > > \weblogic\lib\weblogic510sp5boot.jar;\j2ee\lib\j2ee.jar;\web
              > > > >
              > >
              > logic\lib\servlet.jar;\weblogic\lib\jaxp.jar;\weblogic\lib\parser.jar;\weblo
              > > > > gic\
              > > > >
              > >
              > jre1_2\lib\tools.jar;\weblogic\jre1_2\jre\lib\rt.jar;\weblogic\jre1_2\jre\li
              > > > > b\i1
              > > > >
              > >
              > 8n.jar;C:\weblogic\license;C:\weblogic\classes\boot;C:\weblogic\classes;C:\w
              > > > > eblo
              > > > > gic\lib\weblogicaux.jar;C:\weblogic\eval\cloudscape\lib\cloudscape.jar
              > > > > JAVA_HOME \weblogic\jre1_2
              > > > > WEBLOGIC_LICENSEDIR C:\weblogic\license
              > > > > WEBLOGIC_HOME C:\weblogic
              > > > > system properties:
              > > > > java.security.manager
              > > > > java.security.policy=\weblogic\weblogic.policy
              > > > > weblogic.system.home=\weblogic
              > > > > java.compiler=symcjit
              > > > >
              > > > > weblogic.class.path=\weblogic\lib\weblogic510sp5.jar;\weblog
              > > > > ic\license;\weblogic\classes;\weblogic\lib\weblogicaux.jar
              > > > > INITIAL_HEAP 64 MB
              > > > > MAX_HEAP 64 MB
              > > > > SERVERCLASSPATH
              > > > > \weblogic\lib\weblogic510sp5boot.jar;\j2ee\lib\j2ee.jar;\web
              > > > >
              > >
              > logic\lib\servlet.jar;\weblogic\lib\jaxp.jar;\weblogic\lib\parser.jar;\weblo
              > > > > gic\
              > > > >
              > >
              > jre1_2\jre\lib\rt.jar;\weblogic\jre1_2\jre\lib\i18n.jar;C:\weblogic\classes\
              > > > > boot
              > > > > ;C:\weblogic\eval\cloudscape\lib\cloudscape.jar
              > > > >
              > > > > Type "wlconfig -help" for program usage.
              > > > >
              > > > > code:
              > > > >
              > > > > public void init() throws ServletException{
              > > > > try{
              > > > > Log.debug("in servlet.Webmedx.init");
              > > > > Properties h = new Properties();
              > > > > h.put(Context.INITIAL_CONTEXT_FACTORY,
              > > > > "weblogic.jndi.WLInitialContextFactory");
              > > > > h.put(Context.PROVIDER_URL, "t3://localhost:7001");
              > > > > Context initial = new InitialContext(h);
              > > > > Object objref = initial.lookup("webmedx/pool");
              > > > > webmedxpoolhome =
              > > > >
              > > > >
              > >
              > (WebmedxPoolHome)PortableRemoteObject.narrow(objref,WebmedxPoolHome.class);
              > > > > }catch(Exception ex){
              > > > > Log.error(ex);
              > > > > }
              > > > > }
              > > >
              > >
              > >
              

  • Connecting to Remote EJB from Servlet in same application

    Please help!
    I was able to connect to SessionBeans and EJB from my sample java client in OCJ4 but when I try to do same thing from my web application using servlets, I get the below NullPointerException error.
    The JNDI lookup works fine using java client but difficult from a servlet.
    I am sure there is something I am missing.
    Thanks
    This is what I do in the servlet:
    public void init() throws ServletException, NamingException, CreateException, RemoteException
    Context jndiContext = getInitialContext();
    SessionCartEJBHome home = (SessionCartEJBHome)jndiContext.lookup("SessionCartEJBBean");
    sessionEJB = null;
    try{
    sessionEJB = (SessionCartEJB) home.create();
    }catch (Exception e)
    e.printStackTrace();
    private static Context getInitialContext() throws NamingException
    Hashtable env = new Hashtable();
    // Standalone OC4J connection details
    env.put(Context.INITIAL_CONTEXT_FACTORY, "com.evermind.server.rmi.RMIInitialContextFactory");
    env.put(Context.SECURITY_PRINCIPAL, "admin");
    env.put(Context.SECURITY_CREDENTIALS, "admin");
    env.put(Context.PROVIDER_URL, "ormi://Princeton/ejb1");
    return new InitialContext(env);
    And when I call the following procedure, it blow up at the line sessionEJB.getLineItem(new Long(1304));
    sessionEJB is a class variable.
    void processCatalogPage(HttpServletRequest request,
    HttpServletResponse response,
    ActionMapping mapping,
    HttpSession session
    throws ServletException, IOException , Exception, FinderException{
    try {
    ActionForward actFor = null;
    String itemId = request.getParameter("id");
    if ( itemId != null ) {
    String[] itemIds = new String[1];
    itemIds[0] = itemId;
    sessionEJB.getLineItem(new Long(1304));
    actFor = mapping.findForward("catalog");
    return (mapping.findForward("success"));
    } catch (Exception ex)
    ex.printStackTrace();
    System.err.println(ex.toString());
    throw new EJBException(ex.toString());
    04/12/11 23:45:24 java.lang.NullPointerException
    04/12/11 23:45:24 at com.alashoofi.Cart.processCatalogPage(Cart.java:187)
    04/12/11 23:45:24 at com.alashoofi.Cart.execute(Cart.java:86)
    04/12/11 23:45:24 at org.apache.struts.action.RequestProcessor.processActi
    onPerform(RequestProcessor.java:484)
    04/12/11 23:45:24 at org.apache.struts.action.RequestProcessor.process(Req
    uestProcessor.java:274)
    04/12/11 23:45:24 at org.apache.struts.action.ActionServlet.process(Action
    Servlet.java:1482)
    04/12/11 23:45:24 at org.apache.struts.action.ActionServlet.doGet(ActionSe
    rvlet.java:507)
    04/12/11 23:45:24 at javax.servlet.http.HttpServlet.service(HttpServlet.ja
    va:740)
    04/12/11 23:45:24 at javax.servlet.http.HttpServlet.service(HttpServlet.ja
    va:853)
    04/12/11 23:45:24 at com.evermind.server.http.ServletRequestDispatcher.inv
    oke(ServletRequestDispatcher.java:765)
    04/12/11 23:45:24 at com.evermind.server.http.ServletRequestDispatcher.for
    wardInternal(ServletRequestDispatcher.java:317)
    04/12/11 23:45:24 at com.evermind.server.http.HttpRequestHandler.processRe
    quest(HttpRequestHandler.java:790)
    04/12/11 23:45:24 at com.evermind.server.http.HttpRequestHandler.run(HttpR
    equestHandler.java:270)
    04/12/11 23:45:24 at com.evermind.server.http.HttpRequestHandler.run(HttpR
    equestHandler.java:112)
    04/12/11 23:45:24 at com.evermind.util.ReleasableResourcePooledExecutor$My
    Worker.run(ReleasableResourcePooledExecutor.java:192)
    04/12/11 23:45:24 at java.lang.Thread.run(Thread.java:534)
    04/12/11 23:45:24 java.lang.NullPointerException
    Dec 11, 2004 11:45:24 PM org.apache.struts.action.RequestProcessor processExcept
    ion
    WARNING: Unhandled Exception thrown: class javax.ejb.EJBException

    Avi,
    Thanks for your response. I am actually returning a new InitialContext in a function call in the servlet. What I have noticed though is that JDeveloper creates two ear files for the application. One for the ejbs called ejb1.ear and another for the web files webapp1.ear. These are located in the applications subdirectory in OC4J directory.
    I know I have two projects in the application, model and viewController. I am just trying to follow the MVC pattern.
    In short, I don't think the web and the ejbs are in same ear file. I made the web project depend on the ejbs though. There is an option to set such. I don't know how to tell JDeveloper to put them all in one ear file.
    I will appreciate any suggestion.
    Thanks
    Matilda

  • How to run a MS Access Query from Servlet

    Is there a way to execute an MS Access query from a servlet. I have a query that is doing an INSERT into the database. I tried to code the servlet to directly do the query itself, but it keeps locking the database and hanging. I would appreciate any help.
    Thanks,
    Justin
    [email protected]

    r u refering to the query saved inthe MSACCESS, if so then it may not be possible, bcoz it is not a pure RDBMS. otherwise the u can do it as inthe above mention thread.

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

  • Reference EJB from servlet's action/helper classes

    Hello
    How to make a reference to stateless session bean from one of the helper classes of a servlet WITHOUT using any of these:
    * dependency injection (like @EJB) - I think this is not supported in this kind of class, EJB references can be injected only to servlets themselves or some other things (but not objects of classes "accompanying" a servlet)
    * home or local home interfaces (I would like to avoid writing them)
    * using mappedName (either in @Stateless or in ejb-jar) - since meaning of this is application-server dependent and thus not portable.
    By a "class accompanying a servlet" / "helper class" I mean utility or action classes, like MyActionClass, which would be instantiated and then used by a aforementioned servlet.
    Thanks.

    The EJB dependency must be looked up via the java:comp/env namespace since as you point out
    Java EE 5 environment annotations are not supported on POJOs. However, the dependency itself
    can either be defined using @EJB on some other managed class in the .war or within the
    web.xml. We have an entry in our EJB FAQ that has the details :
    https://glassfish.dev.java.net/javaee5/ejb/EJB_FAQ.html#POJOLocalEJB
    Also, whenever the client component resides in the same application as the target EJB (which is
    required for Local access but not for Remote access) there is no need to use mappedName to
    resolve the EJB dependency. It is either automatically resolved if the business interface type of
    the EJB dependency is only exposed by a single EJB in the application, OR the beanName()
    / ejb-link attributes can be used to unambiguously identify the target EJB using ejb-name.
    You can find more about this in the FAQ as well.

Maybe you are looking for

  • Customize AP Trial Balance Report in R12.1.3

    Hi I have to customize AP Trial Balance Report in R12 Version 12.1.3. Can any one please provide some pointers how do we do it? Here is some background for AP Trial Balance Report: Its an XML Publisher Report with XDODTEXE Executable. XLAAPRPT.xml is

  • Ipod touch 5g will not connect to home wifi

    Hello there! I have this problem where my ipod touch wil not let me connect to my home wifi. When I try to join, a message will pop up saying "incorrect password". I know for sure that the password is 100% right. My ipod touch had no problems connect

  • Help removing possible email virus

    I am getting tons of bounce backs from emails that i did not send and addresses are not from my address book. Virus scans of hard drive with multiple security software products  come up negative. any ideas of where to go from here?

  • HT1338 I had OS X Lion and had to reinstall snow leopard due to a factory reset how can i get os x lion back

    need help getting os x lion back after having to reinstall snow leopard

  • QBE report

    QBE report claims to allow users to insert update and delete from it. I can find ways to update and delete but not insert, am I missing something?