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