Topic
9 replies Latest Post - ‏2011-05-23T14:04:06Z by SystemAdmin
BrokerDevelop1
BrokerDevelop1
5 Posts
ACCEPTED ANSWER

Pinned topic SCA EJB 3 Implementation

‏2011-05-19T14:55:01Z |
Hi,

I have created a Distinguished Application Composite in an EAR project.
The EAR contains an EJB and Web module and itself has an SCA facet.

BrokerDepositRatesEAR.ear (contains)
BrokerDepositRatesWeb.war (contains a Servlet using @Reference to an EJB3 Session bean Remote interface)
BrokerDepositRatesEJB.jar (contains an EJB3 session bean using JPA entities to connect to 2 databases)

The composite file is attached (application.composite)

When I invoke the servlet which uses :

"@Reference BrokerSavingsRatesServiceBeanRemote brokerSavingsRatesServiceBeanRemoteRef"

(which matches the reference name in the component xml file)

to call the method on the remote session interface I get this error:


19/05/11 11:55:10:613 IST 00000019 InjectionBind E CWNEN0030E: The com.ibm.ws.soa.sca.injection.util.IndirectSCALookupObjectFactory@1a71afd factory encountered a problem getting the object instance Reference Class Name: com.ebs.brokerdeposits.web.BrokerDepositRatesServlet/brokerSavingsRatesServiceBeanRemoteRef
Type: SCAJEEInfo
Content: _JEEName = app5116345980415654804#BrokerDepositRatesWeb.war
_applicationName = app5116345980415654804
_moduleName = BrokerDepositRatesWeb.war
_annotationName = brokerSavingsRatesServiceBeanRemoteRef
_annotationType = interface org.osoa.sca.annotations.Reference
_injectionClassTypeinterface com.ebs.brokersavings.rates.BrokerSavingsRatesServiceBeanRemote
_requiredtrue


The following tutorial seems to follow a similar pattern
http://publib.boulder.ibm.com/infocenter/rsahelp/v8/index.jsp?topic=/com.ibm.sca.tools.doc/tutorials/accountservices/topics/sca_account3.html

Would anyone know what I am doing incorrectly or is this possible?
Thanks
Updated on 2011-05-23T14:04:06Z at 2011-05-23T14:04:06Z by SystemAdmin
  • BrokerDevelop1
    BrokerDevelop1
    5 Posts
    ACCEPTED ANSWER

    Re: SCA EJB 3 Implementation

    ‏2011-05-19T15:11:49Z  in response to BrokerDevelop1
    Hi Again

    When I add a Service to the Component called

    BrokerDepositRatesService

    with a Java interface "com.ebs.brokersavings.rates.BrokerSavingsRatesServiceBeanRemote".

    And use the name "BrokerDepositRatesService" in the @Reference tag, I get the same error except this time the anotatation name is "BrokerDepositRatesService"

    Type: SCAJEEInfo
    Content: _JEEName = app4263885877145735353#BrokerDepositRatesWeb.war
    _applicationName = app4263885877145735353
    _moduleName = BrokerDepositRatesWeb.war
    _annotationName = BrokerDepositRatesService
    _annotationType = interface org.osoa.sca.annotations.Reference
    _injectionClassTypeinterface com.ebs.brokersavings.rates.BrokerSavingsRatesServiceBeanRemote
    _requiredtrue
    • SystemAdmin
      SystemAdmin
      126 Posts
      ACCEPTED ANSWER

      Re: SCA EJB 3 Implementation

      ‏2011-05-19T15:55:34Z  in response to BrokerDevelop1
      Hello.

      Let me see if I understand you question right. You have an Enhanced EAR which contains two archives, one WAR and one EJB JAR. In you WAR archive you have a Servlet that is calling an EJB through SCA injection. So I guess your Servlet looks like this:

      
      
      
      public 
      
      class MyServlet 
      
      extends HttpServlet 
      { @Reference 
      
      public MyEJBRemote myEjbRemoteRef; 
      }
      


      and your EJB is something like this:
      
      @Remote 
      
      public 
      
      interface MyEJBRemote 
      { 
      }   @EJB 
      
      public 
      
      class MyEJBBean 
      
      implements MyEJBRemote  
      { 
      }
      


      Your Distinguished Composite should look like this:

      
      <composite xmlns=
      "http://www.osoa.org/xmlns/sca/1.0" autowire=
      "false" name=
      "application" targetNamespace=
      "http://some.uri">   <component name=
      "EJBComponent"> <implementation.ejb ejb-link=
      "MyEJB.jar#MyEJBBean"/> <service name=
      "MyEJBBean_MyEJBRemote"> <interface.java interface=
      "MyEJBRemote"/> </service> </component>   <component name=
      "WARComponent"> <implementation.web web-uri=
      "MyWAR.war"/> <reference name=
      "myEjbRemoteRef"> <interface.java interface=
      "MyEJBRemote"/> </reference> </component>   <reference name=
      "myEjbRemoteRef"  promote=
      "WARComponent/myEjbRemoteRef"> <interface.java interface=
      "MyEJBRemote"/> </reference>   </composite>
      


      Note that the service name of an EJB interface is named as NameOfEJBBean_NameOfRemoteInterface.

      Please, let us know if this helps.

      "Software development has been, is, and will remain fundamentally hard"
      - Grady Booch
      • SystemAdmin
        SystemAdmin
        126 Posts
        ACCEPTED ANSWER

        Re: SCA EJB 3 Implementation

        ‏2011-05-19T19:56:44Z  in response to SystemAdmin
        I'm just realizing that the reference and service are not wiring between each other, but just in case you want that I'm posting the composite with this scenario (instead of promoting the reference). Check the target attribute in reference element

        
        <composite xmlns=
        "http://www.osoa.org/xmlns/sca/1.0" autowire=
        "false" name=
        "application" targetNamespace=
        "http://some.uri"> <component name=
        "EJBComponent"> <implementation.ejb ejb-link=
        "MyEJB.jar#MyEJBBean"/> <service name=
        "MyEJBBean_MyEJBRemote"> <interface.java interface=
        "MyEJBRemote"/> </service> </component> <component name=
        "WARComponent"> <implementation.web web-uri=
        "MyWAR.war"/> <reference name=
        "myEjbRemoteRef" target=
        "EJBComponent/MyEJBBean_MyEJBRemote"> <interface.java interface=
        "MyEJBRemote"/> </reference> </component> </composite>
        


        "Software development has been, is, and will remain fundamentally hard"
        - Grady Booch
  • BrokerDevelop1
    BrokerDevelop1
    5 Posts
    ACCEPTED ANSWER

    Re: SCA EJB 3 Implementation

    ‏2011-05-20T09:30:09Z  in response to BrokerDevelop1
    Hi

    Thanks for the reply

    I tried both combinations of the composite that you posted:

    1-------------------
    <component name="BrokerDepositRatesEJBComponent">
    <implementation.ejb ejb-link="BrokerSavingsRatesEJB.jar#BrokerSavingsRatesServiceBean"/>
    <service name="BrokerSavingsRatesServiceBean_BrokerSavingsRatesServiceBeanRemote">
    <interface.java interface="com.ebs.brokersavings.rates.BrokerSavingsRatesServiceBeanRemote"/>
    </service>
    </component>

    <component name="BrokerDepositRatesWebComponent">
    <implementation.web web-uri="BrokerSavingsRatesWeb.war"/>
    <reference name="brokerSavingsRatesServiceBeanRemoteRef">
    <interface.java interface="com.ebs.brokersavings.rates.BrokerSavingsRatesServiceBeanRemote"/>
    </reference>
    </component>

    <reference name="brokerSavingsRatesServiceBeanRemoteRef" promote="BrokerDepositRatesWebComponent/brokerSavingsRatesServiceBeanRemoteRef">
    <interface.java interface="com.ebs.brokersavings.rates.BrokerSavingsRatesServiceBeanRemote"/>
    </reference>

    2------------------

    <component name="BrokerDepositRatesEJBComponent">
    <implementation.ejb ejb-link="BrokerSavingsRatesEJB.jar#BrokerSavingsRatesServiceBean"/>
    <service name="BrokerSavingsRatesServiceBean_BrokerSavingsRatesServiceBeanRemote">
    <interface.java interface="com.ebs.brokersavings.rates.BrokerSavingsRatesServiceBeanRemote"/>
    </service>
    </component>

    <component name="BrokerDepositRatesWebComponent">
    <implementation.web web-uri="BrokerSavingsRatesWeb.war"/>
    <reference name="brokerSavingsRatesServiceBeanRemoteRef" target="BrokerDepositRatesEJBComponent/BrokerSavingsRatesServiceBean_BrokerSavingsRatesServiceBeanRemote">
    <interface.java interface="com.ebs.brokersavings.rates.BrokerSavingsRatesServiceBeanRemote"/>
    </reference>
    </component>


    But I still get the following error:

    20/05/11 10:24:17:783 IST 0000001a InjectionBind E CWNEN0030E: The com.ibm.ws.soa.sca.injection.util.IndirectSCALookupObjectFactory@1b230c2 factory encountered a problem getting the object instance Reference Class Name: com.ebs.brokerdeposits.web.BrokerDepositRatesServlet/brokerSavingsRatesServiceBeanRemoteRef
    Type: SCAJEEInfo
    Content: _JEEName = app7826522136719085207#BrokerDepositRatesWeb.war
    _applicationName = app7826522136719085207
    _moduleName = BrokerDepositRatesWeb.war
    _annotationName = brokerSavingsRatesServiceBeanRemoteRef
    _annotationType = interface org.osoa.sca.annotations.Reference
    _injectionClassTypeinterface com.ebs.brokersavings.rates.BrokerSavingsRatesServiceBeanRemote
    _requiredtrue


    I'm not sure if (above)
    com.ebs.brokerdeposits.web.BrokerDepositRatesServlet/brokerSavingsRatesServiceBeanRemoteRef

    is correct to be able to resolve.

    thanks
    • SystemAdmin
      SystemAdmin
      126 Posts
      ACCEPTED ANSWER

      Re: SCA EJB 3 Implementation

      ‏2011-05-20T14:33:46Z  in response to BrokerDevelop1
      Hmmm... this looks really odd to me. Can you please download the SCA Java EE sample and try it? In RAD/RSA 8 you can go to Help > Help Contents and then navigate through Samples > SCA > SCA Java EE Sample. In RAD/RSA 7.x you can simply go to Help > Samples.

      I know it is a bit different (this sample doesn't have an EJB implementation), but as far as the @Reference concern it is the same (using a @Reference from a Servlet that is pointing to a Service (Remote EJB) in a Component implemented by JEE, which in turn has an EJB module).

      Also, it would be really helpful to know the version levels you have. In order to do this, in RAD/RSA you can go to Help > About... And for WAS you can execute this command in a DOS terminal:
      
      <WAS_INSTALL_DIR>\bin\versionInfo.bat
      

      Thanks you, let us know the results!

      "Software development has been, is, and will remain fundamentally hard"
      - Grady Booch
  • BrokerDevelop1
    BrokerDevelop1
    5 Posts
    ACCEPTED ANSWER

    Re: SCA EJB 3 Implementation

    ‏2011-05-20T15:56:43Z  in response to BrokerDevelop1
    Hi

    thanks for the reply.

    the WAS version is
    Name IBM WebSphere Application Server
    Version 8.0.0.0
    ID BASE
    Build Level hh1108.14
    Build Date 2/25/11

    the RAD version is 8.0.2


    Yes I have installed and successfully tested the SCA helloJEE sample.


    In the logs when running the sample I notice the URI:

    20/05/11 16:43:37:804 IST 000002f5 SCAServiceBin I CWSBD0001I: Domain component service ready for invocation over the default binding. Component/service name = EnhancedSbeanComponent/HelloJeeEnhancedSBean_HelloJeeEnhancedSBeanRemote and URI = HelloJeeEnhancedComponent/EnhancedSbeanComponent/HelloJeeEnhancedSBean_HelloJeeEnhancedSBeanRemote.
    With my own application when I tried to use the CompositeContext class in the Servlet to resolve the RemoteBean I got this error (notice the URI is null)

    compositeContext.getService(BrokerSavignsRatesServiceBeanRemote.class, "BrokerDepositRatesEJBComponent/BrokerSavingsRatesServiceBean_BrokerSavingsRatesServiceBeanRemote")

    ication app5506979669705623505. Exception created : [com.ibm.websphere.sca.context.NoSuchServiceException: getService failed for interface=interface com.ebs.brokersavings.rates.BrokerSavingsRatesServiceBeanRemote and service='BrokerDepositRatesEJBComponent/BrokerSavingsRatesServiceBean_BrokerSavingsRatesServiceBeanRemote' and domainURI='null'

    thanks again
    • HasanMuhammad
      HasanMuhammad
      8 Posts
      ACCEPTED ANSWER

      Re: SCA EJB 3 Implementation

      ‏2011-05-20T20:23:08Z  in response to BrokerDevelop1
      You are wiring the reference to the component service within the application.composite itself. This will not work, because ultimately the name of the service BrokerDepositRatesEJBComponent/BrokerSavingsRatesServiceBean_BrokerSavingsRatesServiceBeanRemote is going to be depend on whatever component you are using this EAR as a component implementation in your top level deployable composite which is in your SCA JAR application. So you would need to wire the reference target in your deployable composite and not in your application.composite. Please try to do that.
  • BrokerDevelop1
    BrokerDevelop1
    5 Posts
    ACCEPTED ANSWER

    Re: SCA EJB 3 Implementation

    ‏2011-05-23T07:44:45Z  in response to BrokerDevelop1
    Hi

    thanks for your reply. However I am a little confused by it. Your post seems to imply that I need to deploy my EJB in EAR1.ear and my SCA component in another external jar (a separate SCA jar)

    And that both will need seperate composite files, an application.composite and a top level deployable composite. This is not really what i am trying to achieve.

    According to the following link

    http://publib.boulder.ibm.com/infocenter/rsahelp/v8/index.jsp?topic=/com.ibm.sca.tools.doc/tutorials/accounts

    I should be able to create a single Distinguished Application Composite in an SCA Enhanced EAR (which contains both the Session implementation and the web code to test). I am currently developing some new JPA/ejb 3 session database access code and would like to deploy SCA content to access the session bean all in one EAR. preferably using the Local interface of the EJB 3 session bean.

    Thanks again.