Weblogic 10.3.2 EJB3 Local Interface in POJO/Helper classes

Hi,
I have a jar file containing all EJB's in application & some Helper classes. I want to access Local interfaces of EJBs in those helper classes. Is there any way I can do it? I've gone through Maxence Button & Jay SenSharma 's blogs about accessing Local interface. but it doesn't help. May be these two guys can help me more here.. My requirement is very simple. Just to access local interface in POJO/Helper classes that are in same JAR file as EJB's. I can't get reference with @EJB class level annotation as Helper classes are called independently from MBean services.. not from any EJB or Servlert.
Please if anyone can tell me how do I get reference of local interfaces, that would be really good.
my environment is
Weblogic 10.3.2
EJB3
Regards,
Prasad

Hi,
Just check ...If you want something like mentioned in the below Link with a complete Example:
[http://jaysensharma.wordpress.com/2009/08/16/weblogic-10-3-ejb3-local-lookup-sample/|http://jaysensharma.wordpress.com/2009/08/16/weblogic-10-3-ejb3-local-lookup-sample/]
Regards
Jay SenSharma

Similar Messages

  • Lookup for local interfaces.

    Isn't lookup for local interfaces allowed from web client. I have defined a
    ejb-reference for the bean in my web.xml. When I do a lookup as
    TestBeanLocalHome home = (TestBeanLocalHome)
    ic.lookup("java:comp/env/ejb/TestBeanLocal");
    This statement result in an error
    javax.naming.NameNotFoundException: Unable to resolve
    comp/env/ejb/TestSLSBeanLocal/ Resolved: 'comp/env/ejb'
    Unresolved:'TestBeanLocal' ; remaining name ''
    at
    weblogic.jndi.internal.BasicNamingNode.newNameNotFoundException(BasicNamingN
    ode.java:887)
    at
    weblogic.jndi.internal.BasicNamingNode.lookupHere(BasicNamingNode.java:219)
    at weblogic.jndi.internal.BasicNamingNode.lookup(BasicNamingNode.java:183)
    at weblogic.jndi.internal.BasicNamingNode.lookup(BasicNamingNode.java:191)
    at weblogic.jndi.internal.BasicNamingNode.lookup(BasicNamingNode.java:191)
    at weblogic.jndi.internal.BasicNamingNode.lookup(BasicNamingNode.java:191)
    at weblogic.jndi.internal.WLContextImpl.lookup(WLContextImpl.java:339)
    at
    weblogic.jndi.factories.java.ReadOnlyContextWrapper.lookup(ReadOnlyContextWr
    apper.java:36)
    at
    weblogic.jndi.internal.AbstractURLContext.lookup(AbstractURLContext.java:124
    at javax.naming.InitialContext.lookup(InitialContext.java:345)
    at jsp_servlet.__client._jspService(__client.java:108)
    at weblogic.servlet.jsp.JspBase.service(JspBase.java:27)
    at
    weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java
    :265)
    at
    weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java
    :200)
    at
    weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletCo
    ntext.java:2495)
    at
    weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java
    :2204)
    at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:139)
    at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)
    The same thing works when lookup is done for remote interface.
    Regards,
    Rupesh.

    You need to use "ejb-local-ref" to refer to local interfaces. I meant
    "ejb-local-ref" element was not available in web.xml in Servlet 2.2. They
    were added in Servlet 2.3 specification. So unless your app server is
    Servlet 2.3 compliant it does not need to support references to local
    interfaces in web components (servlets or jsps). Weblogic 6.1 did not seem
    to support them last time I tried.
    -- Anand
    "Rupesh" <[email protected]> wrote in message
    news:[email protected]...
    what do u mean by local interface in web component? its ejb's local
    interfaces and lookups are any way being
    done using ejb-ref and ref mapping are given in weblogic.xml.
    Where does Servlet spec come into the picture?
    Do you mean to say that you can not lookup for local home from a jsp in
    WL6.1?
    Regards,
    Rupesh.
    Anand Byrappagari <[email protected]> wrote in message
    news:[email protected]...
    Are you using Weblogic 6.1? Then local interfaces in web components arenot
    supported. Local interfaces were added only in Servlet 2.3 I think.Weblogic
    6.1 is not completely compliant with Servlet 2.3.
    -- Anand
    "Rupesh" <[email protected]> wrote in message
    news:[email protected]...
    Isn't lookup for local interfaces allowed from web client. I have
    defined
    a
    ejb-reference for the bean in my web.xml. When I do a lookup as
    TestBeanLocalHome home = (TestBeanLocalHome)
    ic.lookup("java:comp/env/ejb/TestBeanLocal");
    This statement result in an error
    javax.naming.NameNotFoundException: Unable to resolve
    comp/env/ejb/TestSLSBeanLocal/ Resolved: 'comp/env/ejb'
    Unresolved:'TestBeanLocal' ; remaining name ''
    at
    weblogic.jndi.internal.BasicNamingNode.newNameNotFoundException(BasicNamingN
    ode.java:887)
    at
    weblogic.jndi.internal.BasicNamingNode.lookupHere(BasicNamingNode.java:219)
    atweblogic.jndi.internal.BasicNamingNode.lookup(BasicNamingNode.java:183)
    atweblogic.jndi.internal.BasicNamingNode.lookup(BasicNamingNode.java:191)
    atweblogic.jndi.internal.BasicNamingNode.lookup(BasicNamingNode.java:191)
    atweblogic.jndi.internal.BasicNamingNode.lookup(BasicNamingNode.java:191)
    atweblogic.jndi.internal.WLContextImpl.lookup(WLContextImpl.java:339)
    at
    weblogic.jndi.factories.java.ReadOnlyContextWrapper.lookup(ReadOnlyContextWr
    apper.java:36)
    at
    weblogic.jndi.internal.AbstractURLContext.lookup(AbstractURLContext.java:124
    at javax.naming.InitialContext.lookup(InitialContext.java:345)
    at jsp_servlet.__client._jspService(__client.java:108)
    at weblogic.servlet.jsp.JspBase.service(JspBase.java:27)
    at
    weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java
    :265)
    at
    weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java
    :200)
    at
    weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletCo
    ntext.java:2495)
    at
    weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java
    :2204)
    at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:139)
    at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)
    The same thing works when lookup is done for remote interface.
    Regards,
    Rupesh.

  • EJB 3.0 Session bean local interface NullPointerException

    I am trying a very simple test of a Stateless EJB 3.0 bean called from a servlet.
    The bean has a local interface, annotated with @Local. The bean implements that interface and is annotated with @Stateless.
    I have a servlet with a variable of the local interface type, annotated with @EJB. The servlet's doGet method invokes the bean's one method using that interface and it works fine.
    BUT if I put the same variable, annotated with @EJB into another class in the web container, it is not injected correctly and I get a NullPointerException on the variable. This class is in WEB-INF/classes with the servlet class, so I assume it is loaded by the same classloader.
    I don't understand why the servlet can instantiate the EJB local interface successfully but another class in the web container can't. I get the same result in OC4J standalone 10.1.3.1 and 10.1.3.3.

    Only managed classes like servlets, filters etc. will have context and EJB references injected into them, and only with servlet version 2.5. A work colleague found the answer in Debu Panda's blog:
    http://debupanda.blogspot.com/2006_10_01_archive.html#116184543992078773
    This behaviour appears to be part of the EJB 3.0 standard.
    The solution is to use JNDI lookup in the client class (POJO) and declare an ejb-local-ref in web.xml.

  • How to get Initial context of Local Interface in weblogic 8.1

    I have developed a local entity bean but i wouldnt able to initial context of that bean
    CAN ANYBODY HELP ME
    bean deployment descriptor
    <?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'>
    <!--
    ** This file was automatically generated by EJBGen 2.16
    ** Build: 20031001-1049
    -->
    <ejb-jar>
    <enterprise-beans>
    <entity>
    <ejb-name>CabinBean</ejb-name>
    <home>my.CabinRemoteHome</home>
    <remote>my.CabinRemote</remote>
    <ejb-class>my.CabinBean</ejb-class>
    <persistence-type>Container</persistence-type>
    <prim-key-class>java.lang.Integer</prim-key-class>
    <reentrant>True</reentrant>
    <cmp-version>2.x</cmp-version>
    <abstract-schema-name>CabinBean</abstract-schema-name>
    <cmp-field>
    <field-name>bedCount</field-name>
    </cmp-field>
    <cmp-field>
    <field-name>deckLevel</field-name>
    </cmp-field>
    <cmp-field>
    <field-name>id</field-name>
    </cmp-field>
    <cmp-field>
    <field-name>name</field-name>
    </cmp-field>
    <cmp-field>
    <field-name>shipId</field-name>
    </cmp-field>
    <primkey-field>id</primkey-field>
    <security-identity>
    <use-caller-identity/>
    </security-identity>
    </entity>
    <entity>
    <ejb-name>CabinLocal</ejb-name>
    <local-home>my.CabinLocalHome</local-home>
    <local>my.CabinLocalLocal</local>
    <ejb-class>my.CabinLocal</ejb-class>
    <persistence-type>Container</persistence-type>
    <prim-key-class>java.lang.Integer</prim-key-class>
    <reentrant>True</reentrant>
    <cmp-version>2.x</cmp-version>
    <abstract-schema-name>CabinLocal</abstract-schema-name>
    <cmp-field>
    <field-name>bedCount</field-name>
    </cmp-field>
    <cmp-field>
    <field-name>deckLevel</field-name>
    </cmp-field>
    <cmp-field>
    <field-name>id</field-name>
    </cmp-field>
    <cmp-field>
    <field-name>name</field-name>
    </cmp-field>
    <cmp-field>
    <field-name>shipId</field-name>
    </cmp-field>
    <primkey-field>id</primkey-field>
    <ejb-local-ref>
    <ejb-ref-name>LocalCabin</ejb-ref-name>
    <ejb-ref-type>Entity</ejb-ref-type>
    <local-home>CabinLocalHome</local-home>
    <local>CabinLocal</local>
    <ejb-link>LocalCabin</ejb-link>
    </ejb-local-ref>
    <security-identity>
    <use-caller-identity/>
    </security-identity>
    </entity>
    </enterprise-beans>
    <assembly-descriptor>
    <container-transaction>
    <method>
    <ejb-name>CabinLocal</ejb-name>
    <method-name>*</method-name>
    </method>
    <trans-attribute>Required</trans-attribute>
    </container-transaction>
    <container-transaction>
    <method>
    <ejb-name>CabinBean</ejb-name>
    <method-name>*</method-name>
    </method>
    <trans-attribute>Required</trans-attribute>
    </container-transaction>
    </assembly-descriptor>
    <ejb-client-jar>EjbClient</ejb-client-jar>
    </ejb-jar>
    ************************************** Client Code****************
    package com;
    import my.CabinBean;
    import my.CabinRemoteHome;
    import my.CabinRemote;
    import javax.naming.InitialContext;
    import javax.naming.Context;
    import javax.naming.NamingException;
    import java.rmi.RemoteException;
    import java.util.Properties;
    import javax.rmi.PortableRemoteObject;
    import weblogic.jndi.Environment;
    public class Test
        public static void main(String args[])
            try{
                 Context context = getInitialContext();
                          Object cab = context.lookup("CabinLocalHome");
                ///**********-- Exception is thrown at this point -******************
                System.out.println("============ done====");
                Context ct = getInitialContext();
                Object ref = ct.lookup("CabinHomeRemote");
                CabinRemoteHome home = (CabinRemoteHome)PortableRemoteObject.narrow(ref,CabinRemoteHome.class);
                //CabinRemote cab = home.create(new Integer(1));
                //cab.setName("Master Suite");
                //cab.setDeckLevel(new Integer(1));
                //cab.setShipId(new Integer(1));
                //cab.setBedCount(new Integer(1));
                Integer pk = new Integer(1);
                CabinRemote cab1 = home.findByPrimaryKey(pk);
                System.out.println("--->>>>>>>> "+cab1.getName());
                System.out.println("--->>>>>>>>  "+cab1.getShipId());
                System.out.println("--->>>>>>>>"+cab1.getBedCount());
                System.out.println("--->>>>>>>>"+cab1.getDeckLevel());
                System.out.println("---");  
          }catch(java.rmi.RemoteException e){e.printStackTrace();}
           catch(javax.naming.NamingException e){e.printStackTrace();}
           //catch(javax.ejb.CreateException e){e.printStackTrace();}
           catch(javax.ejb.FinderException e){e.printStackTrace();}
        public static Context getInitialContext() throws javax.naming.NamingException
           Properties p = new Properties();
           p.put(Context.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.WLInitialContextFactory");
           p.put(Context.PROVIDER_URL,"t3://localhost:7001");
           return new javax.naming.InitialContext(p);
    } ************************************** Error ***********************
    javax.naming.LinkException: [Root exception is javax.naming.LinkException:  [Root exception is javax.naming.NameNotFoundException: remaining name: /app/ejb/myejb.jar#CabinLocal/local-home]; Link Remaining Name: 'null']; Link Remaining Name: 'java:app/ejb/myejb.jar#CabinLocal/local-home'
         at weblogic.rjvm.BasicOutboundRequest.sendReceive(BasicOutboundRequest.java:108)
         at weblogic.rmi.cluster.ReplicaAwareRemoteRef.invoke(ReplicaAwareRemoteRef.java:284)
         at weblogic.rmi.cluster.ReplicaAwareRemoteRef.invoke(ReplicaAwareRemoteRef.java:244)
         at weblogic.jndi.internal.ServerNamingNode_813_WLStub.lookup(Unknown Source)
         at weblogic.jndi.internal.WLContextImpl.lookup(WLContextImpl.java:369)
         at weblogic.jndi.internal.WLContextImpl.lookup(WLContextImpl.java:357)
         at javax.naming.InitialContext.lookup(InitialContext.java:347)
         at com.Test.main(Test.java:27)
    Caused by: javax.naming.LinkException: [Root exception is javax.naming.NameNotFoundException: remaining name: /app/ejb/myejb.jar#CabinLocal/local-home]; Link Remaining Name: 'null'
         at weblogic.jndi.internal.WLNamingManager.getObjectInstance(WLNamingManager.java:98)
         at weblogic.jndi.internal.ServerNamingNode.resolveObject(ServerNamingNode.java:292)
         at weblogic.jndi.internal.BasicNamingNode.resolveObject(BasicNamingNode.java:771)
         at weblogic.jndi.internal.BasicNamingNode.lookup(BasicNamingNode.java:191)
         at weblogic.jndi.internal.RootNamingNode_WLSkel.invoke(Unknown Source)
         at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:477)
         at weblogic.rmi.cluster.ReplicaAwareServerRef.invoke(ReplicaAwareServerRef.java:108)
         at weblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.java:420)
         at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:363)
         at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:144)
         at weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:415)
         at weblogic.rmi.internal.BasicExecuteRequest.execute(BasicExecuteRequest.java:30)
         at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:219)
         at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:178)
    Caused by: javax.naming.NameNotFoundException: remaining name: /app/ejb/myejb.jar#CabinLocal/local-home
         at weblogic.j2eeclient.SimpleContext.resolve(SimpleContext.java:35)
         at weblogic.j2eeclient.SimpleContext.resolve(SimpleContext.java:39)
         at weblogic.j2eeclient.SimpleContext.lookup(SimpleContext.java:57)
         at weblogic.j2eeclient.SimpleContext.lookup(SimpleContext.java:62)
         at weblogic.jndi.factories.java.ReadOnlyContextWrapper.lookup(ReadOnlyContextWrapper.java:45)
         at weblogic.jndi.internal.AbstractURLContext.lookup(AbstractURLContext.java:130)
         at javax.naming.InitialContext.lookup(InitialContext.java:347)
         at weblogic.jndi.internal.WLNamingManager.getObjectInstance(WLNamingManager.java:96)

    Hi,
    from what I gather, u have two jars
    1. EJBClient - this will have remote and home interfaces and will be used by the client
    2. myEJB - this iwll have all the classes - remote & home interfaces, the bean class and all the other classes required by the bean.
    Now, the question is, who is acting as the client of your EJB ? There are 3 possibilities
    1. A servlet
    2. Another EJB
    3. a simple java program.
    In the first 2 cases, you can go for Local Interfaces (more so in the second case than the first). The reason being that the the client and server will be in the same JVM. Thus, in the first case, if the Web container and the ejb container are in the same app server, EJBs can be local.
    However, in the third case, it is unlikey that you will have the client runnng and the same jvm as the server, because the server is using the jvm provided by weblogic.
    Thus, you cannot use local interfaces in this 3rd case. I have a feeling that this is what you are doing. If so, change the local interfaces to remote.
    See if this helps. Else, I will mail you some sample code. But I am afraid, sample code wont be of much help bcoz this seems to be a design problem.
    regards

  • Local Interfaces in WebLogic 7.0 Not Faster Than Remote Interfaces?

    I was curious how much faster calling business methods in
    a stateless session EJB in WebLogic 7.0 would be through
    a local interface than calling the same business methods
    through a remote interface. I timed both ways of calling
    the same methods and much to my surprise the times were
    nearly identical. I double-checked that in one case I really
    used the local interface (using ejb-local-ref, local-jndi-name,
    local interfaces in source code). Does anybody (perhaps from
    BEA) have an explanation for this? By the way, I ran the
    same experiment with other J2EE application servers such
    as IBM's WebSphere 5 (Beta) and there was a tremendous
    performance difference between local and remote interface
    usage.
    Thanks,
    Reinhard

    "Reinhard Klemm" <[email protected]> wrote in message
    news:[email protected]...
    I appreciate your response and, at the same time, I am somewhat
    surprised about it. Here are the reasons for my surprise:
    1. Your response indicates that WebLogic uses RMI for
    EJB local method calls, i.e., even if the client is on the same VM.
    I would have assumed that WebLogic would bypass RMI in such
    a situation.That is not what I said. Local interfaces wont use rmi.
    But remote interfaces do better if the call is from the same VM. This is
    weblogic rmi optimization. Please see Rob's posting also.
    2. Other J2EE application servers fare a lot better. In one
    experiment, I timed WebLogic against WebSphere 5.0 Technology
    for Developers (i.e., WebSphere 5.0 Beta, which is expressly
    NOT for performance testing) and against the Sun Reference
    Implementation. Here are the numbers for calling business
    methods in a stateless session EJB through its local interface:
    WebLogic: 5.15 ms on the average
    WebSphere: 0.41 ms on the average
    Sun Reference Implementation: 0.11 ms on the average
    This indicates to me that both WebSphere and the Sun Reference
    Implementation are better optimized than WebLogic by excluding
    RMI when making local EJB calls.
    Reinhard
    "Maruthi Nuthikattu" <[email protected]> wrote in message
    news:<[email protected]>...
    Can you post some numbers so that we can visualize the difference.
    Please add the numbers with other J2EE appserver also.
    Otherwise top of my head, the reason is:
    Weblogic rmi is well optimized for the calls with in the same JVM andsame
    J2EE application.
    This could be the reason you are not seeing much difference.
    ..maruthi
    "Reinhard Klemm" <[email protected]> wrote in message
    news:[email protected]...
    I was curious how much faster calling business methods in
    a stateless session EJB in WebLogic 7.0 would be through
    a local interface than calling the same business methods
    through a remote interface. I timed both ways of calling
    the same methods and much to my surprise the times were
    nearly identical. I double-checked that in one case I really
    used the local interface (using ejb-local-ref, local-jndi-name,
    local interfaces in source code). Does anybody (perhaps from
    BEA) have an explanation for this? By the way, I ran the
    same experiment with other J2EE application servers such
    as IBM's WebSphere 5 (Beta) and there was a tremendous
    performance difference between local and remote interface
    usage.
    Thanks,
    Reinhard

  • Local Interface in weblogic-ejb-jar.xml file

    I used Local Interface in WLS 7.0, and specifies the jndi-name as
    <weblogic-enterprise-bean>
    <ejb-name>MailboxService</ejb-name>
    <jndi-name>ejb/MailboxServiceHome</jndi-name>
    </weblogic-enterprise-bean>
    <weblogic-enterprise-bean>
    <ejb-name>MailboxServiceLocal</ejb-name>
    <jndi-name>ejb/MailboxServiceLocalHome</jndi-name>
    </weblogic-enterprise-bean>
    When I migrate to WLS 8.1, I keep receiving warning messages like:
    "[java] WARNING: Warning from ejbc: <jndi-name> must be defined for a bean
    with remo
    te interface. 'RecognitionServiceLocal(Jar: C:\ebdev\dev\make\eb-ejb\..\..\dist\eb-ejb.j
    ar)' does not have a remote interface."
    What is wrong here?
    Thanks in advance.

    jndi-name is specified for a remote interface.
    local-jndi-name is specified for a local interface.
    thanks,
    Deepak Vohra
    "Andy yang" <[email protected]> wrote:
    >
    I used Local Interface in WLS 7.0, and specifies the jndi-name as
    <weblogic-enterprise-bean>
    <ejb-name>MailboxService</ejb-name>
    <jndi-name>ejb/MailboxServiceHome</jndi-name>
    </weblogic-enterprise-bean>
    <weblogic-enterprise-bean>
    <ejb-name>MailboxServiceLocal</ejb-name>
    <jndi-name>ejb/MailboxServiceLocalHome</jndi-name>
    </weblogic-enterprise-bean>
    When I migrate to WLS 8.1, I keep receiving warning messages like:
    "[java] WARNING: Warning from ejbc: <jndi-name> must be defined
    for a bean
    with remo
    te interface. 'RecognitionServiceLocal(Jar: C:\ebdev\dev\make\eb-ejb\..\..\dist\eb-ejb.j
    ar)' does not have a remote interface."
    What is wrong here?
    Thanks in advance.

  • How will be the weblogic-ejb-jar and ejb-jar xml for EJB Local Interface?

    Hi,
    I have one ear application which is using Stateless Session Beans. I don't have any Bean to Bean communication . At present, the client is invoking remote methods thro Home/Remote interfaces. My doubt is , shall I implement EJBLocal home/ local interface to obtain this same functionality cos, in this app, both client and EJb bean have been deployed in same JVM. Can Local interfaces only be applicable to Bean - Bean relation ship?If LocalHome/Local interfaces can be implemented in my scenario, then may I know how will be the ejb-jar.xml and weblogic-ejb-jar.xml?
    thanks and regards,
    Venkat.

    Local interfaces are for communication between ejbs and their clients when both are in the same JVM. The clients can be normal clients, jsps, servlets, and other ejbs. If the client is not in the same JVM you cannot use local interfaces even though your client is another ejb.
    Advantage of using local interface is it reduces the network overhead.
    For more information you can download Mastering Enterprise Java Beans Third Edition by Ed Roman. You can go through 45
    You can download pdf version from.
    http://www.theserverside.com/books/wiley/masteringEJB/index.tss.
    Let me know the URL of the ejb doc that you referred.
    Thanks..

  • Use of local interface btw EAR

    hi,
    Can i use local interfaces to call session bean of EAR1 from EAR2. in my case EAR1 and EAR2 are deployed in the weblogic instance(same jvm). and parameters are being passed by value(because of 2 different classloaders).
    I tried doin this ... but resulted in exception being thrown when i tried to do a lookup to the localhome of EAR1.
    Please advise,
    venkat

    Hi,
    Even though they are running in the same JVM, the classes are not visible between EAR1 and EAR2 because they are loaded in separate classloaders, therefore local interfaces won't work.
    -thorick

  • EJB 3.0 local interface JNDI

    Hello
    I found some information that will probably help a lot of people having trouble with local interface not referenced in JNDI.
    You need to delacre each local interface in the web.xml.
         <ejb-local-ref>
              <ejb-ref-name>MappedNameInYourEJB</ejb-ref-name>
              <ejb-ref-type>Session</ejb-ref-type>
    <local> yourLocalInterface
              </local>
         </ejb-local-ref>
    The weird thing about this is you don't need to do it when you use remote interface!! I would have thought Weblogic was smart enough to put your EJB in the JNDI when you declare @local on your interface!!
    Am I wrong with something here?
    When I read the EJB spec, it says you don't need to declare your EJB anywhere when you use annotation....
    If someone have an explanation I would be very happy to read about it!!!!
    Tanx

    Hi,
    In our current impl, we don't bind local business interface impl onto global jndi, this is because adding global JNDI binding for local EJB means every local business interface object must be bound into global JNDI, which will give rise to strange errors when accessing remotely or in different application context.
    On the other hand, you needn't add each local interface in the web.xml, you can use annotation through EJB link, which is the suggested way to use EJB local reference, for example:
    @Stateful(name="AccountManagementBean")
    public class AccountManagementBean
    @EJB(
    name="PersonBeanRef",
    beanName="PersonBean"
    Person person;
    @Stateless(name="PersonBean")
    public class PersonBean implements Person {
    In this example, AccountManagementBean has a local reference of PersonBean, the key is you should use beanName in @EJB, whose value is the ejb name of referenced EJB.

  • CMR and Local Interfaces

    I have a question on setting up CMR in an environment where I want to utilize local
    interfaces within a weblogic server instance. In the deployment descriptor, I have
    set up the home, remote, local-home, local, and ejb-class entries. I then want to
    define the relationships between two CMP entity beans. Here is where I run into
    problems.
    1) If I define the CMR field using the local interface, I get an error stating that
    the type defined by the bean for the field does not match that of the remote interface.
    2) If I define the CMR field using the remote interface, I get an error stating that
    the bean must use the local interface for the CMR if one exists.
    Seems kind of circular to me. What am I missing?

    If you want to be able to have mutiple children companies for a parent
    company and you want to be able to query for the parent company for a given
    comapnay then this is the XML I would do something like the following. In
    your xml you had the mutiplicities inverted and also the cmr field was
    either in the wrong place or misnamed (ie, if it had to be in the top block
    then it should have been "childCompanies" instead of "parentCompany").
    Assuming the bean name in the descriptor for the CompanyEJB is Company:
    <ejb-relation>
    <ejb-relation-name>Company-ParentCompany</ejb-relation-name>
    <ejb-relationship-role>
    <ejb-relationship-role-name>Company-Has-ChildCompanies</ejb-relationship-rol
    e-name>
    <multiplicity>one</multiplicity>
    <relationship-role-source>
    <ejb-name>Company</ejb-name>
    </relationship-role-source>
    </ejb-relationship-role>
    <ejb-relationship-role>
    <ejb-relationship-role-name>Company-Has-ParentCompany</ejb-relationship-role
    -name>
    <multiplicity>many</multiplicity>
    <relationship-role-source>
    <ejb-name>Company</ejb-name>
    </relationship-role-source>
    <cmr-field>
    <cmr-field-name>parentCompany</cmr-field-name>
    </cmr-field>
    </ejb-relationship-role>
    </ejb-relation>
    In the CompanyEJB you would have:
    public abstract CompanyLocal getParentCompany();
    public abstract void setParentCompany( CompanyLocal parent );
    -- Anand
    "Steve Ebersole" <[email protected]> wrote in message
    news:[email protected]...
    >
    The jar I am running through ejbc is attached (with source). The EJBobject naming
    conventions are as follows:
    ejb-class = CompanyEJB
    home = CompanyHome
    remote = Company
    local-home = CompanyLocalHome
    local = CompanyLocal
    The pertinent ejb-jar snippet:
    <ejb-relation>
    <ejb-relation-name>Company-ParentCompany</ejb-relation-name>
    <ejb-relationship-role>
    <ejb-relationship-role-name>Company-Has-ChildCompanies</ejb-relationship-rol
    e-name>
    <multiplicity>Many</multiplicity>
    <relationship-role-source>
    <ejb-name>Company</ejb-name>
    </relationship-role-source>
    <cmr-field>
    <cmr-field-name>parentCompany</cmr-field-name>
    </cmr-field>
    </ejb-relationship-role>
    <ejb-relationship-role>
    <ejb-relationship-role-name>Company-Has-ParentCompany</ejb-relationship-role
    -name>
    <multiplicity>One</multiplicity>
    <relationship-role-source>
    <ejb-name>Company</ejb-name>
    </relationship-role-source>
    </ejb-relationship-role>
    </ejb-relation>
    And the weblogic-cmp-rdbms-jar snippet:
    <weblogic-rdbms-relation>
    <relation-name>Company-ParentCompany</relation-name>
    <weblogic-relationship-role>
    <relationship-role-name>Company-Has-ParentCompany</relationship-role-name>
    </weblogic-relationship-role>
    <weblogic-relationship-role>
    <relationship-role-name>Company-Has-ChildCompanies</relationship-role-name>
    <column-map>
    <foreign-key-column>PRNT_COMP_ID</foreign-key-column>
    <key-column>COMP_ID</key-column>
    </column-map>
    </weblogic-relationship-role>
    </weblogic-rdbms-relation>
    In the CompanyEJB, these are the two scenarios I tried:
    1)
    public abstract Company getParentCompany();
    public abstract void setParentCompany( Company prnt );
    2)
    public abstract CompanyLocal getParentCompany();
    public abstract void setParentCompany( CompanyLocal prnt );
    The only way I have been able to get it to work so far is to use thesyntax in #1
    above and then to remove all references to the local interfaces in thedeployment
    descriptors.
    Thanks for all help

  • No performance gain when using local interfaces

    Hello,
    I'm doing some tests to compare performances between remote ejb interfaces and local ejb interfaces.
    I have two stateless session beans EJB1 and EJB2, EJB1 calls a method on EJB2, this method receives one object as the only parameter and returns it immediately. The parameter is a big object (~700ko). My test consists simply of making 1000 calls from EJB1 to EJB2, one time with remote interfaces, one time with local interface. For both tests, the EJBs run in the same container, same VM.
    The results show absolutely no differences between the remote and the local interface !
    As I found these results a bit surprising, I changed the serialization method of my parameter object this way:
    private void writeObject(java.io.ObjectOutputStream out) throws IOException {
    System.out.println("writeObject(MyBigObject)");
    out.defaultWriteObject();
    just to check if my object is serialized when using remote interface. And the response is no.
    So question is: is there an "undocumented optimization" of the stub/skel generated by weblogic which make local calls when calling a remote method inside the same VM ?
    Some precisions:
    - I'am using weblogic 8.1sp2
    - When calling remotely my EJB2 from an external batch (running in a separate VM), I see the message "writeObject(MyBigObject)" so the serialization is done in this case.

    <Fr?d?ric Chopard> wrote in message news:[email protected]..
    So question is: is there an "undocumented optimization" of the stub/skel generated by weblogic which make local calls when callinga remote method inside the same VM ?
    >
    Some precisions:
    - I'am using weblogic 8.1sp2
    - When calling remotely my EJB2 from an external batch (running in a separate VM), I see the message "writeObject(MyBigObject)" sothe serialization is done in this case.
    WebLogic 5.x, 6.x and 7.x do call by reference for co-located EJBs by default. 8.1 has this behavior turned off by default. You may
    experience call-by-reference optimization in 8.1 only if it has been turned on explicitly in the deployment descriptor.
    Hope this helps.
    Regards,
    Slava Imeshev

  • Local interfaces documentation/examples

    i'm looking for good examples/documentation on using local interfaces
    with weblogic (6.1).
    i gave it a try and kept getting a class cast exception while trying to
    cast the ic.lookup result to the localhome interface. something tells
    me that some deployment descriptors weren't up to snuff perhaps. i'm
    using stateless session beans one main bean trying to call others. i'm
    also using xdoclet to generate all the interfaces, but not the
    deployment descriptors. i've reverted to using remote interfaces for
    the time being just to get it all working.
    one specific question that i've been getting mixed answers on. for
    ejb's to use local interfaces, do they need to be in the same jar/war?
    all our beans are deployed as one bean per jar file. makes for lots of
    descriptor files ;).
    thanks!
    ~mark

    none wrote:
    i'm looking for good examples/documentation on using local interfaces
    with weblogic (6.1).You might have a look at the bands example. You could also check out
    http://learnweblogic.com/updates/webauction.zip
    >
    i gave it a try and kept getting a class cast exception while trying to
    cast the ic.lookup result to the localhome interface. The best way to debug ClassCastExceptions is to print out the class name
    and loader of each class.
    Something like this:
    Object h = ic.lookup("fooHome")
    System.out.println("lookup returned "+h.getClass().getName());
    System.out.println("loaded by "+h.getClass().getClassLoader());
    System.out.println("Trying to cast into "
    +FooHome.class.getClassLoader());
    something tells
    me that some deployment descriptors weren't up to snuff perhaps. i'm
    using stateless session beans one main bean trying to call others. i'm
    also using xdoclet to generate all the interfaces, but not the
    deployment descriptors. i've reverted to using remote interfaces for
    the time being just to get it all working.I'd suggest you check out EJBGen as well.
    >
    one specific question that i've been getting mixed answers on. for
    ejb's to use local interfaces, do they need to be in the same jar/war?
    all our beans are deployed as one bean per jar file. makes for lots of
    descriptor files ;).Personally I'm not a big fan of 1 ejb per jar file. You can make local
    calls between jars if they are packaged within the same ear.
    -- Rob
    >
    thanks!
    ~mark

  • Naming Exception: Name not found for local interface in 8.1

    Hi,
    I am trying to use local interfaces for my ejbs to call from my web application
    as both are running on the same server. I am migrating from 6.1 to 8.1 and with
    6.1, I was using the remote interfaces. Now, I am planning to use local interfaces
    from my web application, which is deployed as part of an EAR which has my ejbs
    also.
    Here is my ejb-jar.xml:
    <session>
         <ejb-name>TestService</ejb-name>
         <local-home>com.test.ejb.home.PrefsServiceHome</local-home>
         <local>com.test.ejb.TestService</local>
         <ejb-class>com.test.ejb.impl.PrefsServiceBean</ejb-class>
         <session-type>Stateless</session-type>
         <transaction-type>Bean</transaction-type>
         <resource-ref>
         <res-ref-name>jdbc/DataSource</res-ref-name>
         <res-type>javax.sql.DataSource</res-type>
         <res-auth>Container</res-auth>
         </resource-ref>
    </session>
    and my weblogic.xml looks like:
    <weblogic-enterprise-bean>
    <ejb-name>TestService</ejb-name>
    <stateless-session-descriptor>
    <pool>
         <max-beans-in-free-pool>20</max-beans-in-free-pool>
         <initial-beans-in-free-pool>20</initial-beans-in-free-pool>
    </pool>
    </stateless-session-descriptor>
    <reference-descriptor>
    <resource-description>
    <res-ref-name>jdbc/DataSource</res-ref-name>
    <jndi-name>jdbc.DataSource</jndi-name>
    </resource-description>
    </reference-descriptor>
    <jndi-name>ejb.PrefsService</jndi-name>
    </weblogic-enterprise-bean>
    I used the following code to get home interface:
    InitialContext initCtx = new InitialContext();
    Object objRef=null;
    objRef=initCtx.lookup("java:comp/env/ejb/TestService");
    return (EJBLocalHome)(objRef);
    I tried several combination for lookup.. but none of them worked. When i tried
    testing this particular ejb from administration console, I got "The EJB TestService
    has not been tested succesfully" message.
    lookup names I used:
    java:comp/env/ejb/TestService:not found
    java:comp/env/ejb/TestServiceHome:not found
    java:comp/env/ejb/ejb.TestServiceHome:not found
    java:comp/env/ejb/ejb.TestService:not found
    java:comp/env/ejb.TestServiceHome:not found
    java:comp/env/ejb.TestService:not found
    java:comp/env/TestServiceHome:not found
    java:comp/env/TestService:not found
    ejb.TestService:not found
    TestService:not found
    Please let me know... where I am going wrong..
    Thanks
    Raj

    There's 2 ways to lookup local EJBs
    1) Specify an ejb-link in your ejb-jar.xml. Specify an ejb-link in your
    web.xml and lookup java:/comp/env/<link-name>
    2) Specify a <local-jndi-name> in your weblogic-ejb-jar.xml and lookup
    that name.
    -- Rob
    Raj wrote:
    Hi,
    I am trying to use local interfaces for my ejbs to call from my web application
    as both are running on the same server. I am migrating from 6.1 to 8.1 and with
    6.1, I was using the remote interfaces. Now, I am planning to use local interfaces
    from my web application, which is deployed as part of an EAR which has my ejbs
    also.
    Here is my ejb-jar.xml:
    <session>
         <ejb-name>TestService</ejb-name>
         <local-home>com.test.ejb.home.PrefsServiceHome</local-home>
         <local>com.test.ejb.TestService</local>
         <ejb-class>com.test.ejb.impl.PrefsServiceBean</ejb-class>
         <session-type>Stateless</session-type>
         <transaction-type>Bean</transaction-type>
         <resource-ref>
         <res-ref-name>jdbc/DataSource</res-ref-name>
         <res-type>javax.sql.DataSource</res-type>
         <res-auth>Container</res-auth>
         </resource-ref>
    </session>
    and my weblogic.xml looks like:
    <weblogic-enterprise-bean>
    <ejb-name>TestService</ejb-name>
    <stateless-session-descriptor>
    <pool>
         <max-beans-in-free-pool>20</max-beans-in-free-pool>
         <initial-beans-in-free-pool>20</initial-beans-in-free-pool>
    </pool>
    </stateless-session-descriptor>
    <reference-descriptor>
    <resource-description>
    <res-ref-name>jdbc/DataSource</res-ref-name>
    <jndi-name>jdbc.DataSource</jndi-name>
    </resource-description>
    </reference-descriptor>
    <jndi-name>ejb.PrefsService</jndi-name>
    </weblogic-enterprise-bean>
    I used the following code to get home interface:
    InitialContext initCtx = new InitialContext();
    Object objRef=null;
    objRef=initCtx.lookup("java:comp/env/ejb/TestService");
    return (EJBLocalHome)(objRef);
    I tried several combination for lookup.. but none of them worked. When i tried
    testing this particular ejb from administration console, I got "The EJB TestService
    has not been tested succesfully" message.
    lookup names I used:
    java:comp/env/ejb/TestService:not found
    java:comp/env/ejb/TestServiceHome:not found
    java:comp/env/ejb/ejb.TestServiceHome:not found
    java:comp/env/ejb/ejb.TestService:not found
    java:comp/env/ejb.TestServiceHome:not found
    java:comp/env/ejb.TestService:not found
    java:comp/env/TestServiceHome:not found
    java:comp/env/TestService:not found
    ejb.TestService:not found
    TestService:not found
    Please let me know... where I am going wrong..
    Thanks
    Raj

  • How to set transaction isolation level for a method in a Local Interface

              By reference at:
              http://e-docs.bea.com/wls/docs61/ejb/reference.html#1071267,
              the value for method-intf can only be "Remote" or "Home".
              My question is--
              How to set transaction isolation level for a method inside a Local Interface or
              Local_Home Interface?
              Thanks.
              Xing
              

    I'd try 6.1SP2. I'm pretty sure this works now.
              -- Rob
              Xing wrote:
              > I tried "Local", but got an error when deploying the EJB jar, saying that only
              > "Remote" or "Home" is allowed.
              >
              > Any idea?
              >
              > Xing
              >
              > Rob Woollen <[email protected]> wrote:
              > >
              > >
              > >Use LocalHome or Local.
              > >
              > >-- Rob
              > >
              > >Xing wrote:
              > >
              > >> By reference at:
              > >> http://e-docs.bea.com/wls/docs61/ejb/reference.html#1071267,
              > >> the value for method-intf can only be "Remote" or "Home".
              > >>
              > >> My question is--
              > >>
              > >> How to set transaction isolation level for a method inside a Local
              > >Interface or
              > >> Local_Home Interface?
              > >>
              > >> Thanks.
              > >>
              > >> Xing
              > >
              > >--
              > >
              > >----------------------------------------------------------------------
              > >
              > >AVAILABLE NOW!: Building J2EE Applications & BEA WebLogic Server
              > >
              > >by Michael Girdley, Rob Woollen, and Sandra Emerson
              > >
              > >http://learnWebLogic.com
              > >
              > >
              > >
              > >
              > ><!doctype html public "-//w3c//dtd html 4.0 transitional//en">
              > ><html>
              > >Use LocalHome or Local.
              > ><p>-- Rob
              > ><p>Xing wrote:
              > ><blockquote TYPE=CITE>By reference at:
              > ><br>http://e-docs.bea.com/wls/docs61/ejb/reference.html#1071267,
              > ><br>the value for method-intf can only be "Remote" or "Home".
              > ><p>My question is--
              > ><p>How to set transaction isolation level for a method inside a Local
              > >Interface
              > >or
              > ><br>Local_Home Interface?
              > ><p>Thanks.
              > ><p>Xing</blockquote>
              > >
              > ><pre>--
              > >
              > >----------------------------------------------------------------------
              > >
              > >AVAILABLE NOW!: Building J2EE Applications & BEA WebLogic Server
              > >
              > >by Michael Girdley, Rob Woollen, and Sandra Emerson
              > >
              > >http://learnWebLogic.com</pre>
              > > </html>
              > >
              > >
              AVAILABLE NOW!: Building J2EE Applications & BEA WebLogic Server
              by Michael Girdley, Rob Woollen, and Sandra Emerson
              http://learnWebLogic.com
              [att1.html]
              

  • Local interfaces and WLS 7

    Hi *,
    does anybody know if localinterfaces work in WLS7 SP1?
    thanx,
    Yauheni

    Yes. my classes were inclueded in system CLASSPATH. but Sun spec says nothing about
    that local interfaces could work only in the application context. it says that restriction
    is that it could work only on the same JVM. so it looks very strange, isn't it? i
    will try to pack everything in ear and try it again.
    Thanx,
    Yauheni
    "Dimitri I. Rakitine" <[email protected]> wrote:
    Yes, it looks like this is a problem. Your application used to work on 6
    because you
    added all your classes to the system classpath, right? And it sounds like
    in 7, local
    calls also depend on the application environment being set.
    Yauheni Prykhodzka <[email protected]> wrote:
    actually, may be that is the problem, we have no ear. we have a set ofjars with
    ejbs and a set of web applications, whci are not packed in war. couldit be a problem,
    when i use local interfaces?
    but spec says that local interface could be used inside a JVM. i thinkit should
    not play a role, if classloadres of ejb and component that use ejb aredifferent.
    is it true?
    Yauheni
    "Dimitri I. Rakitine" <[email protected]> wrote:
    Do you mean that servlet, which is a part of a .war which is deployed
    in
    the
    same .ear with the EJB components fails to invoke EJB's using local interfaces?
    Yauheni Prykhodzka <[email protected]> wrote:
    "Dimitri I. Rakitine" <[email protected]> wrote:
    Interesting. I guess that the problem will go away if you stop using
    startup
    classes
    (for example, use load-on-startup servlet instead to perform initialization
    steps).
    No. I get the same problem after weblogic started. If i try to use localinterfaces
    from another bean o servlet i get the same exception.
    Yauheni
    Yauheni Prykhodzka <[email protected]> wrote:
    Here is the exception, which i'm getting:
    <10.07.2002 11:43:55 CEST> <Emergency> <WebLogicServer> <000342> <Unableto init
    ialize the server: Fatal initialization exception
    Throwable: weblogic.t3.srvr.FatalStartupException: Can't start serverdue to sta
    rtup class failure IdGeneratorStartUp - with nested exception:
    [javax.naming.LinkException:  [Root exception is javax.naming.NameNotFoundExcept
    ion: remaining name: /app/ejb/dox.comp.IdGenerator.jar#IdGenerator/local-home];
    Link Remaining Name: 'java:app/ejb/dox.comp.IdGenerator.jar#IdGenerator/local-ho
    me']
    javax.naming.LinkException: . Root exception is javax.naming.NameNotFoundExcept
    ion: remaining name: /app/ejb/dox.comp.IdGenerator.jar#IdGenerator/local-home
    <<no stack trace available>>
    --------------- nested within: ------------------
    weblogic.t3.srvr.FatalStartupException: Can't start server due to
    startup
    class
    failure IdGeneratorStartUp - with nested exception:
    [javax.naming.LinkException:  [Root exception is javax.naming.NameNotFoundExcept
    ion: remaining name: /app/ejb/dox.comp.IdGenerator.jar#IdGenerator/local-home];
    Link Remaining Name: 'java:app/ejb/dox.comp.IdGenerator.jar#IdGenerator/local-ho
    me']
    at weblogic.t3.srvr.StartupClassRunner$1.run(StartupClassRunner.java:95)
    at weblogic.security.service.SecurityServiceManager.runAs(SecurityServic
    eManager.java:721)
    at weblogic.t3.srvr.StartupClassRunner.run(StartupClassRunner.java:71)
    at java.lang.Thread.run(Thread.java:484)
    >
    The WebLogic Server did not start up properly.
    the JNDI name for local interface is IdGeneratorLocalHome. i use thisname for lookup.
    Thanx,
    Yauheni--
    Dimitri--
    Dimitri
    Dimitri

Maybe you are looking for

  • I can reset my security questions.  I have checked my email and but am not receiving the email to reset.  Its not in spam.

    How can I reset my security questions for icloud account.  I am not receiving the reset email.   Is there a way to change where the email is being sent?   ice checked my spam folders.

  • How to re-install mvdemo ?

    I've installed MapViewer from MapViewer-p7384506_10131_Generic-08092008.zip and it works also in Chrome fine :-)) But I am testing on a mvemo imported for a previouse release. Is there a script to drop the mvdemo data objects and the metadata to re-i

  • Installing Leopard 10.5.1 update hanging

    I have downloaded the update, but when Leopard restarts to install the update it just hangs at the software update window. it says "installing 1 item" but hangs in the progress bar while "configuring installation" i have to end up doing a hard reset

  • How to expand hierarchy at one shot in WAD.

    HI gurus I have a hierarchy  in WAD with 10 nodes.To expand I have to click each note which takes some time to expand .The user wants to expand all node in one click. Is there any way to incorporate in WAD . Thanks Rgds Pradeep

  • New Quadro FX cards 2010

    Hi everyone, i just want  to confirm if there will be new Quadro cards to be released some time in  the following weeks/months.. I saw on the other thread, "The FX4800 is  end-of-life, the successor is expected to be announced  this month.... -  Harm