You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by john lee <sh...@yahoo.com> on 2012/12/14 20:46:23 UTC
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(Configuration.java:2018)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1935)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1914)
at Test.main(Test.java:12)
Caused by: org.xml.sax.SAXParseException: Document is invalid: no grammar found.
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:195)
alpha:/var/apache-tomcat-7.0.34/webapps/ecommerce/WEB-INF # ls -R
.:
classes compile.sh lib src web.xml
./classes:
Student.hbm.xml Test.class example hibernate.cfg.xml struts.xml
./classes/example:
Student.class
./lib:
commons-fileupload-1.2.2.jar freemarker-2.3.19.jar ognl-3.0.5.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 struts2-core-2.3.7.jar
commons-lang3-3.1.jar javassist-3.11.0.GA.jar xwork-core-2.3.7.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
./src:
example
./src/example:
Student.java Test.java
*********************************************
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"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="example.Student" table="student">
<id name="studentId" column="student_id">
<generator class="increment" />
</id>
<property name="firstName" type="string" column="first_name" />
<property name="lastName" type="string" column="last_name" />
<property name="address" type="string" column="address" />
</class>
</hibernate-mapping>
alpha:/var/apache-tomcat-7.0.34/webapps/ecommerce/WEB-INF/classes # cat hibernate.cfg.xml
<hibernate-configuration>
<session-factory>
<property name="connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="connection.url">jdbc:mysql://10.1.1.37/mytest</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"/>
</session-factory>
</hibernate-configuration>
alpha:/var/apache-tomcat-7.0.34/webapps/ecommerce/WEB-INF/src/example # cat Test.java
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();
session.beginTransaction();
Student s = new Student("firstname", "lastname", "address");
session.save(s);
session.getTransaction().commit();
}
}
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)
Re: struts2+hiberate org.hibernate.cfg.Configuration
Posted by Dave Newton <da...@gmail.com>.
Maybe a Hibernate list/group would be more appropriate.
Dave
(pardon brevity, typos, and top-quoting; on cell)
On Dec 14, 2012 2:46 PM, "john lee" <sh...@yahoo.com> wrote:
> 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(Configuration.java:2018)
> at
> org.hibernate.cfg.Configuration.configure(Configuration.java:1935)
> at
> org.hibernate.cfg.Configuration.configure(Configuration.java:1914)
> at Test.main(Test.java:12)
> Caused by: org.xml.sax.SAXParseException: Document is invalid: no grammar
> found.
> at
> com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:195)
>
>
> alpha:/var/apache-tomcat-7.0.34/webapps/ecommerce/WEB-INF # ls -R
> .:
> classes compile.sh lib src web.xml
>
> ./classes:
> Student.hbm.xml Test.class example hibernate.cfg.xml struts.xml
>
> ./classes/example:
> Student.class
>
> ./lib:
> commons-fileupload-1.2.2.jar
> freemarker-2.3.19.jar ognl-3.0.5.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 struts2-core-2.3.7.jar
> commons-lang3-3.1.jar
> javassist-3.11.0.GA.jar xwork-core-2.3.7.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
>
> ./src:
> example
>
> ./src/example:
> Student.java Test.java
>
> *********************************************
> 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"
> "
> http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
>
> <hibernate-mapping>
> <class name="example.Student" table="student">
> <id name="studentId" column="student_id">
> <generator class="increment" />
> </id>
> <property name="firstName" type="string"
> column="first_name" />
> <property name="lastName" type="string" column="last_name"
> />
> <property name="address" type="string" column="address" />
> </class>
> </hibernate-mapping>
>
>
> alpha:/var/apache-tomcat-7.0.34/webapps/ecommerce/WEB-INF/classes # cat
> hibernate.cfg.xml
> <hibernate-configuration>
>
> <session-factory>
>
> <property
> name="connection.driver_class">com.mysql.jdbc.Driver</property>
> <property name="connection.url">jdbc:mysql://
> 10.1.1.37/mytest</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"/>
>
> </session-factory>
>
> </hibernate-configuration>
>
>
> alpha:/var/apache-tomcat-7.0.34/webapps/ecommerce/WEB-INF/src/example #
> cat Test.java
>
> 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();
> session.beginTransaction();
> Student s = new Student("firstname", "lastname", "address");
> session.save(s);
> session.getTransaction().commit();
> }
> }
>
>
> 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)
RE: struts2+hiberate org.hibernate.cfg.Configuration
Posted by Martin Gainty <mg...@hotmail.com>.
way too many variables to venture an intelligent answer you might have a firewall issue in whicbh case we will need to know all intervening proxies and authentication credentials to all intervening proxiesyour Hibernate Configuration (hibernate.cfg.*) xml might be malformedthe database that you are attempting to access might be offline or missing tables or columnsinclude everything... including ALL DB create statements as well as hibernate confiigurations and of course the full url for your DB as well as username and password for the DBVscan everything..zip up everything in this webapp ..toss it on dropbox or some other public site and post the link here and we'll try to reproduce your problemMartin
> > Date: Fri, 14 Dec 2012 12:52:16 -0800
> > From: sh_thorn_bird@yahoo.com
> > Subject: Re: struts2+hiberate org.hibernate.cfg.Configuration
> > To: jeffrey.black@yahoo.com; user@struts.apache.org
> >
> > 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 <je...@yahoo.com>
> > To: Struts Users Mailing List <us...@struts.apache.org>; john lee <sh...@yahoo.com>
> > Sent: Friday, December 14, 2012 2:44 PM
> > Subject: Re: struts2+hiberate org.hibernate.cfg.Configuration
> >
> >
> > John,
> >
> > 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.
> >
> > Best,
> >
> > Jeff
> >
> >
> >
> >
> >
> > ________________________________
> > From: john lee <sh...@yahoo.com>
> > To: "user@struts.apache.org" <us...@struts.apache.org>
> > 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(Configuration.java:2018)
> > at org.hibernate.cfg.Configuration.configure(Configuration.java:1935)
> > at org.hibernate.cfg.Configuration.configure(Configuration.java:1914)
> > at Test.main(Test.java:12)
> > Caused by: org.xml.sax.SAXParseException: Document is invalid: no grammar found.
> > at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:195)
> >
> >
> > alpha:/var/apache-tomcat-7.0.34/webapps/ecommerce/WEB-INF # ls -R
> > .:
> > classes compile.sh lib src web.xml
> >
> > ./classes:
> > Student.hbm.xml Test.class example hibernate.cfg.xml struts.xml
> >
> > ./classes/example:
> > Student.class
> >
> > ./lib:
> > commons-fileupload-1.2.2.jar freemarker-2.3.19.jar ognl-3.0.5.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 struts2-core-2.3.7.jar
> > commons-lang3-3.1.jar javassist-3.11.0.GA.jar xwork-core-2.3.7.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
> >
> > ./src:
> > example
> >
> > ./src/example:
> > Student.java Test.java
> >
> > *********************************************
> > 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"
> > "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
> >
> > <hibernate-mapping>
> > <class name="example.Student" table="student">
> > <id name="studentId" column="student_id">
> > <generator class="increment" />
> > </id>
> > <property name="firstName" type="string" column="first_name" />
> > <property name="lastName" type="string" column="last_name" />
> > <property name="address" type="string" column="address" />
> > </class>
> > </hibernate-mapping>
> >
> >
> > alpha:/var/apache-tomcat-7.0.34/webapps/ecommerce/WEB-INF/classes # cat hibernate.cfg.xml
> > <hibernate-configuration>
> >
> > <session-factory>
> >
> > <property name="connection.driver_class">com.mysql.jdbc.Driver</property>
> > <property name="connection.url">jdbc:mysql://10.1.1.37/mytest</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"/>
> >
> > </session-factory>
> >
> > </hibernate-configuration>
> >
> >
> > alpha:/var/apache-tomcat-7.0.34/webapps/ecommerce/WEB-INF/src/example # cat Test.java
> >
> > 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();
> > session.beginTransaction();
> > Student s = new Student("firstname", "lastname", "address");
> > session.save(s);
> > session.getTransaction().commit();
> > }
> > }
> >
> >
> > 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)
>
RE: struts2+hiberate org.hibernate.cfg.Configuration
Posted by Martin Gainty <mg...@hotmail.com>.
way too many variables to venture an intelligent answer you might have a firewall issue in whicbh case we will need to know all intervening proxies and authentication credentials to all intervening proxies
your Hibernate Configuration (hibernate.cfg.*) xml might be malformed
the database that you are attempting to access might be offline or missing tables or columns
include everything... including ALL DB create statements as well as hibernate confiigurations and of course the full url for your DB as well as username and password
for the DB Vscan everything..zip up everything in this webapp ..toss it on dropbox or some other public site and post the link here and we'll try to reproduce your problem
Martin
______________________________________________
Verzicht und Vertraulichkeitanmerkung Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich dem Austausch von Informationen und entfaltet keine rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen.
> Date: Fri, 14 Dec 2012 12:52:16 -0800
> From: sh_thorn_bird@yahoo.com
> Subject: Re: struts2+hiberate org.hibernate.cfg.Configuration
> To: jeffrey.black@yahoo.com; user@struts.apache.org
>
> 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 <je...@yahoo.com>
> To: Struts Users Mailing List <us...@struts.apache.org>; john lee <sh...@yahoo.com>
> Sent: Friday, December 14, 2012 2:44 PM
> Subject: Re: struts2+hiberate org.hibernate.cfg.Configuration
>
>
> John,
>
> 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.
>
> Best,
>
> Jeff
>
>
>
>
>
> ________________________________
> From: john lee <sh...@yahoo.com>
> To: "user@struts.apache.org" <us...@struts.apache.org>
> 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(Configuration.java:2018)
> at org.hibernate.cfg.Configuration.configure(Configuration.java:1935)
> at org.hibernate.cfg.Configuration.configure(Configuration.java:1914)
> at Test.main(Test.java:12)
> Caused by: org.xml.sax.SAXParseException: Document is invalid: no grammar found.
> at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:195)
>
>
> alpha:/var/apache-tomcat-7.0.34/webapps/ecommerce/WEB-INF # ls -R
> .:
> classes compile.sh lib src web.xml
>
> ./classes:
> Student.hbm.xml Test.class example hibernate.cfg.xml struts.xml
>
> ./classes/example:
> Student.class
>
> ./lib:
> commons-fileupload-1.2.2.jar freemarker-2.3.19.jar ognl-3.0.5.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 struts2-core-2.3.7.jar
> commons-lang3-3.1.jar javassist-3.11.0.GA.jar xwork-core-2.3.7.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
>
> ./src:
> example
>
> ./src/example:
> Student.java Test.java
>
> *********************************************
> 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"
> "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
>
> <hibernate-mapping>
> <class name="example.Student" table="student">
> <id name="studentId" column="student_id">
> <generator class="increment" />
> </id>
> <property name="firstName" type="string" column="first_name" />
> <property name="lastName" type="string" column="last_name" />
> <property name="address" type="string" column="address" />
> </class>
> </hibernate-mapping>
>
>
> alpha:/var/apache-tomcat-7.0.34/webapps/ecommerce/WEB-INF/classes # cat hibernate.cfg.xml
> <hibernate-configuration>
>
> <session-factory>
>
> <property name="connection.driver_class">com.mysql.jdbc.Driver</property>
> <property name="connection.url">jdbc:mysql://10.1.1.37/mytest</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"/>
>
> </session-factory>
>
> </hibernate-configuration>
>
>
> alpha:/var/apache-tomcat-7.0.34/webapps/ecommerce/WEB-INF/src/example # cat Test.java
>
> 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();
> session.beginTransaction();
> Student s = new Student("firstname", "lastname", "address");
> session.save(s);
> session.getTransaction().commit();
> }
> }
>
>
> 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)
Re: struts2+hiberate org.hibernate.cfg.Configuration
Posted by john lee <sh...@yahoo.com>.
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 <je...@yahoo.com>
To: Struts Users Mailing List <us...@struts.apache.org>; john lee <sh...@yahoo.com>
Sent: Friday, December 14, 2012 2:44 PM
Subject: Re: struts2+hiberate org.hibernate.cfg.Configuration
John,
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.
Best,
Jeff
________________________________
From: john lee <sh...@yahoo.com>
To: "user@struts.apache.org" <us...@struts.apache.org>
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(Configuration.java:2018)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1935)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1914)
at Test.main(Test.java:12)
Caused by: org.xml.sax.SAXParseException: Document is invalid: no grammar found.
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:195)
alpha:/var/apache-tomcat-7.0.34/webapps/ecommerce/WEB-INF # ls -R
.:
classes compile.sh lib src web.xml
./classes:
Student.hbm.xml Test.class example hibernate.cfg.xml struts.xml
./classes/example:
Student.class
./lib:
commons-fileupload-1.2.2.jar freemarker-2.3.19.jar ognl-3.0.5.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 struts2-core-2.3.7.jar
commons-lang3-3.1.jar javassist-3.11.0.GA.jar xwork-core-2.3.7.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
./src:
example
./src/example:
Student.java Test.java
*********************************************
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"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="example.Student" table="student">
<id name="studentId" column="student_id">
<generator class="increment" />
</id>
<property name="firstName" type="string" column="first_name" />
<property name="lastName" type="string" column="last_name" />
<property name="address" type="string" column="address" />
</class>
</hibernate-mapping>
alpha:/var/apache-tomcat-7.0.34/webapps/ecommerce/WEB-INF/classes # cat hibernate.cfg.xml
<hibernate-configuration>
<session-factory>
<property name="connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="connection.url">jdbc:mysql://10.1.1.37/mytest</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"/>
</session-factory>
</hibernate-configuration>
alpha:/var/apache-tomcat-7.0.34/webapps/ecommerce/WEB-INF/src/example # cat Test.java
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();
session.beginTransaction();
Student s = new Student("firstname", "lastname", "address");
session.save(s);
session.getTransaction().commit();
}
}
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)
Re: struts2+hiberate org.hibernate.cfg.Configuration
Posted by Jeff Black <je...@yahoo.com>.
John,
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.
Best,
Jeff
________________________________
From: john lee <sh...@yahoo.com>
To: "user@struts.apache.org" <us...@struts.apache.org>
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(Configuration.java:2018)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1935)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1914)
at Test.main(Test.java:12)
Caused by: org.xml.sax.SAXParseException: Document is invalid: no grammar found.
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:195)
alpha:/var/apache-tomcat-7.0.34/webapps/ecommerce/WEB-INF # ls -R
.:
classes compile.sh lib src web.xml
./classes:
Student.hbm.xml Test.class example hibernate.cfg.xml struts.xml
./classes/example:
Student.class
./lib:
commons-fileupload-1.2.2.jar freemarker-2.3.19.jar ognl-3.0.5.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 struts2-core-2.3.7.jar
commons-lang3-3.1.jar javassist-3.11.0.GA.jar xwork-core-2.3.7.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
./src:
example
./src/example:
Student.java Test.java
*********************************************
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"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="example.Student" table="student">
<id name="studentId" column="student_id">
<generator class="increment" />
</id>
<property name="firstName" type="string" column="first_name" />
<property name="lastName" type="string" column="last_name" />
<property name="address" type="string" column="address" />
</class>
</hibernate-mapping>
alpha:/var/apache-tomcat-7.0.34/webapps/ecommerce/WEB-INF/classes # cat hibernate.cfg.xml
<hibernate-configuration>
<session-factory>
<property name="connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="connection.url">jdbc:mysql://10.1.1.37/mytest</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"/>
</session-factory>
</hibernate-configuration>
alpha:/var/apache-tomcat-7.0.34/webapps/ecommerce/WEB-INF/src/example # cat Test.java
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();
session.beginTransaction();
Student s = new Student("firstname", "lastname", "address");
session.save(s);
session.getTransaction().commit();
}
}
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)