Discussion:
[jboss-user] [JNDI and Naming] - How to add a resource-adapter programatically?
Madhu Garimilla
2013-06-19 17:54:55 UTC
Permalink
Madhu Garimilla [https://community.jboss.org/people/madhu.garimilla] created the discussion

"How to add a resource-adapter programatically?"

To view the discussion, visit: https://community.jboss.org/message/823960#823960

--------------------------------------------------------------
I would like to add a resource-adapter (data source) while jboss 7 is up and running. As per the doc, we can add this using CLI command, but is there a way i can configure this through a java program?  or Can we add this inside a *-ds.xml file in an ear file which jboss 7 can automatically detect?  Could someone please give an example of how this can be done.
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/823960#823960]

Start a new discussion in JNDI and Naming at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2083]
Ramesh Reddy
2013-06-19 22:26:58 UTC
Permalink
Ramesh Reddy [https://community.jboss.org/people/rareddy] created the discussion

"Re: How to add a resource-adapter programatically?"

To view the discussion, visit: https://community.jboss.org/message/823989#823989

--------------------------------------------------------------
Anything operations that can be done through CLI can be done through a JAVA program. See https://github.com/teiid/teiid/blob/master/test-integration/common/src/test/java/org/teiid/arquillian/IntegrationTestDeployment.java https://github.com/teiid/teiid/blob/master/test-integration/common/src/test/java/org/teiid/arquillian/IntegrationTestDeployment.java
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/823989#823989]

Start a new discussion in JNDI and Naming at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2083]
Madhu Garimilla
2013-06-24 13:26:10 UTC
Permalink
Madhu Garimilla [https://community.jboss.org/people/madhu.garimilla] created the discussion

"Re: How to add a resource-adapter programatically?"

To view the discussion, visit: https://community.jboss.org/message/824563#824563

--------------------------------------------------------------
Hi Ramesh,

I tried with below code to add a file data source programmatically.

        Admin admin = AdminFactory.getInstance().createAdmin("localhost",9999,"admin","admin".toCharArray());
        Properties p = new Properties();
        p.setProperty("class-name","org.teiid.resource.adapter.file.FileManagedConnectionFactory");
        p.setProperty("pool-name", "marketdata-file");
        p.setProperty("max-pool-size", "4");
        p.setProperty("enabled", "true");
        p.setProperty("use-java-context", "true");
        p.setProperty("ParentDirectory", "../data/");
        p.setProperty("AllowParentPaths", "true");
        admin.createDataSource("java:/marketdata-file","teiid-connector-file.rar",p);

This shows up the below error in jboss console. Am i missing anything here? How do i avoid this error.

15:32:52,571 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-5) MSC00001: Failed to start service jboss.ra.deployment."teiid-connector-file.r
ar_1": org.jboss.msc.service.StartException in service jboss.ra.deployment."teiid-connector-file.rar_1": org.jboss.jca.core.spi.mdr.NotFoundException:
IJ000855: teiid-connector-file isn't registered
        at org.jboss.as.connector.metadata.deployment.ResourceAdapterXmlDeploymentService.start(ResourceAdapterXmlDeploymentService.java:127)
        at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
        at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) [rt.jar:1.7.0_03]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) [rt.jar:1.7.0_03]
        at java.lang.Thread.run(Thread.java:722) [rt.jar:1.7.0_03]
Caused by: org.jboss.jca.core.spi.mdr.NotFoundException: IJ000855: teiid-connector-file isn't registered
        at org.jboss.jca.core.mdr.SimpleMetadataRepository.getResourceAdapter(SimpleMetadataRepository.java:150)
        at org.jboss.as.connector.metadata.deployment.ResourceAdapterXmlDeploymentService.start(ResourceAdapterXmlDeploymentService.java:87)
        ... 5 more

15:32:52,673 INFO  [org.jboss.as.controller] (management-handler-thread - 22) JBAS014774: Service status report
JBAS014777:   Services which failed to start:      service jboss.ra.deployment."teiid-connector-file.rar_1": org.jboss.msc.service.StartException in s
ervice jboss.ra.deployment."teiid-connector-file.rar_1": org.jboss.jca.core.spi.mdr.NotFoundException: IJ000855: teiid-connector-file isn't registered

Thanks
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/824563#824563]

Start a new discussion in JNDI and Naming at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2083]
Ramesh Reddy
2013-06-24 15:04:38 UTC
Permalink
Ramesh Reddy [https://community.jboss.org/people/rareddy] created the discussion

"Re: How to add a resource-adapter programatically?"

To view the discussion, visit: https://community.jboss.org/message/824576#824576

--------------------------------------------------------------
try

admin.createDataSource("java:/marketdata-file","file",p);


In 8.4, the RAR files have been converted to use JBoss modules and they have simple names like "file".

Ramesh..
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/824576#824576]

Start a new discussion in JNDI and Naming at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2083]
Madhu Garimilla
2013-06-25 15:28:50 UTC
Permalink
Madhu Garimilla [https://community.jboss.org/people/madhu.garimilla] created the discussion

"Re: How to add a resource-adapter programatically?"

To view the discussion, visit: https://community.jboss.org/message/824814#824814

--------------------------------------------------------------
We are using teiid 8.1. Is there anyway that we could do this in 8.1?
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/824814#824814]

Start a new discussion in JNDI and Naming at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2083]
Ramesh Reddy
2013-06-25 17:20:17 UTC
Permalink
Ramesh Reddy [https://community.jboss.org/people/rareddy] created the discussion

"Re: How to add a resource-adapter programatically?"

To view the discussion, visit: https://community.jboss.org/message/824831#824831

--------------------------------------------------------------
The original code above should be right one then. Look in 8.1 branch otherwise. Also note there is bug JBoss AS JCA connection factory creation if added it once and deleted and added with same name again.

as per the above exception, you need to make sure "teiid-connector-file.rar" has been deployed. You can a call "admin.getDataSourceTemplateNames" to make sure.

Ramesh..
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/824831#824831]

Start a new discussion in JNDI and Naming at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2083]
Madhu Garimilla
2013-06-25 17:54:09 UTC
Permalink
Madhu Garimilla [https://community.jboss.org/people/madhu.garimilla] created the discussion

"Re: How to add a resource-adapter programatically?"

To view the discussion, visit: https://community.jboss.org/message/824838#824838

--------------------------------------------------------------
Hi Ramesh, 

teiid-connector-file.rar is already deployed. I have checked with admin.getDataSourceTemplateNames and teiid-connector-file.rar is coming as part of it.I see the data source getting added and the vdb referring to it also getting deployed properly but i was not able to query the data source because of the exception i was getting while creating the data source. When i try to query, It says "TEIID30504 text-connector: TEIID30481 Failed to find the Connection Factory with JNDI name java:marketdata-file."

Are you referring to the bug https://issues.jboss.org/browse/AS7-4776 (https://issues.jboss.org/browse/AS7-4776)? Currently I am using jboss 7.1.1.
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/824838#824838]

Start a new discussion in JNDI and Naming at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2083]
Ramesh Reddy
2013-06-25 17:58:41 UTC
Permalink
Ramesh Reddy [https://community.jboss.org/people/rareddy] created the discussion

"Re: How to add a resource-adapter programatically?"

To view the discussion, visit: https://community.jboss.org/message/824840#824840

--------------------------------------------------------------
Yes, I was referring to that issue. It got better with JBoss EAP 6.1 alpha build, so you can try using that. EAP 6.1 Alpha works with Teiid 8.4

Also where is "/" in your name? shouldn't that be "java:/marketdata-file"?

Ramesh..
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/824840#824840]

Start a new discussion in JNDI and Naming at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2083]
Madhu Garimilla
2013-06-26 03:05:06 UTC
Permalink
Madhu Garimilla [https://community.jboss.org/people/madhu.garimilla] created the discussion

"Re: How to add a resource-adapter programatically?"

To view the discussion, visit: https://community.jboss.org/message/824896#824896

--------------------------------------------------------------
"/" is given while creating the data source but it was not present in the error message i got while querying the data source
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/824896#824896]

Start a new discussion in JNDI and Naming at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2083]
Ramesh Reddy
2013-06-26 12:29:10 UTC
Permalink
Ramesh Reddy [https://community.jboss.org/people/rareddy] created the discussion

"Re: How to add a resource-adapter programatically?"

To view the discussion, visit: https://community.jboss.org/message/824986#824986

--------------------------------------------------------------
Pls attach your log file, if it is too long, delete and restart the server and re-run the testcase and attach that. I do not see anything wrong with it so far.
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/824986#824986]

Start a new discussion in JNDI and Naming at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2083]
Madhu Garimilla
2013-06-27 14:35:50 UTC
Permalink
Madhu Garimilla [https://community.jboss.org/people/madhu.garimilla] created the discussion

"Re: How to add a resource-adapter programatically?"

To view the discussion, visit: https://community.jboss.org/message/825280#825280

--------------------------------------------------------------
Hi Ramesh, I tried the following 2 approaches.

*Approach 1:*
With jboss 7.1.1 and teiid 8.1 , I tried to add a file data source using the below code and it resulted in an exception which i mentioned in my earlier post, attached the log(jboss_711_Teiid_81.log).

Admin admin = AdminFactory.getInstance().createAdmin("localhost",9999,"admin","admin".toCharArray());
final Properties p = new Properties();
p.setProperty("class-name","org.teiid.resource.adapter.file.FileManagedConnectionFactory");
p.setProperty("pool-name", "marketdata-file");
p.setProperty("max-pool-size", "4");
p.setProperty("enabled", "true");
p.setProperty("use-java-context", "true");
p.setProperty("ParentDirectory", "../data/");
p.setProperty("AllowParentPaths", "true");
admin.createDataSource("java:/marketdata-file","teiid-connector-file.rar",p);

*Approach 2:*
With jboss-eap-6.1 and teiid 8.4,I tried to add a file data source using the below code and it resulted in an exception in my test case, attached the log (jboss_eap_61_Teiid_81.log)

Admin admin = AdminFactory.getInstance().createAdmin("localhost",9999,"admin","admin".toCharArray());
final Properties p = new Properties();
p.setProperty("class-name","org.teiid.resource.adapter.file.FileManagedConnectionFactory");
p.setProperty("pool-name", "marketdata-file");
p.setProperty("max-pool-size", "4");
p.setProperty("enabled", "true");
p.setProperty("use-java-context", "true");
p.setProperty("ParentDirectory", "../data/");
p.setProperty("AllowParentPaths", "true");
admin.createDataSource("java:/marketdata-file", "file", p);
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/825280#825280]

Start a new discussion in JNDI and Naming at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2083]
Ramesh Reddy
2013-06-27 17:47:48 UTC
Permalink
Ramesh Reddy [https://community.jboss.org/people/rareddy] created the discussion

"Re: How to add a resource-adapter programatically?"

To view the discussion, visit: https://community.jboss.org/message/825334#825334

--------------------------------------------------------------
*try*

Admin admin = AdminFactory.getInstance().createAdmin("localhost",9999,"admin","admin".toCharArray());
final Properties p = new Properties();
p.setProperty("class-name","org.teiid.resource.adapter.file.FileManagedConnectionFactory");
p.setProperty("ParentDirectory", "../data/");
p.setProperty("AllowParentPaths", "true");
admin.createDataSource("java:/marketdata-file","teiid-connector-file.rar",p);




*
*
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/825334#825334]

Start a new discussion in JNDI and Naming at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2083]
Madhu Garimilla
2013-07-01 09:40:29 UTC
Permalink
Madhu Garimilla [https://community.jboss.org/people/madhu.garimilla] created the discussion

"Re: How to add a resource-adapter programatically?"

To view the discussion, visit: https://community.jboss.org/message/825742#825742

--------------------------------------------------------------
Thanks Ramesh. I could get this working.

However, I still have the problem (https://issues.jboss.org/browse/AS7-4776 (https://issues.jboss.org/browse/AS7-4776)) while deleting and readding data source as i am using Jboss 7.1.1 and Teiid 8.1.
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/825742#825742]

Start a new discussion in JNDI and Naming at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2083]
Madhu Garimilla
2013-07-15 08:11:26 UTC
Permalink
Madhu Garimilla [https://community.jboss.org/people/madhu.garimilla] created the discussion

"Re: How to add a resource-adapter programatically?"

To view the discussion, visit: https://community.jboss.org/message/827919#827919

--------------------------------------------------------------
Hi Ramesh,

I tried to test this by adding multiple file data sources.



final Admin admin = AdminFactory.getInstance().createAdmin("localhost",9999,"admin","admin".toCharArray());

        final Properties p = new Properties();
        p.setProperty("class-name","org.teiid.resource.adapter.file.FileManagedConnectionFactory");
        p.setProperty("ParentDirectory", "${jboss.home.dir}/../data/");
        p.setProperty("AllowParentPaths", "true");
        admin.createDataSource("java:/marketdata-file","teiid-connector-file.rar",p);

        final Properties p1 = new Properties();
        p1.setProperty("class-name","org.teiid.resource.adapter.file.FileManagedConnectionFactory");
        p1.setProperty("ParentDirectory", "${jboss.home.dir}/../data/");
        p1.setProperty("AllowParentPaths", "true");
        admin.createDataSource("java:/marketdata-file1","teiid-connector-file.rar",p1);



Then it throws the below exception in the jboss console.


13:28:58,987 INFO  org.jboss.as.connector.deployers.RaXmlDeployer org.jboss.as.connector.deployers.RaXmlDeployer (MSC service thread 1-2) IJ020001: Required license terms for file:/C:/Chorus/CAR/
Work/jboss-as-7.1.1.Final/standalone/tmp/vfs/temp98701600a4006a0e/teiid-connector-file.rar-4c490c2c33dad3d0/contents/
13:28:58,993 INFO  org.jboss.as.deployment.connector org.jboss.as.deployment.connector (MSC service thread 1-2) JBAS010406: Registered connection factory java:/marketdata-file
13:28:58,996 INFO  org.jboss.as.connector.deployers.RaXmlDeployer org.jboss.as.connector.deployers.RaXmlDeployer (MSC service thread 1-2) IJ020002: Deployed: file:/C:/Chorus/CAR/Work/jboss-as-7.1
.1.Final/standalone/tmp/vfs/temp98701600a4006a0e/teiid-connector-file.rar-4c490c2c33dad3d0/contents/
13:28:58,998 INFO  org.jboss.as.deployment.connector org.jboss.as.deployment.connector (MSC service thread 1-8) JBAS010401: Bound JCA ConnectionFactory java:/marketdata-file
13:28:59,379 INFO  org.jboss.as.deployment.connector org.jboss.as.deployment.connector (MSC service thread 1-11) JBAS010410: Unbound JCA ConnectionFactory java:/marketdata-file
13:28:59,381 ERROR org.jboss.msc.service.fail org.jboss.msc.service.fail (MSC service thread 1-16) MSC00001: Failed to start service jboss.ra.deployment."teiid-connector-file.
rar_1": org.jboss.msc.service.StartException in service jboss.ra.deployment."teiid-connector-file.rar_1": org.jboss.jca.core.spi.mdr.NotFoundException
: IJ000855: teiid-connector-file isn't registered
        at org.jboss.as.connector.metadata.deployment.ResourceAdapterXmlDeploymentService.start(ResourceAdapterXmlDeploymentService.java:127)
        at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811) jboss-msc-1.0.2.GA.jar:1.0.2.GA
        at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746) jboss-msc-1.0.2.GA.jar:1.0.2.GA
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) https://community.jboss.org/message/827919#827919#827919/rt.jar:1.7.0_03 Re: How to add a resource-adapter programatically?
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) https://community.jboss.org/message/827919#827919#827919/rt.jar:1.7.0_03 Re: How to add a resource-adapter programatically?
        at java.lang.Thread.run(Thread.java:722) https://community.jboss.org/message/827919#827919#827919/rt.jar:1.7.0_03 Re: How to add a resource-adapter programatically?
Caused by: org.jboss.jca.core.spi.mdr.NotFoundException: IJ000855: teiid-connector-file isn't registered
        at org.jboss.jca.core.mdr.SimpleMetadataRepository.getResourceAdapter(SimpleMetadataRepository.java:150)
        at org.jboss.as.connector.metadata.deployment.ResourceAdapterXmlDeploymentService.start(ResourceAdapterXmlDeploymentService.java:87)
        ... 5 more

13:28:59,453 INFO  org.jboss.as.controller org.jboss.as.controller (management-handler-thread - 1) JBAS014774: Service status report
JBAS014777:   Services which failed to start:      service jboss.ra.deployment."teiid-connector-file.rar_1": org.jboss.msc.service.StartException in s
ervice jboss.ra.deployment."teiid-connector-file.rar_1": org.jboss.jca.core.spi.mdr.NotFoundException: IJ000855: teiid-connector-file isn't registered


Where as this works fine when i add only one file data source. Though it is adding the resource adapters in the standalone-teiid.xml, those are working fine only after a jboss restart.
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/827919#827919]

Start a new discussion in JNDI and Naming at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2083]
Ramesh Reddy
2013-07-15 13:13:44 UTC
Permalink
Ramesh Reddy [https://community.jboss.org/people/rareddy] created the discussion

"Re: How to add a resource-adapter programatically?"

To view the discussion, visit: https://community.jboss.org/message/827988#827988

--------------------------------------------------------------
Yes, that is part of (https://issues.jboss.org/browse/AS7-4776 (https://issues.jboss.org/browse/AS7-4776))  that AS folks did not fix.
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/827988#827988]

Start a new discussion in JNDI and Naming at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2083]
Madhu Garimilla
2013-08-13 14:36:02 UTC
Permalink
Madhu Garimilla [https://community.jboss.org/people/madhu.garimilla] created the discussion

"Re: How to add a resource-adapter programatically?"

To view the discussion, visit: https://community.jboss.org/message/832504#832504

--------------------------------------------------------------
The above thread states that there is a work around exists. Is the workaround applied in teiid admin api as well?
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/832504#832504]

Start a new discussion in JNDI and Naming at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2083]
Ramesh Reddy
2013-08-13 21:45:14 UTC
Permalink
Ramesh Reddy [https://community.jboss.org/people/rareddy] created the discussion

"Re: How to add a resource-adapter programatically?"

To view the discussion, visit: https://community.jboss.org/message/832562#832562

--------------------------------------------------------------
not yet, will be try to target Teiid 8.5
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/832562#832562]

Start a new discussion in JNDI and Naming at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2083]
Madhu Garimilla
2013-08-14 11:19:00 UTC
Permalink
Madhu Garimilla [https://community.jboss.org/people/madhu.garimilla] created the discussion

"Re: How to add a resource-adapter programatically?"

To view the discussion, visit: https://community.jboss.org/message/832619#832619

--------------------------------------------------------------
Hi Ramesh, Can we get this workaround as a patch in teiid 8.1. If we have to write a new method for createDataSource similar to the one we have in Teiid Admin API, what all changes are required in existing createDataSource method to incorporate this work around.
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/832619#832619]

Start a new discussion in JNDI and Naming at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2083]
Ramesh Reddy
2013-08-14 12:07:28 UTC
Permalink
Ramesh Reddy [https://community.jboss.org/people/rareddy] created the discussion

"Re: How to add a resource-adapter programatically?"

To view the discussion, visit: https://community.jboss.org/message/832623#832623

--------------------------------------------------------------
Sorry we do not provide patches for older versions, only fixes in the latest version. If you want you can backport those when the fix is available. As I said above, this is not fixed per the workaround yet, it is still works, when done I will post the link. Otherwise you can take look at AdminImpl.java class and fix it per workaround suggestions and post the changes here and I will be gald to accept them.

Thanks

Ramesh..
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/832623#832623]

Start a new discussion in JNDI and Naming at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2083]
Madhu Garimilla
2013-06-25 18:09:31 UTC
Permalink
Madhu Garimilla [https://community.jboss.org/people/madhu.garimilla] created the discussion

"Re: How to add a resource-adapter programatically?"

To view the discussion, visit: https://community.jboss.org/message/824845#824845

--------------------------------------------------------------
Is there any other way that we could read the data from a csv file and refer to it through a teiid view?
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/824845#824845]

Start a new discussion in JNDI and Naming at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2083]
Loading...