Hi,
I'm new to hibernate and need som advice.
I'm using NetBean 6.8, running hibernate against Oracle. I'm able to connect to Oracle instance from NB (i.e I can 'browse the tables'). FYI the Oracle instance reside on a virtual server with a different host id.
Hibernate has been configured according to the instructions in the NB hibernate tutorial and the provided sample exercise worked. However trying a similar example myself, fails.
I've tried the following class:
public class CreateTest {
public static void main(String args[]) throws Exception { // Create a configuration based on the XML file we've put // in the standard place. System.out.println("h0"); Configuration config = new Configuration(); System.out.println("h1"); config.configure(); System.out.println("h2"); // Get the session factory we can use for persistence SessionFactory sessionFactory = config.buildSessionFactory(); System.out.println("h3"); // Ask for a session using the JDBC information we've configured Session session = sessionFactory.openSession(); Transaction tx = null; try { // Create some data and persist it long id = 111;
tx = session.beginTransaction(); Items items = new Items(id,"12345","item_name","A","In Work","NEW","23456","doc name","A","NEW","2010-01-02");
System.out.println("Howdy ...");
session.save(items); // We're done; make our changes permanent tx.commit(); } catch (Exception e) { if (tx != null) { // Something went wrong; discard all partial changes tx.rollback(); } throw new Exception("Transaction failed", e); } finally { // No matter what, close the session session.close(); } // Clean up after ourselves sessionFactory.close(); }
Running this class results in the following error:
h0 Jan 4, 2010 9:53:02 AM org.hibernate.cfg.Environment <clinit> INFO: Hibernate 3.2.5 Jan 4, 2010 9:53:02 AM org.hibernate.cfg.Environment <clinit> INFO: hibernate.properties not found Jan 4, 2010 9:53:02 AM org.hibernate.cfg.Environment buildBytecodeProvider INFO: Bytecode provider name : cglib Jan 4, 2010 9:53:02 AM org.hibernate.cfg.Environment <clinit> INFO: using JDK 1.4 java.sql.Timestamp handling h1 Jan 4, 2010 9:53:03 AM org.hibernate.cfg.Configuration configure INFO: configuring from resource: /hibernate.cfg.xml Jan 4, 2010 9:53:03 AM org.hibernate.cfg.Configuration getConfigurationInputStream INFO: Configuration resource: /hibernate.cfg.xml Jan 4, 2010 9:53:03 AM org.hibernate.cfg.Configuration addResource INFO: Reading mappings from resource : ext/ecc/erp/data/Structure.hbm.xml Jan 4, 2010 9:53:03 AM org.hibernate.cfg.HbmBinder bindRootPersistentClassCommonValues INFO: Mapping class: ext.ecc.erp.data.Structure -> STRUCTURE Jan 4, 2010 9:53:03 AM org.hibernate.cfg.Configuration addResource INFO: Reading mappings from resource : ext/ecc/erp/data/items.hbm.xml h2 Jan 4, 2010 9:53:03 AM org.hibernate.cfg.HbmBinder bindRootPersistentClassCommonValues INFO: Mapping class: ext.ecc.erp.data.Items -> ITEMS Jan 4, 2010 9:53:03 AM org.hibernate.cfg.Configuration doConfigure INFO: Configured SessionFactory: null Jan 4, 2010 9:53:03 AM org.hibernate.connection.DriverManagerConnectionProvider configure INFO: Using Hibernate built-in connection pool (not for production use!) Jan 4, 2010 9:53:03 AM org.hibernate.connection.DriverManagerConnectionProvider configure INFO: Hibernate connection pool size: 20 Jan 4, 2010 9:53:03 AM org.hibernate.connection.DriverManagerConnectionProvider configure INFO: autocommit mode: false Exception in thread "main" java.lang.SecurityException: Invalid signature file digest for Manifest main attributes at sun.security.util.SignatureFileVerifier.processImpl(SignatureFileVerifier.java:221) at sun.security.util.SignatureFileVerifier.process(SignatureFileVerifier.java:176) at java.util.jar.JarVerifier.processEntry(JarVerifier.java:277) at java.util.jar.JarVerifier.update(JarVerifier.java:188) at java.util.jar.JarFile.initializeVerifier(JarFile.java:321) at java.util.jar.JarFile.getInputStream(JarFile.java:386) at sun.misc.URLClassPath$JarLoader$2.getInputStream(URLClassPath.java:689) at sun.misc.Resource.cachedInputStream(Resource.java:61) at sun.misc.Resource.getByteBuffer(Resource.java:144) at java.net.URLClassLoader.defineClass(URLClassLoader.java:249) at java.net.URLClassLoader.access$000(URLClassLoader.java:56) at java.net.URLClassLoader$1.run(URLClassLoader.java:195) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:188) at java.lang.ClassLoader.loadClass(ClassLoader.java:315) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:330) at java.lang.ClassLoader.loadClass(ClassLoader.java:250) at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:398) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:169) at org.hibernate.connection.DriverManagerConnectionProvider.configure(DriverManagerConnectionProvider.java:57) at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:124) at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:56) at org.hibernate.cfg.SettingsFactory.createConnectionProvider(SettingsFactory.java:414) at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:62) at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2009) at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1292) at ext.ecc.erp.CreateTest.main(CreateTest.java:31) Java Result: 1
So, as you can see, the code never gets pass 'SessionFactory sessionFactory = config.buildSessionFactory();'
Here is the hibernate config file:
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"> <hibernate-configuration> <session-factory> <property name="hibernate.dialect">org.hibernate.dialect.OracleDialect</property> <property name="hibernate.connection.driver_class">oracle.jdbc.OracleDriver</property> <property name="hibernate.connection.url">jdbc:oracle:thin:@vmserver.ecc.com:1521:wind</property> <property name="hibernate.connection.username">erp</property> <property name="hibernate.connection.password">erp</property> <property name="hibernate.show_sql">true</property> <property name="hibernate.current_session_context_class">thread</property> <mapping resource="ext/ecc/erp/data/Structure.hbm.xml"/> <mapping resource="ext/ecc/erp/data/items.hbm.xml"/> </session-factory> </hibernate-configuration>
Any ideas why this happens?
Cheers ...
|