Implementing Local Interface or not

I wish to define a Local SessionBean as simply as possible.
The following compiles ok:
@Stateless
@Local
public class LocalSessionGreetingBean {
     @Resource
     private SessionContext sessionContext;
     * Default constructor.
    public LocalSessionGreetingBean() {
    }but does not deploy on JBoss 5.
I am wondering is this because I am specified no interface in the @Local annotation?
Because it works when I do that.
I am confused, I thought I could get away with any interfaces as just have the Session as a POJO?
Thanks?

beginner2 wrote:
I am confused, I thought I could get away with any interfaces as just have the Session as a POJO?
Thanks?As far as I know that is true for JEE6, it certainly is not for JEE5 (and JBoss 5.X is a JEE5 server). You must implement the local interface or it won't work.

Similar Messages

  • EXTREMELY URGENT!!  Last question on Local Interfaces

    Using Oracle9iAS 9.0.3
    Running on RedHat 8.0
    Trying to implement local interfaces to my entity bean. (Oracle9iAS Containers for J2EE for 9.0.3) provides an example for writing local interfaces.
    pg. 2-10 states:
    //The variable is specified in the assembly descriptor (META-INF/ejb-jar.xml)
    Object homeObject = context.lookup("java:comp/env/EmployeeLocalBean");
    but, if you look at the ejb-jar.xml they reference, it's as follows (pg. 2-12):
    <ejb-jar>
    <enterprise-beans>
    <session>
    <description>Session Bean Employee Example</description>
    <ejb-name>EmployeeBean</ejb-name>
    <home>employee.EmployeeHome</home>
    <remote>employee.Employee</remote>
    <local-home>employee.EmployeeLocalHome</local-home>
    <local>employee.EmployeeLocal</local>
    <ejb-class>employee.EmployeeBean</ejb-class>
    <session-type>Stateless</session-type>
    <transaction-type>Bean</transaction-type>
    </session>
    </enterprise-beans>
    </ejb-jar>
    Where does the EmployeeLocalBean name come from for the lookup?!
    Also, do I NEED to deploy BOTH remote and local interfaces to get my local interfaces to work? Another post on this forum had a problem where they couldn't view the configurations of the EJB because there were not remote interfaces available, but then later they said it was just a problem with the web-based Enterprise Manager.
    Please, can someone let me know if these questions are not interesting enough to the forum? Has nobody here ever implemented Local Interfaces on 9.0.3? Do I need to be posting these questions to a different forum? Please advise and I will take care to get my answers elsewhere if necessary.
    It's just that every resource I've looked at for Local Interfaces (which 9.0.3 CAN implement...right?!) has conflicting information and seems to have buggy implementations. Please....help!
    Thanks in advance!

    Strangely enough, I'm not aware of troubles with enviroment variables and JNDI lookup. There are some misunderstandings - compared to WLS, JNDI tree is different.
    Here is an example of Session EJB settings:
    <session>
    <description>Session Bean ( Stateless )</description>
    <display-name>XSLTransformerEJB</display-name>
    <ejb-name>XSLTransformerEJB</ejb-name>
    <local-home>com.ness.europe.integration.transformer.XSLTransformerEJBLocalHome</local-home>
    <local>com.ness.europe.integration.transformer.XSLTransformerEJBLocal</local>
    <ejb-class>com.ness.europe.integration.transformer.impl.XSLTransformerEJBBean</ejb-class>
    <session-type>Stateless</session-type>
    <transaction-type>Bean</transaction-type>
    <env-entry>
    <description>path to root transformatin file</description>
    <env-entry-name>config/RootTransformFile</env-entry-name>
    <env-entry-type>java.lang.String</env-entry-type>
    <env-entry-value>/oracle/product/IAS903/j2ee/MwCezPassport/xslt/passport.xslt</env-entry-value>
    </env-entry>
    </session>
    Next, there is an MDB with reference to it:
    <message-driven>
    <description>Message Driven Bean</description>
    <display-name>PassportMDB</display-name>
    <ejb-name>PassportMDB</ejb-name>
    <ejb-class>com.ness.europe.integration.inbound.mdb.InboundMDBBean</ejb-class>
    <transaction-type>Bean</transaction-type>
    <acknowledge-mode>Auto-acknowledge</acknowledge-mode>
    <message-driven-destination>
    <destination-type>javax.jms.Queue</destination-type>
    <subscription-durability>Durable</subscription-durability>
    </message-driven-destination>
    <ejb-local-ref>
    <ejb-ref-name>ejb/XSLTransformerEJB</ejb-ref-name>
    <ejb-ref-type>Session</ejb-ref-type>
    <local-home>com.ness.europe.integration.transformer.XSLTransformerEJBLocalHome</local-home>
    <local>com.ness.europe.integration.transformer.XSLTransformerEJBLocal</local>
    <ejb-link>XSLTransformerEJB</ejb-link>
    </ejb-local-ref>
    There is basically this piece of code to do lookup environment variable:
    String toRet = (String)this.initCtx.lookup("java:comp/env/config/" + paramName);
    (of course, the config prefix is our syntax)
    As for EJB lookup, this is used:
    final InitialContext context = new InitialContext();
    return (XSLTransformerEJBLocalHome)context.lookup("java:comp/env/ejb/XSLTransformerEJB");
    I didn't created those beans but I asked mate from my team and answer as to troubles was "no".
    Is the problem lies in "not hard coded" names of beans in lookup? We are not trying to get "env/ejb" but just straighforwardly EJB using its name.
    Myrra

  • Performance: T3 vs. Local Interfaces ?

    Hi there!
    What gain in performance can be expected from Local Interfaces?
    T3 and Local Interfaces are ment to tackle the same problem, if I'm not mistaken:
    enabling a local call to a Bean
    without serializing the parameters (enabling call by reference).
    I have implemented a test scenario using:
    - T3 with <enable-call-by-reference> false
    - T3 with <enable-call-by-reference> true
    - Local Interfaces and <enable-call-by-reference> false
    The testcase with T3 and <enable-call-by-reference> false is the slowest obviously.
    The testcase with T3 and <enable-call-by-reference> true works 15% faster.
    The testcase with local interfaces shows NO improvement compared to
    T3 and <enable-call-by-reference> false.
    Is there anything else I have to think about when using local Interfaces - any
    switch forgotten?
    Or do local interfaces do not improve performance?
    Thanks for any help...
    Manfred Schneider

    Hi there!
    What gain in performance can be expected from Local Interfaces?
    T3 and Local Interfaces are ment to tackle the same problem, if I'm not mistaken:
    enabling a local call to a Bean
    without serializing the parameters (enabling call by reference).
    I have implemented a test scenario using:
    - T3 with <enable-call-by-reference> false
    - T3 with <enable-call-by-reference> true
    - Local Interfaces and <enable-call-by-reference> false
    The testcase with T3 and <enable-call-by-reference> false is the slowest obviously.
    The testcase with T3 and <enable-call-by-reference> true works 15% faster.
    The testcase with local interfaces shows NO improvement compared to
    T3 and <enable-call-by-reference> false.
    Is there anything else I have to think about when using local Interfaces - any
    switch forgotten?
    Or do local interfaces do not improve performance?
    Thanks for any help...
    Manfred Schneider

  • Cmp2.0 /local interface

    Hi! I'm trying to deploy the wrox ch16 sample on cmp2.0 and local interfaces and got the following error:
    java.lang.InstantiationException: local/local-home tag not supported in this version
    Does OC4J ver 9.0.2 supports the new cmp2/cmr and local interfaces?
    Thanks.

    Pedro -- Local interfaces were not available in v902 but they are available in the OC4J v903 Developer Preview. You can download this from OTN. Please start at http://otn.oracle.com/tech/java/oc4j/content_preview.html to find the download as well as updated documentation and more data about the J2EE compliant version of OC4J.
    Thanks -- Jeff

  • Does OAS9i(oc4j) support EJB Local interface?

    Hi, I'm trying to use the petstore 1.3 framework on oc4j. I read the documentation, and know that it supports EJB 2. But I find the ejb local interface isn't supported.
    Am I right?

    Hi Patrick,
    As far as I know, OC4J only partially implements EJB 2.0 -- it
    doesn't implement local interfaces. However, there are several,
    different versions available. Which version are you using?
    If you haven't already found it, there is a version of the pet
    store application available for download from:
    http://technet.oracle.com/sample_code/tech/java/oc4j/content.html
    but it's an implementation of the 1.1.2 version.
    Hope this helps,
    Avi.

  • Problem with local interfaces using oc4j 9.0.4 standalone

    I am not able to get oc4j 9.0.4 standalone to use local interfaces. I belive that my configurations and code are correct. I am receiving javax.naming.NameNotFoundException
    whenever I attempt to lookup a local ejb
    lookup code
    Context context = new InitialContext();
    ApplicationBMPLocalHome appBMPLocalHome = (ApplicationBMPLocalHome)context.lookup("java:comp/env/ejb/ApplicationBMPLocalHome");
    part of ejb-jar.xml
    <ejb-local-ref>
    <ejb-ref-name>ejb/ApplicationBMPLocal</ejb-ref-name>
    <ejb-ref-type>Entity</ejb-ref-type>
    <local-home>JRun2.ApplicationBMPLocalHome</local-home>
    <local>JRun2.ApplicationBMPLocal</local>
    <ejb-link>ApplicationBMP</ejb-link>
    </ejb-local-ref>
    I know that local interfaces did not work in 9.0.3 oc4j, bu t I assume that this problem was fixed in 9.0.4. Correct me if that is not the case.

    In your code you look up ApplicationBMPLocalHome, but your <ejb-ref-name> is ApplicationBMPLocal.
    Try too change your lookup to
    (ApplicationBMPLocalHome)context.lookup("java:comp/env/ejb/ApplicationBMPLocal");
    /Fredrik

  • 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

  • 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

  • Local Data AddressDoes not belong to any of this hosts local interfaces

    I'm facing this error when I try to run the Applet from a client that download the applet and try to connect to de ip address of the origin.
    When I run localy, there is no error!
    Example: On 10.1.0.2, I browse 10.1.0.1/transmitapplet.html, and the error:Local Data AddressDoes not belong to any of this hosts local interfaces occurs.
    On 10.1.0.1, I browse 10.1.0.1/transmitapplet.html and the applet run properly.
    Anybody knows what is the problem?

    Sorry, but I hadn't have this problem till last week. Then I tried out to run my Application as Applet...
    The problem is, that a applet is not allowed to read the local IP-Address. I've solved this a little bit strange, by using a dummy SessionManager:
    public String getLocalAddress() {
    String result = null;
    SessionAddress addr = null;
    RTPSessionMgr mngrSession = (RTPSessionMgr) RTPManager.newInstance();
    if (mngrSession != null) {
    SessionAddress sessAddr = new SessionAddress();
    // empty address will use standard IP
    try {
    mngrSession.initialize(sessAddr);
    addr = mngrSession.getLocalSessionAddress();
    catch (InvalidSessionAddressException e1) {}
    if (addr != null) {
    result = addr.getDataHostAddress();
    mngrSession.closeSession();
    mngrSession.dispose();
    return result;
    else return null;
    This method does not support multiple IP-addresses.

  • Interface method  not implemented by class :(

    I'm getting an error for interface method
    Interface method handleLogout in namespace  views.interfaces:IWiseMediator not implemented by class  views.mediators:RatingViewMediator.    RatingViewMediator.as 
    package views.interfaces
        import flash.events.Event;
        public interface IWiseMediator
            function handleLogout(event:Event):void;
    but I done this in RatingViewMediator
    private function handleLogout(event:Event):void
                viewObject.clearFields();

    interfaces are used to enforce a public 'interface' to the class. as a private method can only be accessed by the class itself, it doesn't make sense to include private methods in an interface.

  • Not resolving Local Interface

    Hi,
    I'm developing a CMP bean on weblogic 7.0.
    When I'm using Remote Interfaces, its working, but when using Local Interfaces my JSP gives Errors.
    javax.naming.LinkException: [Root exception is javax.naming.NameNotFoundException: Unable to resolve 'app/ejb/EmployeeJAR.jar#EmployeeEJB/local-home' Resolved: 'app/ejb' Unresolved:'EmployeeJAR.jar#EmployeeEJB' ; remaining name 'EmployeeJAR.jar#EmployeeEJB/local-home']; Link Remaining Name: 'java:app/ejb/EmployeeJAR.jar#EmployeeEJB/local-home'
    Can somebody help?

    I have similar problem, I have checked the jndi and the bean (after changing it to local) is not registered in it!
    here are the changes in ejb-jar:
    <ejb-ref > !!!!!!!!!!!!!!!!!!!!!!!
    <ejb-ref-name>ejb/EntityBook</ejb-ref-name>
    <ejb-ref-type>Entity</ejb-ref-type>
    <home>myBooks.ejbs.EntityBookHome</home>
    <remote>myBooks.ejbs.EntityBook</remote>
    <ejb-link>EntityBook</ejb-link>
    </ejb-ref>
    into
    <ejb-local-ref >
    <ejb-ref-name>ejb/EntityBook</ejb-ref-name>
    <ejb-ref-type>Entity</ejb-ref-type>
    <local-home>myBooks.ejbs.EntityBookLocalHome</local-home>
    <local>myBooks.ejbs.EntityBookLocal</local>
    <ejb-link>EntityBook</ejb-link>
    </ejb-local-ref>
    and in entity:
    <home>myBooks.ejbs.EntityBookHome</home>
    <remote>myBooks.ejbs.EntityBook</remote>
    into
    <local-home>myBooks.ejbs.EntityBookLocalHome</local-home>
    <local>myBooks.ejbs.EntityBookLocal</local>
    I'm working on sun one appserver 7 (free edition - community?)
    and pointbase
    have you any ideas?

  • Local Data Address Does not belong to any of this hosts local interfaces

    I cannot get through this exception while running
    sessionManager.initSession(
    localAddress,
    new SourceDescription[] {  },
    0.05,
    0.25);
    I get this debug output:
    Initalizing session (localAddress)
    DataAddress: 10.8.0.6/10.8.0.6
    ControlAddress: 10.8.0.6/10.8.0.6
    DataPort: 2838
    ControlPort: 2839
    10.8.0.6 is on my tun0 interface, I also tried with 192.168.1.100 which is on my eth2 interface but always get the message in the subject. The only address I can init session on is loopback address.
    I use code that looks at local interfaces and grabs ip address from one of them so I'm sure the assigned address belongs to one of my interfaces.
    Anybody knows how I can solve this problem?

    I solved this one. The problem is JMF seems to use InetAddress.getAllByName() which returns (at least in my case) only single IP address no matter how many addresses I have defined on my interfaces. The problem was solved by placing my IP address that I wanted to use by session manager into /etc/hosts. It must be the first line in /etc/hosts otherwise the other row that matches is used.

  • How can I get a reference to the Local interface of a EJB 3 session?

    Hi,
    How can I get a reference to the Local interface of a EJB 3 session?
    My session implements both the local and remote interfaces, so in my client, when I look up the remote interface using the following code, I did get a reference
              processor = (IItemProcessorRemote)initialContext.lookup(IItemProcessorRemote.class.getName());but if I also look up the local interface in th eclient using this:
    processorLocal =(IItemProcessor)initialContext.lookup(IItemProcessor.class.getName());I got errors like the following, do you know why? Thanks a lot!
    Exception in thread "main" javax.naming.NameNotFoundException: sessions.IItemProcessor not found
         at com.sun.enterprise.naming.TransientContext.doLookup(TransientContext.java:203)
         at com.sun.enterprise.naming.TransientContext.lookup(TransientContext.java:175)
         at com.sun.enterprise.naming.SerialContextProviderImpl.lookup(SerialContextProviderImpl.java:61)
         at com.sun.enterprise.naming.RemoteSerialContextProviderImpl.lookup(RemoteSerialContextProviderImpl.java:116)
         at sun.reflect.GeneratedMethodAccessor114.invoke(Unknown Source)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:597)
         at com.sun.corba.ee.impl.presentation.rmi.ReflectiveTie._invoke(ReflectiveTie.java:121)
         at com.sun.corba.ee.impl.protocol.CorbaServerRequestDispatcherImpl.dispatchToServant(CorbaServerRequestDispatcherImpl.java:650)
         at com.sun.corba.ee.impl.protocol.CorbaServerRequestDispatcherImpl.dispatch(CorbaServerRequestDispatcherImpl.java:193)
         at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequestRequest(CorbaMessageMediatorImpl.java:1705)
         at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequest(CorbaMessageMediatorImpl.java:1565)
         at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleInput(CorbaMessageMediatorImpl.java:947)
         at com.sun.corba.ee.impl.protocol.giopmsgheaders.RequestMessage_1_2.callback(RequestMessage_1_2.java:178)
         at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequest(CorbaMessageMediatorImpl.java:717)
         at com.sun.corba.ee.impl.transport.SocketOrChannelConnectionImpl.dispatch(SocketOrChannelConnectionImpl.java:473)
         at com.sun.corba.ee.impl.transport.SocketOrChannelConnectionImpl.doWork(SocketOrChannelConnectionImpl.java:1270)
         at com.sun.corba.ee.impl.orbutil.threadpool.ThreadPoolImpl$WorkerThread.run(ThreadPoolImpl.java:479)

    BTW, findItemByTitle(String title) is a business method in my ItemProcessor session bean.
    public String findItemByTitle(String title) {
              AuctionItem item;
              String result = null;
              try {
                   Query query = entityManager
                             .createNativeQuery("SELECT i from AuctionItem i WHERE i.title LIKE : aTitle");
                   query.setParameter("aTitle", title);
                   item = (AuctionItem) query.getSingleResult();
                   result = item.toString();
              } catch (EntityNotFoundException notFound) {
              } catch (NonUniqueResultException nonUnique) {
              return result;
         }

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

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

Maybe you are looking for