-->
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 not bound error
PostPosted: Sun Apr 25, 2010 11:29 pm 
Newbie

Joined: Sun Apr 25, 2010 9:46 pm
Posts: 2
Hi Folks, im getting the following error message when running chapter 5 a exercise from JbossAtWork book. I have been using JBoss 5.1 and Java 6 with Oracle XE thus far and have had no problems running the previous exercises up until this point.

the error message:
[STDOUT] com.jbossatwork.util.ServiceLocatorException: com.jbossatwork.util.ServiceLocatorException: javax.naming.NamingException: Could not dereference object [Root exception is javax.naming.NameNotFoundException: hibernate not bound]

here is a short hand version of what my ear, war and common jars look like:

jaw.ear (contains)
- META-INF
----- application.xml
------ jboss-app.xml
- common.jar
- jaw.har
- webapp.war

common.jar (contains)
- classes (including HibernateCarDAO.class, CarDTO.class, ServiceLocator.class)

jaw.har (contains)
- CarDTO.hbm.xml
- META-INF
----- hibernate-service.xml

webapp.war (contains)
- META-INF
- WEB-INF
----- classes (including ControllerServlet.class)
----- lib folder
----- jboss-web.xml
------ web.xml
- jsps and other files

Code:
<server>
   <mbean code="org.jboss.hibernate.jmx.Hibernate" name="jboss.har:service=Hibernate">
      <attribute name="DatasourceName">java:/JBossAtWorkDS</attribute>
      <!-- DatasourceName matches the ds name -->
      <!-- attribute name="Dialect">org.hibernate.dialect.HSQLDialect</attribute-->
      <attribute name="Dialect">org.hibernate.dialect.OracleDialect</attribute>
      <attribute name="SessionFactoryName">java:/hibernate/SessionFactory</attribute>
      <attribute name="CacheProviderClass">org.hibernate.cache.HashtableCacheProvider</attribute>
   </mbean>
</server>


build.xml for hibernatedoclet looks as follows:

Code:
    <target name="generate-hbm" description="Generate Hibernate hbm.xml file">
        <taskdef name="hibernatedoclet" classname="xdoclet.modules.hibernate.HibernateDocletTask" classpathref="xdoclet.lib.path" />
        <mkdir dir="${build.dir}" />   
        <mkdir dir="${gen.source.dir}" />               
        <hibernatedoclet destdir="${gen.source.dir}">
            <fileset dir="${source.dir}">
                <include name="**/*DTO.java" /><!-- bean class -->
            </fileset>
            <hibernate version="3.0" />
        </hibernatedoclet>       
    </target>
    <!-- ====================================== -->
    <target name="har" depends="generate-hbm" description="Builds the Hibernate HAR file">
        <mkdir dir="${distribution.dir}" />
        <jar destfile="${distribution.dir}/jaw.har">       
            <!-- include the hbm.xml files  -->
            <fileset dir="${gen.source.dir}">
                <include name="**/*.hbm.xml"/>
            </fileset>   
            <!-- include jboss-service.xml -->
            <metainf dir="${hibernate.dir}">
                <include name="hibernate-service.xml"/>
            </metainf>
        </jar>
    </target>


I have used the hibernate jars contained in the C:\jboss-5.1.0.GA\common\lib for my compile and xdoclet classpaths
and also tried to alternatively use distribution-3.5.1 instead for the classpaths

Code:
        <property name="hibernate.lib.dir" value="C:/hibernate-distribution-3.5.1-Final/lib/required"/>
   <property name="hibernate2.lib.dir" value="C:/hibernate-distribution-3.5.1-Final"/>
OR the other path
   <!--property name="hibernate.lib.dir" value="${env.JBOSS_HOME}/common/lib"/-->


ControllerServlet.java generates the following tags successfully in web.xml and jboss-web.xml :

Code:
* @web.servlet
*    name="Controller"
*
* @web.servlet-mapping
*    url-pattern="/controller/*"
*
* @web.resource-ref
*    name="jdbc/JBossAtWorkDS"
*    type="javax.sql.DataSource"
*    auth="Container"
*
* @jboss.resource-ref
*    res-ref-name="jdbc/JBossAtWorkDS"
*    jndi-name="java:/JBossAtWorkDS"
*
* @web.resource-ref
*    name="hibernate/SessionFactory"
*    type="net.sf.hibernate.SessionFactory"
*    auth="Container"
*
* @jboss.resource-ref
*    res-ref-name="hibernate/SessionFactory"
*    jndi-name="java:/hibernate/SessionFactory"


HibernateCarDAO.java sends the following
private static final String HIBERNATE_SESSION_FACTORY="java:comp/env/hibernate/SessionFactory"
to ServiceLocator.java to perform a ServiceLocator.getHibernateSession(HIBERNATE_SESSION_FACTORY) which then does a lookup ctx.lookup(jndiSessionFactoryName)


where am i going wrong. what are some alternatives i can test.

Thanks in advance


Top
 Profile  
 
 Post subject: Re: hibernate not bound error
PostPosted: Mon Apr 26, 2010 9:36 am 
Newbie

Joined: Sun Apr 25, 2010 9:46 pm
Posts: 2
after googling a bit more, I found this link that helped me solve the problem.
http://www.len.ro/2010/02/jboss-migrati ... -5-1-0-ga/


Top
 Profile  
 
 Post subject: Re: hibernate not bound error
PostPosted: Fri Feb 04, 2011 12:25 pm 
Newbie

Joined: Fri Feb 04, 2011 1:04 am
Posts: 2
OK I have this problem as well. I'm a newbie so apologies if I'm missing something obvious. I reviewed the information on http://www.len.ro/2010/02/jboss-migrati ... o-5-1-0-ga, and I thought the root cause of my problem was with the deployment descriptor being in 4x format since I'm running 6x (6.0.0.20100911-M5 specifically). So I renamed hibernate-service.xml to service-hibernate.xml and updated the descriptor with the new formatting:

<hibernate-configuration xmlns="urn:jboss:hibernate-deployer:1.0">
<session-factory name="java:/hibernate/SessionFactory" bean="jboss.har:service=Hibernate">
<property name="datasourceName">java:/JBossAtWorkDS</property>
<property name="dialect">org.hibernate.dialect.HSQLDialect</property>
<property name="cacheProviderClass">org.hibernate.cache.HashtableCacheProvider</property>
</session-factory>
</hibernate-configuration>

I was able to successfully build the project (I had to copy hibernate-core.jar to /usr/local/bin/jboss-6-M5/server/default/lib to successfully build the HAR), but when I Click "View Inventory" I still don't see any cars listed (verified the DB has data) and the console still displays:

com.jbossatwork.util.ServiceLocatorException: com.jbossatwork.util.ServiceLocatorException: javax.naming.NamingException: Could not dereference object [Root exception is javax.naming.NameNotFoundException: hibernate not bound]

I know I'm missing some small thing, but not sure what it is. Any help would be greatly appreciated.


Top
 Profile  
 
 Post subject: Re: hibernate not bound error
PostPosted: Tue Jun 07, 2011 4:16 pm 
Newbie

Joined: Tue Jun 07, 2011 4:09 pm
Posts: 1
I'm running 5.0.1.GA and am having the same problems as well. Did you get your problem resolved?

Monty


Top
 Profile  
 
 Post subject: Re: hibernate not bound error
PostPosted: Wed Jun 08, 2011 4:36 pm 
Newbie

Joined: Fri Feb 04, 2011 1:04 am
Posts: 2
I had to modify the build.xml file to deploy the renamed hibernate descriptor to the EAR file.


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.