File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Object Relational Mapping and the fly likes JNDI Mapping for oracle datasource Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "JNDI Mapping for oracle datasource" Watch "JNDI Mapping for oracle datasource" New topic
Author

JNDI Mapping for oracle datasource

AmitKumar Dutta
Greenhorn

Joined: Sep 27, 2010
Posts: 14
Hi

I have created a custom datasource in my local JBOSS server "ecommDS"
datasources>
<local-tx-datasource>
<jndi-name>ecommDS</jndi-name>
<rar-name>jboss-local-jdbc.rar</rar-name>
<use-java-context>true</use-java-context>
<connection-definition>javax.sql.DataSource</connection-definition>
<jmx-invoker-name>jboss:service=invoker,type=jrmp</jmx-invoker-name>
<min-pool-size>0</min-pool-size>
<max-pool-size>10</max-pool-size>
<blocking-timeout-millis>30000</blocking-timeout-millis>
<idle-timeout-minutes>30</idle-timeout-minutes>
<prefill>false</prefill>
<background-validation>false</background-validation>
<background-validation-millis>0</background-validation-millis>
<validate-on-match>true</validate-on-match>
<statistics-formatter>org.jboss.resource.statistic.pool.JBossDefaultSubPoolStatisticFormatter</statistics-formatter>
<isSameRM-override-value>false</isSameRM-override-value>
<allocation-retry>0</allocation-retry>
<allocation-retry-wait-millis>5000</allocation-retry-wait-millis>
<security-domain-and-application xsi:type="securityMetaData" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
<metadata>
<type-mapping>Oracle9i</type-mapping>
</metadata>
<type-mapping>Oracle9i</type-mapping>
<local-transaction/>
<user-name>XXXXXX</user-name>
<password>XXXXXXXXX</password>
<check-valid-connection-sql>SELECT * FROM DUAL</check-valid-connection-sql>
<exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleExceptionSorter</exception-sorter-class-name>
<prepared-statement-cache-size>0</prepared-statement-cache-size>
<share-prepared-statements>false</share-prepared-statements>
<set-tx-query-timeout>false</set-tx-query-timeout>
<query-timeout>0</query-timeout>
<use-try-lock>60000</use-try-lock>
<driver-class>oracle.jdbc.driver.OracleDriver</driver-class>
<connection-url>jdbcracle:thin:@****************</connection-url>
</local-tx-datasource>
</datasources>

my persistance xml looks like

<persistence-unit name="AAAAA">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>java:/ecommDS</jta-data-source>

<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.Oracle10gDialect"/>
</properties>
</persistence-unit>

When I run a test case I get
- Could not find datasource: java:/ecommDS
javax.naming.NameNotFoundException: ecommDS not bound
at org.jnp.server.NamingServer.getBinding(NamingServer.java:771)
at org.jnp.server.NamingServer.getBinding(NamingServer.java:779)
at org.jnp.server.NamingServer.getObject(NamingServer.java:785)
at org.jnp.server.NamingServer.lookup(NamingServer.java:443)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:726)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:686)
Can any one point me what is that I am doing wrong here...

Thanks
Amit
AmitKumar Dutta
Greenhorn

Joined: Sep 27, 2010
Posts: 14
This problem is resolved by making the jndi as global to do that
Please note : I have changed from datasource TX-local to XA
I made
<use-java-context>false</use-java-context>
in the datasource file (xx-ds.xml)

Now I am facing another issue for class not found

org.jboss.resource.JBossResourceException: Could not create connection; - nested throwable: (org.jboss.resource.JBossResourceException: Class not found for XADataSource oracle.jdbc.xa.client.OracleXADataSource; - nested throwable: (java.lang.ClassNotFoundException: oracle.jdbc.xa.client.OracleXADataSource from BaseClassLoader@1c6160c{VFSClassLoaderPolicy@1d198cb{name=vfsfile:/C:/XX/jboss-5.1.0/server/default/deploy/SampleDatabase-ds.xml domain=ClassLoaderDomain@bd09e8{name=DefaultDomain parentPolicy=BEFORE parent=org.jboss.bootstrap.NoAnnotationURLClassLoader@1e859c0} roots=[MemoryContextHandler@25588173[path= context=vfsmemory://a5k6g1f-75ti6h-gemzb2j7-1-gemznni2-k3 real=vfsmemory://a5k6g1f-75ti6h-gemzb2j7-1-gemznni2-k3]] delegates=null exported=[] <IMPORT-ALL>NON_EMPTY}}))
at org.jboss.resource.adapter.jdbc.xa.XAManagedConnectionFactory.getXAManagedConnection(XAManagedConnectionFactory.java:465)
at org.jboss.resource.adapter.jdbc.xa.XAManagedConnectionFactory.createManagedConnection(XAManagedConnectionFactory.java:409)
at org.jboss.resource.connectionmanager.InternalManagedConnectionPool.createConnectionEventListener(InternalManagedConnectionPool.java:633)

Can any one help me regarding this issue
AmitKumar Dutta
Greenhorn

Joined: Sep 27, 2010
Posts: 14
This is resolved by adding ojdbc14.jar in the server class path
JBOSS_HOME/commom/lib
now I am getting
I am sure that the url I specified is correct.
12:58:21,078 WARN [JBossManagedConnectionPool] Throwable while attempting to get a new connection: null
org.jboss.resource.JBossResourceException: Could not create connection; - nested throwable: (java.sql.SQLException: Invalid Oracle URL specified: OracleDataSource.makeURL)
at org.jboss.resource.adapter.jdbc.xa.XAManagedConnectionFactory.getXAManagedConnection(XAManagedConnectionFactory.java:465)
at org.jboss.resource.adapter.jdbc.xa.XAManagedConnectionFactory.createManagedConnection(XAManagedConnectionFactory.java:409)
at org.jboss.resource.connectionmanager.InternalManagedConnectionPool.createConnectionEventListener(InternalManagedConnectionPool.java:633)
at org.jboss.resource.connectionmanager.InternalManagedConnectionPool.getConnection(InternalManagedConnectionPool.java:267)
at org.jboss.resource.connectionmanager.JBossManagedConnectionPool$BasePool.getConnection(JBossManagedConnectionPool.java:622)
at org.jboss.resource.connectionmanager.BaseConnectionManager2.getManagedConnection(BaseConnectionManager2.java:404)
at org.jboss.resource.connectionmanager.TxConnectionManager.getManagedConnection(TxConnectionManager.java:381)
at org.jboss.resource.connectionmanager.BaseConnectionManager2.allocateConnection(BaseConnectionManager2.java:496)
at org.jboss.resource.connectionmanager.BaseConnectionManager2$ConnectionManagerProxy.allocateConnection(BaseConnectionManager2.java:941)
at org.jboss.resource.adapter.jdbc.WrapperDataSource.getConnection(WrapperDataSource.java:104)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.jboss.resource.adapter.jdbc.remote.WrapperDataSourceService.doDataSourceMethod(WrapperDataSourceService.java:347)
at org.jboss.resource.adapter.jdbc.remote.WrapperDataSourceService.invoke(WrapperDataSourceService.java:201)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:157)
at org.jboss.mx.server.Invocation.dispatch(Invocation.java:96)
at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:668)
at org.jboss.invocation.jrmp.server.JRMPInvoker$MBeanServerAction.invoke(JRMPInvoker.java:855)
at org.jboss.invocation.jrmp.server.JRMPInvoker.invoke(JRMPInvoker.java:422)
at sun.reflect.GeneratedMethodAccessor272.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at sun.rmi.server.UnicastServerRef.dispatch(Unknown Source)
at sun.rmi.transport.Transport$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Unknown Source)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(Unknown Source)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(Unknown Source)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JNDI Mapping for oracle datasource