How local interfaces work in EJBs

How exactly local interfaces work in EJBs and how should I use them ?
Thank you.

They are simply non-RMI interface implementations that directly delgate to the EJB's implementation. They are called and in turn call the EJB just as you would call any normal class.
As such, there is no RMI or serialization overhead and the interfaces can include methods that update their arguments, something not possible in remote interfaces.
Generally speaking, you should define local interfaces for all entities as one seldom if ever would access entities remotely. You might even consider defining ONLY local interfaces for entities, but that is a tougher call.
You would define local interfaces for session EJB's that are invoked by other session EJB's within the same container. I would normally always define both local and remote interfaces unless there is some reason why I can eliminate one or the other.
Chuck

Similar Messages

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

  • Accessing the local interface of an EJB

    Hello.
    I am using Jdeveloper 11G and it's integrated application server. Using the Jdeveloper wizards, i created a simple stateless session EJB which has both a local and a remote interface (code listed below). I then used the "Create test client" option to create a simple test client.
    The way these classes and interfaces are set up by the wizards, i am using the remote interface. However, i would like to lookup the local interface and use that instead. But i just can't figure out how to lookup the local interface of the EJB. I have tried pretty much every variation i can think of but still no success. Is there anyone out there who can give me a hand? Is there a way to see the lookup name in the integrated WLS server?
    My remote interface looks like this:
    @Remote
    public interface SessionEJB {
    and the remote one:
    @Local
    public interface SessionEJBLocal {
    And my EJB class:
    @Stateless(name = "SessionEJB", mappedName = "NewTestApplication-SessionEJB")
    public class SessionEJBBean implements SessionEJBLocal, SessionEJB {
    My test client does this lookup that works fine:
    public class SessionEJBClient1 {
    public static void main(String [] args) {
    try {
    final Context context = getInitialContext();
    SessionEJB sessionEJB = (SessionEJB)context.lookup("NewTestApplication-SessionEJB#model.SessionEJB");
    }

    Hi,
    Your lookup in your client would look something like
    SessionEJBLocal sessionEJB = (SessionEJBLocal)context.lookup("NewTestApplication-SessionEJB#SessionEJBLocal ");
    The part before the # in the lookup is your mapped name from your session facade, and after the # you have your package, like com.oracle. and ending it with your local interface name.
    Just remember that if your client is not actually running inside the application server container (which with the generated test client it wouldn't be, its a java standalone app with a main method), you will not be able to use the local interface, and you would have to look up remote interface. This can be done in exactly the same way as the above line of code, just replacing the local interface parts with the remote interface's. Hope this helps.
    Drikus
    Edited by: Drikus Britz on Jun 3, 2009 8:46 PM
    Edited by: Drikus Britz on Jun 3, 2009 8:50 PM

  • Remote and local interface on same ejb 3.0 bean instance

    Hi,
    Is it posible to get remote and local interface on same ejb 3.0 bean instance.
    For example get local interface of a bean and than pass it as remote to client.
    Both interfaces must operate on same bean instance.
    Thanks
    Zlaja

    yes. You can implement multiple interfaces on a single class, so you can add a local and a remote interface. One trick to avoid duplicate code is to simply make the remote interface extend the local interface; then you only have to add the @Remote annotation and you're done.
    For example get local interface of a bean and than pass it as remote to client.You don't pass an instances to a client, a client looks up a remote instance of the bean through JNDI.

  • 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 marker interface works?

    Marker interface have blank body containing nothing.
    I want to know how implementing class start behaving in that manner or how marker interface technology work??

    Marker interfaces are also called "tag" interfaces since they tag all the derived classes into a category based on their purpose. For example, all classes that implement the Cloneable interface can be cloned (i.e., the clone() method can be called on them). The Java compiler checks to make sure that if the clone() method is called on a class and the class implements the Cloneable interface. For example, consider the following call to the clone() method on an object o:
    MyObject o = new MyObject();
    MyObjectref = (MyObject)(o.clone());
    If the class MyObject does not implement the interface Cloneable (and Cloneable is not implemented by any of the superclasses that MyObject inherits from), the compiler will mark this line as an error. This is because the clone() method may only be called by objects of type "Cloneable." Hence, even though Cloneable is an empty interface, it serves an important purpose.

  • Questions about EJB local interfaces - 9iAS 9.03

    Intro: I am new in developing EJB, and I am trying to build an example to verify that a stateless session bean with local interfaces is quite efficient.
    Q1: I have read that an application trying to access local interfaces of an EJB must run into the same JVM. Does it means that it should be deployed into the same OC4J instance as the servlet?
    Q2: I am using JDev 10g to build the EJB, with local and remote interfaces. Using the internal OC4J container, I can use the remote interfaces but not the internal one: an object of class "_Proxy1" is returned after the lookup (with the same name as given for the remote interface related call). Is it possible to access the local interface?
    Q3: My application architecture is already defined to split the business logic in two EJBs: one stateless session bean for volatile data and one entity bean for a global user list cache. Where can I find a working example (with source code, please) to be deployed on 9iAS that can validate my design?
    Q4: In many places, I read that CMP entity bean are easier to develop than BMP one. Is there any special consideration I should be aware of before implementing a CMP for my global user list cache?
    Thanks a lot, Dom.

    I have just read:
    I think the problem is that local interfaces can only by
    accessed through the same container, and JSP/Servlet's
    one is different from EJB's one, regardless of you many
    application server's instances do you have... Hope this
    is the answer...Is there anyone who know if it applies too to 9iAS?
    A+, Dom

  • ClassCastException by using Local Interface of EJB in other, but local EAR

    Hi,
    I get a ClassCastException if I try to cast the EJSWrapper-Class returned from local EJB Lookup to the interface it implements.
    The environment I use is WSADIE 5.1.1 with integrated Testenvironment.
    I have defined two EARs. One with a Web-Application and one wich contains the EJB to call from the WebApp. Both run in the same appserver instance wich means both run in the same JVM and i should be able to use Local Interface of the EJB.
    The EJB should use Libraries from the Server Environment while the WebApp uses newer Libs than the Server Environment offers(eg axis-rpc,wsdl4j,saaj). The Classloader-Policy of the EAR with the WebApp is set to PARENT_LAST while the Classloader-Policy of the EAR with the EJB is set to PARENT_FIRST.
    I do a Lookup by using an EJB-Local-Reference. The returned object is an EJSLocalStatelessHome-Object, wich implements my LocalEJBInterface. But if i try to cast to Object to this interface a ClassCastException occurs.
    The Classes of the EJB are packaged as follows:
    EJBName.jar contains the EJB-Impl class, the Serverside Implementations for RMI/IIOP interaction an EJSWrapper classes. This jar is packaged with the EJB-EAR.
    EJBClient.jar contains the Local- and Remote-Interface classes and the Stub-classes for EJBHome and EJB-Implementation. This jar is packaged wich both EARs, because of the interfaces, wich are needed in both projects.
    The Classloader of the EAR with the WebApp has no access the jar with the EJB-Impl, the generated Ties- and EJSWrapperclasses because it is located in only the EJB-EAR. But the interface-class is contained in the WebApp-EAR as described above.
    The exact Exception is as follows:
    java.lang.ClassCastException: com/ibm/wsrf/EJSLocalStatelessBPEAdapterHome_c2546ef5 incompatible with com/ibm/wsrf/BPEAdapterLocalHome
    java.lang.Throwable.<init>(Throwable.java)
    java.lang.Throwable.<init>(Throwable.java)
    java.lang.ClassCastException.<init>(ClassCastException.java:53)
    org.tempuri.ResourceDiscoveryService.DiscoverySoapHttpBindingImpl.getResourceEPR(DiscoverySoapHttpBindingImpl.java)
    sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java)
    sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java)
    ... The EJSLocalStatelessBPEAdapterHome_c2546ef5 implements the BPEAdapterLocalHome interface.
    Please, can anyone give me a hint how to solve this problem?
    Thanks in advance, Michael

    Problem solved!
    The different EAR contained each an own copy of the jar with the local and remote interfaces of the EJB. The Problem is caused by the separate classloaders of the EARs in an application server. Each EAR Classloader loads his own version of the interface classes. Is the same class loaded by different classloaders, the JVM handles this classes as different classes. An example if you create an instance of a class in one classloader and try to reference the created instance by the same class from another classloader, the association will fail, because of different classloaders in the same JVM.
    The solution in an application server where you have deployed two projects and want to use local interfaces is, store the interfaces(and only the interfaces) in an directory, where it is found by the parent classloader of the EAR classloaders. Remove the Jar with the interface from the EARs. The EAR Classloaders will then search in the their parent classloader for the interfaces. The interfaces will be loaded by the parent classloader and will recognized as compatible by the JVM.
    Greetings, hope this helps help others!
    Michael

  • Does JDev 9.0.3 support EJB Local Interfaces?

    Hi everyone, we are very interested in using local interfaces for our EJB's to set up and use a standard set of server beans that will run in each server. I did not see any reference to local interfaces in any of the release notes on version 9.0.3.
    Does anyone know? And if not, does anyone know when they might be supported?
    TIA for any responses.

    Yes. Local interfaces for EJBs are supported.

  • 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

  • Creating local interfaces with JDeveloper (release 2)

    Hi
    Maybe I'm missing something here, but how does one create a local- and a local-home interface with JDeveloper? It only seems to give me the option to create a remote- and a home interface.
    I've tried creating the local interfaces by hand and then adding them as <ejb-local-ref> references in the ejb-jar.xml deployment descriptor, but I get the message "local/local-home tag not supported in this version" when trying to test the code with the Embedded OC4J Server.
    Now, I've managed to create EJB 2.0-style CMP entity beans by modifying the code and deployment descriptors a little, which made me believe that EJB 2.0 is supported, but that seems to be where it stops.
    Am I doing something wrong, or is EJB 2.0 not fully implemented in the Embedded OC4J Server yet?
    Hope you can help
    Christof

    JDeveloper 9.0.2 doesn't have support for local interfaces or any EJB 2.0 features.
    Next release of JDeveloper (9.0.3) will have complete support of J2EE 1.3 features including EJB 2.0.
    This release is slated for this summer (2002)
    raghu
    JDev Team

  • Accessing bean using its Local interface

    Hi,
    I have a problem accessing a bean using its local interface in J2EE1.3 environment on J2EE test server. I have two beans, one trying to access other, residing in two different ears. During deployment, after I select "Local" interface option in EJB-refs tag of the standard deployment tool of J2ee, it does not show me the bean-name in the "Enterprise Bean Name" combo-box. When I put the name of the actual bean in the box and try to deploy it, gives the null-pointer exception for the above tag as it does not find the corresponding ejb to be referred.
    Is it necessary to have a client bean and actual bean to be in the same ear for local interface access? The specifications says that both the beans must be in the same container that does not mean same ear, right????
    Thanks

    i am having the exact same problem now.
    did anyone solve this.(you can email [email protected])

  • Basic ques - Local Interface

    Is it mandatory to have Local Interfaces in my ejbs built in EJB2.0? Or can I build
    my beans without them?

    As Rob stated you have to use local ejbs when you define a CMP2.0
    relationship (example Customer-Contact, where Contact is defined as a local
    ejb).
    Also, you could prefer to use local ejbs if you think they are going to be
    accessed from the same virtual machine.
    Do I have to have classes derived from EJBLocalObject and EJBLocalHome in my
    ejb?
    Yes. Your local ejb interface should extend EJBLocalObject and the home
    interface should extend EJBLocalHome.
    "vishal" <[email protected]> wrote in message
    news:3c764d48$[email protected]..
    >
    Do I have to have classes derived from EJBLocalObject and EJBLocalHome inmy ejb?
    >
    >
    Rob Woollen <[email protected]> wrote:
    The only requirement is that container-managed relationships are only
    through local
    interfaces. If you're not using EJB 2.0 CMP relationships, then you
    can continue to
    use remote interfaces if you wish.
    -- Rob
    vishal wrote:
    Is it mandatory to have Local Interfaces in my ejbs built in EJB2.0?Or can I build
    my beans without them?

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

  • How to use local interface in my easy code ?

    hi everybody
    I work on an ejb project. My code is like that to test remote interface (and it works) :
    public class TestStudent {
       Properties properties;
       public TestStudent() {
          properties = new Properties();
          properties.put("java.naming.factory.initial",
          "org.jnp.interfaces.NamingContextFactory");
          properties.put("java.naming.factory.url.pkgs",
          "org.jboss.naming:org.jnp.interfaces");
          properties.put("java.naming.provider.url", "jnp://localhost:1099");
          properties.put("jnp.disableDiscovery", "true");
       public static void main(String[] args) {
          TestStudent beanStudent = new TestStudent();
          beanStudent.createBean();
       public void createBean() throws EJBException {
          try {
             InitialContext context = new InitialContext(properties);
             Object object = context.lookup(StudentHome.JNDI_NAME);
             StudentHome studentHome = (StudentHome) PortableRemoteObject.narrow(object,StudentHome.class);
             Student student = studentHome.create();
             student.setName("pirlouit");
             System.out.println(student.getId());
             System.out.println(student.getName());
          } catch (NamingException e) {
             throw new EJBException(e);
          } catch (RemoteException e) {
             throw new EJBException(e);
          } catch (CreateException e) {
             throw new EJBException(e);
    }Then I do quite the same thing to test local interface like in the following code but it doen't work :
    public class TestStudent {
       Properties properties;
       public TestStudent() {
          properties = new Properties();
          properties.put("java.naming.factory.initial",
          "org.jnp.interfaces.NamingContextFactory");
          properties.put("java.naming.factory.url.pkgs",
          "org.jboss.naming:org.jnp.interfaces");
          properties.put("java.naming.provider.url", "jnp://localhost:1099");
          properties.put("jnp.disableDiscovery", "true");
       public static void main(String[] args) {
          TestStudent beanStudent = new TestStudent();
          beanStudent.createBean();
       public void createBean() throws EJBException {
          try {
             InitialContext context = new InitialContext(properties);
             Object object = context.lookup(StudentLocalHome.JNDI_NAME);
             StudentLocalHome studentLocalHome = (StudentLocalHome)object;
             System.out.println("studentLocalHome is null ? "+studentHome.equals(null));
             StudentLocal student = studentLocalHome.create();
             student.setName("pirlouit");
             System.out.println(student.getId());
             System.out.println(student.getName());
          } catch (NamingException e) {
             throw new EJBException(e);
          } /*catch (RemoteException e) {
             throw new EJBException(e);
          }*/ catch (CreateException e) {
             throw new EJBException(e);
    }The print of "student local home is null ?" give me 'true' which is not the answer I want ... so here is the problem. How can I get my entity bean using local interface ?
    For the moment 've got the exception (which appears on instruction "StudentLocal student = studentLocalHome.create();") :
    Exception in thread "main" java.lang.NullPointerException
         at org.jboss.ejb.plugins.local.LocalHomeProxy.invoke(LocalHomeProxy.java:118)
         at $Proxy0.create(Unknown Source)Please help !! Thank you very much !

    Write a JSP to test Local Interface. You cannot call Local Interface from a remote JVM.
    Jay
    http://www.javarss.com - Java News from around the world.
    Visit JavaRSS.com and add above signature to your messages. Thanks!

Maybe you are looking for

  • Creative Zen 32GB - how do I remove blank FM presets???

    How do I remove blank presets from the FM list? I have about 20 stations set up as presets but the other 2 blank ones are still there. Delete doesn't delete them. All delete does is to erase the station from a preset that has a station programmed int

  • Unable to install Windows 7 on MacBook Pro with Retina

    Hi, After trying to install via Bootcamp, I get this problem: Windows cannot be installed to this disk. This computer's hardware may not support booting to this disk. Ensure that the disk's controller is enabled in the computer's BIOS menu. Any ideas

  • IPhoto updated but now I can't open iPhoto at all

    iPhoto was installed on my MacBook Pro when I purchased it in Sept.(Along with iMovie, iTunes, etc.) I was having problems with editing some of the photos (it wouldn't open up in the edit screen) so I decided to update it. I downloaded the update and

  • Calling PL/SQL from Javascript with htmldb_Get

    Dear all, I'm trying to call a PL/SQL procedure from JS and return a value to JS code. I'm using the htmldb_Get method but I cannot succeed doing this. My PL/SQL : BEGIN htp.prn('Hello World'); END; My JS : function test() { var get = new htmldb_Get(

  • How do I change the color of the scratch area?

    Is there a way to change the color of the scratch area? I am designing an ad for a newspaper that uses a gray background for a particular advertisement section. Thanks, Mark