I have been trying to get JBoss and Hibernate running, but I keep getting a
"hibernate not bound" message when I try to create a sesseion:
I am using JBoss 4.0.3 and Hibernate 3
My .har file is located in my deploy directory:
C:\jboss403\server\default\deploy\Test.har
The .har file is composed as follows:
C:\jboss403\server\default\deploy\META-INF
| C:\jboss403\server\default\deploy\META-INF\MANIFEST.MF
| C:\jboss403\server\default\deploy\META-INF\hibernate-service.xml
| C:\jboss403\server\default\deploy\com\xxxxx\persistence\Test.class
| C:\jboss403\server\default\deploy\com\xxxxx\persistence\Test.hbm.xml
My hibernate-service.xml is as follows:
-------------------------------------------------------------------------------
<server>
| <mbean code="org.jboss.hibernate.jmx.Hibernate"
name="jboss.har:service=Hibernate">
| <attribute
name="SessionFactoryName">hibernate/HibernateFactory</attribute>
| <attribute name="DatasourceName">java:OracleDS</attribute>
| <attribute
name="Dialect">net.sf.hibernate.dialect.OracleDialect</attribute>
| <attribute
name="CacheProviderClass">net.sf.hibernate.cache.HashtableCacheProvider</attribute>
| </mbean>
| </server>
This is my bean class (com.xxxxx.persistence.Test.java)
---------------------------------------------------------------------------------
package com.xxxxx.persistence;
|
| import java.util.Set;
|
| public class Test implements java.io.Serializable {
| private String Id;
| private String CName;
| private String CNumber;
| private String CDate;
|
| // Constructors
| public Test() {
| }
|
| // Property accessors
| public String getId() {
| return this.Id;
| }
|
| public void setId(String Id) {
| this.Id = Id;
| }
|
| public String getCName() {
| return this.CName;
| }
|
| public void setCName(String CName) {
| this.CName = CName;
| }
|
| public String getCNumber() {
| return this.CNumber;
| }
|
| public void setCNumber(String CNumber) {
| this.CNumber = CNumber;
| }
|
| public String getCDate() {
| return this.CDate;
| }
|
| public void setCDate(String CDate) {
| this.CDate = CDate;
| }
| }
This is the mapping file (Test.hbm.xml):
------------------------------------------------------------------------------
<?xml version="1.0"?>
| <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD
3.0//EN"
| "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
| <hibernate-mapping>
| <class name="com.xxxxx.persistence.Test" table="TEST">
| <id name="Id">
| <column name="ID"/>
| <generator class="native" />
| </id>
| <property name="CName">
| <column name="C_NAME"/>
| </property>
| <property name="CNumber">
| <column name="C_NUMBER"/>
| </property>
| <property name="CDate">
| <column name="C_DATE"/>
| </property>
| </class>
| </hibernate-mapping>
This is my table in Oracle
-----------------------------------------------------------------------
create table TEST
| (
| ID INTEGER not null,
| C_NAME VARCHAR2(256),
| C_NUMBER NUMBER,
| C_DATE DATE
| )
This is the JSP file I am using to test my Hibernate/JBoss config.
-------------------------------------------------------------------------
<%@ page import="java.io.*" %>
| <%@ page import="java.util.*" %>
| <%@ page import="org.hibernate.*" %>
| <%@ page import="org.hibernate.cfg.*" %>
| <%@ page import="javax.naming.*" %>
| <%@ page import="javax.transaction.*" %>
| <%@ page import="org.hibernate.*" %>
| <%@ page import="org.hibernate.cfg.*" %>
| <%@ page import="com.xxxxx.persistence.*" %>
| <%@ page import="org.jboss.hibernate.session.*" %>
|
| <HTML>
| <HEAD>
| <title>Greetings!</title>
| </HEAD>
| <BODY>
| <hr>xxxyyy
| <%
| try {
| System.out.println("test.1");
|
| Context ctx = new InitialContext();
| SessionFactory sf =
(SessionFactory)ctx.lookup("hibernate/SessionFactory");
| Session s = sf.openSession();
|
|
|
| //Session s =
HibernateContext.getSession("java:/hibernate/SessionFactory");
| System.out.println("test.2");
| org.hibernate.Transaction tx = s.beginTransaction();
| System.out.println("test.3");
| Test test = new Test();
| System.out.println("test.4");
| test.setCName("bubba");
| System.out.println("test.5");
| s.save(test);
| System.out.println("test.6");
| }
| catch(Exception exception){
| exception.printStackTrace();
| }
| %>
| <hr>
This is the message I get when I load this page:
----------------------------------------------------------------------------
javax.naming.NameNotFoundException: hibernate not bound
I have been working on getting Hibernate running in JBoss for a while, and am
not having any luck. Any help would by greatly appreciated.
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3902725#3902725
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3902725
-------------------------------------------------------
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions,
and more. http://solutions.newsforge.com/ibmarch.tmpl
_______________________________________________
JBoss-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jboss-user