-->
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.  [ 6 posts ] 
Author Message
 Post subject: Hibernate can't obtain connection to SQL Server 2008 in JBos
PostPosted: Fri Sep 14, 2012 11:05 am 
Newbie

Joined: Fri Sep 14, 2012 10:57 am
Posts: 3
I have a datasource defined in JBoss 7. I have verified the setup by using JNDI lookup and obtaining a DB connection to it using Java code in a servlet as below.

DataSource patternSpyDB;
Connection conn;
try {
Context ctx = new InitialContext();
patternSpyDB = (DataSource)ctx.lookup("java:jboss/datasources/patternspy");
conn = patternSpyDB.getConnection();
System.out.println("### SQLServer database connection obtained...");
And it works well.

Now I tried using org.jbpm.task persistence unit (or any other persistence.xml file) and the Hibernate seems to be waiting forever to obtain DB connection. Please see excerpt below.

10:55:10,250 INFO [org.jboss.as.server.deployment] (MSC service thread 1-4) JBAS015876: Starting deployment of "T1.war"
10:55:10,287 INFO [org.jboss.as.remoting] (MSC service thread 1-4) JBAS017100: Listening on 127.0.0.1:9999
10:55:10,311 INFO [org.jboss.as.remoting] (MSC service thread 1-3) JBAS017100: Listening on 127.0.0.1:4447
10:55:10,528 INFO [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-3) JBAS010400: Bound data source [java:jboss/datasources/ExampleDS]
10:55:10,530 INFO [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-3) JBAS010400: Bound data source [java:jboss/datasources/patternspy]
10:55:10,974 INFO [org.jboss.as.jpa] (MSC service thread 1-4) JBAS011401: Read persistence.xml for mgTest
10:55:11,689 INFO [org.jboss.as.osgi] (MSC service thread 1-1) JBAS011907: Register module: Module "deployment.T1.war:main" from Service Module Loader
10:55:11,703 INFO [org.jboss.as.jpa] (MSC service thread 1-1) JBAS011402: Starting Persistence Unit Service 'T1.war#mgTest'
10:55:12,567 INFO [org.hibernate.annotations.common.Version] (MSC service thread 1-1) HCANN000001: Hibernate Commons Annotations {4.0.1.Final-redhat-1}
10:55:12,573 INFO [org.hibernate.Version] (MSC service thread 1-1) HHH000412: Hibernate Core {4.1.3.Final-redhat-1}
10:55:12,575 INFO [org.hibernate.cfg.Environment] (MSC service thread 1-1) HHH000206: hibernate.properties not found
10:55:12,577 INFO [org.hibernate.cfg.Environment] (MSC service thread 1-1) HHH000021: Bytecode provider name : javassist
10:55:12,924 INFO [org.hibernate.service.jdbc.connections.internal.ConnectionProviderInitiator] (MSC service thread 1-1) HHH000130: Instantiating explicit connection provider: org.hibernate.ejb.connection.InjectedDataSourceConnectionProvider:
org.hibernate.ejb.connection.InjectedDataSourceConnectionProvider

And it hangs there until timeout.

Why is it hanging? The datasource setup is correct as verified above. What can be missing?

Here is a smaller persistence unit I tested with in addition to org.jbpm.task.

<persistence-unit name="org.jbpm.task">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>java:jboss/datasources/patternspy</jta-data-source>
<mapping-file>META-INF/Taskorm.xml</mapping-file>
<class>org.jbpm.task.Attachment</class>
<class>org.jbpm.task.BooleanExpression</class>
<class>org.jbpm.task.Comment</class>
<class>org.jbpm.task.Content</class>
<class>org.jbpm.task.Deadline</class>
<class>org.jbpm.task.Delegation</class>
<class>org.jbpm.task.EmailNotification</class>
<class>org.jbpm.task.EmailNotificationHeader</class>
<class>org.jbpm.task.Escalation</class>
<class>org.jbpm.task.Group</class>
<class>org.jbpm.task.I18NText</class>
<class>org.jbpm.task.Notification</class>
<class>org.jbpm.task.OnAllSubTasksEndParentEndStrategy</class>
<class>org.jbpm.task.OnParentAbortAllSubTasksEndStrategy</class>
<class>org.jbpm.task.PeopleAssignments</class>
<class>org.jbpm.task.Reassignment</class>
<class>org.jbpm.task.Status</class>
<class>org.jbpm.task.SubTasksStrategy</class>
<class>org.jbpm.task.Task</class>
<class>org.jbpm.task.TaskData</class>
<class>org.jbpm.task.User</class>
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.SQLServerDialect"/>
<property name="hibernate.hbm2ddl.auto" value="validate"/>
<property name="hibernate.connection.username" value="pattern2008"/>
<property name="hibernate.connection.password" value="pattern2008"/>
<property name="hibernate.show_sql" value="true"/>
<property name="hibernate.format_sql" value="true"/>
<property name="hibernate.max_fetch_depth" value="3"/>
<property name="hibernate.default_schema" value="dbo"/>
</properties>
</persistence-unit>


Thanks for helping.

Madhav


Top
 Profile  
 
 Post subject: Re: Hibernate can't obtain connection to SQL Server 2008 in JBos
PostPosted: Fri Sep 14, 2012 11:54 pm 
Beginner
Beginner

Joined: Fri Sep 14, 2012 10:41 am
Posts: 20
Are you trying to connect to Windows Azure database by any chance? You know that Azure uses the Windows SQL Server, exactly like you described.


Top
 Profile  
 
 Post subject: Re: Hibernate can't obtain connection to SQL Server 2008 in JBos
PostPosted: Sat Sep 15, 2012 9:34 am 
Newbie

Joined: Fri Sep 14, 2012 10:57 am
Posts: 3
No, I am trying to connect to SQL Server 2008.


Top
 Profile  
 
 Post subject: Re: Hibernate can't obtain connection to SQL Server 2008 in JBos
PostPosted: Sat Sep 15, 2012 10:38 am 
Beginner
Beginner

Joined: Fri Sep 14, 2012 10:41 am
Posts: 20
Your bug is not really Hibernate related.

I would suggest that you use the Microsoft Server Management Studio - Revision 2 (earlier versions don't work to do what you want to do). It's a free product. Go ahead! Download and install it. This Microsoft product is nice. It allows you to connect to your database and browse through the database. While attempting to connect, you can play with the connection parameters. If you can't connect with that program, there is no point in going to Hibernate.

Once you connect with that product, you will get a connection string (and possible other parameters) that you will use with Hibernate.

I have done what you are doing. I have connected to a local SQL Server using the product. Following that I connected using Hibernate. Following that I connected to Hibernate to SQL Azure using Hibernate. It all works fine!

I can just tell you that there might be issues with security (permission) and firewall.
Good Luck!


Top
 Profile  
 
 Post subject: Re: Hibernate can't obtain connection to SQL Server 2008 in JBos
PostPosted: Sun Sep 16, 2012 4:41 pm 
Newbie

Joined: Fri Sep 14, 2012 10:57 am
Posts: 3
Thanks for your reply. I do have the right connection string and have been using the Microsoft Management studio for a long time. I have a datasource defined in JBoss 7.1 and as I have it in my post, I can connect to it using standard Java code (in my post).

My problem is when I introduce a persistence.xml unit in my deployment. If I use the built-in H2 datasource, Hibernate handles the persistence unit correctly. But hangs if I use the SQL Server datasource in the persistence.xml.

So it must have something to do with Hibernate and SQL Server. I suspect something to do with dependencies in JBoss 7.1, but not sure how to look for the problem. I even have TRACE level logging for Hibernate, but it doesn't show anything past the last message as in my post.

Thanks,

Madhav


Top
 Profile  
 
 Post subject: Re: Hibernate can't obtain connection to SQL Server 2008 in JBos
PostPosted: Mon Sep 17, 2012 1:04 pm 
Beginner
Beginner

Joined: Fri Sep 14, 2012 10:41 am
Posts: 20
Possible avenue for solution: Downlaod the dialect class sets again and select something more specific. My class selection was this: org.hibernate.dialect.SQLServer2008Dialect

Use a class that is dated.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 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.