EJB Lookup Frustration

Hello,
We have 2 OC4J instances deployed in our application. Both the OC4J instances run on seperate machines on seperate Oracle J2EE (Standalone) installations. One of the OC4J instances has an EJB application which we try to call from the other OC4J instance. We use normal Java Context lookups with the following code:
env                     =      new Hashtable();
               //env.put(Context.INITIAL_CONTEXT_FACTORY, "com.evermind.server.rmi.RMIInitialContextFactory");
               env.put(Context.INITIAL_CONTEXT_FACTORY,InitialDataLoader.getPropertyValue("INITIAL_CONTEXT_FACTORY"));
               env.put(Context.SECURITY_PRINCIPAL, "admin");
               env.put(Context.SECURITY_CREDENTIALS, "welcome");
               //env.put(Context.PROVIDER_URL, "ormi://localhost:3108/fcxmlg38");
               env.put(Context.PROVIDER_URL,InitialDataLoader.getPropertyValue("PROVIDER_URL"));
               env.put("dedicated.connection","true");
               System.out.println("environment connection is*********"+env);
               Log.warn("hashtable of the context is****"+env,"UtilityWarn.log");
               ctx                     =      new InitialContext(env);
Object obj = ctx.lookup(strFlexmlJndiName);
Log.warn("This Object is*****"+obj,"UtilityWarn.log");
aIFEjbProcHome = (IFEjbProcHom)PortableRemoteObject.narrow(obj,IFEjbProcHom.class);
aIFEjbProcRem = aIFEjbProcHome.create();
The point is we get the handle to the remote...but after a period of inactivity when the application tries to access the EJB , the application hangs....on start and stop of the OC4J instances, we get the handle again...This is turning out to be frustrating as there seems to be no logic to this kind of "un"persistent connection...any kind of help would be gladly appreciated...thanks.....
a very frustrated developer....VJ

Hello,
The version of the Oracle Application Server is:
9.0.2.0.0. So using "opmn:ormi" is out of the question
The problem seems to crop up pretty often. "dedicated.rmicontext=true" is for version 9.0.3 and above not for Base Release. We have exhausted all options of maintaining a dedicated connection...because it behaves very wierdly....A new problem is that the first hit after an inactivity results in a hang ...but subsequent hits give us a proper response from the EJB....This is really getting frustrating as I am just not able to predict the reason for this uncertainty....
Can someone please enlighten me as I have started going back to my basics in EJB to actaully understand how this stuff works...
Thanks....Still very frustrated to the core....
VJ

Similar Messages

  • EJB lookup on Remote Server or different domain fails

    Hi,
    I am having two different domain (domain1,domain2) respectvely. My ABC.ear j2eee application is deployed on domain2 and its iiop port is 33703.In domain1 i have xyz.war (web application) and it's IIOP port is 3700 .In xyz.war i am having CallEJB.jsp file.In this Jsp file i want to lookup an EJB Service called PaymentEJB(JNDI Name is ejb/PaymentEJB).
    The code is below
    InitialContext context=new InitialContext();
    Object objRef=context.lookup("corbaname:iiop:andaman:33703#ejb/PaymentEJB");
    I am getting the following error.
    [#|2005-12-14T16:42:03.422+0530|SEVERE|sun-appserver-pe8.1_02|javax.enterprise.resource.corba._DEFAULT_.rpc.transport|_ThreadID=11;|"IOP00410216: (COMM_FAILURE) Unable to create IIOP listener on the specified host/port: all interfaces/3700"
    org.omg.CORBA.COMM_FAILURE: vmcid: SUN minor code: 216 completed: No
    at com.sun.corba.ee.impl.logging.ORBUtilSystemException.createListenerFailed(ORBUtilSystemException.java:2661)
    My doubt is
    1.While starting domain1 and domain2 iiop listeners are started on the port 3700 and 33703.in that case why EJB lookup tries to create listener on one more time.
    2.I am looking the 33703 port only.but it tries to create port on 3700 why?
    3.It was working till JES2005Q1.Is there any patch i need to install? or i need to change anything in my code.
    I am frustrated with this error for past one week.I will be happy if some body will give me the peace of mind(thru some solution).

    Hi
    I found the solution for this issue.
    To lookup the EJB applications in web component,we should not set any thing in the Initial Context.i.e the lookup should be
    InitialContext initContext=new InitialContext();
    Object objref = initContext.lookup("java:comp/env/ejb/"+ejbName_);
    This will get you the Home object of the EJB you are looking.
    In your web.xml you should have the entry like below.(Just replace the ejbname which you are looking for)
    <ejb-ref>
    <ejb-ref-name>ejb/GetAssertionEJB</ejb-ref-name>
    <ejb-ref-type>Session</ejb-ref-type>
    <home>com.ssertion.GetAssertionHome</home>
    <remote>com.assertion.GetAssertionRemote</remote>
    </ejb-ref>
    In your sun-wb.xml,you should have the entry like below(Just replace the ejbname which you are looking for)
    <ejb-ref>
    <ejb-ref-name>ejb/GetAssertionEJB</ejb-ref-name>
    <jndi-name>corbaname:iiop:<hostname>:<iiopport>#ejb/GetAssertionEJB</jndi-name>
    </ejb-ref>
    Hope this works.

  • JNDI EJB Lookup fails on Remote Server

    Hi,
    I am having two different domain (domain1,domain2) respectvely. My ABC.ear j2eee application is deployed on domain2 and its iiop port is 33703.In domain1 i have xyz.war (web application) and it's IIOP port is 3700 .In xyz.war i am having CallEJB.jsp file.In this Jsp file i want to lookup an EJB Service called PaymentEJB(JNDI Name is ejb/PaymentEJB).
    The code is below
    InitialContext context=new InitialContext();
    Object objRef=context.lookup("corbaname:iiop:andaman:33703#ejb/PaymentEJB");
    I am getting the following error.
    [#|2005-12-14T16:42:03.422+0530|SEVERE|sun-appserver-pe8.1_02|javax.enterprise.resource.corba._DEFAULT_.rpc.transport|_ThreadID=11;|"IOP00410216: (COMM_FAILURE) Unable to create IIOP listener on the specified host/port: all interfaces/3700"
    org.omg.CORBA.COMM_FAILURE: vmcid: SUN minor code: 216 completed: No
    at com.sun.corba.ee.impl.logging.ORBUtilSystemException.createListenerFailed(ORBUtilSystemException.java:2661)
    My doubt is
    1.While starting domain1 and domain2 iiop listeners are started on the port 3700 and 33703.in that case why EJB lookup tries to create listener on one more time.
    2.I am looking the 33703 port only.but it tries to create port on 3700 why?
    3.It was working till JES2005Q1.Is there any patch i need to install? or i need to change anything in my code.
    I am frustrated with this error for past one week.I will be happy if some body will give me the peace of mind(thru some solution).

    http://docs.sun.com/source/819-0079/dgjndi.html
    This might help.

  • EJB lookup works in embedded OC4J but not stand-alone

    I use JDeveloper 9.0.3.1 to develop a combined web & EJB application. The EJBs are deployed on a 9.0.3 iAS server on a different machine.
    The EJB lookup is in a helper class that's called by the servlet. For EJB lookup, I use the class "com.evermind.server.rmi.RMIInitialContextFactory" as described by the OC4J servlet guide (http://download-uk.oracle.com/docs/cd/A97688_10/generic.903/a97680/develop.htm#1003973). So my code looks like this:
    Hashtable map = new Hashtable();
    map.put(Context.INITIAL_CONTEXT_FACTORY, "com.evermind.server.rmi.RMIInitialContextFactory");
    map.put(Context.PROVIDER_URL, "ormi://server:port/app-business");
    map.put(Context.SECURITY_PRINCIPAL, "admin");
    map.put(Context.SECURITY_CREDENTIALS, "password");
    map.put("dedicated.rmicontext", "true");
    InitialContext context = new InitialContext(map);
    Object thing = context.lookup("MyEjb");
    EJBHome feedback = (EJBHome)PortableRemoteObject.narrow(thing, "com.company.ejb.MyEjbHome");
    The last insert into the map (map.put("dedicated.rmicontext", "true");) wasn't mentioned neither in the servlet guide nor the EJB one. But without it, I'd always get some "domain is null" error.
    Now this code above works flawlessly in the embedded OC4J of JDeveloper. But it always hangs in the "Object thing = context.lookup("MyEjb");" line when executed either in a stand-alone OC4J (the one from JDeveloper launched through the batch file in [JDeveloper directory]\jdev\bin\start_oc4j.bat) or in the OC4J in iAS.
    Does anybody know why this happens or how to fix it? I know that there are other ways of EJB lookup in servlets but since we also have plain Java classes for testing purposes that access EJBs, this seemed like the simplest thing to do for both Java classes and servlets.

    I was referring to the java client case where this optoin is not required. In general for web clients one doesn't use the rmi initial context to find the bean. This is because the bean and the webclient are both packaged in the same application. One defines the ejb-ref in the web.xml for the bean and then looks it using the default initial context. Something like
    Context ctx = new InitialCOntext();
    ctx.lookup("bean ejb-ref-name");
    However if you must use rmi for accessing the bean from the web client then the dedicated connection property is required.
    For java clients you would setup the rmi context environment.
    Since you are trying to use a common utility class for both java and webclient I would recommend that you look into packaging the java client as a j2ee application client. Basically in that case you would be able to define a ejb-ref in the aplication-client.xml and use the default initial context in code for both the cases.
    Hope that helps
    Dhiraj

  • EJB lookup returned stub from a different classloader.

    I've written an EJB for doing authenitcation. This EJB is accessed by an security-mbean (BEA's login module).
    - The EJB is deployed in an EAR.
    - The EJB-stubs are extracted and is included as part of the MBEAN Jar.
    When I hit a webapp causing the EJB lookup to occur, the stub object returned is created by the webapp's classloader. This cause a ClassCastException when trying to cast the returned home interface into the home interface of the MBEAN's classloader.
    Note that all this is happening on the same BEA server running WLS8.1.
    I don't want to put the EJB jar on the system classpath so I can redeploy the EJB, the Application's EAR and the MBEAN to a cluster.
    -alex

    Robert Greig <[email protected]> wrote:
    Thanks for responding to my question, which newsgroup is more appropriate for
    my line of question?
    But before I move this thread, I would like to add:
    I've already handled the recursion problem on top of the ejb-lookup before JNDI
    becomes avaliable (while doing server startup) problem.
    The advantage with the EJB model is this. By changing the host/port configuration,
    I can switch between a local-authentication server or a remote provide authentication
    server network configuration.
    If I were to include the necessary classes in the mbean JAR from our application,
    there maybe resources issues since I now have 2 classloaders loading my server-portion
    of classes. Not sure how that will workout with resources and all. This model
    has the disadvantage of any classes I have in the mbean JAR will require updates
    outside my EAR. This wroks against the EAR deployment model.
    -alex
    Alex Cheung wrote:
    I've written an EJB for doing authenitcation. This EJB is accessedby an security-mbean (BEA's login module).
    - The EJB is deployed in an EAR.
    - The EJB-stubs are extracted and is included as part of the MBEANJar.
    This isn't a good approach. You are pretty much stuffed mainly for the
    reasons you outline.
    Also note that if you continue to go down this road you will have to
    handle the potential recursion (i.e accessing an EJB will invoke a
    security call to your provider!).
    Why do you need to implement this as an EJB? The main advantages of EJBs
    are security and container managed transactions neither of which is
    relevant here surely?
    Robert

  • EJB lookup from another EJB server

    Hi people,
    I have two application servers on two different computers. One
    of them contains an EJB, which I need to access from another EJB
    server. I know that I can achieve this using RMI, but will then
    security and transaction contexts be propagated to the called
    EJB?
    Sincerely,
    Sergei Batiuk.

    Here is the solution posted on another forum:
    [email protected] Dec 8, 6:03 am show options
    Newsgroups: ibm.software.websphere.studio
    From: [email protected]
    Date: 8 Dec 2004 06:03:04 -0800
    Local: Wed, Dec 8 2004 6:03 am
    Subject: Re: EJB lookup on from one server to another does not work
    Eric,
    I dealt with this same problem trying to run 2 local servers (websphere
    test servers), using 2 separate WSAD 5.1.2 workspaces. Running on 1
    server I have an application that contains an EJB, and running on the
    other server is an application that uses an access bean to make a
    remote call to my EJB, running on my other server. I too repeately
    received the "NameNotFoundException" when trying to lookup my EJB home
    reference.
    What you have to do to get around this is to modify the server
    configuration of the application that contains the EJB that you are
    attempting to call remotely. You must open the the server.wsi file for
    the server that is running the EJB and go to the "Configuration" tab.
    You must check the "Enable administrative console". Once this is
    complete, start your server. When it is started, right click on the
    server, and select "run administrative console". In the admin console,
    select
    servers -> application servers -> <your server> -> end points ->
    bootstrap address. For "host" you must change "localhost" to either
    your ip address or computer name (ive only tried my ip, but your
    computer name should work too). When building your properties to get
    the initial context, make sure you use
    "env.put(Context.PROVIDER_URL, "corbaloc:iiop:<the ip or computer name
    listed as the bootstrap host of server running ejb>:<the port listed as
    the bootstrap port of server running ejb, which is 2809 in your case>
    Restart your server and things should work.

  • EJB lookup with weblogic?

    Hi, experts
    I have a question with the EJB lookup in weblogic, this is a question which has been asked many times when I google that. But likely there is not a clearly answer, so maybe I can get the answer from the experts?
    If we lookup an EJB, we need to use the "mappedName#interface_name" as the query name used in lookup method, Is this the only way that we query the EJB? Or is there any other ways we can simply the query name?
    Thanks for your time.

    Try posting in the forum dedicated to WLS EJB - WebLogic Server - EJB
    Also, why don't you explain what you're looking for exactly, how would you like to look up the EJB's, or are you asking for a best practice? Describing your use case will help get the best answer, right now your question is extremely generic.

  • Error while invoking EJB lookup

    Hello
    Outline:
    Two DCs, one containing some JPA code, exposing method as EJB. The other generated as WS skeleton from ESR.
    Code in WS method:
    TrainingSBLocal bean = (TrainingSBLocal) context.lookup("app.company.pl/training2ear/LOCAL/TrainingSBBean"); 
    causes:
    ClassCastException: class com.sap.engine.services.jndi.implclient.ClientContext:service:naming_com.sap.engine.boot.loader.ResourceMultiParentClassLoader_e5025_alive incompatible with interface pl.company.app.zss_prototyp.TrainingSBLocal:app.company.pl/training2ear_com.sap.engine.boot.loader.ResourceMultiParentClassLoader_1b7731b_alive
    ("at" replaced by _ )
    WS DC is dependent on EJB one in Design, Deploy and Runtime.
    Any suggestions?
    Thanks in advance.
    Regards
    Maciej

    Ok, I got it working now, I found there's an OC4J_Client.zip not just oc4jClient.jar which has to be included in the classpath.
    Thanks

  • Problem in ejb lookup

    Hi,
    I am new to J2EE and JDeveloper. I am trying to manually migrate one Oracle Form to J2EE. I have created two jsps. First JSP creates UI, does all the validation and then calls second jsp for processing. In second jsp I am trying to get homeinterface for ejb on which I will call database operations method. The problem I am facing is I am not getting what exactly should be entry for lookup(calling lookup on initail context). I tried to locate it in orion-ejb-jar.xml and also in ejb-jar.xml but didn't get it. Pls help me regarding the same.
    Regds,
    Sampada

    Well this is possible only in JDeveloper.
    In the web.xml, specify the details as
    <ejb-ref>
    <ejb-ref-name>ejb/EmployeeHome</ejb-ref-name>
    <ejb-ref-type>Session</ejb-ref-type>
    <home>EmployeeHome</home>
    <remote>Employee</remote>
    <ejb-link>Employee</ejb-link>
    </ejb-ref>
    </web-app>
    In the orion-ejb-jar.xml, specify the following
    <orion-ejb-jar>
    <enterprise-beans>
    <session-deployment max-instances="-1" name="Employee" location="ejb/EmployeeHome"/>
    <entity-deployment max-instances="-1" name="EmpEB" copy-by-value="false" data-source="jdbc/EmpDS" exclusive-write-access="false"/>
    </enterprise-beans>
    In the snippet above, i access a session bean, you change this according to ur settings.
    The client code has been already posted above.
    regards,
    Sachin

  • EJB lookup in a cluster (DNS names to servers mapping)

              I am using weblogic6.0 to setup a object clusters. Currently I have 2 physical
              machine each running one object server.
              I have a servlet in the web tier (it is not part of the cluster) that lookups
              the EJB's.
              From the documentation, I understand intialContext lookup should use one DNS name
              that maps to both the object servers.
              My question is how can I setup that ?
              - I tried the following, I am not sure if this is right
              I created a virtualhost with
              name: MyVirtualHost
              virtual host names : MyCluster (this is name of the cluster I had setup )
              Targets : MyCluster
              I tried looking up with
              t3//MyVirtualHost:7001 and t3//MyCluster:7001
              No luck in both the cases !!!!!
              Note : I restarted my weblogic servers after
              creating the virtual host. But I did not reboot my machine ( don't know if this
              is required )
              Please help !!!!
              Thanks
              Abi -
              

              You need add an entry in Domain Name Server to include your host1 and host2, and
              use it in your JNDI lookup. Or you can do:
              t3://host1,host2:7001
              Both ways should work. Will load balancing to two JNDI trees.
              Jim Zhou.
              "Abinesh Puthenpurackal" <[email protected]> wrote:
              >
              >I am using weblogic6.0 to setup a object clusters. Currently I have 2
              >physical
              >machine each running one object server.
              >
              >I have a servlet in the web tier (it is not part of the cluster) that
              >lookups
              >the EJB's.
              >
              >From the documentation, I understand intialContext lookup should use
              >one DNS name
              >that maps to both the object servers.
              >
              >My question is how can I setup that ?
              > - I tried the following, I am not sure if this is right
              > I created a virtualhost with
              > name: MyVirtualHost
              > virtual host names : MyCluster (this is name of the cluster I had
              >setup )
              > Targets : MyCluster
              >
              >I tried looking up with
              >t3//MyVirtualHost:7001 and t3//MyCluster:7001
              >
              >No luck in both the cases !!!!!
              >
              >Note : I restarted my weblogic servers after
              >creating the virtual host. But I did not reboot my machine ( don't know
              >if this
              >is required )
              >
              >Please help !!!!
              >
              >Thanks
              >Abi -
              >
              

  • Ejb lookup and oc4j container startup

    I have a servlet that is set to auto start on container startup that does a lookup on a ejb in another container. jndi locates the ejbhome but fails to load the class for the ejb home. It knows the name of the class but the classloader cannot find it. This same servlet works fine after the container has started up.
    It feel the problem is a classloader problem or a restriction by oracle. Any help is appreciated.
    Why can't the OC4J default application that auto starts servlets at container startup not find the ejbhome class?
    David Jacobs

    We have previously done it, but it only worked when we are using in 10g AS R1. But now, we are porting to R2, but it doesn't work. We didn't do any other things, just a simple lookup using the url, context factory. In R1 it worked fine, in R2, we are encountering the same, NameNotFoundException. Hope someone could help us also with this. Another thing, when we are using ormi://<rest of url>, it doesn't return any exception and our application hangs, but if we use opmn:ormi://<rest of URL>, that's the time it throws the NameNotFoundException. In R1, we didn't have any problems.

  • EJB lookup failing in DCM managed Oracle AS clustering

    Hi
    My purpose is to test DCM managed Oracle AS clustering:
    For that I have two Oracle Application servers installed in two different machines with
    Version: 10.1.2.0.2 and Installation Type as J2EE and Web Cache
    I created an OracleAS File-based Farm and associated both the instances of AS to the cluster. Then I created One OC4J instance called InstanceOne on the cluster and deployed my Application ear onto the cluster.I also configued web Application and EJB Application State Replication the with OracleAS Cluster (OC4J).
    My Application has one Ejb module and a web module. My stateless Session bean is Spring framework implemented and I am trying to load the Spring Context lookup from the Struts Action Class by using WebApplicationContext.
    My spring context looks like this
    <bean id="jndiTemplate"
    class="org.springframework.jndi.JndiTemplate">
    <property name="environment">
    <props>
    <prop key="java.naming.factory.initial">com.evermind.server.rmi.RMIInitialContextFactory</prop>
    <prop key="java.naming.provider.url">opmn:ormi://<server host>:InstanceOne/<Application Name></prop>
    <prop key="java.naming.security.principal">oc4jadmin</prop>
    <prop key="java.naming.security.credentials">admin</prop>
    <prop key="oracle.j2ee.naming.cache.timeout">30</prop>
    <prop key="Dedicated.Connection">yes</prop>
    <prop key="Dedicated.RMIcontext">false</prop>
    <prop key="LoadBalanceOnLookup">true</prop>
    </props>
    </property>
    </bean>
    <bean id="service"
    class="org.springframework.ejb.access.SimpleRemoteStatelessSessionProxyFactoryBean">
    <property name="jndiTemplate">
                   <ref bean="jndiTemplate"/>
              </property>
    <property name="jndiName">
    <value>MyServiceEJB</value>
    </property>
    <property name="cacheHome">
    <value>false</value>
    </property>
    <property name="refreshHomeOnConnectFailure">
    <value>true</value>
    </property>
    <property name="businessInterface">
    <value>com.my.springejb.MyBusinessInterface</value>
    </property>
    </bean>
    When I give only one server lookup like
    opmn:ormi://<server host1>:InstanceOne/<Application Name>
    then lookup is working, But by giving two servers in cluster, like opmn:ormi://<server host1>:InstanceOne/<Application Name>, opmn:ormi://<server host2>:InstanceOne/<Application Name>
    I am getting error like this
    06/12/01 19:27:41 java.lang.NumberFormatException: For input string: "InstanceOne"
    06/12/01 19:27:41 at java.lang.NumberFormatException.forInputString(NumberFormatException.java:48)
    06/12/01 19:27:41 at java.lang.Integer.parseInt(Integer.java:468)
    06/12/01 19:27:41 at java.lang.Integer.parseInt(Integer.java:518)
    06/12/01 19:27:41 at com.evermind.server.rmi.RMIInitialContextFactory.getInitialContext(RMIInitialContextFactory.java:237)
    06/12/01 19:27:41 at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:662)
    06/12/01 19:27:41 at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:243)
    06/12/01 19:27:41 at javax.naming.InitialContext.init(InitialContext.java:219)
    06/12/01 19:27:41 at javax.naming.InitialContext.<init>(InitialContext.java:195)
    06/12/01 19:27:41 at org.springframework.jndi.JndiTemplate.createInitialContext(JndiTemplate.java:105)
    06/12/01 19:27:41 at org.springframework.jndi.JndiTemplate.execute(JndiTemplate.java:83)
    06/12/01 19:27:41 at org.springframework.ejb.access.SimpleRemoteStatelessSessionProxyFactoryBean.create(SimpleRemoteStatelessSessionProxyFactoryBean.java:19)
    My intension of testing is, if I make one server instance (InstanceOne) down then my lookup should divert all ejb calls to the other server in the cluster, which is not happening at all, and I am getting Server SHUT DOWN exception in the server.
    Can anybody please let me know, whether the approach is correct and is there any problem with Spring lookup which does not support multiple host lookup or anything I am missing in my steps, as I am following the Oracle Application Server High Availability Guide 10g Release 2 (10.1.2)

    you can find an running sample from :
    http://javahowto.blogspot.com/2007/12/calling-weblogic-ejb-3-from-jruby-and.html
    In weblogic, local ejb don't appear in the jndi tree, but , it can be founded ...
    It works into 10.0 and 10.3
    Cheers !

  • EJB lookup via JNDI results in java.lang.NoClassDefFoundError

    Hello,
    I have created and deployed an EJB to the WebAS (ver 6.40).  There is no problem looking up the bean via JNDI and calling its methods from a J2EE application - I successfully did this via a servlet.
    However, a JNDI lookup from a Web Dynpro application - on the same server - results in a java.lang.NoClassDefFoundError error.
    The code for the JNDI lookup is identical in either case.
    Any thoughts?

    Hello,
    I am calling ejb from .jsp use following code
    Properties props = new Properties();
    InitialContext ctx = new InitialContext();
    Object ob = ctx.lookup("java:comp/env/ejb/CalculatorBean");
    CalculatorHome home = (CalculatorHome) PortableRemoteObject.narrow(ob, CalculatorHome.class);
    calc = home.create();
    I have a error:
    java.lang.ClassNotFoundException: class com.sap.examples.calculator.beans.CalcProxy : com.sap.engine.services.jndi.persistent.exceptions.NameNotFoundException: Path to object does not exist at calculator, the whole lookup name is java:comp/env/ejb/CalculatorBean
    My ejb-jar.xml is:
    <display-name>
         CalculatorEjb</display-name>
         <enterprise-beans>
              <session>
                   <icon/>
                   <ejb-name>Calculator</ejb-name>
                   <home>com.sap.examples.calculator.CalculatorHome</home>
                   <remote>com.sap.examples.calculator.CalculatorRemote</remote>
                   <local-home>com.sap.examples.calculator.CalculatorLocalHome</local-home>
                   <local>com.sap.examples.calculator.CalculatorLocal</local>
                   <service-endpoint>com.sap.examples.calculator.CalculatorServiceEndpoint</service-endpoint>
                   <ejb-class>com.sap.examples.calculator.CalculatorBean</ejb-class>
                   <session-type>Stateless</session-type>
                   <transaction-type>Container</transaction-type>
                   <ejb-ref>
                        <ejb-ref-name>ejb/CalculatorBean</ejb-ref-name>
                        <ejb-ref-type>Session</ejb-ref-type>
                        <home>com.sap.examples.calculator.CalculatorHome</home>
                        <remote>com.sap.examples.calculator.CalculatorRemote</remote>
                        <ejb-link>Calculator</ejb-link>
                   </ejb-ref>
                   <ejb-local-ref>
                        <description/>
                        <ejb-ref-name>ejb/CalculatorBean</ejb-ref-name>
                        <ejb-ref-type>Session</ejb-ref-type>
                        <local-home>com.sap.examples.calculator.CalculatorLocalHome</local-home>
                        <local>com.sap.examples.calculator.CalculatorLocal</local>
                        <ejb-link>Calculator</ejb-link>
                   </ejb-local-ref>
              </session>
         </enterprise-beans>
    my ejb-j2ee-engine.xml is:
    <?xml version="1.0" encoding="UTF-8"?>
    <ejb-j2ee-engine
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:noNamespaceSchemaLocation="ejb-j2ee-engine.xsd">
         <enterprise-beans>
              <enterprise-bean>
                   <ejb-name>Calculator</ejb-name>
                   <ejb-ref>
                        <ejb-ref-name>ejb/CalculatorBean</ejb-ref-name>
                        <jndi-name>ejb/CalculatorBean</jndi-name>
                   </ejb-ref>
                   <ejb-local-ref>
                        <ejb-ref-name>ejb/CalculatorBean</ejb-ref-name>
                        <jndi-name>ejb/CalculatorBean</jndi-name>
                   </ejb-local-ref>
              </enterprise-bean>
         </enterprise-beans>
    </ejb-j2ee-engine>

  • EJB lookup

    Hi i am using RSA for developing the code and i use the following code for looking up the ejb from the servelt deployed as part of the Same EAR file.
    Object objsessionBeanLookup = m_initialContext.lookup("java:comp/env/ejb/UpdateHistory");
    UpdateHistoryHome homeInter = (UpdateHistoryHome)PortableRemoteObject.narrow(objsessionBeanLookup, test.UpdateHistoryHome.class);
    I see the below exception.
    [5/30/09 0:52:09:625 CDT] 00000020 SystemErr R javax.naming.NameNotFoundException: Name comp/env/ejb not found in context "java:".
    [5/30/09 0:52:09:656 CDT] 00000020 SystemErr R      at com.ibm.ws.naming.ipbase.NameSpace.getParentCtxInternal(NameSpace.java:1767)
    [5/30/09 0:52:09:656 CDT] 00000020 SystemErr R      at com.ibm.ws.naming.ipbase.NameSpace.lookupInternal(NameSpace.java:1083)
    [5/30/09 0:52:09:656 CDT] 00000020 SystemErr R      at com.ibm.ws.naming.ipbase.NameSpace.lookup(NameSpace.java:991)
    [5/30/09 0:52:09:656 CDT] 00000020 SystemErr R      at com.ibm.ws.naming.urlbase.UrlContextImpl.lookup(UrlContextImpl.java:1263)
    [5/30/09 0:52:09:656 CDT] 00000020 SystemErr R      at com.ibm.ws.naming.java.javaURLContextImpl.lookup(javaURLContextImpl.java:384)
    [5/30/09 0:52:09:656 CDT] 00000020 SystemErr R      at com.ibm.ws.naming.java.javaURLContextRoot.lookup(javaURLContextRoot.java:204)
    [5/30/09 0:52:09:656 CDT] 00000020 SystemErr R      at com.ibm.ws.naming.java.javaURLContextRoot.lookup(javaURLContextRoot.java:144)
    [5/30/09 0:52:09:656 CDT] 00000020 SystemErr R      at javax.naming.InitialContext.lookup(InitialContext.java:363)
    [5/30/09 0:52:09:656 CDT] 00000020 SystemErr R      at EjbClient.doGet(EjbClient.java:38)
    How ever the below code works .
    Object objsessionBeanLookup = m_initialContext.lookup("ejb/test/UpdateHistoryHome");
    UpdateHistoryHome homeInter = (UpdateHistoryHome)PortableRemoteObject.narrow(objsessionBeanLookup, test.UpdateHistoryHome.class);
    Can some one explain me what is the difference between the 2 codes ?
    Regards
    RajaniPB

    Which Application Server r u using??
    Sushil

  • Dynamic ejb lookup

    Hello Community,
    Question for u :)
    I have a necessity to dynamically lookup for ejbs' and call methods on them. I am using EJB 1.0 on VAJ. I have the string values of the home, remote and the JNDI names. I need to read those values and lookup for the bean, and call methods. I have this.
    String h = "MyEjbHome";
    String r = "MyEjbRemote";
    String jndi = "MyEjb";
    I need to do something like this..
    //parenthesis on LHS is just to explain the pbm
    (MyEjbHome) home = jndicontextfactory.lookup(jndi, Class.forName(h));
    (MyEjbRemote) remote = home.create();
    remote.myMethod();
    Now if u visualize the problem here, on the left hand side how can i dynamically give the type as (MyEjbHome) or (MyEjbRemote) when all I know is their names which are strings?
    Please share ur knowledge. Thanks

    Hi I tried this and it worked. But the thing is even though I tried PortableRemoteObject.narrow() I was still gettting ClassCastException. So I had to use reflection. Now the code looks something like this, and it works.
    // child home
    Object obj = newContext.lookup(childJNDI);
    // get the create method
    Method m = obj.getClass().getMethod("create", null);
    // create the remote inteface for child
    Object objRemote = m.invoke(obj, null);
    // cast the child remote to the parent remote
    ParentRemote re = (ParentRemote) PortableRemoteObject.narrow(objRemote, ParentRemote.class);
    re.soSomething();
    Thanks much for your help. I appreciate it.
    look at this:
    http://forums.java.sun.com/thread.jsp?forum=13&thread=2
    8593

Maybe you are looking for

  • What is the battery life span of ipad2? How do you know when it is dying?

    I have only a PC and afraid to loose what I have on my iPad if the battery goes dead. This happened to me on iPod when I lost every thing after 5 years of using it.

  • HELP. I'm stuck in the "set-up" screen on may laptop when attempting to view my stuff..

    Hello there, friendly internet stranger! Okay, so I'm having a bit of an issue here... I'm trying to view my iPhone 4S's Files and whatnot on my laptop, (my phone is hooked up to the laptop, btw,) and when I click on the little "iPhone" icon, I am br

  • Web Gallery only shows 10 pictures cs4

    When I try to create a web gallery in Bridge CS4 and/or Photoshop CS4 only ten images are included even though I have selected many more than 10.  I have tried different column and row configurations, I have reinstalled, but it still only includes th

  • Small pictures not displaying

    This is going to be hard to explain being that I have no knowledge about java and cannot attach a screen shot. I have a website that I am going to and there are small pictures that are not showing when I access the page. I spoke to someone that fixed

  • Button not showing up

    Hello, I'm moving an application from one apex instance to another. There is a template based button where the left and right sides of the image are showing up but not the center. Here is the template code: <table class="t3ButtonAlternative3" cellspa