struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From john lee <>
Subject Re: struts2+hiberate org.hibernate.cfg.Configuration
Date Fri, 14 Dec 2012 20:52:16 GMT
tks for reply.
it is at local, no proxy, no firwall
also, i just change to SYSTEM for give an try, but also receive same error message.

From: Jeff Black <>
To: Struts Users Mailing List <>; john lee <>

Sent: Friday, December 14, 2012 2:44 PM
Subject: Re: struts2+hiberate org.hibernate.cfg.Configuration 


Are you behind a proxy?

Double-check that you can access the DTD from your system.

You might consider changing your DOCTYPE to reference the DTD contained in your Hibernate.jar
(i.e. from PUBLIC to SYSTEM) so it won't try to look things up remotely.



From: john lee <>
To: "" <> 
Sent: Friday, December 14, 2012 1:46 PM
Subject: struts2+hiberate org.hibernate.cfg.Configuration 

i am new to struts2+hiberate,  i can successfuly make struts2 sample project working, but
not hiberate, i just make an simple test program, and compile is good, but when execute, the
error is at following, the project tree is also include
please help, thanks in advance
alpha:/var/apache-tomcat-7.0.34/webapps/ecommerce/WEB-INF/classes # java Test
Dec 14, 2012 2:56:28 PM org.hibernate.cfg.Configuration getConfigurationInputStream
INFO: HHH000040: Configuration resource: /hibernate.cfg.xml
Exception in thread "main" org.hibernate.MappingException: invalid configuration
        at org.hibernate.cfg.Configuration.doConfigure(
        at org.hibernate.cfg.Configuration.configure(
        at org.hibernate.cfg.Configuration.configure(
        at Test.main(
Caused by: org.xml.sax.SAXParseException: Document is invalid: no grammar found.
alpha:/var/apache-tomcat-7.0.34/webapps/ecommerce/WEB-INF # ls -R
classes  lib  src  web.xml  
Student.hbm.xml  Test.class  example  hibernate.cfg.xml    struts.xml
commons-fileupload-1.2.2.jar  freemarker-2.3.19.jar                          
commons-io-2.0.1.jar          hibernate-commons-annotations-4.0.1.Final.jar   spring-test-3.0.5.RELEASE.jar
commons-lang-2.4.jar          hibernate-core-4.1.8.Final.jar                 
commons-lang3-3.1.jar         javassist-3.11.0.GA.jar                        
commons-logging-1.1.1.jar     jboss-logging-3.1.0.GA.jar
dom4j-1.6.1.jar               jboss-transaction-api_1.1_spec-1.0.0.Final.jar
alpha:/var/apache-tomcat-7.0.34/webapps/ecommerce/WEB-INF/classes # cat Student.hbm.xml
<?xml version="1.0"?>
            <!DOCTYPE hibernate-mapping PUBLIC
                "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
        <class name="example.Student" table="student">
                <id name="studentId" column="student_id">
                        <generator class="increment" />
                <property name="firstName" type="string" column="first_name"
                <property name="lastName" type="string" column="last_name"
                <property name="address" type="string" column="address"
alpha:/var/apache-tomcat-7.0.34/webapps/ecommerce/WEB-INF/classes # cat hibernate.cfg.xml
                <property name="connection.driver_class">com.mysql.jdbc.Driver</property>
                <property name="connection.url">jdbc:mysql://</property>
                <property name="connection.username">test</property>
                <property name="connection.password">password</property>
                <property name="dialect">org.hibernate.dialect.MySQLInnoDBDialect</property>
                <property name="show_sql">true</property>
                <mapping resource="Student.hbm.xml"/>
alpha:/var/apache-tomcat-7.0.34/webapps/ecommerce/WEB-INF/src/example # cat
import org.hibernate.Session;
import example.Student;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
public class Test {
        public static void main(String[] args) {
                //Session session = HibernateUtil.getSessionFactory().getCurrentSession();
        Configuration conf=new Configuration().configure();
        SessionFactory sf=conf.buildSessionFactory();
        Session session=sf.openSession();
        Student s = new Student("firstname", "lastname", "address");;
mysql> desc student;
| Field      | Type                | Null | Key | Default | Extra         
| student_id | bigint(10) unsigned | NO   | PRI | NULL    | auto_increment | 
| first_name | varchar(50)         | YES  |     | NULL    |               
| last_name  | varchar(50)         | YES  |     | NULL    |               
| address    | varchar(50)         | YES  |     | NULL    |               
4 rows in set (0.00 sec)
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message