8 Replies Latest reply on Dec 6, 2010 2:34 PM by Jesper Pedersen

    Embedded JCA with Glassfish

    stackpeek Newbie

      Hi,

       

      I'm working on the integration of IronJacamar (1.0.0.Beta3) with Glassfish (2.1.1). The aim being to use something else than Glassfish (maybe Tomcat) and continue to use our JCA connectors.

       

      The problem I get even if I try to configure the naming.xml file in order to use the local JNDI context is the following exception:

       

      Caused by: com.github.fungal.spi.deployers.DeployException: Installing bean NamingBeanImpl
              at com.github.fungal.impl.DeploymentDeployer$BeanDeployer.run(DeploymentDeployer.java:300)
              ... 6 more
      Caused by: javax.naming.NamingException: java:comp namespace cannot be modified
              at com.sun.enterprise.naming.java.javaURLContext.rebind(javaURLContext.java:262)
              at org.jnp.server.NamingBeanImpl.start(NamingBeanImpl.java:184)
              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:597)
              at com.github.fungal.impl.DeploymentDeployer$BeanDeployer.createBean(DeploymentDeployer.java:521)
              at com.github.fungal.impl.DeploymentDeployer$BeanDeployer.run(DeploymentDeployer.java:286)

       

       

      I modified different implementations in order to not rebind the java namespace, but when I deploy my archive (.rar), I can't find it in the JNDI context.

      And when I specify a xxxxx-ra.xml with a jndi-name property in the connection-definition attribute, I get a NotSerializableException from CachedConnectionManager.

       

       

      Any idea ?

      Thanks

        • 1. Re: Embedded JCA with Glassfish
          Jesper Pedersen Master

          I'm working on the integration of IronJacamar (1.0.0.Beta3) with Glassfish (2.1.1).

           

          Wow, neat

           

          The problem I get even if I try to configure the naming.xml file in order to use the local JNDI context

           

          Well, Glassfish already has a naming implementation active - so you need to use that. For that you need to install a bean called "NamingServer" -- by basically replacing ironjacamar-embedded.jar/naming.xml with your own. That bean needs to make sure that the naming environment is initialized.

           

          You can use "new EmbeddedJCA(false)" to boot a clean environment and then deploy each XML file. See which XML files inside the JAR.

           

          There is some documentation here http://jesperpedersen.github.com/fungal/userguide/en/html/lifecycle.html

          And some examples here: http://jesperpedersen.github.com/fungal/userguide/en/html/examples.html

           

          And when I specify a xxxxx-ra.xml with a jndi-name property in the connection-definition attribute, I get a NotSerializableException from CachedConnectionManager.

           

          Two things -- 1) Did your resource adapter deploy without problems when using the standalone distribution -- e.g. no archive validation errors / warnings ?

           

          2) Can you post the full stack trace for that exception ? I need to see the root cause before I fix it

           

          Thanks, and HTH !

          • 3. Re: Embedded JCA with Glassfish
            stackpeek Newbie

            Hi Jesper,

             

            Thanks for your help. I used "new EmbeddedJCA(false)" to boot a clean environment, and deployed the following XML files: transaction.xml, stdio.xml, jca.xml.

             

            I didn't deploy the naming.xml and comment all the dependencies to the "NamingServer" bean in each of these XML files.
            I assume IronJacamar (IJ) can find the local naming environment (the Glassfish one), cause I could see the bindings of the different tx beans (UserTransaction, TransactionPropagationContextImporter, TransactionPropagationContextExporter, TransactionSynchronizationRegistry, TransactionManager) in the JNDI tree.

             

            I still get the NotSerializableException from org.jboss.jca.core.connectionmanager.ccm.CachedConnectionManager (@see the stack at the end of this post).

             

            I don't get any error at archive validation (I changed the BeanValidation namespace in order to prevent NamingException with java:comp namespace modification). I only get a warning when I use IJ in standalone, but the deployment is OK. I could browse the IJ administration console, and view my connection factory and its different configuration properties.

             


            Below the initialization of the JCA container:

             

            {code}
            embeddedJca = new EmbeddedJCA(false);
            embeddedJca.startup();

             

            embeddedJca.deploy(getUrl("transaction.xml"));
            embeddedJca.deploy(getUrl("stdio.xml"));
            embeddedJca.deploy(getUrl("jca.xml"));

             

            RAActivator raa = embeddedJca.lookup("RAActivator", RAActivator.class);
            if (null == raa) throw new IllegalStateException("RAActivator not defined");
            raa.setEnabled(false);

             

            embeddedJca.deploy(getUrl("MyArchive.rar"));
            embeddedJca.deploy(getUrl("my-ra.xml"));

             

            raa.setEnabled(true);
            {code}

             


            Content of my-ra.xml:

             

            <?xml version="1.0" encoding="UTF-8"?>
            <resource-adapters>
                <resource-adapter>
                    <archive>MyArchive.rar</archive>
                    <transaction-support>XATransaction</transaction-support>
                    <connection-definitions>
                        <connection-definition jndi-name="eis/MyArchive" use-java-context="false" enabled="true" class-name="com.xxx.MCF">
                        </connection-definition>
                    </connection-definitions>
                </resource-adapter>
            </resource-adapters>

             


            Thanks for your help.

             


            Caused by: java.lang.RuntimeException: com.github.fungal.spi.deployers.DeployException: Deployment file:/.../my-ra.xml failed
                    ...
            Caused by: com.github.fungal.spi.deployers.DeployException: Deployment file:/.../application-ra.xml failed
                    at org.jboss.jca.deployers.fungal.RaXmlDeployer.doDeploy(RaXmlDeployer.java:291)
                    at org.jboss.jca.deployers.fungal.RaXmlDeployer.deploy(RaXmlDeployer.java:174)
                    at com.github.fungal.impl.MainDeployerImpl.deploy(MainDeployerImpl.java:162)
                    at com.github.fungal.impl.MainDeployerImpl.deploy(MainDeployerImpl.java:77)
                    at org.jboss.jca.embedded.EmbeddedJCA.deploy(EmbeddedJCA.java:169)
                    ...
                    ... 72 more
            Caused by: java.lang.RuntimeException: Cant copy Serializable object:
                    at com.sun.enterprise.naming.NamingUtils.makeCopyOfObject(NamingUtils.java:82)
                    at com.sun.enterprise.naming.LocalSerialContextProviderImpl.bind(LocalSerialContextProviderImpl.java:89)
                    at com.sun.enterprise.naming.SerialContext.bind(SerialContext.java:472)
                    at org.jboss.util.naming.Util.bind(Util.java:105)
                    at org.jboss.util.naming.Util.bind(Util.java:91)
                    at org.jboss.jca.core.naming.ExplicitJndiStrategy.bindConnectionFactories(ExplicitJndiStrategy.java:140)
                    at org.jboss.jca.deployers.fungal.AbstractFungalRADeployer.bindConnectionFactory(AbstractFungalRADeployer.java:209)
                    at org.jboss.jca.deployers.common.AbstractResourceAdapterDeployer.createObjectsAndInjectValue(AbstractResourceAdapterDeployer.java:1344)
                    at org.jboss.jca.deployers.fungal.RaXmlDeployer.doDeploy(RaXmlDeployer.java:273)
                    ... 77 more
            Caused by: java.io.NotSerializableException: org.jboss.jca.core.connectionmanager.ccm.CachedConnectionManager
                    at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1156)
                    at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1509)
                    at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1474)
                    at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1392)
                    at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1150)
                    at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1509)
                    at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1474)
                    at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1392)
                    at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1150)
                    at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:326)
                    at com.sun.enterprise.naming.NamingUtils.makeCopyOfObject(NamingUtils.java:64)
                    ... 85 more

            • 4. Re: Embedded JCA with Glassfish
              Jesper Pedersen Master

              I could see the bindings of the different tx beans (UserTransaction,  TransactionPropagationContextImporter,  TransactionPropagationContextExporter,  TransactionSynchronizationRegistry, TransactionManager) in the JNDI tree

               

              The transaction manager integration is special, since it implements a JBoss specific SPI that IronJacamar is using. But we can get back to that later.

              I still get the NotSerializableException from org.jboss.jca.core.connectionmanager.ccm.CachedConnectionManager

               

              Ah, yes - I see the problem - the Glassfish naming implementation is more strict

               

              Any chance that you could checkut our code and create a patch ?  You'll need to start from AbstractConnectionManager and work your way out.

               

              There are some instructions here: http://docs.jboss.org/ironjacamar/developerguide/en/html/building.html

               

              You could start by making a test case that tries to serialize the NoTxConnectionManager to a byte stream and read it in again.

              • 5. Re: Embedded JCA with Glassfish
                stackpeek Newbie

                Thanks for your help. Instead of working my way out, I got back to the standalone version in order to validate the solution with IronJacamar.

                I could do a lookup on the "TransactionManager", but as you told me, its integration is special.

                I can see in the logs that my connector is well deployed (ManagedConnectionFactory and so on...), but can't do a lookup on the factory.

                I assume I can't do it the same way than the tx beans... I can browse it from the console. Is there a way to do it from JMX ? Do I have to configure something else ?

                • 6. Re: Embedded JCA with Glassfish
                  Jesper Pedersen Master

                  I got back to the standalone version in order to validate the solution with IronJacamar.

                   

                  Ok - I have added https://jira.jboss.org/browse/JBJCA-477 to keep track of this (assigned to me atm). Let me know if you want to work on it

                   

                  Is there a way to do it from JMX ? Do I have to configure something else ?

                   

                  There is not official client application component model for standalone JCA. You can use the kernel model model (http://jesperpedersen.github.com/fungal/userguide/en/html/) or try if the web container integration is good enough for you.

                   

                  Looking up your connection factories and admin objects should be done through JNDI as you normally would. See http://viewvc.jboss.org/cgi-bin/viewvc.cgi/jbossas/projects/jboss-jca/trunk/deployers/src/test/java/org/jboss/jca/test/deployers/spec/RarTestCase.java?revision=109546&view=markup as an example.

                  • 7. Re: Embedded JCA with Glassfish
                    Jesper Pedersen Master

                    I did a quick fix for https://jira.jboss.org/browse/JBJCA-477 just so you can continue. I'll look into a more complete fix.

                    • 8. Re: Embedded JCA with Glassfish
                      Jesper Pedersen Master

                      And I have uploaded a new Maven snapshot to the repository - if you use Maven or Ivy. Note, that the embedded API has changed (for the better ).