2 Replies Latest reply: May 16, 2011 5:42 AM by TakhteJamshid RSS

    Using EJB Local Interface problem

    TakhteJamshid
      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
        • 1. Re: Using EJB Local Interface problem
          Pierluigi Vernetto
          looking at:
          http://download.oracle.com/docs/cd/B32110_01/web.1013/b28221/servjndi004.htm

          maybe ejb-ref-mapping is what is missing from your DDs ?
          • 2. Re: Using EJB Local Interface problem
            TakhteJamshid
            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>