-->
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.  [ 3 posts ] 
Author Message
 Post subject: NoClassDefFoundError: org/hibernate/Session while deploying
PostPosted: Fri May 06, 2005 5:26 am 
Beginner
Beginner

Joined: Sat Apr 16, 2005 4:43 am
Posts: 24
Location: Kolkata,India
Hi,
I am trying to deploy a simple applet based java application without any EJB in JBOSS4.0+Hibernate 3.0+Oracle 10g .My layout is as follows
Directory Structure
===================
trial
|
|-build
| |- class files
| |-org
| |-jboss
| |-deploy
|
|-dd
| |-ear
| | |-application.xml
| | |-jboss-app.xml
| |-har
| | |-hibernate-service.xml
| |-web
| |-web.xml
|-jar
| |-trial.ear
| |-trial.har
| |-trial.war
|-src
| |-mapping xml files
| |-org
| |-jboss
| |-deploy
| |- java files
|-web
|-start.htm
I am coping trial.ear to $JBOSS_HOME/server/default/deploy
JBoss Console Output
====================
14:21:16,226 INFO [EARDeployer] Init J2EE application: file:/opt/jboss-4.0.1sp1/server/default/deploy/trial.ear
14:21:17,025 INFO [Environment] Hibernate 3.0.2
14:21:17,033 INFO [Environment] hibernate.properties not found
14:21:17,090 INFO [Environment] using CGLIB reflection optimizer
14:21:17,091 INFO [Environment] using JDK 1.4 java.sql.Timestamp handling
14:21:17,391 INFO [Hibernate] Using JDBC batch size : null
14:21:17,431 INFO [Configuration] Searching for mapping documents in jar: trial.har
14:21:17,544 INFO [Configuration] Found mapping documents in jar: tb_vou_det.hbm.xml
14:21:17,956 INFO [HbmBinder] Mapping class: tb_vou_det -> tb_vou_det
14:21:18,184 INFO [Configuration] Found mapping documents in jar: tb_vou_main.hbm.xml
14:21:18,256 INFO [HbmBinder] Mapping class: tb_vou_main -> tb_vou_main
14:21:18,264 INFO [Configuration] processing extends queue
14:21:18,317 INFO [Configuration] processing collection mappings
14:21:18,317 INFO [Configuration] processing association property references
14:21:18,318 INFO [Configuration] processing foreign key constraints
14:21:18,698 INFO [NamingHelper] JNDI InitialContext properties:{}
14:21:18,702 INFO [DatasourceConnectionProvider] Using datasource: java:/XAOracleDS
14:21:21,533 INFO [SettingsFactory] RDBMS: Oracle, version: Oracle Database 10g Enterprise Edition Release 10.1.0.2.0 - Production
With the Partitioning, OLAP and Data Mining options
14:21:21,534 INFO [SettingsFactory] JDBC driver: Oracle JDBC driver, version: 10.1.0.3.0
14:21:21,606 INFO [Dialect] Using dialect: org.hibernate.dialect.Oracle9Dialect14:21:21,620 INFO [SettingsFactory] JDBC batch size: 15
14:21:21,673 INFO [SettingsFactory] JDBC batch updates for versioned data: disabled
14:21:21,675 INFO [SettingsFactory] Scrollable result sets: enabled
14:21:21,727 INFO [SettingsFactory] JDBC3 getGeneratedKeys(): disabled
14:21:21,728 INFO [SettingsFactory] Aggressive release : disabled
14:21:21,728 INFO [SettingsFactory] Default batch fetch size: 1
14:21:21,728 INFO [SettingsFactory] Generate SQL with comments: disabled
14:21:21,728 INFO [SettingsFactory] Order SQL updates by primary key: disabled
14:21:21,728 INFO [SettingsFactory] Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
14:21:21,763 INFO [ASTQueryTranslatorFactory] Using ASTQueryTranslatorFactory
14:21:21,763 INFO [SettingsFactory] Query language substitutions: {}
14:21:21,767 INFO [TransactionFactoryFactory] Transaction strategy: org.hibernate.transaction.JTATransactionFactory
14:21:21,820 INFO [NamingHelper] JNDI InitialContext properties:{}
14:21:21,943 INFO [TransactionManagerLookupFactory] instantiating TransactionManagerLookup: org.hibernate.transaction.JBossTransactionManagerLookup
14:21:21,944 INFO [TransactionManagerLookupFactory] instantiated TransactionManagerLookup
14:21:21,944 INFO [TransactionManagerLookupFactory] instantiating TransactionManagerLookup: org.hibernate.transaction.JBossTransactionManagerLookup
14:21:21,944 INFO [TransactionManagerLookupFactory] instantiated TransactionManagerLookup
14:21:21,945 INFO [SettingsFactory] Automatic flush during beforeCompletion():
enabled
14:21:21,972 INFO [SettingsFactory] Automatic session close at end of transaction: enabled
14:21:21,972 INFO [SettingsFactory] Second-level cache: enabled
14:21:21,972 INFO [SettingsFactory] Query cache: disabled
14:21:21,972 INFO [SettingsFactory] Cache provider: org.hibernate.cache.HashtableCacheProvider
14:21:21,976 INFO [SettingsFactory] Optimize cache for minimal puts: disabled
14:21:22,029 INFO [SettingsFactory] Structured second-level cache entries: enabled
14:21:22,075 INFO [SettingsFactory] Echoing all SQL to stdout
14:21:22,076 INFO [SettingsFactory] Statistics: disabled
14:21:22,076 INFO [SettingsFactory] Deleted entity synthetic identifier rollback: disabled
14:21:22,078 INFO [SettingsFactory] Default entity-mode: pojo
14:21:22,581 INFO [SessionFactoryImpl] building session factory
14:21:24,164 INFO [SessionFactoryObjectFactory] Not binding factory to JNDI, no JNDI name configured
14:21:24,173 INFO [Dialect] Using dialect: org.hibernate.dialect.Oracle9Dialect14:21:24,228 INFO [Configuration] processing extends queue
14:21:24,229 INFO [Configuration] processing collection mappings
14:21:24,229 INFO [Configuration] processing association property references
14:21:24,229 INFO [Configuration] processing foreign key constraints
14:21:24,230 INFO [Configuration] processing extends queue
14:21:24,257 INFO [Configuration] processing collection mappings
14:21:24,257 INFO [Configuration] processing association property references
14:21:24,257 INFO [Configuration] processing foreign key constraints
14:21:24,258 INFO [SchemaExport] Running hbm2ddl schema export
14:21:24,285 INFO [SchemaExport] exporting generated schema to database
14:21:24,286 INFO [NamingHelper] JNDI InitialContext properties:{}
14:21:24,286 INFO [DatasourceConnectionProvider] Using datasource: java:/XAOracleDS
14:21:25,073 ERROR [SchemaExport] Unsuccessful: create table tb_vou_det (vou_no
varchar2 not null, ACCT_CODE varchar2, TRAN_DBT number, TRAN_CDT number, primary key (vou_no))
14:21:25,074 ERROR [SchemaExport] ORA-00906: missing left parenthesis

14:21:25,293 ERROR [SchemaExport] Unsuccessful: create table tb_vou_main (vou_no varchar2 not null, vou_date date, narration varchar2, tot_dbt number, tot_cdt number, img_ref varchar2, primary key (vou_no))
14:21:25,294 ERROR [SchemaExport] ORA-00906: missing left parenthesis

14:21:25,294 INFO [SchemaExport] schema export complete
14:21:25,298 INFO [Dialect] Using dialect: org.hibernate.dialect.Oracle9Dialect14:21:25,351 INFO [Configuration] processing extends queue
14:21:25,351 INFO [Configuration] processing collection mappings
14:21:25,351 INFO [Configuration] processing association property references
14:21:25,352 INFO [Configuration] processing foreign key constraints
14:21:25,352 INFO [Configuration] processing extends queue
14:21:25,352 INFO [Configuration] processing collection mappings
14:21:25,379 INFO [Configuration] processing association property references
14:21:25,379 INFO [Configuration] processing foreign key constraints
14:21:25,380 INFO [NamingHelper] JNDI InitialContext properties:{}
14:21:25,407 INFO [SessionFactoryImpl] Checking 0 named queries
14:21:25,409 INFO [Hibernate] SessionFactory successfully built and bound into
JNDI [java:/hibernate/SessionFactory]
14:21:25,455 INFO [TomcatDeployer] deploy, ctxPath=/trial, warUrl=file:/opt/jboss-4.0.1sp1/server/default/tmp/deploy/tmp7981trial.ear-contents/trial.war/
14:21:25,736 INFO [EARDeployer] Started J2EE application: file:/opt/jboss-4.0.1sp1/server/default/deploy/trial.ear

Error at Java Console
=====================
java.lang.NoClassDefFoundError: org/hibernate/Session
at InnerRightPanel.<init>(MainApplet.java:315)
at TopRightPanel.<init>(MainApplet.java:294)
at TopPanel.<init>(MainApplet.java:260)
at SuperPanel.<init>(MainApplet.java:142)
at MainApplet.init(MainApplet.java:48)
at sun.applet.AppletPanel.run(AppletPanel.java:353)
at java.lang.Thread.run(Thread.java:534)

Can someone please tell me what am I missing. My program is uses configure option.
Thanks
Deep

_________________
Greetings


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 06, 2005 6:33 am 
Expert
Expert

Joined: Fri Nov 07, 2003 4:24 am
Posts: 315
Location: Cape Town, South Africa
Looks like you are referencing the hibernate classes in you applet (this is where the class not found error seems to be coming from). Is this intentional.

I think you need to look at your architecture again...


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 06, 2005 6:59 am 
Beginner
Beginner

Joined: Sat Apr 16, 2005 4:43 am
Posts: 24
Location: Kolkata,India
Hi drj,
This is my source program , I have placed hibernate3.jar at $JBOSS_HOME/server/default/lib
import java.awt.*;

import javax.swing.*;

import javax.swing.table.*;

import javax.swing.border.*;

import java.util.*;

import java.util.zip.*;

import java.io.*;

import java.awt.event.*;

import java.text.*;

import java.sql.*;

import javax.swing.event.*;

//import oracle.jdbc.driver.*;

import java.rmi.*;

import java.net.*;



import javax.swing.JTree;

import javax.swing.tree.DefaultMutableTreeNode;

import javax.swing.tree.TreeSelectionModel;

import javax.swing.event.TreeSelectionEvent;

import javax.swing.event.TreeSelectionListener;



import net.sf.jasperreports.engine.*;

import net.sf.jasperreports.engine.design.*;

import net.sf.jasperreports.view.*;



import org.hibernate.*;

import org.hibernate.cfg.*;







public class MainApplet extends JApplet

{

SuperPanel superPanel;









public void init()

{

try {

UIManager.setLookAndFeel(

UIManager.getCrossPlatformLookAndFeelClassName());

} catch (Exception e){

}

Container c=getContentPane();



superPanel=new SuperPanel(getParameter("VoucherDateDateFormat"));









superPanel.topPanel.topRightPanel.innerRightPanel.mPanel.txtPanel.lblVoucherDate.setText(getParameter("lblVoucherDate"));

superPanel.topPanel.topRightPanel.innerRightPanel.mPanel.txtPanel.txtVoucherDate.setText(superPanel.topPanel.topRightPanel.innerRightPanel.mPanel.ob.getSysDate(getParameter("VoucherDateDateFormat")));

superPanel.topPanel.topRightPanel.innerRightPanel.mPanel.txtPanel.lblNarration.setText(getParameter("lblNarration"));

superPanel.topPanel.topRightPanel.innerRightPanel.mPanel.txtPanel.lblTotalDebit.setText(getParameter("lblTotalDebit"));

superPanel.topPanel.topRightPanel.innerRightPanel.mPanel.txtPanel.lblTotalCredit.setText(getParameter("lblTotalCredit"));

superPanel.topPanel.topRightPanel.innerRightPanel.mPanel.txtPanel.lblFileUpload.setText(getParameter("lblFileUpload"));



superPanel.topPanel.topRightPanel.innerRightPanel.mPanel.setBorder(new BevelBorder(BevelBorder.RAISED));







c.add(superPanel);



superPanel.usernamePasswordPanel.btnLogin.addActionListener(new ActionListener()

{

public void actionPerformed(ActionEvent ae)

{



if(superPanel.usernamePasswordPanel.txtUsername.getText().equals("admin") && superPanel.usernamePasswordPanel.txtPassword.getText().equals("password"))

{



superPanel.cardLayout.show(superPanel,"TopPanel");



}

}

});





superPanel.topPanel.topLeftPanel.treeDemo.tree.addTreeSelectionListener(new TreeSelectionListener()

{



public void valueChanged(TreeSelectionEvent e) {

DefaultMutableTreeNode node = (DefaultMutableTreeNode)

superPanel.topPanel.topLeftPanel.treeDemo.tree.getLastSelectedPathComponent();



if (node == null) return;







Object nodeInfo = node.getUserObject();







if(nodeInfo.toString().equals("VoucherEntry"))

{



superPanel.topPanel.topRightPanel.innerRightPanel.cardLayout.show(superPanel.topPanel.topRightPanel.innerRightPanel,"VoucherEntryForm");



}

else

{

if(nodeInfo.toString().equals("Menu"))

{



superPanel.topPanel.topRightPanel.innerRightPanel.cardLayout.show(superPanel.topPanel.topRightPanel.innerRightPanel,"BlankPanel");

}

else

{

if(nodeInfo.toString().equals("Logout"))

{

superPanel.cardLayout.show(superPanel,"UsernamePasswordPanel");

}



}

}



}

});









}

}



class SuperPanel extends JPanel

{

UsernamePasswordPanel usernamePasswordPanel;

TopPanel topPanel;

CardLayout cardLayout;



public SuperPanel(String data)

{

cardLayout=new CardLayout();



setLayout(cardLayout);



usernamePasswordPanel=new UsernamePasswordPanel();



topPanel=new TopPanel(data);



add(usernamePasswordPanel,"UsernamePasswordPanel");

add(topPanel,"TopPanel");





}



}







class UsernamePasswordPanel extends JPanel

{

JLabel lblUsername,lblPassword,lblHostString;

JTextField txtUsername,txtPassword,txtHostString;

JButton btnLogin,btnCancel;

JPanel jp1,jp2,jp3,jp4,jp5;

JPanel jp3Left,jp3Meddium,jp3Right;





public UsernamePasswordPanel()

{

setLayout(new GridLayout(3,1));



jp1=new JPanel();

//jp2=new JPanel();



jp3=new JPanel();



jp3.setLayout(new GridLayout(1,3));



jp3Left=new JPanel();



jp3Meddium=new JPanel();

jp3Meddium.setBorder(new BevelBorder(BevelBorder.RAISED));

jp3Meddium.setBackground(Color.darkGray);

jp3Meddium.setLayout(new GridLayout(5,1));



JPanel titlePanel=new JPanel();

titlePanel.setLayout(new GridLayout(2,1));

JPanel labelPanel=new JPanel();

labelPanel.setLayout(new FlowLayout(FlowLayout.LEFT));



labelPanel.setBackground(Color.gray);

JLabel lblTitle=new JLabel("Login");

lblTitle.setForeground(Color.pink);

labelPanel.add(lblTitle);

titlePanel.add(labelPanel);



JPanel userPanel=new JPanel();

lblUsername=new JLabel("Username :");

//lblUsername.setForeground(Color.white);

txtUsername=new JTextField(15);

userPanel.add(lblUsername);

userPanel.add(txtUsername);



JPanel passwordPanel=new JPanel();

lblPassword=new JLabel("Password :");

//lblPassword.setForeground(Color.white);

txtPassword=new JPasswordField(15);

passwordPanel.add(lblPassword);

passwordPanel.add(txtPassword);



JPanel hostStringPanel=new JPanel();

lblHostString=new JLabel("HostString:");

//lblHostString.setForeground(Color.white);

txtHostString=new JTextField(15);

hostStringPanel.add(lblHostString);

hostStringPanel.add(txtHostString);





JPanel buttonPanel=new JPanel();

btnLogin=new JButton("Login");

btnLogin.setMnemonic('L');

buttonPanel.add(btnLogin);



btnCancel=new JButton("Cancel");

btnCancel.setMnemonic('C');

buttonPanel.add(btnCancel);



jp3Meddium.add(titlePanel);

jp3Meddium.add(userPanel);

jp3Meddium.add(passwordPanel);

jp3Meddium.add(hostStringPanel);

jp3Meddium.add(buttonPanel);



jp3Right=new JPanel();



jp3.add(jp3Left);

jp3.add(jp3Meddium);

jp3.add(jp3Right);



//jp4=new JPanel();

jp5=new JPanel();



add(jp1);

// add(jp2);

add(jp3);

// add(jp4);

add(jp5);



}

}



class TopPanel extends JPanel

{

TopLeftPanel topLeftPanel;

TopRightPanel topRightPanel;

JSplitPane jsp;





public TopPanel(String data)

{







topLeftPanel=new TopLeftPanel();

topRightPanel=new TopRightPanel(data);

jsp=new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,topLeftPanel,topRightPanel);





add(jsp);











}



}



class TopLeftPanel extends JPanel

{

TreeDemo treeDemo;



public TopLeftPanel()

{



treeDemo=new TreeDemo();



add(treeDemo);

}

}



class TopRightPanel extends JPanel

{

JScrollPane scrollPane;

InnerRightPanel innerRightPanel;



public TopRightPanel(String data)

{

innerRightPanel=new InnerRightPanel(data);



scrollPane=new JScrollPane(innerRightPanel,JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);

add(scrollPane);

}



}







class InnerRightPanel extends JPanel

{

MainPanel mPanel;

CardLayout cardLayout;

JPanel blankPanel;



public InnerRightPanel(String data)

{

cardLayout=new CardLayout();

setLayout(cardLayout);



mPanel=new MainPanel(data);//getParameter("VoucherDateDateFormat"));



blankPanel=new JPanel();



blankPanel.setBackground(Color.darkGray);

blankPanel.setPreferredSize(new Dimension(780,560));



add(blankPanel,"BlankPanel");

add(mPanel,"VoucherEntryForm");





}



}





class MainPanel extends JPanel implements ActionListener

{

TextPanel txtPanel;

TablePanel tabPanel;

JButton btnSave,btnReject,btnExit;

JTextField txtVoucherNo;

JLabel lblVoucherNo;

JPanel DataPanel,VoucherAndButtonPanel;

JPanel ButtonPanel,VoucherPanel;

Vector lblContent;

DateCalc ob=new DateCalc();

String dateFormat;



SessionFactory sessionFactory;



public MainPanel(String df)

{



dateFormat=df;



setLayout(new BorderLayout());



DataPanel=new JPanel();



DataPanel.setLayout(new GridLayout(2,1));



txtPanel=new TextPanel();







txtPanel.setBorder(new BevelBorder(BevelBorder.RAISED));

tabPanel=new TablePanel();

tabPanel.setBorder(new BevelBorder(BevelBorder.RAISED));



DataPanel.add(txtPanel);

DataPanel.add(tabPanel);







VoucherAndButtonPanel=new JPanel();

VoucherAndButtonPanel.setLayout(new GridLayout(2,1));



ButtonPanel=new JPanel();



btnSave=new JButton("Save");

btnSave.setMnemonic('S');

btnSave.addActionListener(this);



btnReject=new JButton("Reject");

btnReject.setMnemonic('R');

btnReject.addActionListener(this);



btnExit=new JButton("Exit");

btnExit.setMnemonic('E');

btnExit.addActionListener(this);



ButtonPanel.add(btnSave);

ButtonPanel.add(btnReject);

ButtonPanel.add(btnExit);



VoucherPanel=new JPanel();

VoucherPanel.setLayout(new FlowLayout(FlowLayout.CENTER));

lblVoucherNo=new JLabel("Voucher No : ");

txtVoucherNo=new JTextField(8);

txtVoucherNo.setText(DateCalc.genVoucherNo());

//txtVoucherNo.setEditable(false);

txtVoucherNo.setFont(new Font(txtVoucherNo.getFont().getName(),Font.BOLD,txtVoucherNo.getFont().getSize()));

VoucherPanel.add(lblVoucherNo);

VoucherPanel.add(txtVoucherNo);







VoucherAndButtonPanel.add(VoucherPanel);

VoucherAndButtonPanel.add(ButtonPanel);

DataPanel.setBorder(new BevelBorder(BevelBorder.RAISED));

VoucherAndButtonPanel.setBorder(new BevelBorder(BevelBorder.RAISED));



add(DataPanel,BorderLayout.CENTER);

add(VoucherAndButtonPanel,BorderLayout.SOUTH);



/*txtPanel.cbYes.addItemListener(new ItemListener()

{

public void itemStateChanged(ItemEvent ie)

{

if(txtPanel.cbYes.getState()==true)

{

JOptionPane.showMessageDialog(null,"ok");

txtPanel.btnBrowse.setVisible(true);

}

}

});



txtPanel.cbYes.addItemListener(new ItemListener()

{

public void itemStateChanged(ItemEvent ie)

{

if(txtPanel.cbNo.getState()==true)

{

txtPanel.btnBrowse.setVisible(false);

}

}

});*/



tabPanel.table.addMouseListener(new MouseListener()

{

public void mousePressed(MouseEvent me)

{

}

public void mouseReleased(MouseEvent me)

{

}

public void mouseClicked(MouseEvent me)

{



gridDataCalc();

}

public void mouseEntered(MouseEvent me)

{

}

public void mouseExited(MouseEvent me)

{



}

});



tabPanel.table.addMouseMotionListener(new MouseMotionListener()

{

public void mouseMoved(MouseEvent me)

{

gridDataCalc();

}

public void mouseDragged(MouseEvent me)

{

}

});



/*tabPanel.comboBox.addItemListener(new ItemListener()

{



public void itemStateChanged(ItemEvent ie)

{

if(comboBox.getSelectedItem().toString().length()>0)

{

for(int i=0;i<DescriptionList.size();i++)

{

String str=(String)DescriptionList.elementAt(i);

if(comboBox.getSelectedItem().toString().equals(str.substring(0,comboBox.getSelectedItem().toString().length())))

{

table.setValueAt(str.substring(comboBox.getSelectedItem().toString().length()),table.getEditingRow(),table.getEditingColumn()+1);

}

}

}

else

{

table.setValueAt("Not Match",table.getEditingRow(),table.getEditingColumn()+1);

}

JOptionPane.showMessageDialog(null,tabPanel.comboBox.getSelectedItem().toString());

}



});*/





tabPanel.table.addKeyListener(new KeyListener()

{

public void keyPressed(KeyEvent ke)

{

}

public void keyReleased(KeyEvent ke)

{

}

public void keyTyped(KeyEvent ke)

{



char ch=ke.getKeyChar();





if(Byte.toString((byte)ch).equals("9"))

{

gridDataCalc();

}//end of if

}//End of keyTyped



});



}



public void gridDataCalc()

{

txtPanel.txtTotalDebit.setText("0.00");

txtPanel.txtTotalCredit.setText("0.00");



try

{

int row;

int col;



TableModel myTableModel=tabPanel.table.getModel();





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

{

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

{



if(tabPanel.table.getValueAt(row,0)!=null)

{

String str=(String)tabPanel.table.getValueAt(row,0);



if(str.length()>0)

{



for(int i=0;i<tabPanel.DescriptionList.size();i++)

{

String str1=(String)tabPanel.DescriptionList.elementAt(i);

if(tabPanel.table.getValueAt(row,0).toString().equals(str1.substring(0,tabPanel.table.getValueAt(row,0).toString().length())))

{



tabPanel.table.setValueAt(str1.substring(tabPanel.table.getValueAt(row,0).toString().length()),row,1);

break;

}

}//end of for







if(col>=2)

{

if(col==2)

{

if(tabPanel.table.getValueAt(row,2)==null || "".equals((String)tabPanel.table.getValueAt(row,2)))

{

tabPanel.table.setValueAt("0.00",row,col);

}



if(Double.parseDouble((String)tabPanel.table.getValueAt(row,2)) >0)

{

tabPanel.table.setValueAt("0.00",row,3);

}



txtPanel.txtTotalDebit.setText(Double.toString(Double.parseDouble(txtPanel.txtTotalDebit.getText())+Double.parseDouble((String)tabPanel.table.getValueAt(row,2))));



}

if(col==3)

{



if(tabPanel.table.getValueAt(row,3)==null || "".equals((String)tabPanel.table.getValueAt(row,3)))

{

tabPanel.table.setValueAt("0.00",row,col);

}



if(Double.parseDouble((String)tabPanel.table.getValueAt(row,3)) >0)

{

tabPanel.table.setValueAt("0.00",row,2);

}



txtPanel.txtTotalCredit.setText(Double.toString(Double.parseDouble(txtPanel.txtTotalCredit.getText())+Double.parseDouble((String)tabPanel.table.getValueAt(row,3))));



}

}

}



}else

{

break;

}





}//End of col

}//End of row



}catch(Exception e)

{

JOptionPane.showMessageDialog(null,e.toString());

}





}//End of gridDataCalc







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

{

//DriverManager.registerDriver (new oracle.jdbc.OracleDriver());

gridDataCalc();

/*Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");



//Connection conn = DriverManager.getConnection ("jdbc:oracle:thin:@192.168.16.7:1521:kris","demo", "demo");

Connection conn=DriverManager.getConnection("jdbc:odbc:ora10g","demo","demo");



Statement stmt = conn.createStatement ();



stmt.executeUpdate("insert into tb_vou_main values('"+txtPanel.txtVoucherDate.getText()+"','"+txtVoucherNo.getText()+"','"+txtPanel.txtNarration.getText()+"',"+txtPanel.txtTotalDebit.getText()+","+txtPanel.txtTotalCredit.getText()+",'"+txtPanel.txtFileUpload.getText()+"')");*/



//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)

{

//stmt.executeUpdate("insert into tb_vou_det values('"+txtVoucherNo.getText()+"','"+tabData.elementAt(0)+"',"+tabData.elementAt(2)+","+tabData.elementAt(3)+")");











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











JOptionPane.showMessageDialog(null,"Data Saved successfully");



} catch (Exception e) {

e.printStackTrace();

}















/*stmt.close();

conn.close();*/



ClearData();



//jasperReport code

try

{

JasperDesign jasperDesign = JasperManager.loadXmlDesign("E:/download/Doc/voucher/Voucher.jrxml");

JasperReport jasperReport = JasperCompileManager.compileReport(jasperDesign);

Connection con1 = DriverManager.getConnection("jdbc:odbc:ora10g","demo","demo");



Statement s1 = con1.createStatement();



java.util.Map parameters = new java.util.HashMap();



parameters.put("Tittle","Test JasperReport");



JasperPrint report = JasperFillManager.fillReport(jasperReport, parameters, con1);



//JasperExportManager.exportReportToPdfFile(report,"report1.pdf");



JasperViewer.viewReport(report);

}



catch(Exception ex)

{

System.out.print(ex.toString());

}





}catch(Exception e)

{

JOptionPane.showMessageDialog(null,e.toString());

}







}catch(Exception e)

{

}



}catch(Exception e)

{

JOptionPane.showMessageDialog(null,"This Field ( Voucher Date ) Date Format is not Ok");

txtPanel.txtVoucherDate.setSelectedTextColor(Color.white);

txtPanel.txtVoucherDate.setSelectionColor(Color.red);

txtPanel.txtVoucherDate.select(0,txtPanel.txtVoucherDate.getText().length());

btnExit.transferFocus();

}



}

else

{

JOptionPane.showMessageDialog(null,"This Field ( Voucher Date ) Date Format is not Ok");

txtPanel.txtVoucherDate.setSelectedTextColor(Color.white);

txtPanel.txtVoucherDate.setSelectionColor(Color.red);

txtPanel.txtVoucherDate.select(0,txtPanel.txtVoucherDate.getText().length());

btnExit.transferFocus();



}







}





if(ae.getSource()==btnReject)

{

ClearData();

JOptionPane.showMessageDialog(null,"All Data Cleared");







}//End of Reject Button



}

private void ClearData()

{

try

{

int row,col;



txtPanel.txtVoucherDate.setText(DateCalc.getSysDate(dateFormat));

txtPanel.txtNarration.setText("");

txtPanel.txtTotalDebit.setText("");

txtPanel.txtTotalDebit.setText("0.00");

txtPanel.txtTotalCredit.setText("0.00");

txtPanel.txtFileUpload.setText("");

txtVoucherNo.setText(DateCalc.genVoucherNo());







tabPanel.table.selectAll();

tabPanel.table.clearSelection();

tabPanel.table.transferFocus();

tabPanel.table.setEditingRow(tabPanel.table.getEditingRow()+1);



TableModel myTableModel=tabPanel.table.getModel();





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

{

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

{

tabPanel.table.setValueAt("",row,col);

}

}







btnExit.transferFocus();



}catch(Exception e)

{

JOptionPane.showMessageDialog(null,e.toString());

}



}

}







class TextPanel extends JPanel implements ActionListener

{

JLabel lblVoucherDate,lblNarration,lblTotalDebit,lblTotalCredit,lblFileUpload;

JTextField txtVoucherDate,txtTotalDebit,txtTotalCredit,txtFileUpload;

JTextField txtNarration;

JButton btnBrowse;

//Checkbox cbYes,cbNo;

//CheckboxGroup cbg;

JPanel jp4;

public TextPanel()

{



try {

UIManager.setLookAndFeel(

UIManager.getCrossPlatformLookAndFeelClassName());

} catch (Exception e){

}



setLayout(new GridLayout(4,1));





JPanel jp1=new JPanel();

FlowLayout f1=new FlowLayout(FlowLayout.LEFT);



jp1.setLayout(f1);

lblVoucherDate=new JLabel(" Voucher Date :");

txtVoucherDate=new JTextField(8);



/*cbg=new CheckboxGroup();

cbYes=new Checkbox("Yes",cbg,true);

cbNo=new Checkbox("No",cbg,false);*/



jp1.add(lblVoucherDate);

jp1.add(txtVoucherDate);

//jp1.add(cbYes);

//jp1.add(cbNo);





JPanel jp2=new JPanel();

jp2.setSize(600,40);

FlowLayout f2=new FlowLayout(FlowLayout.LEFT);

jp2.setLayout(f2);



lblNarration=new JLabel(" Narration :");

txtNarration=new JTextField(30);



txtNarration.addCaretListener(new CaretListener()

{

public void caretUpdate(CaretEvent e)

{

if(txtNarration.getText().length()>50)

{

txtNarration.setText(txtNarration.getText().substring(0,50));

}

}

});



//txtNarration.setMaximumSize(30);

jp2.add(lblNarration);



jp2.add(txtNarration);





JPanel jp3=new JPanel();

FlowLayout f3=new FlowLayout(FlowLayout.LEFT);



jp3.setLayout(f3);

lblTotalDebit=new JLabel(" TotalDebit :");

txtTotalDebit=new JTextField(8);

txtTotalDebit.setEditable(false);

txtTotalDebit.setText("0.00");

jp3.add(lblTotalDebit);

jp3.add(txtTotalDebit);









lblTotalCredit=new JLabel(" TotalCredit :");

txtTotalCredit=new JTextField(8);

txtTotalCredit.setEditable(false);



txtTotalCredit.setText("0.00");

jp3.add(lblTotalCredit);

jp3.add(txtTotalCredit);





jp4=new JPanel();

FlowLayout f4=new FlowLayout(FlowLayout.LEFT);

jp4.setLayout(f4);

lblFileUpload=new JLabel(" FileUpload :");

txtFileUpload=new JTextField(30);

jp4.add(lblFileUpload);

jp4.add(txtFileUpload);

btnBrowse=new JButton("Browse");



btnBrowse.setMnemonic('B');

jp4.add(btnBrowse);



btnBrowse.addActionListener(this);



add(jp1);

add(jp2);

add(jp3);

add(jp4);



}



public void actionPerformed(ActionEvent ae)

{

JFileChooser jfc=new JFileChooser();

jfc.showOpenDialog(null);

File f=jfc.getSelectedFile();

txtFileUpload.setText(f.getAbsolutePath());



if(txtFileUpload.getText().length()>0)

{



try

{



FileInputStream fin=new FileInputStream(txtFileUpload.getText());

String str="";

int i;



while((i=fin.read())!=-1)

{

str=str+(char)i;

}

fin.close();



byte b[]=new byte[str.length()];



str.getBytes(0,str.length(),b,0);



ZipOutputStream z=new ZipOutputStream(new FileOutputStream("C:/Documents and Settings/Administrator/Desktop/MyZip.zip"));

ZipEntry ze=new ZipEntry("C:/Documents and Settings/Administrator/Desktop/MyZip.zip");

z.putNextEntry(ze);

z.write(b);

z.close();



ZipInputStream zin=new ZipInputStream(new FileInputStream("C:/Documents and Settings/Administrator/Desktop/MyZip.zip"));



zin.read(b);



fileUploadIntf file=(fileUploadIntf)Naming.lookup("rmi://192.168.16.4"+"/FileServer");



JOptionPane.showMessageDialog(null,file.fileWriteInRemote(b));







}catch(Exception e)

{

JOptionPane.showMessageDialog(null,e.toString());

}



}

else

{

JOptionPane.showMessageDialog(null,"No Specefied file for Upload");

}//end of if

}

}



class TablePanel extends JPanel{



JPanel jp1,jp2,jp3;

JLabel lblDetail;

JTable table;

TableModel tabModel;

Vector DescriptionList;

JComboBox comboBox;



private String[] columnNames = {"A/c",

"Description",

"Debit",

"Credit"};

private Object[][] data =new Object[30][4];



public TablePanel() {



setLayout(new BorderLayout());



try {

UIManager.setLookAndFeel(

UIManager.getCrossPlatformLookAndFeelClassName());

} catch (Exception e){

}





/*Combo add*/





//end code





jp1=new JPanel();



lblDetail=new JLabel("Detail Block");

jp1.add(lblDetail);



jp2=new JPanel();







table = new JTable(data,columnNames);



table.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);





table.setPreferredScrollableViewportSize(new Dimension(550, 180));



//Create the scroll pane and add the table to it.

JScrollPane scrollPane = new JScrollPane(table,JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);







setUpAccountColumn(table.getColumnModel().getColumn(0));



//Add the scroll pane to this panel.

jp2.add(scrollPane);







add(jp1,BorderLayout.NORTH);

add(jp2,BorderLayout.CENTER);



}

//

public void setUpAccountColumn(TableColumn AccountColumn) {



//final JComboBox comboBox;

DescriptionList=new Vector();



//Set up the editor for the Account cells.



comboBox = new JComboBox();

comboBox.setEditable(true);





try

{





//DriverManager.registerDriver (new oracle.jdbc.OracleDriver());

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");



//Connection conn = DriverManager.getConnection ("jdbc:oracle:thin:@192.168.16.7:1521:kris","demo", "demo");

Connection conn=DriverManager.getConnection("jdbc:odbc:ora10g","demo","demo");



Statement stmt = conn.createStatement ();

ResultSet rset = stmt.executeQuery ("SELECT Acct_code,Acct_desp FROM tb_acct_mas");









// Print the name out

while (rset.next ())

{





String ac=rset.getString (1);

comboBox.addItem(ac);

DescriptionList.addElement(ac+rset.getString (2));

}









// Close the result set, statement, and the connection

rset.close();

stmt.close();

conn.close();

}catch(Exception e)

{



}







AccountColumn.setCellEditor(new DefaultCellEditor(comboBox));



//Set up tool tips for the sport cells.

DefaultTableCellRenderer renderer =

new DefaultTableCellRenderer();



renderer.setToolTipText("Click for combo box");



AccountColumn.setCellRenderer(renderer);



} //End of setUpAccountColoumn

}



class DateCalc

{

static String getSysDate(String dateFormat)

{



java.util.Date d=new java.util.Date();

SimpleDateFormat sf=new SimpleDateFormat(dateFormat);



return sf.format(d);



}



static String genVoucherNo()

{

java.util.Date d=new java.util.Date();

SimpleDateFormat sf1=new SimpleDateFormat("dd-MM/");

return sf1.format(d);



}



}









class MyTableModel extends AbstractTableModel {



private String[] columnNames = {"A/c",

"Description",

"Debit",

"Credit"};

private Object[][] data =new Object[30][4];



public final Object[] longValues = {"cacffacsdfs","sbsdushdasdasdsadad","100000","120000"};





public int getColumnCount() {

return columnNames.length;

}



public int getRowCount() {

return data.length;

}



public String getColumnName(int col) {

return columnNames[col];

}



public Object getValueAt(int row, int col) {

return data[row][col];

}



public Class getColumnClass(int c) {

return getValueAt(0, c).getClass();

}





public boolean isCellEditable(int row, int col) {





if (col < 2) {



return false;



} else {



return true;

}

}





public void setValueAt(Object value, int row, int col) {



data[row][col] = value;

fireTableCellUpdated(row, col);



}



}





/*class FileRead

{

public static Vector funRead()

{

Vector v=new Vector();

try

{

String content="";

int i;

FileInputStream fread=new FileInputStream("E:/AppletProperties.txt");



while((i=fread.read())!=-1)

{

content=content+(char)i;

}



StringTokenizer st=new StringTokenizer(content,"=;");



while(st.hasMoreTokens())

{

content=st.nextToken();

v.addElement(st.nextToken());



}





}catch(Exception e)

{

JOptionPane.showMessageDialog(null,e.toString());

}

return v;



}

}*/







class TreeDemo extends JPanel

{

JTree tree;

URL helpURL;

static boolean DEBUG = false;



//Optionally play with line styles. Possible values are

//"Angled" (the default), "Horizontal", and "None".

private static boolean playWithLineStyle = false;

private static String lineStyle = "Horizontal";



//Optionally set the look and feel.

private static boolean useSystemLookAndFeel = false;



public TreeDemo() {

//super(new GridLayout(1,0));

setBackground(Color.darkGray);



//Create the nodes.

DefaultMutableTreeNode top =

new DefaultMutableTreeNode("Menu");



DefaultMutableTreeNode voucherEntryForm =

new DefaultMutableTreeNode("VoucherEntry");



DefaultMutableTreeNode logout =

new DefaultMutableTreeNode("Logout");





top.add(voucherEntryForm);





top.add(logout);





//Create a tree that allows one selection at a time.

tree = new JTree(top);

tree.getSelectionModel().setSelectionMode

(TreeSelectionModel.SINGLE_TREE_SELECTION);



//Listen for when the selection changes.

// tree.addTreeSelectionListener(this);



if (playWithLineStyle) {

System.out.println("line style = " + lineStyle);

tree.putClientProperty("JTree.lineStyle", lineStyle);

}



//Create the scroll pane and add the tree to it.

JScrollPane treeView = new JScrollPane(tree,JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);

treeView.setPreferredSize(new Dimension(140, 580));



add(treeView);



}//End of constructor











}
Could you please let me know which portion of my code the actual flaw is in. Secondly DO I HAVE TO PUT hibernate3.jar in the .ear file.Why is JBoss Console throws hibernate.properties not found.Can you please suggest me an alternative architecture

Thanks a million 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.  [ 3 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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.