-->
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.  [ 8 posts ] 
Author Message
 Post subject: JBoss4.0+Hibernate3 throws DataSource Not found
PostPosted: Wed May 04, 2005 10:32 am 
Beginner
Beginner

Joined: Sat Apr 16, 2005 4:43 am
Posts: 24
Location: Kolkata,India
Hi,
I have a simple applet based program which uses hibernate-3.0,Oracle 10g and JBoss 4.0
the code of the data saving portion is as below
public void actionPerformed(ActionEvent ae)

{


if(ae.getSource()==btnSave)

{

int row,col;


if(txtPanel.txtVoucherDate.getText().length()>0)

{

try

{

java.util.Date date=new java.util.Date(txtPanel.txtVoucherDate.getText());

try

{

SimpleDateFormat sdf=new SimpleDateFormat("dd-MMM-yyyy");

txtPanel.txtVoucherDate.setText(sdf.format(date));


try

{
//DATA SAVED THROUGH HIBERNATE FOR TB_VOU_MAIN



try {

Configuration cfg = new Configuration();

cfg.configure(new File("hibernate.cfg.xml"));

// cfg.addResource("tb_vou_main.hbm.xml");

//cfg.setProperties(System.getProperties());

sessionFactory = cfg.buildSessionFactory();





tb_vou_main mainOb=new tb_vou_main(txtVoucherNo.getText(),new java.util.Date(txtPanel.txtVoucherDate.getText()),txtPanel.txtNarration.getText(),Double.parseDouble(txtPanel.txtTotalDebit.getText()),Double.parseDouble(txtPanel.txtTotalCredit.getText()),txtPanel.txtFileUpload.getText());





Session session = sessionFactory.openSession();

Transaction tx = session.beginTransaction();

session.save(mainOb);

tx.commit();

session.flush();

session.close();



Configuration cfg1 = new Configuration();

cfg1.configure(new File("hibernate.cfg.xml"));

// cfg1.addResource("tb_vou_det.hbm.xml");

//cfg.setProperties(System.getProperties());

SessionFactory sessionFactory1= cfg1.buildSessionFactory();





TableModel myTableModel=tabPanel.table.getModel();



for(row=0;row<myTableModel.getRowCount();row++)

{

int flag=1;

Vector tabData=new Vector();



for(col=0;col<myTableModel.getColumnCount();col++)

{

if(tabPanel.table.getValueAt(row,col)!=null && "".equals(tabPanel.table.getValueAt(row,col))!=true)

{

tabData.addElement((String)tabPanel.table.getValueAt(row,col));

}

else

{

flag=0;

break;

}

}



if(flag!=0)

{

Session session1= sessionFactory1.openSession();

Transaction tx1 = session1.beginTransaction();

tb_vou_det detOb=new tb_vou_det(txtVoucherNo.getText(),tabData.elementAt(0).toString(),Double.parseDouble(tabData.elementAt(2).toString()),Double.parseDouble(tabData.elementAt(3).toString()));

session1.save(detOb);

detOb=null;

session1.flush();

tx1.commit();

session.close();

}//END OF IF


}//END OF ROW LOOP
My hibernate-service.xml is as follows
<server>
<mbean code="org.jboss.hibernate.jmx.Hibernate" name="jboss.har:service=Hibernate">
<attribute name="DatasourceName">java:/DefaultDS</attribute>
<attribute name="SessionFactoryName">java:/hibernate/SessionFactory</attribute>
<attribute name="Dialect">org.hibernate.dialect.Oracle9Dialect</attribute>
<attribute name="CacheProviderClass">org.hibernate.cache.HashtableCacheProvider</attribute>
<attribute name="Hbm2ddlAuto">create-drop</attribute>
<attribute name="ShowSqlEnabled">true</attribute>
</mbean>
</server>
when I am deploying this system Jboss throws an error

20:04:27,651 ERROR [URLDeploymentScanner] Incomplete Deployment listing:
MBeans waiting for other MBeans:
ObjectName: jboss.har:service=Hibernate
state: FAILED
I Depend On:
Depends On Me: org.jboss.deployment.DeploymentException: DataSource Not Found.

The application doesnt get populated with data. Any idea what I am doing wrong.Further I AM NOT USING ANY EJB's

Thanks for your time
Deep

_________________
Greetings


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 04, 2005 1:03 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
Is "java:/DefaultDS" really the jndi-name of your datasource?


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 05, 2005 4:53 am 
Beginner
Beginner

Joined: Sat Apr 16, 2005 4:43 am
Posts: 24
Location: Kolkata,India
Hi,
I am pasting all the comfiguration files

oracle-xa-ds.xml
------------------------
<datasources>
<xa-datasource>
<jndi-name>XAOracleDS</jndi-name>
<track-connection-by-tx>true</track-connection-by-tx>
<isSameRM-override-value>false</isSameRM-override-value>
<xa-datasource-class>oracle.jdbc.xa.client.OracleXADataSource</xa-datasource-class>
<xa-datasource-property name="URL">jdbc:oracle:thin:@192.168.16.7:1521:kris</xa-datasource-property>
<xa-datasource-property name="User">jboss</xa-datasource-property>
<xa-datasource-property name="Password">jboss</xa-datasource-property>
<no-tx-separate-pools/>
<metadata>
<type-mapping>Oracle9i</type-mapping>
</metadata>
</xa-datasource>

<mbean code="org.jboss.resource.adapter.jdbc.vendor.OracleXAExceptionFormatter"
name="jboss.jca:service=OracleXAExceptionFormatter">
<depends optional-attribute-name="TransactionManagerService">jboss:service=TransactionManager</depends>
</mbean>

</datasources>

oracle-ds.xml
------------------
<datasources>
<local-tx-datasource>
<jndi-name>jndioracle</jndi-name>
<connection-url>jdbc:oracle:thin:@192.168.16.7:1521:kris</connection-url>
<driver-class>oracle.jdbc.OracleDriver</driver-class>
<user-name>demo</user-name>
<password>demo</password>
<exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleExceptionSorter</exception-sorter-class-name>
<metadata>
<type-mapping>Oracle9i</type-mapping>
</metadata>
</local-tx-datasource>
</datasources>

hibernate-service.xml
---------------------------
<server>
<mbean code="org.jboss.hibernate.jmx.Hibernate" name="jboss.har:service=Hibernate">
<attribute name="DatasourceName">jndioracle</attribute>
<attribute name="SessionFactoryName">java:/hibernate/SessionFactory</attribute>
<attribute name="Dialect">org.hibernate.dialect.Oracle9Dialect</attribute>
<attribute name="CacheProviderClass">org.hibernate.cache.HashtableCacheProvider</attribute>
<attribute name="Hbm2ddlAuto">create-drop</attribute>
<attribute name="ShowSqlEnabled">true</attribute>
</mbean>
</server>

application.xml
-------------------
<?xml version="1.0" encoding="ISO-8859-1"?>



<application>

<display-name>trial </display-name>

<module>

<web>

<web-uri>trial.war</web-uri>

<context-root>/trial</context-root>

</web>

</module>

</application>

jboss-app.xml
-----------------
<jboss-app>
-
<module>
<har>trial.har</har>
</module>
</jboss-app>

web.xml
----------
<?xml version="1.0" encoding="ISO-8859-1"?>



<!DOCTYPE web-app

PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"

"http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">



<web-app>



</web-app>


jboss-build.xml(ant file)
---------------------------
project name="Example1" default="all" basedir=".">
<property file="../../jboss-build.properties"/>

<property name="lib.dir" value="/opt/jboss-4.0.1sp1/lib" />
<property name="src.dir" value="${basedir}/src" />
<property name="build.dir" value="${basedir}/build" />


<!-- The classpath for running the client -->

<path id="client.classpath">
<fileset dir="/opt/jboss-4.0.1sp1/client">
<include name="**/*.jar"/>
</fileset>
</path>

<!-- The build classpath -->
<path id="build.classpath">
<path refid="client.classpath"/>
<pathelement location="${build.dir}"/>
</path>
Oracle classpath
<path id="hsql.classpath">
<pathelement location="/usr/lib/oracle/10.1.0.3/client/lib/ojdbc14.jar"/>
</path>

<target name="prepare">
<mkdir dir="${build.dir}"/>
</target>

<target name="compile" depends="prepare">
<javac destdir="${build.dir}" classpathref="build.classpath"
debug="true">
<src path="${src.dir}" />
</javac>
</target>

<target name="package-har" depends="compile">
<mkdir dir="jar" />
<delete file="jar/trial.har"/>

<jar jarfile="jar/trial.har">
<metainf dir="dd/har" includes="*.xml"/>
<fileset dir="${build.dir}">
<include name="**/*.class"/>
</fileset>
<fileset dir="${src.dir}">
<include name="**/*.hbm.xml"/>
</fileset>
</jar>
</target>

<target name="package-web" depends="compile">
<mkdir dir="jar" />
<delete file="jar/trial.war"/>

<war warfile="jar/trial.war" webxml="dd/web/web.xml">
<metainf dir="dd/web" includes="*.xml"/>
<?-- <lib dir="${lib.dir}">
<include name="jstl.jar"/>
<include name="standard.jar"/>
</lib>-->
<fileset dir="web" />
</war>
</target>

<target name="assemble">
<mkdir dir="jar" />
<delete file="jar/trial.ear"/>

<ear destfile="jar/trial.ear"
appxml="dd/ear/application.xml">
<metainf dir="dd/ear" includes="jboss-app.xml" />
<fileset dir="jar" includes="*.har" />
<fileset dir="jar" includes="*.war" />
</ear>
</target>

<!-- <target name="deploy">
<copy file="jar/HibernateRoster.ear" todir="${jboss.server}/deploy"/>
</target>-->

<target name="all"
depends="compile,package-har,package-web,assemble" />
<!-- depends="compile,package-har,package-web,assemble,deploy" />-->

<target name="clean">
<delete dir="${build.dir}" />
<delete dir="jar" />
</target>
</project>

I am sure I am doing some thing wrong at the jboss-build.xml level or in some configuration files.
Actually this is our first time with Hibernate and JBoss, this is a prototype to convince the Management honchos that this technology works and works quite well.I apologize for being a pain.
Thanks
Deep

_________________
Greetings


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 05, 2005 10:40 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
You need to prefix the JNDI name with "java:/":
Code:
    <attribute name="DatasourceName">java:/jndioracle</attribute>


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 05, 2005 12:12 pm 
Beginner
Beginner

Joined: Sat Apr 16, 2005 4:43 am
Posts: 24
Location: Kolkata,India
Hi Steve,
I think I am goofing up on the datasource protion. I have followed JBoss getting started 4.0
Chapter 8 Using other datasources in totality. Then I read www.hibernate.org/66.html and followed it in totality.
when I Bind my Oracle10g datasource I get
20:08:44,460 INFO [WrapperDataSourceService] Bound connection factory for resource adapter for ConnectionManager 'jboss.jca:name=XAOracleDS,service=DataSourceBinding to JNDI name 'java:XAOracleDS'
then I created the jboss-service.xml as per www.hibernate.org/66.html as
<?xml version="1.0" encoding="UTF-8"?>
<server>
<mbean code="org.hibernate.jmx.HibernateService"
name="jboss.jca:service=HibernateFactory,
name=HibernateFactory">
<depends>jboss.jca:service=RARDeployer</depends>
<!--Make it Deploy ONLY after Datasource has been started-->
<depends>jboss.jca:service=LocalTxCM,name=XAOracleDS</depends>
<attribute name="MapResources">mappings/tb_vou_main.hbm.xml,
mappings/tb_vou_det.hbm.xml</attribute>
<attribute name="JndiName">java:/XAOracleDS</attribute>
<attribute name="Datasource">java:/jdbc/OracleDS</attribute>
<attribute name="Dialect">org.hibernate.dialect.Oracle9Dialect</attribute>
<attribute
name="TransactionStrategy">org.hibernate.transaction.JTATransactionFactory</attribute>
<attribute
name="TransactionManagerLookupStrategy">org.hibernate.transaction.JBossTransactionManagerLookup</attribute>
<attribute name="CacheProviderClass">org.hibernate.cache.HashtableCacheProvider</attribute>
<attribute name="ShowSqlEnabled">true</attribute>
</mbean>
</server>
the directory structure conforms to the one specified. But I am getting

21:36:26,287 ERROR [URLDeploymentScanner] Incomplete Deployment listing:
MBeans waiting for other MBeans:
ObjectName: jboss.jca: name=HibernateFactory,service=HibernateFactory
state: CONFIGURED
I Depend On: jboss.jca:service=RARDeployer
jboss.jca:name=XAOracleDS,service=LocalTxCM

Depends On Me:

MBEANS THAT ARE THE ROOT CAUSE OF THE PROBLEM:
ObjectName: jboss.jca:name=XAOracleDS,service=LocalTxCM
state: NOTYETINSTALLED
I Depend On:
Depends On Me: jboss.jca: name=HibernateFactory,service=HibernateFactory
Can you please let me know where I am going wrong. Today is the last day and I dont want the next project to start without Hibernate.Pleaseeeeeeeeeeeeeee.
Thanks
Deep

_________________
Greetings


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 05, 2005 2:59 pm 
Beginner
Beginner

Joined: Sat Apr 16, 2005 4:43 am
Posts: 24
Location: Kolkata,India
hi Mr Steve,
Could you please explain what causes this error

00:28:03,000 ERROR [BasicLazyInitializer] CGLIB Enhancement failed: tb_vou_main
net.sf.cglib.core.CodeGenerationException: java.lang.reflect.InvocationTargetException-->
null
at net.sf.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:23
any help .Please
Deep

_________________
Greetings


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 05, 2005 3:33 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
Quote:
Could you please explain what causes this error

Not sure specifically, but I would guess you are not following one of the rules regarding defining your JavaBean. Is it final? What is its visibility?


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 05, 2005 3:57 pm 
Beginner
Beginner

Joined: Sat Apr 16, 2005 4:43 am
Posts: 24
Location: Kolkata,India
No it is not final.Can you please let me know what rule I am ov erlooking.
Deep

_________________
Greetings


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