I was messing around with the Tomcat REST API and I found out that it has a command to list all JNDI names for a class. I ran that with the ConnectionFactory I was using and found that it generated a default JNDI name for the ConnectionFactory. Following Romain Manni-Bucau's blog post at https://rmannibucau.wordpress.com/2013/09/25/tomee-and-resource-adapters/, I set up an alias for the ConnectionFactory to the JNDI name that I wanted.
Thanks everyone for their help, Mike Spencer On 07/22/2015 10:46 AM, Mike Spencer wrote:
Hi Uday,That helps greatly. I was able to configure the properties I needed to this way.Is there a way of configuring a JNDI name for the ConnectionFactory via the system.properties? If I use the envContext.lookup("RA NAME") you provided I get a javax.resource.spi.ResourceAdapter implementation back instead of the ConnectionFactory implementation I need. I was able to work around that by adding an id attribute to the <connection-definition> tag and use that the JNDI name for the ConnectionFactory, but I am hoping to avoid modifying the ra.xml if at all possible.The following is for future users who are having troubles with configuring a resource adapter (or anyone who wants to help improve the TomEE documentation)This is a (very simplified) form of the ra.xml I am using (lots of tags have been omitted for brevity's sake):<connector id="Connector_ID"> <resourceadapter> <outbound-resourceadapter> <connection-definition id="eis/ra-connection"> <managedconnectionfactory-class> <config-property> valuesomitted </config-property> <connectionfactory-interface> javax.resource.cci.ConnectionFactory </connectionfactory-interface> all other details omittedTomEE starts up and creates a Resource with a name of Connector_IDRA. This is what I am using to configure the ManagedConnectionFactory implementation properties in system.properties (example: Connector_IDRA.userName=<username> ).I am able to look up the ConnectionFactory implementation under the JNDI name of openejb:Resource/eis/ra-connection (the connection-definition id value).Thanks, Mike Spencer On 07/22/2015 01:31 AM, Uday Gire wrote:Hi 1- To update resource adaptor ManagedConnectionFactory properties:- Open conf/system.properties file in TomEE, and add each managedconnectionfactory property in this file as:- RA_NAME.PROPERTY_NAME=PROPERTY_VALUE2- To get the javax.resource.cci.ConnectionFactory instance, write the following code :Context initialContext = new InitialContext();Context envContext = (Context) initialContext.lookup("openejb:Resource");Object connectionFactory = envContext.lookup(“YOUR RA NAME”);javax.resource.cci.ConnectionFactory connectionFactory = (javax.resource.cci.ConnectionFactory) connectionFactory;Best Uday Gire ManageCat Support uday.g...@managecat.comOn 21 Jul 2015, at 00:37, Mike Spencer<mspen...@denniskirk.com> wrote:Using class-name with the implementation worked, but it turns out that isn't what I needed. I am going to take a step back and try to describe what I am trying to do.I have a resource adapter packaged in a .rar file that includes the JCA implementation .jar and a ra.xml in the META-INF folder. It appears to be deploying to TomEE successfully. It makes two Resources available - one for the <connector id="Connector_ID"> root element and one for the <resourceadapter> using the <resourceadapter id="ra-id"> tag. These resources are currently *not* defined in the tomee.xml file.I need to configure two additional properties outside of the ra.xml as they are specific to the server that the resource adapter is deployed to. In Glassfish they are defined as properties on the <connector-connection-pool> tag. JBoss defines them in a ra-name-ds.xml file. These properties are configuring a javax.resource.spi.ManagedConnectionFactory implementation.In addition, I need to make the javax.resource.cci.ConnectionFactory implementation class defined in the ra.xml available via a JNDI name. Glassfish defines this a a <connector-resource> element that references the <connector-connection-pool> element above. JBoss defines this information in the ra-name-ds.xml file.In my previous attempt, I configured the additional properties using a <Resource class-name="ManagedConnectionFactory impl"> and made that available via JNDI. It turned out that I did not need that implementation but instead I need the javax.resource.cci.ConnectionFactory.Thanks, Mike Spencer On 07/17/2015 04:00 PM, Romain Manni-Bucau wrote:2015-07-17 12:48 GMT-07:00 Mike Spencer<mspen...@denniskirk.com>:class-name should use the actual implementation - it means you instantiate yourself the class by this definition, also means the jar in the rar needsHi Romain,Using class-name allowed it to get past the 'Cannot determine a provider'message, but now I am encountering a new error. This error occurs when using <Resource id="ra-jrac"class-name"javax.resource.cci.ConnectionFactory"></Resource> in tomee.xml:to be added in tomee/libSEVERE: FATAL ERROR: Unknown error in Assembler. Please send the following stack trace and this message tous...@openejb.apache.org :org.apache.xbean.recipe.ConstructionException: Class is an interface:javax.resource.cci.ConnectionFactory When I try to use the concrete implementation(class-name="com.unisys.coms.connector.COMSManagedConnectionFactory") I getthe following error: SEVERE: FATAL ERROR: Unknown error in Assembler. Please send the following stack trace and this message tous...@openejb.apache.org :org.apache.xbean.recipe.ConstructionException: Type class could not befound: com.unisys.coms.connector.COMSConnectionFactoryThe resource adapter I am deploying contains that class. The log says that the .rar is loaded before this error occurs. What could be the reason thatthe Resource definition can't find the class? Thanks, Mike On 07/17/2015 02:04 PM, Romain Manni-Bucau wrote:Hi Using class-name in Resource declaration should make it. That said <ra name as logged>.<property> =<value> in conf/system.properties should work IIRC.Le 17 juil. 2015 20:32, "Mike Spencer"<mspen...@denniskirk.com> aécrit : Hi all,I am trying to migrate an application using a resource adapter in a .rar file from Glassfish to TomEE. The resource adapter needs to be deployedglobally (so multiple application can access it) and make thejavax.resource.cci.ConnectionFactory implementation available via JNDI.I believe I have deployed the resource adapter to TomEE by adding theline<Deployments dir="apps" /> in the tomee.xml file. I see the followinglinesin the logs afterwards, so I am assuming the .rar is detected and madeavailable. INFO: Configuring enterprise application: /opt/apps/tomee-plume-1.7.1/apps/jrac-tweb.rar Jul 17, 2015 1:18:08 PM org.apache.openejb.config.OutputGeneratedDescriptors writeRaXml INFO: Dumping Generated ra.xml to:/opt/apps/tomee-plume-1.7.1/temp/ra-6993024062304172339Connector_ID.xml Jul 17, 2015 1:18:08 PM org.apache.openejb.config.ConfigurationFactoryconfigureServiceINFO: Configuring Service(id=ra-jrac, type=Resource, provider-id=ra-jrac) Jul 17, 2015 1:18:08 PM org.apache.openejb.config.ConfigurationFactoryconfigureService INFO: Configuring Service(id=Connector_ID, type=Resource, provider-id=Connector_ID)Jul 17, 2015 1:18:08 PM org.apache.openejb.config.AppInfoBuilder buildINFO: Enterprise application "/opt/apps/tomee-plume-1.7.1/apps/jrac-tweb.rar" loaded.However, I cannot figure out how to configure properties on the resourceadapter. I need to specify some configuration properties (username,password, etc). In Glassfish, I have the connector-connection-pool and connector-resource elements in the domain.xml where I can configure thisinformation and set up a JNDI name for the connector.I tried to add a <Resource> block to the tomee.xml file, but it failswith the following message: SEVERE: Failed Configuring Service(id=ra-jrac)org.apache.openejb.config.NoSuchProviderException: Cannot determine aprovider for Resource(id=ra-jrac, type=javax.resource.cci.ConnectionFactory, provider=null). Possible valid configurations might be: <Resource id="ra-jrac" type="DataSource"/> <Resource id="ra-jrac" type="javax.sql.DataSource"/> <Resource id="ra-jrac" type="ActiveMQResourceAdapter"/><Resource id="ra-jrac" type="javax.jms.QueueConnectionFactory"/><Resource id="ra-jrac" type="TopicConnectionFactory"/> <Resource id="ra-jrac" type="javax.jms.ConnectionFactory"/><Resource id="ra-jrac" type="javax.jms.TopicConnectionFactory"/><Resource id="ra-jrac" type="QueueConnectionFactory"/> <Resource id="ra-jrac" type="javax.jms.Destination"/> <Resource id="ra-jrac" type="javax.jms.Queue"/> <Resource id="ra-jrac" type="Queue"/> <Resource id="ra-jrac" type="javax.jms.Topic"/> <Resource id="ra-jrac" type="Topic"/> <Resource id="ra-jrac" type="ORB"/> <Resource id="ra-jrac" type="org.omg.CORBA.ORB"/> <Resource id="ra-jrac" type="javax.mail.Session"/> <Resource id="ra-jrac" type="javax.enterprise.concurrent.ManagedExecutorService"/> <Resource id="ra-jrac" type="ManagedExecutorService"/> <Resource id="ra-jrac" type="ManagedScheduledExecutorService"/> <Resource id="ra-jrac"type="javax.enterprise.concurrent.ManagedScheduledExecutorService"/><Resource id="ra-jrac" type="javax.enterprise.concurrent.ManagedThreadFactory"/> <Resource id="ra-jrac" type="ManagedThreadFactory"/> <Resource id="ra-jrac" type="ContextService"/> <Resource id="ra-jrac" type="javax.enterprise.concurrent.ContextService"/> atorg.apache.openejb.config.ConfigurationFactory.configureService(ConfigurationFactory.java:1092)atorg.apache.openejb.config.ConfigurationFactory.getOpenEjbConfiguration(ConfigurationFactory.java:484)...I have also tried setting up a <Resource> in the context.xml file in the same way that I have database connections configured, hoping that wouldletme access the ConnectionFactory via JNDI, but my application fails tofind the JNDI name. <Resource id="ra-jrac" name="foo/bar/baz" auth="Container" type="javax.resource.cci.ConnectionFactory" username="USERNAME" password="PASSWORD" />I am using TomEE-plume 1.7.1. It would be greatly appreciated if anyonecan point me in the correct direction to get this configured. Thanks, Mike