-->
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: Location of hibernate config files when deploying in Jboss 4
PostPosted: Tue May 03, 2005 11:07 am 
Beginner
Beginner

Joined: Sat Apr 16, 2005 4:43 am
Posts: 24
Location: Kolkata,India
I am using Jboss 4.0 with Hibernate 3.0 and Oracle 10g on RH9.2 Box. I have followed the docs in totality. Now whenever I was deploying the app it was throwing NoClassDefFound for org.hibernate.... ,I placed a copy of hibernate3.jar in the /jre/lib/ext directory along with two other commons-logging jars. Now my application works but it is unable to map. thats understandable as I have not put the .hbm.xml and the mapping files . I would like to know where to put this files.And why do I have to put the hibernate3.jar and the commons-loggings jars in the jre/lib/ext direc tory. Any hep is highly appreciated.
Deep

_________________
Greetings


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 03, 2005 11:13 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
Um, you should never put *anything* in /jre/lib/ext.

As for where it should go, you have not told us nearly enough information regarding what the heck it is you are trying to deploy.

In general, they should go inside your deployment archive, or perhaps in your jboss server/lib directory.


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 04, 2005 3:13 am 
Beginner
Beginner

Joined: Sat Apr 16, 2005 4:43 am
Posts: 24
Location: Kolkata,India
Hi,
Thanks,I have learnt that the hard way.I couldnt start JBoss server and had to remove the
commons-collections-2.1.1.jar and
commons-logging-1.0.4.jar only then I could boot the server. I apologise for not giving a clear picture. I am trying to deploy a application which is basically a applet. Its a normal form and it uses hibernate 3.0 for the ORM mapping. I have used Ant to create the .EAR file which has been placed in the deploy directory of the server.I fail to un drstand why do I ned to add this files to the deployment archive that would mean I would have to place a copy in all the archives.Is there a single location from where it can pick.Further I would like to ask, would adding a Hibernate service using a Mbean to the server----.xml file and then using JNDI to read the mapping files adviseable in a production environment.
Thanks
Deep

_________________
Greetings


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 04, 2005 9:39 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
Quote:
I fail to un drstand why do I ned to add this files to the deployment archive that would mean I would have to place a copy in all the archives.Is there a single location from where it can pick

Yes, thats a major concept behind J2EE: isolatable classloaders. If you don't care about isolating the classloaders, then you can just drop the needed jars into you jboss server/lib directory and all deployments on that server will be able to see them.

Quote:
Further I would like to ask, would adding a Hibernate service using a Mbean to the server----.xml file and then using JNDI to read the mapping files adviseable in a production environment.

Absolutely. Have a look at the JBoss-Hibernate integration.
http://wiki.jboss.org/wiki/Wiki.jsp?page=JBossHibernate


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 04, 2005 10:41 am 
Beginner
Beginner

Joined: Sat Apr 16, 2005 4:43 am
Posts: 24
Location: Kolkata,India
Hi,
I guess I was too cryptic about what I wanted to achieve I am attaching a small code snippet for you folks to understand what I am trying to achieve
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"));
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"));
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. I have been to the link you have provided and changed jboss-deploy to hibernate3 that elimenated some errors.

Thanks for your time
Deep

_________________
Greetings


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.