-->
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.  [ 10 posts ] 
Author Message
 Post subject: [Newbie] trying to do the hibernate tutorial
PostPosted: Tue Feb 23, 2010 12:08 pm 
Newbie

Joined: Thu Feb 18, 2010 6:21 pm
Posts: 6
Hi.
I try to do the hibernate tutorial : http://docs.jboss.org/hibernate/stable/ ... orial.html
I have an error when trying to do the 1.1.7 step of the tutorial.

mvn exec:java -Dexec.mainClass="org.hibernate.tutorial.EventManager" -Dexec.args="store"

Quote:
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] An exception occured while executing the Java class. null

socket creation error
[INFO] ------------------------------------------------------------------------
[INFO] Trace
org.apache.maven.lifecycle.LifecycleExecutionException: An exception occured while executing the Java class. null
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:583)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeStandaloneGoal(DefaultLifecycleExecutor.java:512)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:482)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:330)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:291)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:142)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:336)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:129)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:287)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:616)
at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
Caused by: org.apache.maven.plugin.MojoExecutionException: An exception occured while executing the Java class. null
at org.codehaus.mojo.exec.ExecJavaMojo.execute(ExecJavaMojo.java:338)
at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:451)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:558)
... 16 more
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:616)
at org.codehaus.mojo.exec.ExecJavaMojo$1.run(ExecJavaMojo.java:283)
at java.lang.Thread.run(Thread.java:636)
Caused by: org.hibernate.exception.JDBCConnectionException: Cannot open connection
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:97)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:52)
at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:449)
at org.hibernate.jdbc.ConnectionManager.getConnection(ConnectionManager.java:167)
at org.hibernate.jdbc.JDBCContext.connection(JDBCContext.java:142)
at org.hibernate.transaction.JDBCTransaction.begin(JDBCTransaction.java:85)
at org.hibernate.impl.SessionImpl.beginTransaction(SessionImpl.java:1354)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:616)
at org.hibernate.context.ThreadLocalSessionContext$TransactionProtectionWrapper.invoke(ThreadLocalSessionContext.java:342)
at $Proxy0.beginTransaction(Unknown Source)
at org.hibernate.tutorial.EventManager.createAndStoreEvent(EventManager.java:23)
at org.hibernate.tutorial.EventManager.main(EventManager.java:15)
... 6 more
Caused by: java.sql.SQLException: socket creation error
at org.hsqldb.jdbc.Util.sqlException(Unknown Source)
at org.hsqldb.jdbc.jdbcConnection.<init>(Unknown Source)
at org.hsqldb.jdbcDriver.getConnection(Unknown Source)
at org.hsqldb.jdbcDriver.connect(Unknown Source)
at java.sql.DriverManager.getConnection(DriverManager.java:620)
at java.sql.DriverManager.getConnection(DriverManager.java:169)
at org.hibernate.connection.DriverManagerConnectionProvider.getConnection(DriverManagerConnectionProvider.java:133)
at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:446)
... 18 more


Top
 Profile  
 
 Post subject: Re: [Newbie] trying to do the hibernate tutorial
PostPosted: Tue Feb 23, 2010 12:23 pm 
Beginner
Beginner

Joined: Wed Nov 21, 2007 8:02 am
Posts: 48
Did you start your hsql first?

mvn exec:java -Dexec.mainClass="org.hsqldb.Server" -Dexec.args="-database.0 file:target/data/tutorial"


Top
 Profile  
 
 Post subject: Re: [Newbie] trying to do the hibernate tutorial
PostPosted: Tue Feb 23, 2010 2:41 pm 
Newbie

Joined: Thu Feb 18, 2010 6:21 pm
Posts: 6
oO
so sorry.
I had shut it down.

But if i execute the two commands on two shells i got on one shell :
mvn exec:java -Dexec.mainClass="org.hsqldb.Server" -Dexec.args="-database.0 file:target/data/tutorial"
Quote:
[INFO] Scanning for projects...
[INFO] Searching repository for plugin with prefix: 'exec'.
[INFO] ------------------------------------------------------------------------
[INFO] Building First Hibernate Tutorial
[INFO] task-segment: [exec:java]
[INFO] ------------------------------------------------------------------------
[INFO] Preparing exec:java
[INFO] No goals needed for project - skipping
[INFO] [exec:java]
[Server@1f758500]: [Thread[org.hsqldb.Server.main(),5,org.hsqldb.Server]]: checkRunning(false) entered
[Server@1f758500]: [Thread[org.hsqldb.Server.main(),5,org.hsqldb.Server]]: checkRunning(false) exited
[Server@1f758500]: Startup sequence initiated from main() method
[Server@1f758500]: Loaded properties from [/media/stockage/workspace_maven_hibernate/hibernate-tuto/server.properties]
[Server@1f758500]: Initiating startup sequence...
[Server@1f758500]: Server socket opened successfully in 5 ms.
[Server@1f758500]: Database [index=0, id=0, db=file:target/data/tutorial, alias=] opened sucessfully in 234 ms.
[Server@1f758500]: Startup sequence completed in 239 ms.
[Server@1f758500]: 2010-02-23 19:36:11.150 HSQLDB server 1.8.0 is online
[Server@1f758500]: To close normally, connect and execute SHUTDOWN SQL
[Server@1f758500]: From command line, use [Ctrl]+[C] to abort abruptly


And an error on the other one :

Quote:
An exception occured while executing the Java class. org.hibernate.tutorial.EventManager

[INFO] ------------------------------------------------------------------------
[INFO] Trace
org.apache.maven.lifecycle.LifecycleExecutionException: An exception occured while executing the Java class. org.hibernate.tutorial.EventManager
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:583)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeStandaloneGoal(DefaultLifecycleExecutor.java:512)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:482)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:330)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:291)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:142)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:336)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:129)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:287)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:616)
at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
Caused by: org.apache.maven.plugin.MojoExecutionException: An exception occured while executing the Java class. org.hibernate.tutorial.EventManager
at org.codehaus.mojo.exec.ExecJavaMojo.execute(ExecJavaMojo.java:338)
at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:451)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:558)
... 16 more
Caused by: java.lang.ClassNotFoundException: org.hibernate.tutorial.EventManager
at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
at java.lang.ClassLoader.loadClass(ClassLoader.java:319)
at java.lang.ClassLoader.loadClass(ClassLoader.java:264)
at org.codehaus.mojo.exec.ExecJavaMojo$1.run(ExecJavaMojo.java:276)
at java.lang.Thread.run(Thread.java:636)


Top
 Profile  
 
 Post subject: Re: [Newbie] trying to do the hibernate tutorial
PostPosted: Tue Feb 23, 2010 4:29 pm 
Newbie

Joined: Thu Feb 18, 2010 6:21 pm
Posts: 6
I had to launch mvn compile

And a new error.
Now my problem is that hibernate.cfg.xml is not found.

Where should i put this file?
l have tried the root of the project and the same folder than EventManager.


Top
 Profile  
 
 Post subject: Re: [Newbie] trying to do the hibernate tutorial
PostPosted: Tue Feb 23, 2010 4:34 pm 
Beginner
Beginner

Joined: Wed Nov 21, 2007 8:02 am
Posts: 48
If you put under src/main/resources, maven will copy it to class path


Top
 Profile  
 
 Post subject: Re: [Newbie] trying to do the hibernate tutorial
PostPosted: Tue Feb 23, 2010 6:25 pm 
Newbie

Joined: Thu Feb 18, 2010 6:21 pm
Posts: 6
Thanks.
I have already corrected this error.
But now it's resource: org/hibernate/tutorial/domain/Event.hbm.xml that is not found.

Event.hbm.xml is in src/main/java/org/hibernate/tutorial/domain with Event.java.

But it's not duplicated with Event.class after a "mvn install" command.


Top
 Profile  
 
 Post subject: Re: [Newbie] trying to do the hibernate tutorial
PostPosted: Thu Mar 25, 2010 11:36 am 
Newbie

Joined: Thu Mar 25, 2010 10:51 am
Posts: 1
Natoine (or anybody else!):
I have encountered what appears to be the same error as you - I get a resource not found error concerning org/hibernate/tutorial/domain/Event.hbm.xml when running the Maven exec command to invoke the EventManager class file. That's after I run the "mvn compile" command in the root folder (where my pom.xml and src and target folders are). The compile step is successful - it puts the hibernate.cfg.xml and log4j.properties files in the target\classes folder and the EventManager.class, Event.class, and HibernateUtil.class files in their appropriate folders.

Before running the Maven exec command for EventManager, I did run the Maven exec command for org.hsqldb.Server in a separate command window, and it appeared to have no errors or warnings.

The compile does give a "warning", as follows: "[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!" I don't know if that is important. My platform is Windows XP pro, 32 bit.

The compile doesn't copy the Event.hbm.xml anywhere in the target folder, however. I'm thinking this is a problem. I copied that file manually to the target folder, and then ran the Maven exec again for EventManager, and it appeared to work.

So I guess my open question is why didn't Maven copy the Event.hbm.xml file to the target folder?

(Obviously I'm a Maven and Hibernate newbie, so please forgive my absolute ignorance! I did see that it's possible to generate java code from the *.hbm.xml file, but that doesn't appear to be part of the Tutorial, at least not yet - I'm still working my way through the first page of it!)


Top
 Profile  
 
 Post subject: Re: [Newbie] trying to do the hibernate tutorial
PostPosted: Mon Apr 26, 2010 9:56 am 
Newbie

Joined: Sat Apr 24, 2010 7:53 pm
Posts: 1
Hi all,
I did not succed in starting HSQLDB server using maven command line:
Code:
mvn exec:java -Dexec.mainClass="org.hsqldb.Server" -Dexec.args="-database.0 file:target/data/
I am receiving this error message from the command line:
    C:\Users\blutch009>mvn exec:java -Dexec.MainClass="org.hsqldb.Server" -Dexec.arg
    s="-database.0 file:target/data/tutorial"
    [INFO] Scanning for projects...
    [INFO] Searching repository for plugin with prefix: 'exec'.
    [INFO] ------------------------------------------------------------------------
    [INFO] Building Maven Default Project
    [INFO] task-segment: [exec:java]
    [INFO] ------------------------------------------------------------------------
    [INFO] Preparing exec:java
    [INFO] No goals needed for project - skipping
    [INFO] ------------------------------------------------------------------------
    [ERROR] BUILD ERROR
    [INFO] ------------------------------------------------------------------------
    [INFO] Cannot execute mojo: java. It requires a project with an existing pom.xml
    , but the build is not using one.
    [INFO] ------------------------------------------------------------------------
    [INFO] For more information, run Maven with the -e switch
    [INFO] ------------------------------------------------------------------------
    [INFO] Total time: < 1 second
    [INFO] Finished at: Mon Apr 26 09:50:18 EDT 2010
    [INFO] Final Memory: 2M/15M
    [INFO] ------------------------------------------------------------------------
I use Windows Vista, JDK 6, mvn 2.2.1. I am surprised when they say that mojo:java requires a project with an existing pom.xml. Do I have to create a pomm.xml file to have the server started using maven exec plugin? Could you help me?


Top
 Profile  
 
 Post subject: Re: [Newbie] trying to do the hibernate tutorial
PostPosted: Wed Apr 28, 2010 1:03 pm 
Newbie

Joined: Tue Feb 26, 2008 12:41 pm
Posts: 1
Location: Toronto
I was able to solve the resource not found error by creating a packaged named org.hibernate.tutorial.domain in the source folder src/main/resources. Maven will copy the resources to the correct location in the target directory. It won't copy any non java files into the target WEB-INF/classes folder from src/main/java.

My directory layout is now:

/project
pom.xml
...other files
/src/main/java
...../org/hibernate/tutorial/domain
..........Event.java
..........Person.java
/src/main/resources
.....hibernate.cfg.xml
...../org/hibernate/tutorial/domain
..........Event.hbm.xml
..........Person.hbm.xml


Top
 Profile  
 
 Post subject: Re: [Newbie] trying to do the hibernate tutorial
PostPosted: Tue May 11, 2010 11:23 pm 
Newbie

Joined: Tue May 11, 2010 6:25 pm
Posts: 3
I followed this tutorial and ran in to this issue and many others. I was able to clear these road-blocks and complete the tutorial. I you want any further details on how i fixed various issues, please see my blog post. http://kaizenprogrammer.blogspot.com/20 ... orial.html


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 10 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.