Use of local interfaces

Hello,
I am trying to deploy a web application that uses local ejb interfaces. The app server I use is Jonas. I successfully deployed the ejb as well as the web app however I get a java.lang.NoClassDefFoundError error when I try to access the ejb from the web app. What I am getting wrong?
Thanks in advance,
Julien.

Hello,
Here is the code in my business delegate
try {
               ResourceSessionFacadeHomeLocal home = (ResourceSessionFacadeHomeLocal) ServiceLocator.getInstance().getLocalHome("AccountSessionFacadeHome_L");
               session = home.create();
          } catch (ServiceLocatorException e) {
               //TODO: translate exc
               e.printStackTrace();
          } catch (CreateException e) {
               //TODO: translate exc
               e.printStackTrace();
          }and my service locator:
public EJBLocalHome getLocalHome(String jndiHomeName) throws ServiceLocatorException {
          EJBLocalHome localHome = null;
          try {
               if (cache.containsKey(jndiHomeName)) {
                    localHome = (EJBLocalHome) cache.get(jndiHomeName);
               } else {
                    localHome = (EJBLocalHome) initialContext.lookup(jndiHomeName);
                    cache.put(jndiHomeName, localHome);
          } catch (NamingException nex) {
               nex.printStackTrace();
               throw new ServiceLocatorException(nex);
          } catch (Exception ex) {
               ex.printStackTrace();
               throw new ServiceLocatorException(ex);
          return localHome;
     }HTH
Julien

Similar Messages

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

  • 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

  • Using EJB Local Interface problem

    Hi to all
    I have got a problem in using Local EJB Interface in Weblogic , please attention to my description
    I use JDeveloper as IDE
    At first I create an Application in JDeveloper that has two projects that their names are Model and ViewContorller that first one contains my EJB and another contains my JSP page respectively
    The EJB code is :
    @Stateless(name="AliEJB001Bean")
    @Remote
    @Local
    public class AliEJB001Bean implements AliEJB001, AliEJB001Local {
    public AliEJB001Bean() {
    public String Hi(){
    return "Hi000";
    And its Local Interface code is :
    @Local
    public interface AliEJB001Local {
    String Hi();
    I deploy Model project to an EJB Jar file that its name is AliEE1ejb1.jar
    and I deploy the ViewContorller project to a WAR file that its name is AliEE1WebApp.war
    Now I add this tags to web.xml
    <ejb-local-ref>
    <ejb-ref-name>ali/testejb</ejb-ref-name>
    <ejb-ref-type>Session</ejb-ref-type>
    <local>model.AliEJB001Local</local>
    </ejb-local-ref>
    Then I deploy the Application to an EAR file by name AliEE1
    After those I run my JSP page witch calls the EJB in JDeveloper (through Local EJB Interface) , JDeveloper deploy my Application to the ItegratedWeblogicServer
    Ultimately the JSP can calls the EJB through Local Interface and use the Hi method and shows me the result but JDeveloper while compiles the application give me these Warnings :
    Warning: <May 15, 2011 9:02:52 AM PDT> <Error> <J2EE> <BEA-160187> <weblogic.appc failed to compile your application. Recompile with the -verbose option for more details. Please see the error message(s) below.>
    Warning: There are 1 nested errors:
    Warning: weblogic.servlet.internal.dd.compliance.ComplianceException: Element "<ejb-local-ref>" with ejb-ref-name "ali/testejb" must either specify a valid ejb-link element or have a corresponding ejb-reference-descriptor element in weblogic.xml with a valid jndi-name.
    Warning:      at weblogic.servlet.internal.dd.compliance.BaseComplianceChecker.addDescriptorError(BaseComplianceChecker.java:74)
    Warning:      at weblogic.servlet.internal.dd.compliance.BaseComplianceChecker.addDescriptorError(BaseComplianceChecker.java:80)
    Warning:      at weblogic.servlet.internal.dd.compliance.EJBRefsComplianceChecker.validate(EJBRefsComplianceChecker.java:97)
    Warning:      at weblogic.servlet.internal.dd.compliance.EJBRefsComplianceChecker.checkEJBLocalRef(EJBRefsComplianceChecker.java:47)
    Warning:      at weblogic.servlet.internal.dd.compliance.EJBRefsComplianceChecker.check(EJBRefsComplianceChecker.java:39)
    Warning:      at weblogic.servlet.internal.dd.compliance.ComplianceUtils.checkCompliance(ComplianceUtils.java:48)
    Warning:      at weblogic.servlet.jsp.JspcInvoker.checkCompliance(JspcInvoker.java:145)
    Warning:      at weblogic.servlet.jsp.JspcInvoker.compile(JspcInvoker.java:198)
    Warning:      at weblogic.application.compiler.AppcUtils.compileWAR(AppcUtils.java:376)
    Warning:      at weblogic.application.compiler.WARModule.compile(WARModule.java:245)
    Warning:      at weblogic.application.compiler.flow.SingleModuleCompileFlow.proecessModule(SingleModuleCompileFlow.java:18)
    Warning:      at weblogic.application.compiler.flow.SingleModuleFlow.compile(SingleModuleFlow.java:36)
    Warning:      at weblogic.application.compiler.FlowDriver$FlowStateChange.next(FlowDriver.java:69)
    Warning:      at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:41)
    Warning:      at weblogic.application.compiler.FlowDriver.nextState(FlowDriver.java:36)
    Warning:      at weblogic.application.compiler.FlowDriver.run(FlowDriver.java:26)
    Warning:      at weblogic.application.compiler.WARCompiler.compile(WARCompiler.java:29)
    Warning:      at weblogic.application.compiler.flow.AppCompilerFlow.compileInput(AppCompilerFlow.java:112)
    Warning:      at weblogic.application.compiler.flow.AppCompilerFlow.compile(AppCompilerFlow.java:37)
    Warning:      at weblogic.application.compiler.Appc.runBody(Appc.java:198)
    Warning:      at weblogic.utils.compiler.Tool.run(Tool.java:158)
    Warning:      at weblogic.utils.compiler.Tool.run(Tool.java:115)
    Warning:      at weblogic.application.compiler.Appc.main(Appc.java:257)
    Warning:      at weblogic.appc.main(appc.java:14)
    According to the warning messages I wanna add <ejb-link> tag to the web.xml for resolving warnings I add the <ejb-link> like this:
    <ejb-local-ref>
    <ejb-ref-name>ali/testejb</ejb-ref-name>
    <ejb-ref-type>Session</ejb-ref-type>
    <local>model.AliEJB001Local</local>
    <ejb-link>AliEE1ejb1.jar#AliEJB001Bean </ejb-link>
    </ejb-local-ref>
    But when JDeveloper want deploy my application again it shows me this Error
    [09:29:59 AM] Redeploying Application...
    <May 15, 2011 9:29:59 AM PDT> <Error> <Deployer> <BEA-149265> <Failure occurred in the execution of deployment request with ID '1305476999381' for task '7'. Error is: 'weblogic.application.ModuleException: Could not setup environment'
    weblogic.application.ModuleException: Could not setup environment
         at weblogic.servlet.internal.WebAppModule.activateContexts(WebAppModule.java:1499)
         at weblogic.servlet.internal.WebAppModule.activate(WebAppModule.java:442)
         at weblogic.application.internal.flow.ModuleStateDriver$2.next(ModuleStateDriver.java:375)
         at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:41)
         at weblogic.application.internal.flow.ModuleStateDriver.activate(ModuleStateDriver.java:95)
         Truncated. see log file for complete stacktrace
    Caused By: weblogic.deployment.EnvironmentException: [J2EE:160101]Error: The ejb-link 'AliEE1ejb1.jar#AliEJB001Bean' declared in the ejb-ref or ejb-local-ref 'ali/testejb' in the application module 'ViewControllerWebApp.war' could not be resolved. The target EJB for the ejb-ref could not be found. Please ensure the link is correct.
         at weblogic.deployment.BaseEnvironmentBuilder.addEJBLinkRef(BaseEnvironmentBuilder.java:464)
         at weblogic.deployment.EnvironmentBuilder.addEJBReferences(EnvironmentBuilder.java:485)
         at weblogic.servlet.internal.CompEnv.activate(CompEnv.java:157)
         at weblogic.servlet.internal.WebAppServletContext.activate(WebAppServletContext.java:3117)
         at weblogic.servlet.internal.WebAppModule.activateContexts(WebAppModule.java:1497)
         Truncated. see log file for complete stacktrace
    >
    <May 15, 2011 9:29:59 AM PDT> <Error> <Deployer> <BEA-149202> <Encountered an exception while attempting to commit the 9 task for the application 'AliEE1'.>
    <May 15, 2011 9:29:59 AM PDT> <Warning> <Deployer> <BEA-149004> <Failures were detected while initiating deploy task for application 'AliEE1'.>
    <May 15, 2011 9:29:59 AM PDT> <Warning> <Deployer> <BEA-149078> <Stack trace for message 149004
    weblogic.application.ModuleException: Could not setup environment
         at weblogic.servlet.internal.WebAppModule.activateContexts(WebAppModule.java:1499)
         at weblogic.servlet.internal.WebAppModule.activate(WebAppModule.java:442)
         at weblogic.application.internal.flow.ModuleStateDriver$2.next(ModuleStateDriver.java:375)
         at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:41)
         at weblogic.application.internal.flow.ModuleStateDriver.activate(ModuleStateDriver.java:95)
         Truncated. see log file for complete stacktrace
    Caused By: weblogic.deployment.EnvironmentException: [J2EE:160101]Error: The ejb-link 'AliEE1ejb1.jar#AliEJB001Bean' declared in the ejb-ref or ejb-local-ref 'ali/testejb' in the application module 'ViewControllerWebApp.war' could not be resolved. The target EJB for the ejb-ref could not be found. Please ensure the link is correct.
         at weblogic.deployment.BaseEnvironmentBuilder.addEJBLinkRef(BaseEnvironmentBuilder.java:464)
         at weblogic.deployment.EnvironmentBuilder.addEJBReferences(EnvironmentBuilder.java:485)
         at weblogic.servlet.internal.CompEnv.activate(CompEnv.java:157)
         at weblogic.servlet.internal.WebAppServletContext.activate(WebAppServletContext.java:3117)
         at weblogic.servlet.internal.WebAppModule.activateContexts(WebAppModule.java:1497)
         Truncated. see log file for complete stacktrace
    >
    [09:30:00 AM] #### Deployment incomplete. ####
    [09:30:00 AM] Remote deployment failed
    Do you know how I can solve this issue ?
    thanks

    Thank you so much
    I find out the solution
    I have to define my EJB in ejb-jar.xml like this
    <enterprise-beans>
         <session>
         <ejb-name>ReplicableSFSB2</ejb-name>
         <business-local>model2.AliEJB001Local</business-local>
         <business-remote>model2.AliEJB001</business-remote>
         <ejb-class>model2.AliEJB001Bean</ejb-class>
         <session-type>Stateless</session-type>
         </session>
    </enterprise-beans>
    And then I use the EJB name witch I defined in <ejb-name> tag in <ejb-link> tag of web.xml
    like this
    <ejb-local-ref>
    <ejb-ref-name>ali/testejb2</ejb-ref-name>
    <ejb-ref-type>Session</ejb-ref-type>
    <local>model2.AliEJB001Local</local>
    <ejb-link>Model2EJB.jar#ReplicableSFSB2</ejb-link>
    </ejb-local-ref>

  • Use of Local interfaces in Servlets

              Can I use ejbLocalHome and ejbLocalObject when a servlet accesses an EJB,
              both are on the same instance of WebLogic server 6.1
              

    Only if the servlet is in the same EAR with the ejb.
              Bill
              Yefim Kogan wrote:
              > Can I use ejbLocalHome and ejbLocalObject when a servlet accesses an EJB,
              > both are on the same instance of WebLogic server 6.1
              

  • Using local interfaces for EJB (session bean)

    Hi,
    I�ve a question regarding when to use the Local interfaces(EJBLocal and EJBLocalHome) of a enterprise bean. I understand that calls to enterprise bean can be made locally if the client which is invoking is in the same JVM as that of EJB. I�ve written a web client (servlet) which is packaged in a EAR and this servlet is trying to invoke a session bean which is in a �different� EAR using local interfaces. Both the EARs have been deployed in a single server (websphere 6.0 server). It didn�t work for me this way�..If I package the servlet in the same EAR of session bean then it works fine.
    So is this to say that both EARs are not running on the same JVM? Or should it work even if the client and the session bean are in different EARs but in same server?
    Can anyone explain me the fundamentals behind this.
    Thanks in advance

    Local access is only portable within the same .ear. For example, the Java EE SDK and SUN's
    application servers have never supported local EJB access from a web/EJB component in a different
    .ear. One issue is that local access requires that both the caller and target EJB have the same
    classloader. By definition, different Java EE applications have distinct classloaders. In addition,
    in Java EE 5 persistence context propagation does not span applications, so it wouldn't work in the
    local case.
    --ken                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • CMP Entity beans using local interfaces

    Why CMP entity beans with CMR relation ship using local interfaces only?
    Why we should not use remote interface to get the CMR field relationship?
    Pls give me the solutions

    "Local interfaces provide the foundation for container-managed relationships among entity beans and session beans. The bean uses the local interface to maintain its references to other beans. For example, an entity bean uses its local interfaces to maintain relationships to other entity beans. Using local interfaces, beans can also expose their state and use pass-by-reference to pass their state between related bean instances. "
    http://java.sun.com/developer/technicalArticles/ebeans/EJB20CMP/

  • JBoss and local interfaces (JNDI)

    I'm trying to do simple example involving local interfaces on JBoss.
    There is Bar remote interface, which uses Foo, local interface. And the problem is - i cant locate Foo within Bar:
    ejb-jar.xml:
    <session>
    <ejb-name>BarEjb</ejb-name>
    </session>
    <entity>
    <ejb-name>FooEjb</ejb-name>
    </entity>To make FooEjb accessible for Bar via local interface, as manual says, i have to put additional reference in ejb-jar.xml for Bar:
    <ejb-local-ref>
         <ejb-ref-name>LocalFooEjb</ejb-ref-name>
         <ejb-ref-type>Entity</ejb-ref-type>
         <local-home>beans.FooHome</local-home>
         <local>beans.Foo</local>
         <ejb-link>FooEjb</ejb-link>
    </ejb-local-ref>But it doesnt change anything, JBoss maps Foo like this: "Bound EJB LocalHome 'FooEjb' to jndi 'local/FooEjb@13595063'", and
    public class  Bar ... {
    Object ref = context.lookup("LocalFooEjb");
    }resuluts in exception:
    "java.lang.RuntimeException: LocalFooEjb not bound ..."
    Question: how do i map local interfaces within JBoss to some human-readable and predictable name?
    Thanks for help.
    update:
    specifying JNDI names in jboss.xml does the trick, but i still dont understand why JBoss ignores local-ref element. So anyone who can explain is welcome.
    jboss.xml
    ...xml declaration..
    <jboss>
         <enterprise-beans>
              <session>
                   <ejb-name>StockListEjb</ejb-name>
                   <jndi-name>remote/StockListEjb</jndi-name>
              </session>
              <entity>
                   <ejb-name>StockEjb</ejb-name>
                   <local-jndi-name>local/StockEjb</local-jndi-name>
              </entity>
         </enterprise-beans>
    </jboss>Edited by: anykeyN on Jun 29, 2008 7:06 AM

    [skipped]

  • 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

  • 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

  • Lookup Local Interface from client app

    I have had an entity bean running using the remote interface.
    When I convert over to using a local interface I have problems
    with the jndi lookup. My environment is JDK 1.4, J2EE 1.3.1, Win 2k.
    The deployment using the J2EE RI works fine.
    I need to know what changes to the client code I need to make
    to locate the bean using lookup().
    I have tried two versions of the lookup:
    // same as the version which workds for the remote interface
    Properties p = new java.util.Properties();
    Context ctx = null;
    p.put (javax.naming.Context.INITIAL_CONTEXT_FACTORY,
    "com.sun.jndi.cosnaming.CNCtxFactory");
    p.put(javax.naming.Context.PROVIDER_URL,
    "iiop://localhost:1050");
    ctx = new InitialContext(p);
    Object objref = ctx.lookup("LocalSPIConnector");
    cat.debug ("GOT THE OBJ REF");
    spiHome = (ServiceProviderBeanLocalHome)
    javax.rmi.PortableRemoteObject.narrow (objref,
    ServiceProviderBeanLocalHome.class);
    cat.debug ("AFTER NARROW");
    I get the following exception;
    javax.naming.NameNotFoundException. Root exception is org.omg.CosNaming.NamingContextPackage.NotFound: IDL:omg.org/CosN
    aming/NamingContext/NotFound:1.0
    In the J2EE RI I can see that this JNDI is associated with the bean.
    Is there a different context factory to be used?
    I have tried to use the initialContext and then lookup
    various forms of the JNDi name:
    a. LocalSPIConnector
    b. java:comp/env/ejb/LocalSPIConnector
    c. java:comp/env/LocalSPIConnector
    d. the classpath to the home interface
    All these fail as the name has not been bound

    Thanks for the reply.
    I have simpliefied the lookup to the following:
    Context ctx = new InitialContext();
    spiHome = (ServiceProviderBeanLocalHome) ctx.lookup ("ServiceProviderBeanEJB");
    I still get the following exception:
    javax.naming.NameNotFoundException: ServiceProviderBeanEJB not found
    at com.sun.enterprise.naming.TransientContext.doLookup(TransientContext.java:174)
    I looked up the deployment descriptor from J2EE RI and took the name
    to lookup from the ejb-name:
    <ejb-jar>
    <display-name>localSPIJAR</display-name>
    <enterprise-beans>
         <entity>
              <display-name>ServiceProviderBeanEJB</display-name>
              <ejb-name>ServiceProviderBeanEJB</ejb-name>
    I presume that this is the correct name to use.

  • Creating a simple java client for a session EJB local interface

    Hi all
    Is it possible to create a simple java client for a session ejb local interface with JDeveloper.
    The problem is that it creates a test client for a remote interface only...
    i.e.
    MySessionEJB sessionEJB = context.lookup("MySessionEJB")
    and once i try to adjust it manually for the local interface...
    MySessionEJBLocal sessionEJB = (MySessionEJBLocal) context.lookup("MySessionEJBLocal") (MySessionEJBLocal - is the name of my local interface)
    it generates the exception:
    javax.naming.NotFoundException: SessionEJBLocal not found
    at...........................(RMIClientContext.java:52)
    There is still no problem with accessing the local interface object from the jsf project where i've added <ejb-local-ref> tag into the web.xml file.
    but i need the possibility of testing the simple java client for the local interface to test business methods wich should return objects without indirect properties
    Thanks in advance.
    Alex.

    Pedja thanks for reply.
    I still dont understand what is wrong with my example.
    The first peace of the code i wrote (getting the reference to the remote interface object) works pretty well, and even more it is produced automatically by JDeveloper, so why we cant get a reference to the local interface object the same way?
    Certanly we should use the local interface for getting access to the resource functioning under the same local jvm and i think it doesnt metter wich app server we really use wls or oas or others
    Thanks. Alex.

  • 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

  • [JNDI] problem to publish local interface

    I have a problem (same as OC4J AS), the remote interface work well, but I can't use the local interface:
    package be.starapic.test.ejb;
    import javax.ejb.Local;
    import javax.ejb.Stateless;
    @Stateless(name="mysession2", mappedName="mysession2")
    @Local(MySession2Local.class)
    public class MySession2Bean implements MySession2Local {
         public String sayHello2() {
              return "You are welcome :)";
    Can't find that Local interface when browsing JNDI tree, so I guest you, what must I do ??? I think it would work because I use mappedName, but won't work with local interface :(

    Hi,
    Are you implementing Windows Azure Pack [WAP] solution ?
    If so, then I would request to post your question once again on the Azure Pack Forum.
    http://social.msdn.microsoft.com/forums/azure/en-US/home?forum=windowsazurepack
    Regards,
    Mekh.

  • Local interfaces

    Hi,
    the EJB 2.0 allows multiple entity beans to have container-managed relationships among themselves. It accomplishes this by introducing a local model which uses local interfaces, in addition to a remote model that uses remote interfaces.
    Now my question: Is it possible to have a relationship between a EJB of one container and a EJB of another container over remote interface? I do not like to use a local interface for that task.
    so far,
    Christian

    You asked: Is it possible to have a relationship between a EJB of one container and a EJB of another container over remote interface? I do not like to use a local interface for that task.
    First, via a local interface you will never be able to access an EJB in another EJB container (as others already said).
    But second: Maybe you want to let your EJB interfaces to extend both the EJBObject and the EJBLocalObject interfaces?
    But most of all I do not understand why you "do not like to use a local interface for that task.". I would be quite happy if I could use local EJB interfaces as often as possible because access to them is said to be 2.000 times faster than via normal/remote interfaces, see my topic
    "Inter-EJB calls 2000 times faster by using LOCAL EJBs - great! But how?" that I posted today.
    Good luck,
    Thomas.

Maybe you are looking for