Hi Bill, Another way to skip the initialize-db step is to run ant like this
ant -Dinitialize-db-skip=true [target] ie to do nothing run ant -Dinitialize-db-skip=true initialize-db I've attached an updated build.xml too in case you'd prefer that. Hope this helps, -Mike On 9/19/07, Bill Slack <[EMAIL PROTECTED]> wrote: > > I am having the same problems that you initially were experiencing running > the sample 'reversemapping'; however, your remedy isn't working for me. > I am not altogether familiar with Ant, so would it be too much trouble to > ask you to send me a copy of the build file so I can see exactly what you > changed? > Thanks, > Bill > > ----- Original Message ----- > From: "Huynh Van Chung" < [EMAIL PROTECTED]> > To: <[email protected]> > Sent: Thursday, September 13, 2007 6:18 PM > Subject: Re: Error when run > apache-openjpa-1.0.0\examples\reversemapping\build.xml > > > > Hi all, > > > > I have solved this problem. It is error when using derby database. > > I see in this site: > > http://db.apache.org/derby/papers/DerbyTut/embedded_intro.html > > "However, only one JVM may boot ("open") that database, so multiple > > applications running in /different/ JVMs cannot access the same > database." > > > > So in reversemapping\build.xml task, reverse-map-schema task depend on > > initialize-db, and so we will fail to run reverse-map-shema when open > > derby database. > > I make the reverse-map-schema task not depend on initialize-db, and then > > run initialize-db, run reverse-map-schema, it work ok. > > > > Huynh Van Chung > > > > chung huynh さんは書きました: > >> I download apache-openjpa-1.0.0 binary, then import examples to Eclipse > >> follow this site: > >> http://openjpa.apache.org/quick-start.html > >> > >> And i see error when run > >> apache-openjpa-1.0.0\examples\reversemapping\build.xml > >> Please help me. > >> > >> Huynh Van Chung > >> > >> Buildfile: C:\dev\apache- > openjpa-1.0.0\examples\reversemapping\build.xml > >> initialize-db: > >> [sql] Executing file: C:\dev\apache- > >> openjpa-1.0.0\examples\reversemapping\schema\dropdb.sql > >> [sql] 7 of 7 SQL statements executed successfully > >> [sql] Executing file: > >> C:\dev\apache- > openjpa-1.0.0\examples\reversemapping\schema\ToursDB_schema.sql > >> [sql] Executing file: > >> C:\dev\apache- > openjpa-1.0.0\examples\reversemapping\schema\loadCOUNTRIES.sql > >> [sql] Executing file: > >> C:\dev\apache- > openjpa-1.0.0\examples\reversemapping\schema\loadCITIES.sql > >> [sql] Executing file: C:\dev\apache- > >> openjpa-1.0.0\examples\reversemapping\schema\loadAIRLINES.sql > >> [sql] Executing file: > >> C:\dev\apache- > openjpa-1.0.0\examples\reversemapping\schema\loadFLIGHTS1.sql > >> [sql] Executing file: > >> C:\dev\apache- > openjpa-1.0.0\examples\reversemapping\schema\loadFLIGHTS2.sql > >> [sql] Executing file: > >> C:\dev\apache- > openjpa-1.0.0\examples\reversemapping\schema\loadFLIGHTAVAILABILITY1.sql > >> [sql] Executing file: > >> C:\dev\apache- > openjpa-1.0.0\examples\reversemapping\schema\loadFLIGHTAVAILABILITY2.sql > >> [sql] 1282 of 1282 SQL statements executed successfully > >> reverse-map-schema: > >> [reversemappingtool] 391 none INFO [main] openjpa.Tool - The reverse > >> mapping tool will run on the database. The tool is gathering schema > >> information; this process may take some time. Enable the > >> org.apache.openjpa.jdbc.Schema logging category to see messages about > >> schema data. > >> [reversemappingtool] 1063 none INFO [main] openjpa.jdbc.JDBC - Using > >> dictionary class " org.apache.openjpa.jdbc.sql.DerbyDictionary ". > >> [reversemappingtool] java.sql.SQLException: Failed to start database > >> 'C:\dev\apache- > openjpa-1.0.0\examples\reversemapping/reversemapping-database ', > >> see the next exception for details. > >> [reversemappingtool] at > >> org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(Unknown > >> Source) > >> [reversemappingtool] at > >> org.apache.derby.impl.jdbc.Util.newEmbedSQLException(Unknown Source) > >> [reversemappingtool] at > >> org.apache.derby.impl.jdbc.Util.newEmbedSQLException (Unknown Source) > >> [reversemappingtool] at > >> org.apache.derby.impl.jdbc.Util.generateCsSQLException(Unknown Source) > >> [reversemappingtool] at > >> org.apache.derby.impl.jdbc.EmbedConnection.newSQLException(Unknown > >> Source) > >> [reversemappingtool] at > >> org.apache.derby.impl.jdbc.EmbedConnection.bootDatabase(Unknown Source) > >> [reversemappingtool] at > >> org.apache.derby.impl.jdbc.EmbedConnection.<init>(Unknown Source) > >> [reversemappingtool] at org.apache.derby.impl.jdbc.EmbedConnection30 > >> .<init>(Unknown Source) > >> [reversemappingtool] at > >> org.apache.derby.jdbc.Driver30.getNewEmbedConnection (Unknown Source) > >> [reversemappingtool] at > >> org.apache.derby.jdbc.InternalDriver.connect(Unknown Source) > >> [reversemappingtool] at > >> org.apache.derby.jdbc.AutoloadedDriver.connect(Unknown Source) > >> [reversemappingtool] at > >> org.apache.openjpa.jdbc.schema.SimpleDriverDataSource.getConnection( > SimpleDriverDataSource.java:73) > >> [reversemappingtool] at > >> org.apache.openjpa.jdbc.schema.SimpleDriverDataSource.getConnection > >> (SimpleDriverDataSource.java:52) > >> [reversemappingtool] at > >> org.apache.openjpa.lib.jdbc.DelegatingDataSource.getConnection( > DelegatingDataSource.java:106) > >> [reversemappingtool] at > >> org.apache.openjpa.lib.jdbc.DecoratingDataSource.getConnection > >> (DecoratingDataSource.java:87) > >> [reversemappingtool] at > >> org.apache.openjpa.jdbc.schema.SchemaGenerator.generateSchema ( > SchemaGenerator.java:328) > >> [reversemappingtool] at > >> org.apache.openjpa.jdbc.schema.SchemaGenerator.generateSchemas > >> (SchemaGenerator.java:263) > >> [reversemappingtool] at > >> org.apache.openjpa.jdbc.schema.SchemaGenerator.generateSchemas( > SchemaGenerator.java:243) > >> [reversemappingtool] at > >> org.apache.openjpa.jdbc.meta.ReverseMappingTool.run > >> (ReverseMappingTool.java :1970) > >> [reversemappingtool] at > >> org.apache.openjpa.jdbc.ant.ReverseMappingToolTask.executeOn( > ReverseMappingToolTask.java:287) > >> [reversemappingtool] at org.apache.openjpa.lib.ant.AbstractTask.execute > >> (AbstractTask.java:172) > >> [reversemappingtool] at > >> org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275) > >> [reversemappingtool] at org.apache.tools.ant.Task.perform (Task.java > :364) > >> [reversemappingtool] at > >> org.apache.tools.ant.Target.execute(Target.java:341) > >> [reversemappingtool] at > >> org.apache.tools.ant.Target.performTasks(Target.java:369) > >> [reversemappingtool] at > >> org.apache.tools.ant.Project.executeSortedTargets(Project.java :1216) > >> [reversemappingtool] at > >> org.apache.tools.ant.Project.executeTarget(Project.java :1185) > >> [reversemappingtool] at > >> org.apache.tools.ant.helper.DefaultExecutor.executeTargets( > DefaultExecutor.java:40) > >> [reversemappingtool] at > >> > org.eclipse.ant.internal.ui.antsupport.EclipseDefaultExecutor.executeTargets( > EclipseDefaultExecutor.java:32) > >> [reversemappingtool] at > >> org.apache.tools.ant.Project.executeTargets(Project.java:1068) > >> [reversemappingtool] at > >> org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.run ( > InternalAntRunner.java:423) > >> [reversemappingtool] at > >> org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.main( > InternalAntRunner.java:137) > >> > >> BUILD FAILED > >> C:\dev\apache- openjpa-1.0.0\examples\reversemapping\build.xml:77: > >> java.sql.SQLException: Failed to start database > >> 'C:\dev\apache- > openjpa-1.0.0\examples\reversemapping/reversemapping-database', > >> see the next exception for details. > >> > >> Total time: 24 seconds > >> > > > >
<?xml version="1.0" encoding="UTF-8"?> <!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> <project name="hellojpa" default="run"> <property name="example" value="reversemapping"/> <import file="../build.xml"/> <!-- when we clean, also remove all of the auto-generated files --> <target name="pre-clean" description="Pre-clean phase"> <delete includeemptydirs="true"> <fileset dir="${basedir}"> <include name="orm.xml"/> </fileset> <fileset dir="${basedir}"> <include name="*.java"/> <include name="*.java~"/> <contains text="Auto-generated by:"/> </fileset> </delete> </target> <!-- Before we compile and run, we first initialize a database and run the reverse mapping tool on it --> <target name="pre-compile" depends="reverse-map-schema" description="Pre-compilation phase"> </target> <target name="initialize-db" unless="initialize-db-skip" description="Drop then re-create the database"> <!-- first make sure the database is empty --> <sql src="schema/dropdb.sql" driver="${dbdriver}" url="${dburl}" userid="${dbuser}" password="${dbpass}" onerror="continue" classpathref="classpath"/> <!-- build the database --> <sql driver="${dbdriver}" url="${dburl}" userid="${dbuser}" password="${dbpass}" classpathref="classpath"> <transaction src="schema/ToursDB_schema.sql"/> <transaction src="schema/loadCOUNTRIES.sql"/> <transaction src="schema/loadCITIES.sql"/> <transaction src="schema/loadAIRLINES.sql"/> <transaction src="schema/loadFLIGHTS1.sql"/> <transaction src="schema/loadFLIGHTS2.sql"/> <transaction src="schema/loadFLIGHTAVAILABILITY1.sql"/> <transaction src="schema/loadFLIGHTAVAILABILITY2.sql"/> </sql> </target> <target name="reverse-map-schema" depends="" unless="reverse-map-schema-skip" description="Generate java files from the database schema"> <!-- now run the tool to generate java files from the db schema --> <taskdef name="reversemappingtool" classpathref="classpath" classname="org.apache.openjpa.jdbc.ant.ReverseMappingToolTask"/> <reversemappingtool package="reversemapping" directory="${basedir}" innerIdentityClasses="true" customizerProperties="${basedir}/reverse-customizer.properties"> <config connectiondrivername="${dbdriver}" connectionurl="${dburl}" connectionusername="${dbuser}" connectionpassword="${dbpass}"/> <codeformat tabSpaces="4" spaceBeforeParen="false" braceOnSameLine="true"/> </reversemappingtool> <!-- the reverse mapping tool always outputs the orm.xml file to the current directory; move it to the base directory in case we are executing this build file from a different directory. --> <move file="${user.dir}/orm.xml" tofile="${basedir}/orm.xml" failonerror="false"/> </target> </project>
