-->
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.  [ 2 posts ] 
Author Message
 Post subject: newbie question - ant - Failed to copy test.lck
PostPosted: Sat Dec 16, 2006 10:31 pm 
Beginner
Beginner

Joined: Sat Dec 16, 2006 9:53 pm
Posts: 31
Location: Brisbane, Australia
Please help a dumb newbie with a test.lck problem.

Hibernate version: 3.? - how do I find out?

I'm doing the tutorial in chapter 1 of the hibernate manual...

In section 1.2.6. Loading and storing objects we build and run with the command:
Code:
ant run -Daction=store

But I get the error:
Code:
BUILD FAILED
C:\Java\src\Tutorials\Hibernate\build.xml:25: Failed to copy C:\Java\src\Tutorials\Hibernate\src\test.lck to C:\Java\src\Tutorials\H
ibernate\bin\test.lck due to The process cannot access the file because another process has locked a portion of the file


I'm running the hsqldb server in a second cmd session with the command
Code:
java -classpath ../lib/hsqldb.jar org.hsqldb.Server
and it's holding the lock... so I stop the database server and it compiles (and copies) allright, but of course it won't run... I interpret the below stacktrace to mean "can't connect to the database server".

So... I need the database server running, but I can't have the database server running... and I'm Hiber-stumped allready. Please does anyone have any ideas?

Thanx heaps. Keith.

Code:
C:\Java\src\Tutorials\Hibernate>ant run -Daction=store
Buildfile: build.xml

clean:
   [delete] Deleting directory C:\Java\src\Tutorials\Hibernate\bin
    [mkdir] Created dir: C:\Java\src\Tutorials\Hibernate\bin

copy-resources:
     [copy] Copying 7 files to C:\Java\src\Tutorials\Hibernate\bin
     [copy] Copied 2 empty directories to 1 empty directory under C:\Java\src\Tutorials\Hibernate\bin

compile:
    [javac] Compiling 3 source files to C:\Java\src\Tutorials\Hibernate\bin

run:
     [java] 12:12:08,329  INFO Environment:479 - Hibernate 3.1.3
     [java] 12:12:08,329  INFO Environment:509 - hibernate.properties not found
     [java] 12:12:08,329  INFO Environment:525 - using CGLIB reflection optimizer
     [java] 12:12:08,345  INFO Environment:555 - using JDK 1.4 java.sql.Timestamp handling
     [java] 12:12:08,407  INFO Configuration:1308 - configuring from resource: /hibernate.cfg.xml
     [java] 12:12:08,407  INFO Configuration:1285 - Configuration resource: /hibernate.cfg.xml
     [java] 12:12:08,517  INFO Configuration:469 - Reading mappings from resource: events/Event.hbm.xml
     [java] 12:12:08,626  INFO HbmBinder:309 - Mapping class: events.Event -> EVENTS
     [java] 12:12:08,657  INFO Configuration:1419 - Configured SessionFactory: null
     [java] 12:12:08,720  INFO DriverManagerConnectionProvider:41 - Using Hibernate built-in connection pool (not for production use
!)
     [java] 12:12:08,720  INFO DriverManagerConnectionProvider:42 - Hibernate connection pool size: 1
     [java] 12:12:08,720  INFO DriverManagerConnectionProvider:45 - autocommit mode: false
     [java] 12:12:08,736  INFO DriverManagerConnectionProvider:80 - using driver: org.hsqldb.jdbcDriver at URL: jdbc:hsqldb:hsql://l
ocalhost
     [java] 12:12:08,736  INFO DriverManagerConnectionProvider:86 - connection properties: {user=sa, password=****}
     [java] 12:12:09,689  WARN SettingsFactory:103 - Could not obtain connection metadata
     [java] java.sql.SQLException: socket creation error
     [java]     at org.hsqldb.jdbc.Util.sqlException(Unknown Source)
     [java]     at org.hsqldb.jdbc.jdbcConnection.<init>(Unknown Source)
     [java]     at org.hsqldb.jdbcDriver.getConnection(Unknown Source)
     [java]     at org.hsqldb.jdbcDriver.connect(Unknown Source)
     [java]     at java.sql.DriverManager.getConnection(DriverManager.java:525)
     [java]     at java.sql.DriverManager.getConnection(DriverManager.java:140)
     [java]     at org.hibernate.connection.DriverManagerConnectionProvider.getConnection(DriverManagerConnectionProvider.java:110)
     [java]     at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:72)
     [java]     at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:1881)
     [java]     at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1174)
     [java]     at util.HibernateUtil.<clinit>(Unknown Source)
     [java]     at events.EventManager.newEvent(Unknown Source)
     [java]     at events.EventManager.main(Unknown Source)
     [java] 12:12:09,720  INFO Dialect:103 - Using dialect: org.hibernate.dialect.HSQLDialect
     [java] 12:12:09,736  INFO TransactionFactoryFactory:31 - Using default transaction strategy (direct JDBC transactions)
     [java] 12:12:09,736  INFO TransactionManagerLookupFactory:33 - No TransactionManagerLookup configured (in JTA environment, use
of read-write or transactional second-level cache is not recommended)
     [java] 12:12:09,736  INFO SettingsFactory:125 - Automatic flush during beforeCompletion(): disabled
     [java] 12:12:09,736  INFO SettingsFactory:129 - Automatic session close at end of transaction: disabled
     [java] 12:12:09,736  INFO SettingsFactory:144 - Scrollable result sets: disabled
     [java] 12:12:09,736  INFO SettingsFactory:152 - JDBC3 getGeneratedKeys(): disabled
     [java] 12:12:09,736  INFO SettingsFactory:160 - Connection release mode: auto
     [java] 12:12:09,736  INFO SettingsFactory:187 - Default batch fetch size: 1
     [java] 12:12:09,736  INFO SettingsFactory:191 - Generate SQL with comments: disabled
     [java] 12:12:09,736  INFO SettingsFactory:195 - Order SQL updates by primary key: disabled
     [java] 12:12:09,736  INFO SettingsFactory:338 - Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
     [java] 12:12:09,736  INFO ASTQueryTranslatorFactory:24 - Using ASTQueryTranslatorFactory
     [java] 12:12:09,736  INFO SettingsFactory:203 - Query language substitutions: {}
     [java] 12:12:09,736  INFO SettingsFactory:209 - Second-level cache: enabled
     [java] 12:12:09,751  INFO SettingsFactory:213 - Query cache: disabled
     [java] 12:12:09,751  INFO SettingsFactory:325 - Cache provider: org.hibernate.cache.NoCacheProvider
     [java] 12:12:09,751  INFO SettingsFactory:228 - Optimize cache for minimal puts: disabled
     [java] 12:12:09,751  INFO SettingsFactory:237 - Structured second-level cache entries: disabled
     [java] 12:12:09,751  INFO SettingsFactory:257 - Echoing all SQL to stdout
     [java] 12:12:09,751  INFO SettingsFactory:264 - Statistics: disabled
     [java] 12:12:09,751  INFO SettingsFactory:268 - Deleted entity synthetic identifier rollback: disabled
     [java] 12:12:09,751  INFO SettingsFactory:283 - Default entity-mode: pojo
     [java] 12:12:09,782  INFO SessionFactoryImpl:154 - building session factory
     [java] 12:12:10,095  INFO SessionFactoryObjectFactory:82 - Not binding factory to JNDI, no JNDI name configured
     [java] 12:12:10,095  INFO SchemaExport:152 - Running hbm2ddl schema export
     [java] 12:12:10,095 DEBUG SchemaExport:168 - import file not found: /import.sql
     [java] 12:12:10,111  INFO SchemaExport:177 - exporting generated schema to database
     [java] 12:12:11,173 ERROR SchemaExport:200 - schema export unsuccessful
     [java] java.sql.SQLException: socket creation error
     [java]     at org.hsqldb.jdbc.Util.sqlException(Unknown Source)
     [java]     at org.hsqldb.jdbc.jdbcConnection.<init>(Unknown Source)
     [java]     at org.hsqldb.jdbcDriver.getConnection(Unknown Source)
     [java]     at org.hsqldb.jdbcDriver.connect(Unknown Source)
     [java]     at java.sql.DriverManager.getConnection(DriverManager.java:525)
     [java]     at java.sql.DriverManager.getConnection(DriverManager.java:140)
     [java]     at org.hibernate.connection.DriverManagerConnectionProvider.getConnection(DriverManagerConnectionProvider.java:110)
     [java]     at org.hibernate.tool.hbm2ddl.SuppliedConnectionProviderConnectionHelper.prepare(SuppliedConnectionProviderConnectio
nHelper.java:27)
     [java]     at org.hibernate.tool.hbm2ddl.SchemaExport.execute(SchemaExport.java:178)
     [java]     at org.hibernate.tool.hbm2ddl.SchemaExport.create(SchemaExport.java:131)
     [java]     at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:295)
     [java]     at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1176)
     [java]     at util.HibernateUtil.<clinit>(Unknown Source)
     [java]     at events.EventManager.newEvent(Unknown Source)
     [java]     at events.EventManager.main(Unknown Source)
     [java] 12:12:12,392  WARN JDBCExceptionReporter:71 - SQL Error: -80, SQLState: 08000
     [java] 12:12:12,392 ERROR JDBCExceptionReporter:72 - socket creation error
     [java] Exception in thread "main" org.hibernate.exception.JDBCConnectionException: Cannot open connection
     [java]     at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:74)
     [java]     at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
     [java]     at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:29)
     [java]     at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:420)
     [java]     at org.hibernate.jdbc.ConnectionManager.getConnection(ConnectionManager.java:144)
     [java]     at org.hibernate.jdbc.JDBCContext.connection(JDBCContext.java:129)
     [java]     at org.hibernate.transaction.JDBCTransaction.begin(JDBCTransaction.java:57)
     [java]     at org.hibernate.impl.SessionImpl.beginTransaction(SessionImpl.java:1290)
     [java]     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
     [java]     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
     [java]     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
     [java]     at java.lang.reflect.Method.invoke(Method.java:585)
     [java]     at org.hibernate.context.ThreadLocalSessionContext$TransactionProtectionWrapper.invoke(ThreadLocalSessionContext.jav
a:301)
     [java]     at $Proxy0.beginTransaction(Unknown Source)
     [java]     at events.EventManager.newEvent(Unknown Source)
     [java]     at events.EventManager.main(Unknown Source)
     [java] Caused by: java.sql.SQLException: socket creation error
     [java]     at org.hsqldb.jdbc.Util.sqlException(Unknown Source)
     [java]     at org.hsqldb.jdbc.jdbcConnection.<init>(Unknown Source)
     [java]     at org.hsqldb.jdbcDriver.getConnection(Unknown Source)
     [java]     at org.hsqldb.jdbcDriver.connect(Unknown Source)
     [java]     at java.sql.DriverManager.getConnection(DriverManager.java:525)
     [java]     at java.sql.DriverManager.getConnection(DriverManager.java:140)
     [java]     at org.hibernate.connection.DriverManagerConnectionProvider.getConnection(DriverManagerConnectionProvider.java:110)
     [java]     at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:417)
     [java]     ... 12 more
     [java] Java Result: 1

BUILD SUCCESSFUL
Total time: 6 seconds


Top
 Profile  
 
 Post subject: got it - we need a "start-db" ant task.
PostPosted: Sat Dec 16, 2006 11:12 pm 
Beginner
Beginner

Joined: Sat Dec 16, 2006 9:53 pm
Posts: 31
Location: Brisbane, Australia
I just added the below "start-db" task to my build.xml, and made the "run" task depandant on it (instead of "compile") and it works.
Code:
<target name="start-db" depends="compile">
    <java fork="true" spawn="true" classname="org.hsqldb.Server" classpathref="libraries">
      <classpath path="${targetdir}"/>
    </java>
  </target>

Thanx guys.


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