Use remote or local interface in my CMP EB?

I found it's suggested to writer your CMP EB with Local interface.and a Session Bean with Remote interface.and bundle them into a same EJB JAR file.my end-user client (WAR file) call SB in another JVM.
I wrote two methods in my SB named [CreateAuser & DeleteAuser] which call enity bean by local interface.
and I found it wokrs good anywhere while doing Create or Remove an enity object in my jsp files;
But I have no way to directly call enity bean in jsp files to do database query.
Do I have to write a method like findbyuserid which calls entity bean's home method findByPrimaryKey()? if so I should rewriter many methods in my SB to meet my jsp files need.
What shall I do ,what is the common way to do sth like that?

Hi,
You SessionBean (Session Facade pattern) should provide service such as Business Service (Create User, Remote User, GetUser ...) that's the role of SessionBean as Session Facade.
All the method you expect to call from Presentation Tier.
Regards
Sebastien Degardin.

Similar Messages

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

  • Remote and local interfaces....

    Hey.. I used to work with weblogic 8, and now have to work with 10.01....
    I remember reading some documentation about that the container can see what JVM it is running in... and hence that creating localhome interfaces it not necessary.... creating remote interfaces should be ok... as the container wont be making any remote calls and serialization when it can see that the applications are running in the same JVM...
    But where can i find some documentation about this... ???
    Regards
    Kris

    Hi Kristian,
    The term local can be misleading ...
    You've got to understand that when you talk about local with EJBs, it's not in the same JVM but within the same EAR.
    If you want to go further, I detailed the use of EJB3 on WLS 10 on my blog :
    http://m-button.blogspot.com/2008/07/reminder-on-how-to-use-ejb3-with.html
    Regards,
    Maxence.

  • Remote interface / Local interface

    Hi
    I would like to if its possible to avoid using remote interfaces completely and improve performance by using - JSP -> Servlet -> (local interface) Session bean -> Entity bean ???
    Let the client call from JSP which is sent to control servlet which uses local-interface to send the request to a session bean that may in turn interact with Entity bean ?
    Is there any specific guidelines regarding that ?
    Thanks
    Ramesh

    building thru ANT is much more helpful, fast and efficient(I personally haven't tried any tools for builing EARs...:-)....Check out the EAR task in the ANT documentation...it describes each of its option and you will also find the EXAMPLES which you can download and tweak according to your beans....

  • Problem with Local Interfaces (WSAD 5)

    I built an Entity Bean with Local Interface and a Remote Interface (apperently they both have the same JNDI name in WSAD)
    and when I look up for the name from other Session Bean (same EJB group) and I try to cast it to the local interface there is a classCastException.............
    HELP ME

    Nidhi
    I had the same problems as you that went away. If you have both remote and local interfaces defined, and your remote inerface can be accessed via JNDI lookup using (say) "ejb/sessionbean/stateless/HelloHome", then you can access the local intercafe using "local:ejb/ejb/sessionbean/stateless/HelloHome".
    The URL http://localhost:9080/UTC/initialize?port=2809 is very useful to browse the JNDI tree. Just expand "Local EJB beans" and position your mouse over the item of interest. The JNDI lookup name will echo in the bottom (solid) frame of the browser. The only problem is that the jndilookup name will appear (mistakenly) as local:/ejb/ejb/stateless......, just get rid of the first forward-slash to make it look like local:ejb/ejb/stateless....
    Hope this helps
    Somnath

  • 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

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

  • Local Interfaces using CMP

    I am trying to implement a relationship between two entity beans using RI. Entity A defines a remote interface and references Entity B, to which it has a reference, through Entity B's local interface.
    I cannot get this to work. I get a compile error when trying to deploy the application. When I run the Verifier, I get the following error for Entity A:
    Error: No local interfaces defined
    If I take out the relationship and reference to Entity B, everything works fine. I also downloaded an example from the WROX website which does the same thing I'm trying to do. It also brought up the same error.
    Has anyone been able to get this to work with RI?

    http://forum.java.sun.com/thread.jsp?forum=136&thread=166475

  • No performance gain when using local interfaces

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

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

  • Local Interfaces 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

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

  • How to deside weather to write local interface or remote interface

    Hi All.
    in Ejb 2.0 the concept of local and remote interface is introduced.then how to deside weather to wrire local interface or to write remote interface.
    thanks

    Here in lies the problem. That decision shouldn't be up to a developer, it should be the role of the deployer who decides this. I think they got this wrong in 2.0, its been put at the wrong level. You as the coder need to make scalability decisions about the deployment, which you shouldn't need to. One of the big stengths of the EJB's is that anyone can code them because the container does the hard work for you. That paradigm has been broken now, IMHO.
    Having said that, I was at a SUN developer day just the other day and they suggested that the local interface was mainly for fine grained entity beans and that the course grained entity beans would access the fine grained over local interfaces thus allowing a 'cheaper' implementation of relationship modeling in the entity bean layer. In this scheme of things you would then use the remote interface from session beans to access the course grain entity beans.
    Cheers,
    Peter.

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

  • 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

  • Convert a local interface to the remote interface

    Hello *
    Is it possible to convert a local interface to the same bean's remote interface?
    Regards,
    Lukas

    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.

Maybe you are looking for