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                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

Similar Messages

  • Challenge: call local ejb from remote ejb on weblogic 9.2

    Hi ALL,
    How do I call to local ejb from remote ejb object. The jar file is deployed on weblogic server 9.2, if you want get it http://geocities.yahoo.com.br/lindembe/BEAProject.jar and the source code are http://geocities.yahoo.com.br/lindembe/BEAProject.zip. It is a sample app with two ejb that works so good on JBOSS, JOnAS, but BEA Weblogic.....
    The complete problem you watch http://forum.java.sun.com/thread.jspa?threadID=768718&messageID=4387570#4387570
    or
    http://forums.bea.com/bea/message.jspa?messageID=600043148&tstart=0

    Your code in SigemFacadeBean should just do:
    InitialContext ctx = new InitialContext();
    when you lookup the local EJB. (This will work on all app servers. There's no need to put an app-server specific intial context factory in your code.)
    Also, you can remove the jndi-name setting for the local ejb from your weblogic-ejb-jar.xml. jndi-name is only applied to remote ejbs.
    -- Rob
    WLS Blog http://dev2dev.bea.com/blog/rwoollen/

  • 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

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

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

  • 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

  • Exception during receive an array bytes from servlet

    Hi! I have some problem with receive my array bytes. When I want to recive my array bytes at application site from servlet, I have an exception java.io.ObjectInputStream$PeekInputStream.readFully(Unknown Source) near ObjectInputStream. I don't know what it's make. All looks good. Strings send I recive without any problems. Problem is with array bytes.
    URL url = new URL("http://127.0.0.1/App/servlet/Serwlet");
             URLConnection connect = url.openConnection();
            connect.setUseCaches(false);
             connect.setDefaultUseCaches(false);
             connect.setDoOutput(true);
         connect.setDoInput(true);    
    connect.setRequestProperty("Content-Type","application/x-java-serialized-object");
    ObjectOutputStream out = new sdfgObjectOutputStream(connect.getOutputStream());
              out.writeObject(arrayBytes);
              out.flush();
              out.close();
    //Here during debug is an exception
    ObjectInputStream in = new ObjectInputStream(connect.getInputStream());
              byte[] tmp = (byte[])in.readObject();
              in.close();
    System.out.println("Send array: "+arrayBytes);    
    System.out.println("Receive array: "+tmp);
    Servlet site :
    ObjectInputStream in = new ObjectInputStream(request.getInputStream());
                   byte[] tmp = (byte[])in.readObject();
                   in.close();
    response.setContentType("application/octet-stream");
                   ObjectOutputStream out = new ObjectOutputStream(response.getOutputStream());
                   out.writeObject(tmp);
                   out.flush();
                   out.close();Any ideas? :]

    All this exception looks that :
    java.io.EOFException
         at java.io.ObjectInputStream$PeekInputStream.readFully(Unknown Source)
         at java.io.ObjectInputStream$BlockDataInputStream.readShort(Unknown Source)
         at java.io.ObjectInputStream.readStreamHeader(Unknown Source)
         at java.io.ObjectInputStream.<init>(Unknown Source)
         at Klient.OdbiorcaButton.polaczenie(OdbiorcaButton.java:151)
         at Klient.OdbiorcaButton.actionPerformed(OdbiorcaButton.java:124)
         at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
         at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
         at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
         at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
         at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
         at java.awt.Component.processMouseEvent(Unknown Source)
         at javax.swing.JComponent.processMouseEvent(Unknown Source)
         at java.awt.Component.processEvent(Unknown Source)
         at java.awt.Container.processEvent(Unknown Source)
         at java.awt.Component.dispatchEventImpl(Unknown Source)
         at java.awt.Container.dispatchEventImpl(Unknown Source)
         at java.awt.Component.dispatchEvent(Unknown Source)
         at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
         at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
         at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
         at java.awt.Container.dispatchEventImpl(Unknown Source)
         at java.awt.Window.dispatchEventImpl(Unknown Source)
         at java.awt.Component.dispatchEvent(Unknown Source)
         at java.awt.EventQueue.dispatchEvent(Unknown Source)
         at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
         at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
         at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
         at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
         at java.awt.EventDispatchThread.run(Unknown Source)

  • 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

  • Exception looking up weblogic ejb from tomcat

    i have a servlet in tomcat 4.0 doing a remote lookup on an ejb in
    weblogic 6.1. the code works from a standalone client, but not in tomcat.
    so i assume it is something to do with jaas. do i have to configure jaas
    differently? and how?? i do not need to do anything with a standalone
    client to work.
    the code is
    Properties p = new Properties();
    p.put(Context.INITIAL_CONTEXT_FACTORY,
    "weblogic.jndi.WLInitialContextFactory");
    p.put(Context.PROVIDER_URL, "t3://192.168.254.3:7001");
    p.put(Context.SECURITY_PRINCIPAL, "user");
    p.put(Context.SECURITY_CREDENTIALS, "password");
    InitialContext ctx = new InitialContext(p);
    the exception is
    javax.servlet.ServletException: javax.naming.AuthenticationException
    [Root exception is java.lang.SecurityException: attempting to add an
    object which is not an instance of java.security.Principal to a
    Subject's Principal Set]
         at
    org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:457)
         at
    org.apache.jsp.test_0002dremote$jsp._jspService(test_0002dremote$jsp.java:71)
         at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:107)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at
    org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:201)
         at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:381)
         at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:473)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at
    org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
         at
    org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
         at
    org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:243)
         at
    org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
         at
    org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
         at
    org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:190)
         at
    org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
         at
    org.apache.catalina.valves.CertificatesValve.invoke(CertificatesValve.java:246)
         at
    org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
         at
    org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
         at
    org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2347)
         at
    org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
         at
    org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
         at
    org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170)
         at
    org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
         at
    org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:170)
         at
    org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
         at
    org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:468)
         at
    org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
         at
    org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
         at
    org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
         at
    org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
         at
    org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
         at
    org.apache.catalina.connector.http.HttpProcessor.process(HttpProcessor.java:1027)
         at
    org.apache.catalina.connector.http.HttpProcessor.run(HttpProcessor.java:1125)
         at java.lang.Thread.run(Thread.java:536)
    root cause
    com.realty.remoteservice.RemoteServiceException:
    javax.naming.AuthenticationException [Root exception is
    java.lang.SecurityException: attempting to add an object which is not an
    instance of java.security.Principal to a Subject's Principal Set]
         at com.realty.remoteservice.EjbService.addListingAgent(EjbService.java:43)
         at com.realty.remoteservice.EjbService.main(EjbService.java:23)
         at
    org.apache.jsp.test_0002dremote$jsp._jspService(test_0002dremote$jsp.java:61)
         at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:107)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at
    org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:201)
         at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:381)
         at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:473)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at
    org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
         at
    org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
         at
    org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:243)
         at
    org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
         at
    org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
         at
    org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:190)
         at
    org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
         at
    org.apache.catalina.valves.CertificatesValve.invoke(CertificatesValve.java:246)
         at
    org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
         at
    org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
         at
    org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2347)
         at
    org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
         at
    org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
         at
    org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170)
         at
    org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
         at
    org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:170)
         at
    org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
         at
    org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:468)
         at
    org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
         at
    org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
         at
    org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
         at
    org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
         at
    org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
         at
    org.apache.catalina.connector.http.HttpProcessor.process(HttpProcessor.java:1027)
         at
    org.apache.catalina.connector.http.HttpProcessor.run(HttpProcessor.java:1125)
         at java.lang.Thread.run(Thread.java:536)
    nested exception is:
    javax.naming.AuthenticationException. Root exception is
    java.lang.SecurityException: attempting to add an object which is not an
    instance of java.security.Principal to a Subject's Principal Set
         at javax.security.auth.Subject$SecureSet.add(Subject.java:1071)
         at
    weblogic.common.internal.BootServicesStub.writeUserInfoToSubject(BootServicesStub.java:72)
         at
    weblogic.common.internal.BootServicesStub.authenticate(BootServicesStub.java:80)
         at weblogic.security.acl.internal.Security.authenticate(Security.java:108)
         at
    weblogic.jndi.WLInitialContextFactoryDelegate.pushUser(WLInitialContextFactoryDelegate.java:461)
         at
    weblogic.jndi.WLInitialContextFactoryDelegate.newContext(WLInitialContextFactoryDelegate.java:316)
         at
    weblogic.jndi.WLInitialContextFactoryDelegate.getInitialContext(WLInitialContextFactoryDelegate.java:288)
         at
    weblogic.jndi.WLInitialContextFactoryDelegate.getInitialContext(WLInitialContextFactoryDelegate.java:203)
         at
    weblogic.jndi.WLInitialContextFactory.getInitialContext(WLInitialContextFactory.java:124)
         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.(InitialContext.java:195)
         at
    com.realty.util.RealtyContextFactory.create(RealtyContextFactory.java:25)
         at com.realty.remoteservice.EjbService.addListingAgent(EjbService.java:36)
         at com.realty.remoteservice.EjbService.main(EjbService.java:23)
         at
    org.apache.jsp.test_0002dremote$jsp._jspService(test_0002dremote$jsp.java:61)
         at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:107)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at
    org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:201)
         at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:381)
         at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:473)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at
    org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
         at
    org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
         at
    org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:243)
         at
    org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
         at
    org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
         at
    org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:190)
         at
    org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
         at
    org.apache.catalina.valves.CertificatesValve.invoke(CertificatesValve.java:246)
         at
    org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
         at
    org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
         at
    org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2347)
         at
    org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
         at
    org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
         at
    org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170)
         at
    org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
         at
    org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:170)
         at
    org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
         at
    org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:468)
         at
    org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
         at
    org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
         at
    org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
         at
    org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
         at
    org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
         at
    org.apache.catalina.connector.http.HttpProcessor.process(HttpProcessor.java:1027)
         at
    org.apache.catalina.connector.http.HttpProcessor.run(HttpProcessor.java:1125)
         at java.lang.Thread.run(Thread.java:536)

    Did you try placing weblogic.jar in front of the classpath?
    Or use WebLogic servlet container instead ;-)
    "Simon Evans" <[email protected]> wrote in message
    news:[email protected]...
    any solution? tomcat also uses jaas so i cant remove them.
    Dimitri I. Rakitine wrote:
    Happened to me once - as far as I remember it was caused by non-WL jaas
    classes in the
    classpath.
    "Simon Evans" <[email protected]> wrote in message
    news:[email protected]...
    i have a servlet in tomcat 4.0 doing a remote lookup on an ejb in
    weblogic 6.1. the code works from a standalone client, but not in
    tomcat.
    so i assume it is something to do with jaas. do i have to configure jaas
    differently? and how?? i do not need to do anything with a standalone
    client to work.
    the code is
    Properties p = new Properties();
    p.put(Context.INITIAL_CONTEXT_FACTORY,
    "weblogic.jndi.WLInitialContextFactory");
    p.put(Context.PROVIDER_URL, "t3://192.168.254.3:7001");
    p.put(Context.SECURITY_PRINCIPAL, "user");
    p.put(Context.SECURITY_CREDENTIALS, "password");
    InitialContext ctx = new InitialContext(p);
    the exception is
    javax.servlet.ServletException: javax.naming.AuthenticationException
    [Root exception is java.lang.SecurityException: attempting to add an
    object which is not an instance of java.security.Principal to a
    Subject's Principal Set]
    at
    org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImp
    l.java:457)
    at
    org.apache.jsp.test_0002dremote$jsp._jspService(test_0002dremote$jsp.java:71
    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:107)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    at
    org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.ja
    va:201)
    atorg.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:381)
    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:473)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    at
    org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Application
    FilterChain.java:247)
    at
    org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterCh
    ain.java:193)
    at
    org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.ja
    va:243)
    at
    org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5
    66)
    at
    org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
    >>
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
    at
    org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.ja
    va:190)
    at
    org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5
    66)
    at
    org.apache.catalina.valves.CertificatesValve.invoke(CertificatesValve.java:2
    46)
    at
    org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5
    64)
    at
    org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
    >>
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
    at
    org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2347)
    at
    org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180
    at
    org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5
    66)
    at
    org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.
    java:170)
    at
    org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5
    64)
    at
    org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:170
    at
    org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5
    64)
    at
    org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:468)
    at
    org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5
    64)
    at
    org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
    >>
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
    at
    org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java
    :174)
    at
    org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5
    66)
    at
    org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
    >>
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
    at
    org.apache.catalina.connector.http.HttpProcessor.process(HttpProcessor.java:
    1027)
    at
    org.apache.catalina.connector.http.HttpProcessor.run(HttpProcessor.java:1125
    at java.lang.Thread.run(Thread.java:536)
    root cause
    com.realty.remoteservice.RemoteServiceException:
    javax.naming.AuthenticationException [Root exception is
    java.lang.SecurityException: attempting to add an object which is not an
    instance of java.security.Principal to a Subject's Principal Set]
    at
    com.realty.remoteservice.EjbService.addListingAgent(EjbService.java:43)
    at com.realty.remoteservice.EjbService.main(EjbService.java:23)
    at
    org.apache.jsp.test_0002dremote$jsp._jspService(test_0002dremote$jsp.java:61
    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:107)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    at
    org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.ja
    va:201)
    atorg.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:381)
    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:473)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    at
    org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Application
    FilterChain.java:247)
    at
    org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterCh
    ain.java:193)
    at
    org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.ja
    va:243)
    at
    org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5
    66)
    at
    org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
    >>
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
    at
    org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.ja
    va:190)
    at
    org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5
    66)
    at
    org.apache.catalina.valves.CertificatesValve.invoke(CertificatesValve.java:2
    46)
    at
    org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5
    64)
    at
    org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
    >>
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
    at
    org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2347)
    at
    org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180
    at
    org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5
    66)
    at
    org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.
    java:170)
    at
    org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5
    64)
    at
    org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:170
    at
    org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5
    64)
    at
    org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:468)
    at
    org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5
    64)
    at
    org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
    >>
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
    at
    org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java
    :174)
    at
    org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5
    66)
    at
    org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
    >>
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
    at
    org.apache.catalina.connector.http.HttpProcessor.process(HttpProcessor.java:
    1027)
    at
    org.apache.catalina.connector.http.HttpProcessor.run(HttpProcessor.java:1125
    at java.lang.Thread.run(Thread.java:536)
    nested exception is:
    javax.naming.AuthenticationException. Root exception is
    java.lang.SecurityException: attempting to add an object which is not an
    instance of java.security.Principal to a Subject's Principal Set
    at javax.security.auth.Subject$SecureSet.add(Subject.java:1071)
    at
    weblogic.common.internal.BootServicesStub.writeUserInfoToSubject(BootService
    sStub.java:72)
    at
    weblogic.common.internal.BootServicesStub.authenticate(BootServicesStub.java
    :80)
    at
    weblogic.security.acl.internal.Security.authenticate(Security.java:108)
    at
    weblogic.jndi.WLInitialContextFactoryDelegate.pushUser(WLInitialContextFacto
    ryDelegate.java:461)
    at
    weblogic.jndi.WLInitialContextFactoryDelegate.newContext(WLInitialContextFac
    toryDelegate.java:316)
    at
    weblogic.jndi.WLInitialContextFactoryDelegate.getInitialContext(WLInitialCon
    textFactoryDelegate.java:288)
    at
    weblogic.jndi.WLInitialContextFactoryDelegate.getInitialContext(WLInitialCon
    textFactoryDelegate.java:203)
    at
    weblogic.jndi.WLInitialContextFactory.getInitialContext(WLInitialContextFact
    ory.java:124)
    atjavax.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.(InitialContext.java:195)
    at
    com.realty.util.RealtyContextFactory.create(RealtyContextFactory.java:25)
    at
    com.realty.remoteservice.EjbService.addListingAgent(EjbService.java:36)
    at com.realty.remoteservice.EjbService.main(EjbService.java:23)
    at
    org.apache.jsp.test_0002dremote$jsp._jspService(test_0002dremote$jsp.java:61
    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:107)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    at
    org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.ja
    va:201)
    atorg.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:381)
    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:473)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    at
    org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Application
    FilterChain.java:247)
    at
    org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterCh
    ain.java:193)
    at
    org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.ja
    va:243)
    at
    org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5
    66)
    at
    org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
    >>
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
    at
    org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.ja
    va:190)
    at
    org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5
    66)
    at
    org.apache.catalina.valves.CertificatesValve.invoke(CertificatesValve.java:2
    46)
    at
    org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5
    64)
    at
    org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
    >>
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
    at
    org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2347)
    at
    org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180
    at
    org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5
    66)
    at
    org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.
    java:170)
    at
    org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5
    64)
    at
    org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:170
    at
    org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5
    64)
    at
    org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:468)
    at
    org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5
    64)
    at
    org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
    >>
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
    at
    org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java
    :174)
    at
    org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5
    66)
    at
    org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
    >>
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
    at
    org.apache.catalina.connector.http.HttpProcessor.process(HttpProcessor.java:
    1027)
    at
    org.apache.catalina.connector.http.HttpProcessor.run(HttpProcessor.java:1125
    at java.lang.Thread.run(Thread.java:536)
    Dimitri
    Dimitri

  • 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 neede very very urgently ... to clear the report from Cache.....

    Hello all,,,
    In my project iam using crystsal report for eclipse to generate reports.
    Iam using a .jsp page to call my report.(which i got it from the examples of CRE).
    The name of my jsp page is poi.jsp
    The name of my Crystal report is CrystalReport2.rpt
    My problem is this....
    when i run the report first time i can see my poi.jsp page and user can submit
    the parameter and based on the users parameter the report is generated..(ITs working absoultely fine)
    but when the user runs the report again, its not showing the parameter page (i.e user cannot see poi.jsp)
    rather its showing the old generated report.
    When i tried using session.invalidate and session.removeAttribute it was showing me the poi.jsp page
    but the problem is when the user clicks on the print icon or any icon on the report its just
    showing the poi.jsp page...
    When the user closes the report or when the clicks on the button to generate the report it should
    show the parameter page (poi.jsp).how can i solve this problem???
    the code what iam using is as follows..( got it from the examples of CRE - database login )
    Object reportSource = session.getAttribute("reportSource");
    if (reportSource == null)
    String report = "CrystalReport2.rpt";
    ReportClientDocument reportClientDoc = new ReportClientDocument();
    reportClientDoc.open(report, 0);
    reportSource = reportClientDoc.getReportSource();
    session.setAttribute("reportSource", reportSource);
    ConnectionInfos connInfos = new ConnectionInfos();
    IConnectionInfo connInfo1 = new ConnectionInfo();
    connInfo1.setUserName("USER");
    connInfo1.setPassword("USER");
    connInfos.add(connInfo1);
    CrystalReportViewer viewer = new CrystalReportViewer();
    viewer.setReportSource(reportSource);
    viewer.setEnableLogonPrompt(false);
    viewer.setDatabaseLogonInfos(connInfos);
    if (session.getAttribute("refreshed") == null)
    viewer.refresh();
    session.setAttribute("refreshed", "true");
    viewer.setOwnPage(true);
    viewer.processHttpRequest(request, response, getServletConfig().getServletContext(), null);
    //session.removeAttribute("refreshed");
    //session.invalidate();
    thanks in advance
    regards
    jack

    As far as parameter refresh is concerned add in your code
    viewer.setHasRefreshButton(true)
    refresh button is appeared on crystal report toolbar and you can use this button instead of explorer refrsh button and every time you can add new parameters values.
    Also, if you want to update reportsource in session object. means if user wants to view more than one different reports and want to invalidate reportsource form session.
    add in jsp.
    session.removeAttribute("reportSource");
    Happy programming
    Uzma

  • Please help me very very urgent i am unable to do it from last two months

    i am getting 404 error
    the requested resource is not available
    http://ustca130/Loginportal
    // my web.xml ///
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <web-app xmlns="http://java.sun.com/xml/ns/j2ee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
    version="2.4">
    <display-name>Name for Loginportal</display-name>
    <description>
         This is a simple web application with a source code organization
         based on the recommendations of the Application Developer's Guide.
    </description>
    <servlet>
    <servlet-name>Loginportal</servlet-name>
    <servlet-class>com.hp.ifc.install.verify.Loginportal</servlet-class>
    </servlet>
    <servlet-mapping>
    <servlet-name>Loginportal</servlet-name>
    <url-pattern>Loginportal</url-pattern>
    </servlet-mapping>
    </web-app>
    //Loginportal//
    package com.hp.ifc.install.verify;
    import javax.servlet.http.HttpServlet;
    import java.io.IOException;
    import javax.servlet.ServletException;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import javax.servlet.RequestDispatcher;
    import com.hp.ifc.install.database.Loginportalbean;
    * Servlet Class
    * @web.servlet name="Loginportal"
    * display-name="Name for Loginportal"
    * description="Description for Loginportal"
    * @web.servlet-mapping url-pattern="/Loginportal"
    * @web.servlet-init-param name="A parameter"
    * value="A value"
    public class Loginportal extends HttpServlet {
         protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException,IOException
              // TODO Auto-generated method stub
              RequestDispatcher rd;
              String username=req.getParameter("J_USERNAME");
              String password=req.getParameter("J_PASSWORD");
              Loginportalbean lb = new Loginportalbean();
              if(lb.isUservalid(username,password))
                   rd=req.getRequestDispatcher("success.html");
              else
                   rd=req.getRequestDispatcher("fail.html");
    }

    Shouldn't that URL include the name of your web application? Sort of like this:
    http://ustca130/AppName/Loginportal

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

  • Unable to call EJB from servlet

    Fillowing is my ejb module
    package univesity;
    import java.rmi.RemoteException;
    import javax.ejb.*;
    public interface EnrollmentCartHome extends javax.ejb.EJBHome
         EnrollementCartObject create() throws CreateException,RemoteException;
    package univesity;
    import java.rmi.RemoteException;
    public interface EnrollementCartObject extends javax.ejb.EJBObject
         public void addCourse(int courseID) throws RemoteException;
    package univesity;
    import java.rmi.RemoteException;
    import javax.ejb.CreateException;
    import javax.ejb.EJBException;
    import javax.ejb.SessionBean;
    import javax.ejb.SessionContext;
    public class EnrollementCartEJBBean implements SessionBean
         int courseID;
         public void ejbActivate() throws EJBException, RemoteException {
              // TODO Auto-generated method stub
         public void ejbPassivate() throws EJBException, RemoteException {
              // TODO Auto-generated method stub
         public void ejbRemove() throws EJBException, RemoteException {
              // TODO Auto-generated method stub
         public void setSessionContext(SessionContext arg0) throws EJBException,
                   RemoteException {
              // TODO Auto-generated method stub
         public void addCourse(int courseID)
              System.out.println("i am in add course");
              System.out.println("i am in add course--->"+courseID);
         public void ejbCreate() throws CreateException
              System.out.println("i am in ejbCreate");
              courseID=0;
    }ejb-jar.xml
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN"
              "http://java.sun.com/dtd/ejb-jar_2_0.dtd">
              <jndi-name>ejb/EnrollmentCartHome</jndi-name>
    <ejb-jar>
         <description>Simplest Statefull Session Bean</description>
         <display-name>University EJB</display-name>
         <enterprise-beans>
           <session>
             <ejb-name>Enrollement</ejb-name>
             <home>university.EnrollementCartHome</home>
             <remote>university.EnrollementCartObject</remote>
             <ejb-class>university.EnrollementCartEJBBean</ejb-class>
             <session-type>Statefull</session-type>
             <transaction-type>Bean</transaction-type>
           </session>
         </enterprise-beans>
    </ejb-jar>here is my servlet
    package university;
    import javax.naming.InitialContext;
    import javax.servlet.*;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    public class EnrollCourse extends javax.servlet.http. HttpServlet
         public void doGet(HttpServletRequest req,HttpServletResponse res)
         public void doPost(HttpServletRequest req,HttpServletResponse res)
              try {
                        InitialContext ic = new InitialContext();
                        Object objRef = ic.lookup("ejb/EnrollmentCartHome");
                        university.EnrollementCartHome home=(university.EnrollementCartHome)javax.rmi.PortableRemoteObject.narrow(objref, university.EnrollementCartHome.class);
                        university.EnrollementCartObject obj=(university.EnrollementCartObject)home.create();
                        obj.addCourse(5);
              catch (Exception ex)
              { ex.printStackTrace(); }
    }i am getting following error
    java.lang.Error: Unresolved compilation problems:
         university.EnrollementCartHome cannot be resolved to a type
         university.EnrollementCartHome cannot be resolved to a type
         objref cannot be resolved
         university.EnrollementCartHome cannot be resolved to a type
         university.EnrollementCartObject cannot be resolved to a type
         university.EnrollementCartObject cannot be resolved to a type
         university.EnrollCourse.doPost(EnrollCourse.java:24)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
         org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)

    Thanks for your continuous reply
    i solved all problems i have posted but now i am facing new problem that "EJB is already registerd"
    giving you stack trace
    15:21:22,109 WARN  [ServiceController] Problem creating service jboss.j2ee:module=UniversityProjectEJBModule.jar,uid=22223562,service=EjbModule
    javax.management.InstanceAlreadyExistsException: jboss.j2ee:jndiName=ejb/EnrollmentCartHome,service=EJB already registered.
         at org.jboss.mx.server.registry.BasicMBeanRegistry.add(BasicMBeanRegistry.java:761)
         at org.jboss.mx.server.registry.BasicMBeanRegistry.registerMBean(BasicMBeanRegistry.java:225)
         at sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
         at java.lang.reflect.Method.invoke(Unknown Source)
         at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
         at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
         at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:133)
         at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
         at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:142)
         at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
         at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
         at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
         at org.jboss.mx.server.MBeanServerImpl$3.run(MBeanServerImpl.java:1422)
         at java.security.AccessController.doPrivileged(Native Method)
         at org.jboss.mx.server.MBeanServerImpl.registerMBean(MBeanServerImpl.java:1417)
         at org.jboss.mx.server.MBeanServerImpl.registerMBean(MBeanServerImpl.java:376)
         at org.jboss.ejb.EjbModule.createService(EjbModule.java:373)
         at org.jboss.system.ServiceMBeanSupport.jbossInternalCreate(ServiceMBeanSupport.java:260)
         at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMBeanSupport.java:243)
         at sun.reflect.GeneratedMethodAccessor3.invoke(Unknown Source)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
         at java.lang.reflect.Method.invoke(Unknown Source)
         at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
         at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
         

Maybe you are looking for

  • Mac keeps trying to connect to a server when opening excel

    i worked for a week at a production house and they had me log into their server to access files that we all used.  obviously i forgot to eject their server before i left and instead just closed my computer and left.  now, since Lion makes all documen

  • Changing user's name as shown on iPod

    My daughter has given me her old iPod following me giving her a new one. When I open it up to download from iTunes, it shows her name. How do I change that name to mine? Thanks for any help.

  • Could not start Service Broker for database id

    I am getting this message in the SQL Server error log: Could not start Service Broker for database id: 10. A problem is preventing SQL Server from starting Service Broker. Check the SQL Server error log for additional messages. It appears even when t

  • Where do i see which computer to deauthorize

    i need to authorize my new computer how do I see which one to de authorize

  • Moving or Saving Tabbed Windows

    Using Safari 1.3.4 on OS 10.3.9 and 2.0.4 on OS 10.4.7. I noticed a feature in Firefox and wanted to know if it exists in Safari, as well as a feature I wish Safari had, or if it has, I'd like to know. FF appears to allow you to re-order the tabs in