Discussion:
jndi properties for datasource
kiranreddykasa
2013-08-19 09:57:37 UTC
Permalink
Hi

I have created a datasource in geronimo server.
I'm able to connect it via admin console.

Can anyone let me know how to connect to this datasource by external
standalone application via jndi.

Specifically i'm not sure about these following values :

java.naming.factory.initial=TO_BE_CHANGED_BY_USER
java.naming.factory.object=TO_BE_CHANGED_BY_USER
java.naming.factory.state=TO_BE_CHANGED_BY_USER
java.naming.factory.control=TO_BE_CHANGED_BY_USER
java.naming.factory.url.pkgs=TO_BE_CHANGED_BY_USER
java.naming.provider.url=TO_BE_CHANGED_BY_USER
java.naming.dns.url=TO_BE_CHANGED_BY_USER

And also which jar should be included for this to work ??



--
View this message in context: http://apache-geronimo.328035.n3.nabble.com/jndi-properties-for-datasource-tp3987125.html
Sent from the Users mailing list archive at Nabble.com.
Zhi Xie
2013-08-21 03:42:12 UTC
Permalink
You can create a datasource by a deployment plan. For example,

*Deployment Plan:*
*<?xml version="1.0" encoding="UTF-8"?>*
*<connector xmlns="http://geronimo.apache.org/xml/ns/j2ee/connector-1.2">*
* <dep:environment xmlns:dep="
http://geronimo.apache.org/xml/ns/deployment-1.2">*
* <dep:moduleId>*
* <dep:groupId>console.dbpool</dep:groupId>*
* <dep:artifactId>Test</dep:artifactId>*
* <dep:version>1.0</dep:version>*
* <dep:type>car</dep:type>*
* </dep:moduleId>*
* <dep:dependencies>*
* <dep:dependency>*
* <dep:groupId>mysql</dep:groupId>*
* <dep:artifactId>mysql-connector-java</dep:artifactId>*
* <dep:version>3.1.14</dep:version>*
* <dep:type>jar</dep:type>*
* </dep:dependency>*
* </dep:dependencies>*
* </dep:environment>*
* <resourceadapter>*
* <outbound-resourceadapter>*
* <connection-definition>*
*
<connectionfactory-interface>javax.sql.DataSource</connectionfactory-interface>
*
* <connectiondefinition-instance>*
* <name>Test</name>*
* <config-property-setting
name="DatabaseName">TestDB</config-property-setting>*
* <config-property-setting
name="UserName">admin</config-property-setting>*
* <config-property-setting
name="Password">admin</config-property-setting>*
* <connectionmanager>*
* <local-transaction/>*
* <single-pool>*
* <max-size>10</max-size>*
* <min-size>0</min-size>*
* <match-one/>*
* </single-pool>*
* </connectionmanager>*
* </connectiondefinition-instance>*
* </connection-definition>*
* </outbound-resourceadapter>*
* </resourceadapter>*
*</connector>*
*
*
Deploy Command:
To deploy a database pool from the command line using this plan,copy and
paste it to a file (say, plan-file.xml) and save it. Then run a command
like:

*cd GERONIMO_HOMEjava -jar bin/deployer.jar deploy plan-file.xml \
\repository\org\tranql\tranql-connector-mysql-local\1.6\tranql-connector-mysql-local-1.6.rar*

Add to EAR:

Instead of deploying as a top-level database pool, you can
deploy this pool as part of an EAR. To add a database pool to an EAR
using this plan:

1. Copy and paste the plan to a file
2. Save the plan file to the top level of your EAR
3. Copy the RAR file from
GERONIMO_HOME/\repository\org\tranql\tranql-connector-mysql-local\1.6\tranql-connector-mysql-local-1.6.rar
to the top level of your EAR
4. Create a META-INF/geronimo-application.xml file in your EAR
that has a module entry like this (substituting the correct RAR file
name and plan file name)

*<application
xmlns="http://geronimo.apache.org/xml/ns/j2ee/application-1.1">
<environment>
<moduleId>
<artifactId>MyApplication</artifactId>
</moduleId>
</environment>
<module>
<connector>rar-file-name.rar</connector>
<alt-dd>plan-file-name.xml</alt-dd>
</module>
</application>*


You can click "Show Plan" button to refer it when you create database pool.
Post by kiranreddykasa
Hi
I have created a datasource in geronimo server.
I'm able to connect it via admin console.
Can anyone let me know how to connect to this datasource by external
standalone application via jndi.
java.naming.factory.initial=TO_BE_CHANGED_BY_USER
java.naming.factory.object=TO_BE_CHANGED_BY_USER
java.naming.factory.state=TO_BE_CHANGED_BY_USER
java.naming.factory.control=TO_BE_CHANGED_BY_USER
java.naming.factory.url.pkgs=TO_BE_CHANGED_BY_USER
java.naming.provider.url=TO_BE_CHANGED_BY_USER
java.naming.dns.url=TO_BE_CHANGED_BY_USER
And also which jar should be included for this to work ??
--
http://apache-geronimo.328035.n3.nabble.com/jndi-properties-for-datasource-tp3987125.html
Sent from the Users mailing list archive at Nabble.com.
--
Best Regards
Gary
David Jencks
2013-08-21 05:27:15 UTC
Permalink
Hi,

This is all correct but I'm not sure it answers the original question. Geronimo datasources/database pools are designed to only be accessed in the same VM as they are deployed in. You cannot look up a database pool deployed in geronimo from another VM no matter how you configure the remote jndi. One reason for this is that we don't have a distributed transaction manager and certainly couldn't come up with a correctly configured transaction manager in the remote vm through a jndi lookup.

If you really want a "standalone" application to be able to use a geronimo datasource consider deploying the app in the app client container and deploying the datasource there.

thanks
david jencks
Post by Zhi Xie
You can create a datasource by a deployment plan. For example,
<?xml version="1.0" encoding="UTF-8"?>
<connector xmlns="http://geronimo.apache.org/xml/ns/j2ee/connector-1.2">
<dep:environment xmlns:dep="http://geronimo.apache.org/xml/ns/deployment-1.2">
<dep:moduleId>
<dep:groupId>console.dbpool</dep:groupId>
<dep:artifactId>Test</dep:artifactId>
<dep:version>1.0</dep:version>
<dep:type>car</dep:type>
</dep:moduleId>
<dep:dependencies>
<dep:dependency>
<dep:groupId>mysql</dep:groupId>
<dep:artifactId>mysql-connector-java</dep:artifactId>
<dep:version>3.1.14</dep:version>
<dep:type>jar</dep:type>
</dep:dependency>
</dep:dependencies>
</dep:environment>
<resourceadapter>
<outbound-resourceadapter>
<connection-definition>
<connectionfactory-interface>javax.sql.DataSource</connectionfactory-interface>
<connectiondefinition-instance>
<name>Test</name>
<config-property-setting name="DatabaseName">TestDB</config-property-setting>
<config-property-setting name="UserName">admin</config-property-setting>
<config-property-setting name="Password">admin</config-property-setting>
<connectionmanager>
<local-transaction/>
<single-pool>
<max-size>10</max-size>
<min-size>0</min-size>
<match-one/>
</single-pool>
</connectionmanager>
</connectiondefinition-instance>
</connection-definition>
</outbound-resourceadapter>
</resourceadapter>
</connector>
cd GERONIMO_HOME
java -jar bin/deployer.jar deploy plan-file.xml \
\repository\org\tranql\tranql-connector-mysql-local\1.6\tranql-connector-mysql-local-1.6.rar
Copy and paste the plan to a file
Save the plan file to the top level of your EAR
Copy the RAR file from GERONIMO_HOME/\repository\org\tranql\tranql-connector-mysql-local\1.6\tranql-connector-mysql-local-1.6.rar to the top level of your EAR
Create a META-INF/geronimo-application.xml file in your EAR that has a module entry like this (substituting the correct RAR file name and plan file name)
<application
xmlns="http://geronimo.apache.org/xml/ns/j2ee/application-1.1">
<environment>
<moduleId>
<artifactId>MyApplication</artifactId>
</moduleId>
</environment>
<module>
<connector>rar-file-name.rar</connector>
<alt-dd>plan-file-name.xml</alt-dd>
</module>
</application>
You can click "Show Plan" button to refer it when you create database pool.
Hi
I have created a datasource in geronimo server.
I'm able to connect it via admin console.
Can anyone let me know how to connect to this datasource by external
standalone application via jndi.
java.naming.factory.initial=TO_BE_CHANGED_BY_USER
java.naming.factory.object=TO_BE_CHANGED_BY_USER
java.naming.factory.state=TO_BE_CHANGED_BY_USER
java.naming.factory.control=TO_BE_CHANGED_BY_USER
java.naming.factory.url.pkgs=TO_BE_CHANGED_BY_USER
java.naming.provider.url=TO_BE_CHANGED_BY_USER
java.naming.dns.url=TO_BE_CHANGED_BY_USER
And also which jar should be included for this to work ??
--
View this message in context: http://apache-geronimo.328035.n3.nabble.com/jndi-properties-for-datasource-tp3987125.html
Sent from the Users mailing list archive at Nabble.com.
--
Best Regards
Gary
kiranreddykasa
2013-08-21 10:41:38 UTC
Permalink
Thanks for clarification.



--
View this message in context: http://apache-geronimo.328035.n3.nabble.com/jndi-properties-for-datasource-tp3987125p3987128.html
Sent from the Users mailing list archive at Nabble.com.

Loading...