5 Replies Latest reply: Oct 24, 2012 9:44 AM by MatthewDavidYoung RSS

    JCA adapter with Spring JCA CCI

    MatthewDavidYoung
      Using Tuxedo JCA adapter (12.1.1) on Java 1.6_20 and Spring 3.2.0.....

      Want to get the Tuxedo adapter going outside a container in Spring via the Spring JCA CCI (http://static.springsource.org/spring/docs/3.2.0.M2/reference/html/cci.html). Not much experience with JCA but got the basic idea.

      The resource adapter is the glue for the domain configuration, debug levels and so forth. Started by using the TuxedoClientSideResourceAdapter and registering it to the TuxedoAdapterSupervisor singleton that is used by the TuxedoManagedConnectionFactory. Spring JCA CCI represents the local connection factory inside the LocalConnectionFactoryBean which needs the TuxedoConnectionFactory built by the TuxedoManagedConnectionFactory:
              @Bean
           public TuxedoManagedConnectionFactory tuxedoManagedConnectionFactory() {
                TuxedoClientSideResourceAdapter ra = new TuxedoClientSideResourceAdapter();
                .... (set ra all debugs to true)
                ra.setTraceLevel("100000");
                ra.setLocalAccessPointSpec("//INV000000121176:7001/domainId=matthew");
                ra.setRemoteAccessPointSpec("//vsgtu817.sfa.se:48172/domainId=TR817TU");
      
                try {
                     TuxedoAdapterSupervisor.getInstance().registerClientSideResourceAdapter(ra);
                } catch (ResourceAdapterInternalException e) {
                     System.out.println("Big problem setting resource adapter");
                }
                
                TuxedoManagedConnectionFactory mcf = new TuxedoManagedConnectionFactory();
      
                return mcf;
              }
      
      
              @Bean
           public ConnectionFactory tuxedoConnectionFactory() {
                LocalConnectionFactoryBean cf = new LocalConnectionFactoryBean();
                cf.setManagedConnectionFactory(tuxedoManagedConnectionFactory());
      
                try {
                     cf.afterPropertiesSet();
                } catch (ResourceException e) {
                     System.out.println("Big problem after setting properties");
                }
      
                return (ConnectionFactory) cf.getObject();
           }
      What I am baffled by is that the tracing isn't getting hundred percent. For example I get:
      INFO: Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@1fe1feb: defining beans [org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,applicationConfig,org.springframework.context.annotation.ConfigurationClassPostProcessor.importAwareProcessor,tuxedoManagedConnectionFactory,tuxedoConnectionFactory,tuxedoTransactionManager,tuxedoTemplate,tuxedoDAO]; root of factory hierarchy
      2012-10-18:14:16:03:10:INFO[TuxedoAdapterSupervisor,registerClientSideResourceAdapter]TJA_0220:Tuxedo JCA Adapter, release 12c(12.1.1), resource archive version 1.4.0.0, build date: June 27 2012.
      2012-10-18:14:16:03:10:ERROR[TJAService,TJAService]TJA_0072:Naming exception error: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file:  java.naming.factory.initial
      2012-10-18:14:16:03:10:INFO[TuxedoAdapterSupervisor,createRemoteAccessPoints#2]TJA_0201:INFO: RemoteAccessPoint TR817TU created.
      Expected to see more detailed information about what is going on in the TJASerivce when setting up the context. Which isn't happening due to how I am not correctly rigging Spring. So how to get tracing/debug working? Or can it be that printing via the JUL logger isn't working. Got in my logging.properties file FINEST on everything oracle and weblogic.

      Love to see if anybody has built up JCA outside a container!?
        • 1. Re: JCA adapter with Spring JCA CCI
          user730249
          It looks like Tuxedo JCA Adapter is running in a JVM that its jre/lib/logging.properties still has threshold set at INFO level.
          • 2. Re: JCA adapter with Spring JCA CCI
            MatthewDavidYoung
            Wish that was the case. ;-) Override the logging.properties with the -D directive java.util.logging.config.file. No something else is messing up the logging. In my JUL logging setup I got:
            handlers=java.util.logging.ConsoleHandler
            .level=FINEST
            
            # just in case
            com.oracle.tuxedo=FINEST
            com.bea.core=FINEST
            weblogic=FINEST
            
            java.util.logging.ConsoleHandler.formatter=java.util.logging.SimpleFormatter
            FINEST is definately set for everything Oracle. Plus in the resource adapter I set everything to debug. Weird thing is that the JCA adapter writes out to a "tuxedo" text file in the execution directory. Mimics some of the console data. I am getting some tracing but not complete (from what I have seen on other forum posts).
            • 3. Re: JCA adapter with Spring JCA CCI
              MatthewDavidYoung
              Little bit farther in my configuration but not the entire way. Using the TuxedoClientSideResourceAdapter resource adapter. Setup in Spring as follows:
                   @Bean
                   ResourceAdapterFactoryBean tuxedoResourceAdapter() {
                        TuxedoClientSideResourceAdapter ra = new TuxedoClientSideResourceAdapter();
                        ra.setLocalAccessPointSpec("//INV000000121176:7001/domainId=matthew");
                        ra.setRemoteAccessPointSpec("//vsgtu817.sfa.se:48172/domainId=TR817TU");
              
                        .... (set debug, timeout, local/remote stuff....)
              
                        ResourceAdapterFactoryBean fc = new ResourceAdapterFactoryBean();
                        fc.setResourceAdapter(ra);
              
                        SimpleTaskWorkManager stwm = new SimpleTaskWorkManager(); // basic WM from Spring
                        fc.setWorkManager(stwm);
                        fc.setBootstrapContext(new SimpleBootstrapContext(stwm));  // basic Context from Spring
              
                        return fc;
                   }
              
                   @Bean
                   public ManagedConnectionFactory tuxedoManagedConnectionFactory() {
                        return new TuxedoManagedConnectionFactory();
                   }
              
                   @Bean
                   public LocalConnectionFactoryBean tuxedoConnectionFactoryBean() {
                        LocalConnectionFactoryBean lcfb = new LocalConnectionFactoryBean();
                        lcfb.setManagedConnectionFactory(tuxedoManagedConnectionFactory());
              
                        return lcfb;
                   }
              
                   @Bean
                   public ConnectionFactory tuxedoConnectionFactory() {
                        return (ConnectionFactory) tuxedoConnectionFactoryBean().getObject();
                   }
              
                   @Bean
                   public CciTemplate tuxedoCciTemplate() {
                        CciTemplate ct = new CciTemplate();
                        ct.setConnectionFactory(tuxedoConnectionFactory());
              
                        return ct;
                   }
              There is a bunch of Spring stuff mixed in but the main idea is to wrap the Connection Factory in a template bean (CciTemplate) that eats a Tuxedo interaction specification and handles the start/stop of the connection plus execution. Nowhere in the configuration are resources or the local/remote resource sessions identified. The Oracle documentation says that with the client side the container is responsible for defining resources. Great. How? ;-) Tried doing it by hand:
                   @Autowired
                   CciTemplate template;
              
                   @Test
                   public void pieces() throws ResourceException, TPReplyException, TPException {
                        TuxedoConnectionFactory tcf = (TuxedoConnectionFactory)template.getConnectionFactory();
                        
                        Connection con = ConnectionFactoryUtils.getConnection(template.getConnectionFactory(), template.getConnectionSpec());
                        
                        DMImportBean impBean = new DMImportBean();
                        impBean.setRemoteName("whatever");
                        impBean.setResourceName("whatever");
                        impBean.setSessionName(new String[] {"TR817TU"});
                        
                        ConfigurationManager.getInstance().activateImport(impBean, tcf.getFactoryName());
              
                        TDomainContext ctx = ((TuxedoJCAConnection)con).getTDomainContext();
                        ctx.tpcall("whatever", recordIn.getTypedBuffer(), flags);
                   }
              The code fails on a NullPointer to getProviderRoute in the TuxedoConnectionImpl. Just wondering if I am on the right track?
              • 4. Re: JCA adapter with Spring JCA CCI
                MatthewDavidYoung
                After rereading the Oracle documentation concerning the 3 ways of defining the configuration (xml, factory and client-side) I tested the regular Resource Adapter (RA) with XML and the factory/client-side through their RA properties. All 3 methods update the configuration manager when the RA is registered via the supervisor when Spring issues a call to the start method when the ResourceAdapterFactoryBean is created (afterSetProperties call). So I should have a configuration regular of which RA implementation I choose. However, the setup stills fails in the TuxedoInteraction.doTPCall with a NullPointer exception. Assuming the problem is still down in the TuxedoConnection implementation.

                Set the following in my Tuxedo Client Side RA:
                          ra.setAutoTran(true);
                          
                          ra.setSpCredentialPolicy("LOCAL");
                          
                          ra.setLocalAccessPointSpec("//INV000000121176:7001/domainId=INV000000121176");
                          ra.setRemoteAccessPointSpec("//vsgktdp010:30100/domainId=tdp010k2");
                          
                          ra.setImpResourceName("TOUPPER");
                Ran a test:
                     @Test
                     public void dummy() {
                          ArrayList<RouteGroup> services_set = ServiceManager.getServiceGroupByName("TOUPPER");
                          for (RouteGroup service : services_set) {
                               System.out.println(service.getServiceName());
                          }
                     }
                which finds the TOUPPER service. So the configuration step looks like it works. Guessing that my route is not available.
                • 5. Re: JCA adapter with Spring JCA CCI
                  MatthewDavidYoung
                  Small step further. Went back to a problem with the TJAService startup whereby I was getting a naming exception. Something with create subcontexts so I added a Spring SimpleNamingContextBuilder to define a default context. That elevated the TJAService 072 fatal. Which resulted in a different failure not a Null pointer exception:
                  org.springframework.dao.DataAccessResourceFailureException: CCI operation failed; nested exception is javax.resource.ResourceException: TPCALL failed TPException:TPENOENT(6):0:0:TPED_MINVAL(0):QMNONE(0):0:No local or remote domain available for TOUPPER
                  Caused by: javax.resource.ResourceException: TPCALL failed TPException:TPENOENT(6):0:0:TPED_MINVAL(0):QMNONE(0):0:No local or remote domain available for TOUPPER
                       at com.oracle.tuxedo.adapter.cci.TuxedoInteraction.doTPCall(TuxedoInteraction.java:1019)
                       at com.oracle.tuxedo.adapter.cci.TuxedoInteraction.execute(TuxedoInteraction.java:407)
                       at org.springframework.jca.cci.core.CciTemplate$2.doInInteraction(CciTemplate.java:276)
                       at org.springframework.jca.cci.core.CciTemplate$1.doInConnection(CciTemplate.java:217)
                       at org.springframework.jca.cci.core.CciTemplate.execute(CciTemplate.java:194)
                       ... 32 more