-->
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.  [ 5 posts ] 
Author Message
 Post subject: Hibernate on JBoss - .har question
PostPosted: Fri Feb 26, 2010 12:35 am 
Newbie

Joined: Fri Feb 26, 2010 12:26 am
Posts: 2
Hi All:

I am struggling with configuring my application to use hibernate from inside JBoss. I am running JBoss 5 (Jboss-5.1.0.GA). I am trying to deploy my persistence classes as part of a .har file inside my ear file. The hibernate-service.xml looks like this:

Code:
<server>
    <mbean code="org.jboss.hibernate.jmx.Hibernate" name="com.sanjeev.deals:name=SessionFactory">
        <attribute name="DatasourceName">java:/DealsDS</attribute>
        <attribute name="Dialect">org.hibernate.dialect.MySQLDialect</attribute>
        <attribute name="SessionFactoryName">java:/hibernate/Deals/SessionFactory</attribute>
        <attribute name="CacheProviderClass">
            org.hibernate.cache.HashtableCacheProvider
        </attribute>
        <attribute name="ShowSqlEnabled">true</attribute>
    </mbean>
</server>


But I am unable to lookup the Sessionfactory using this file. The application deploys fine, just throws a NameNotFoundException when I do a lookup.

Code:
     [java] javax.naming.NameNotFoundException: hibernate not bound
     [java]    at org.jnp.server.NamingServer.getBinding(NamingServer.java:771)
     [java]    at org.jnp.server.NamingServer.getBinding(NamingServer.java:779)
     [java]    at org.jnp.server.NamingServer.getObject(NamingServer.java:785)
     [java]    at org.jnp.server.NamingServer.lookup(NamingServer.java:396)
     [java]    at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:726)
     [java]    at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:686)
     [java]    at javax.naming.InitialContext.lookup(InitialContext.java:392)
     [java]    at org.jboss.tutorial.mdb.client.MyHibClient.processMessage(MyHibClient.java:41)
     [java]    at org.jboss.tutorial.mdb.client.MyHibClient.main(MyHibClient.java:32)


Also, in the jmx-console, under the JNDIView, i do not see this Sessionfactory Bound to the JNDI. Can someone please help!

Thanks for looking.


Top
 Profile  
 
 Post subject: Re: Hibernate on JBoss - .har question
PostPosted: Fri Feb 26, 2010 8:45 pm 
Newbie

Joined: Fri Feb 26, 2010 12:26 am
Posts: 2
Ok, so i fixed this yesterday. i found that Jboss 5, I needed to use the following xml configuration:

<hibernate-configuration xmlns="urn:jboss:hibernate-deployer:1.0">

<session-factory name="java:/hibernate/Deals/SessionFactory" bean="jboss.test.har:service=Hibernate,testcase=TimersUnitTestCase">
<property name="datasourceName">java:/DealsDS</property>
<property name="dialect">org.hibernate.dialect.MySQLDialect</property>
<depends>jboss:service=Naming</depends>
<depends>jboss:service=TransactionManager</depends>
</session-factory>

</hibernate-configuration>

AND, the file had to be saved with a name like "*-hibernate.xml". that resolved it.


Top
 Profile  
 
 Post subject: Re: Hibernate on JBoss - .har question
PostPosted: Thu Mar 04, 2010 10:22 am 
Newbie

Joined: Fri Sep 16, 2005 9:36 am
Posts: 6
Hi sanjeevv

I experienced the same problem with Hibernate and JBoss 5.1.0


Please clarify:

<hibernate-configuration xmlns="urn:jboss:hibernate-deployer:1.0">

<session-factory name="java:/hibernate/Deals/SessionFactory" bean="jboss.test.har:service=Hibernate,testcase=TimersUnitTestCase">
<property name="datasourceName">java:/DealsDS</property>
<property name="dialect">org.hibernate.dialect.MySQLDialect</property>
<depends>jboss:service=Naming</depends>
<depends>jboss:service=TransactionManager</depends>
</session-factory>

</hibernate-configuration>


I think you somehow mix JBoss META-INF/hibernate-service.xml and Hibernate hibernate.xml
It does not work for me



Can you give examples of your META-INF/hibernate-service.xml and hibernate.xml ?

Thank in advance


Top
 Profile  
 
 Post subject: Re: Hibernate on JBoss - .har question
PostPosted: Thu Mar 04, 2010 10:44 am 
Newbie

Joined: Fri Sep 16, 2005 9:36 am
Posts: 6
I think it is about the new Virtual Deployment Framework (VDF)

See i.e. http://www.packtpub.com/article/develop ... ign=ramsai



This configuration is still valid for pre 5.0 releases of JBoss AS. With the introduction of the new Virtual Deployment Framework (VDF), you now have to provide your SessionFactory configuration using the Hibernate XML schema. For example, if you want to link your SessionFactory to your MySQL database, you have to add the following service-hibernate.xml. (Be aware, the suffix is -hibernate.xml and not –service.xml.)



<hibernate-configuration xmlns="urn:jboss:hibernate-deployer:1.0">
<session-factory name="java:/hibernate/SessionFactory"
bean="jboss.test.har:service=Hibernate,
testcase=TimersUnitTestCase">
<property name="datasourceName">java:/MySqlDS</property>
<property name="dialect">
org.hibernate.dialect.MySQLDialect
</property>
<depends>jboss:service=Naming</depends>
<depends>jboss:service=TransactionManager</depends>
</session-factory>
</hibernate-configuration>



The preceding configuration file needs to be stored in the META-INF folder of your Hibernate archive (HAR) file.



Now it is clear for me


Top
 Profile  
 
 Post subject: Re: Hibernate on JBoss - .har question
PostPosted: Thu Mar 04, 2010 10:46 am 
Newbie

Joined: Fri Sep 16, 2005 9:36 am
Posts: 6
Sorry

Correct link is

http://www.packtpub.com/article/developing-applications-with-jboss-and-hibernate-1?utm_source=rk_jboss5_abr2_1209&utm_medium=content&utm_campaign=ramsai


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