-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 
Author Message
 Post subject: Can we access DS on AppServer in standalone app using hbm
PostPosted: Thu Dec 29, 2005 10:48 am 
Newbie

Joined: Tue Nov 15, 2005 8:09 am
Posts: 2
Hibernate version:3.0

Hi,

I have a standalone java application that uses hibernate for persistence.
I want make the hibernate to use a datasource configuration so as to
facilitate jdbc connection pooling. Is there any way that I can configure
the datasource on a AppServer and use it in my app which is running
outside of the container.

In short , is hibernate used in a standalone java app will be able to recognize
and use the datasource configured on a appserver. If yes, how to do that.

Can somebody help me on this.


Thanks in advance,
Pavan Kumar


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 02, 2006 7:49 am 
Newbie

Joined: Tue Nov 15, 2005 8:09 am
Posts: 2
Hi

I tried to configure the "hibernate.connection.datasource" property in hibernate to make use of a DS configured on JBoss. I have also set other properties like the ""hibernate.jndi.url" etc .

But it seems that this stratergy is not woking. Hbm is not able to bound to the datasource. The hbm config file is :
Quote:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="hibernate.cglib.use_reflection_optimizer">true</property>
<property name="hibernate.connection.datasource">java:jdbc/myDB_DS</property>
<property name="hibernate.jndi.url">jnp://localhost:1099/</property>
<property name="hibernate.jndi.class">org.jnp.interfaces.NamingContextFactory</property>
<property name="hibernate.transaction.factory_class">org.hibernate.transaction.JTATransactionFactory </property>
<property name="hibernate.dialect">org.hibernate.dialect.MySQLInnoDBDialect</property>
...............
...............
</session-factory>
</hibernate-configuration>

I have even tried changing the "...connection.datasource" property to java:/comp/env/jdbc/myDB_DS, simply jdbc/myDB_DS etc ,but still i am getting the same error.

The error stack trace is :
Quote:
javax.naming.NameNotFoundException: comp not bound
at org.jnp.server.NamingServer.getBinding(NamingServer.java:514)
at org.jnp.server.NamingServer.getBinding(NamingServer.java:522)
at org.jnp.server.NamingServer.getObject(NamingServer.java:528)
at org.jnp.server.NamingServer.lookup(NamingServer.java:252)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:294)
at sun.rmi.transport.Transport$1.run(Transport.java:153)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:149)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701)
at java.lang.Thread.run(Thread.java:595)
at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:247)
at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:223)
at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:126)
at org.jnp.server.NamingServer_Stub.lookup(Unknown Source)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:610)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:572)
at javax.naming.InitialContext.lookup(InitialContext.java:351)
at org.hibernate.connection.DatasourceConnectionProvider.configure(DatasourceConnectionProvider.java:44)
at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:80)
at org.hibernate.cfg.SettingsFactory.createConnectionProvider(SettingsFactory.java:362)
at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:60)
at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:1463)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1004)
at com.sirvisetti.esb.modo.persistence.DashboardInteraction.getSession(DashboardInteraction.java:228)
at com.sirvisetti.esb.modo.persistence.DashboardInteraction.createDashboardEntry(DashboardInteraction.java:108)
at com.sirvisetti.esb.DbRequestInsertor.process(DbRequestInsertor.java:108)
at org.servicemix.components.util.OutBinding.onMessageExchange(OutBinding.java:51)
........
at java.lang.Thread.run(Thread.java:595)
org.hibernate.HibernateException: Could not find datasource
at org.hibernate.connection.DatasourceConnectionProvider.configure(DatasourceConnectionProvider.java:48)
at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:80)
at org.hibernate.cfg.SettingsFactory.createConnectionProvider(SettingsFactory.java:362)
at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:60)
at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:1463)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1004)
.......
at java.lang.Thread.run(Thread.java:595)
Caused by: javax.naming.NameNotFoundException: comp not bound
at org.jnp.server.NamingServer.getBinding(NamingServer.java:514)
at org.jnp.server.NamingServer.getBinding(NamingServer.java:522)
at org.jnp.server.NamingServer.getObject(NamingServer.java:528)
at org.jnp.server.NamingServer.lookup(NamingServer.java:252)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:294)
at sun.rmi.transport.Transport$1.run(Transport.java:153)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:149)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701)
at java.lang.Thread.run(Thread.java:595)
at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:247)
at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:223)
at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:126)
at org.jnp.server.NamingServer_Stub.lookup(Unknown Source)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:610)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:572)
at javax.naming.InitialContext.lookup(InitialContext.java:351)
at org.hibernate.connection.DatasourceConnectionProvider.configure(DatasourceConnectionProvider.java:44)
... 71 more

Can somebody give a good idea of how to resolve this problem.

Thanks,
Pavan Kumar


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 02, 2006 8:20 am 
Regular
Regular

Joined: Wed Jun 29, 2005 11:14 pm
Posts: 119
Location: København
I tried to do similar and found:

Quoted from Steve of the Hibernate team (So I guess pretty accurate) at http://forum.hibernate.org/viewtopic.ph ... 918789d01b

"Datasources in JBoss are not available remotely, as it does not provide any sort of RMI-JDBC capability."

So I gave up...


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 02, 2006 8:24 am 
Regular
Regular

Joined: Wed Jun 29, 2005 11:14 pm
Posts: 119
Location: København
I was using an old JBoss though...

Have you read:
http://wiki.jboss.org/wiki/Wiki.jsp?pag ... ataSources

Configuring a DataSource for remote usage
As of jboss-4.0.0 there is support for accessing a DataSource from a remote client. The one change that is neccessary for the client to be able to lookup the DataSource from jndi is to specify use-java-context=false as shown here:

<datasources>
<local-tx-datasource>
<jndi-name>GenericDS</jndi-name>
<use-java-context>false</use-java-context>
<connection-url>...</connection-url>
...


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.