8 Replies Latest reply on Dec 16, 2004 2:08 PM by adrian.brock

    getting a JCA reference from a session Bean

    narayanrm

      I have a File Adapter, I have to refer it from a session bean.

      In case of Sun One it has a provision in the rar file which can give its JNDI name (sun-ra.xml), which can give the JNDI name reference of the rar deployed, with the tag

      <sun-connector xmlns="http://java.sun.com/xml/ns/j2ee">

      <resource-adapter jndi-name="myrar" idle-timeout-in-seconds="1000" max-pool-size="32" max-wait-time-in-millis="10000" steady-pool-size="4" >
      </resource-adapter>

      </sun-connector>

      This can be refered in the session Bean with the following tag in the sun-ejb-jar.xml like this:

      <resource-ref>
      <res-ref-name>FiletoFile_PROJECTDeployment1_jcdFiletoFile1_File2ConnectionFactory</res-ref-name>
      <jndi-name>FiletoFile_PROJECTDeployment1_jcdFiletoFile1_File2MCF</jndi-name>
      </resource-ref>

      If I have to refer the rar in the jboss.xml of session bean how should I do that?

      How is the JNDI naming for the rar deplyed taken in case of JBOSS.

      Thanks in Advance.


        • 1. Re: getting a JCA reference from a session Bean
          narayanrm



          Incase of Weblogic also there is a way of referencing / binding the rar in the JNDI the weblogic specific dd in the rar file is : weblogic-ra.xml

          <!DOCTYPE weblogic-connection-factory-dd PUBLIC '-//BEA Systems, Inc.//DTD WebLogic 8.1.0 Connector//EN' 'http://www.bea.com/servers/wls810/dtd/weblogic810-ra.dtd'>
          <weblogic-connection-factory-dd>
          <connection-factory-name>com.stc.connector.fileadapter.FileManagedConnectionFactoryImplExt</connection-factory-name>
          <jndi-name>Project1_Deployment1_Service1_File1MCF</jndi-name>
          <pool-params>
          <initial-capacity>1</initial-capacity>
          <max-capacity>20</max-capacity>
          </pool-params>
          </weblogic-connection-factory-dd>

          • 2. Re: getting a JCA reference from a session Bean
            • 3. Re: getting a JCA reference from a session Bean
              narayanrm


              I have gone thro' this but I am still not clear as to where to add this tag

              <tx-connection-factory>
              ...
              <rar-name>myapplication.ear#jms-ra.rar</rar-name>
              <connection-definition>org.jboss.resource.adapter.jms.JmsConnectionFactory</connection-definition>
              ...
              </tx-connection-factory>

              in the ra.xml? does not jboss have some thing like jboss-ra.xml?

              and how should I then give the resource-reference in my jboss.xml of the session bean?


              <resource-ref>
              <res-ref-name>FiletoFile_PROJECTDeployment1_jcdFiletoFile1_File2ConnectionFactory</res-ref-name>
              <jndi-name>my.ear#my.rar</jndi-name>
              </resource-ref>

              • 4. Re: getting a JCA reference from a session Bean
                narayanrm


                This is my file-ds.xml

                <?xml version="1.0" encoding="UTF-8"?>

                <connection-factories>

                <!-- File XA Resource adapter -->
                <tx-connection-factory>
                <jndi-name>FiletoFile_PROJECTDeployment1_jcdFiletoFile1_File2MCF</jndi-name>
                <xa-transaction/>
                <rar-name>jcdFiletoFile1_File2.rar</rar-name>
                <connection-definition>com.stc.connector.framework.jca.system.STCManagedConnectionFactory</connection-definition>
                </tx-connection-factory>

                </connection-factories>

                I have packaged this along with the rar and I have a session bean in form of a jar in the ear. In the jboss.xml I have given the resource look up as

                <!DOCTYPE jboss PUBLIC "-//JBoss//DTD JBOSS 4.0//EN" "http://www.jboss.org/j2ee/dtd/jboss_4_0.dtd">

                <enterprise-beans>

                <ejb-name>jcdFiletoFile1_File2</ejb-name>
                <jndi-name>ejb/local/stc/FiletoFile_PROJECTDeployment1/deployedServices/jcdFiletoFile1_File2</jndi-name>
                <resource-ref>
                <res-ref-name>FiletoFile_PROJECTDeployment1_jcdFiletoFile1_File2ConnectionFactory</res-ref-name>
                <jndi-name>FiletoFile_PROJECTDeployment1_jcdFiletoFile1_File2MCF</jndi-name>
                </resource-ref>

                </enterprise-beans>


                Its giving the following stack trace:

                22:52:03,427 ERROR [EWayRuntimeHandler] Failed to terminate service for FiletoFile_PROJECTDeployment1_jcdFilet
                oFile1_File2(ERROR_TERMINATE_GENERAL)
                javax.naming.NamingException: Could not dereference object [Root exception is javax.naming.NameNotFoundExcepti
                on: FiletoFile_PROJECTDeployment1_jcdFiletoFile1_File2MCF not bound]
                at org.jnp.interfaces.NamingContext.resolveLink(NamingContext.java:971)
                at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:614)
                at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:643)
                at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:508)
                at javax.naming.InitialContext.lookup(InitialContext.java:347)
                at com.stc.connector.codegen.fileadapter.EWayRuntimeHandler.getApplicationConnectionFactory(EWayRuntim
                eHandler.java:394)
                at com.stc.connector.codegen.fileadapter.EWayRuntimeHandler.initializeService(EWayRuntimeHandler.java:
                365)
                at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
                at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                at java.lang.reflect.Method.invoke(Method.java:324)
                at org.jboss.invocation.Invocation.performCall(Invocation.java:345)
                at org.jboss.ejb.StatefulSessionContainer$ContainerInterceptor.invoke(StatefulSessionContainer.java:52
                1)
                at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:128)
                at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor
                .java:185)
                at org.jboss.ejb.plugins.StatefulSessionInstanceInterceptor.invoke(StatefulSessionInstanceInterceptor.
                java:294)
                at org.jboss.ejb.plugins.CallValidationInterceptor.invoke(CallValidationInterceptor.java:48)
                at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:105)
                at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:316)
                at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:149)
                at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:191)
                at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInterceptor.java:122)
                at org.jboss.ejb.SessionContainer.internalInvoke(SessionContainer.java:624)
                at org.jboss.ejb.Container.invoke(Container.java:854)
                at org.jboss.ejb.plugins.local.BaseLocalProxyFactory.invoke(BaseLocalProxyFactory.java:413)
                at org.jboss.ejb.plugins.local.StatefulSessionProxy.invoke(StatefulSessionProxy.java:58)
                at $Proxy132.initializeService(Unknown Source)
                at FiletoFile_PROJECT.jcdFiletoFile1.jcdFiletoFile_Runtime_Handler.handleRequest(jcdFiletoFile_Runtime
                _Handler.java:290)

                Actually I could deploy the same ear file both in sun and websphere application servers as described in my first 2 postings

                Thanks in advance for the reply

                • 5. Re: getting a JCA reference from a session Bean

                  Please post in the beginners forum if you can't read documentation.
                  The FAQ is intended to give pointers (like the -ds.xml link)
                  it is not exhaustive documentation like the getting started or admin docs which
                  you obviously haven't read.

                  Time wasters who require spoon feeding are not welcome here.

                  jboss-ra.xml -> xxx-ds.xml
                  I have just updated the FAQ to try to make this clear for the cerebrally challenged amongst us.
                  If it is not clear from the wording, you are free to rewrite it. It is a WIKI after all.

                  resource-ref is a *very* basic EJB question (examples of which can be found
                  in the getting started guide or admin docs).

                  There is even an example in the post "FAQ - read this second" at the top of this forum,
                  despite the fact that it is NOT a JCA question.
                  I only added it to the JCA FAQ because I got tired of telling newbies to RTFM
                  or search the EJB forum where this question is answered
                  (and ignored) god knows how many times.

                  • 6. Re: getting a JCA reference from a session Bean
                    narayanrm


                    Sorry If I have posted it incorrectly Though I have my file-ds.xml, which earlier I have told that I have packaged with my rar, While depoying the ear I am getting the same problem.

                    "Could not dereference object [Root exception is javax.naming.NameNotFoundExcepti
                    on: FiletoFile_PROJECTDeployment1_jcdFiletoFile1_File2MCF not bound"

                    please suggest me where did I went wrong. Because in the other application servers the same ear did work with the above configurations.

                    • 7. Re: getting a JCA reference from a session Bean

                      Do you even understand why I am getting annoyed with you?

                      We give you the software for free, we give you the documentation for free,
                      we even give you free help in these forums.

                      All that we ask is that you make an effort to understand what you are doing
                      before posting. We are interested in real problems, i.e. bugs, things that
                      are not in the documentation, interesting discussions.

                      These forums are not for people who make random, uneducated modifications
                      to the configuration, then dump the stacktrace into a post for others to solve.

                      What does it say here on the WIKI about jndi-name and use-java-context?
                      http://www.jboss.org/wiki/Wiki.jsp?page=ConfigJCACommon

                      What does the example in the FAQ post at the top of this forum show
                      for the resource-ref binding in jboss.xml?
                      http://www.jboss.org/index.html?module=bb&op=viewtopic&t=46930

                      <jboss>
                      <enterprise-beans>
                      <session>
                       <ejb-name>Whatever</ejb-name>
                      ...
                       <resource-ref>
                       <description>The default DS</description>
                       <res-ref-name>jdbc/DataSource</res-ref-name>
                       <jndi-name>java:/MySQLDS</jndi-name>
                       </resource-ref>
                      </session>
                      </enterprise-beans>
                      </jboss>
                      



                      • 8. Re: getting a JCA reference from a session Bean

                        Claiming things work correctly in other application servers and not in JBoss
                        isn't going to endear you to people who might want to help you, is it?

                        Especially, when the real problem is your lack of ability to read documentation
                        or use search engines.