You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-user@db.apache.org by Neil Aggarwal <ne...@JAMMConsulting.com> on 2003/09/26 18:01:23 UTC

Problem building repository (Posting again)

Hello:

When I try to build my repository using the build-torque.xml target
project-ojb-repository-classpath, I get several errors in the velocity
log:

2003-09-20 11:28:04,859 - Starting Jakarta Velocity v1.3.1
2003-09-20 11:28:04,859 - RuntimeInstance initializing.
2003-09-20 11:28:04,859 - Default Properties File:
org\apache\velocity\runtime\defaults\velocity.properties
2003-09-20 11:28:04,859 - Trying to use logger class
org.apache.velocity.runtime.log.AvalonLogSystem
2003-09-20 11:28:04,859 - Couldn't find class
org.apache.velocity.runtime.log.AvalonLogSystem or necessary supporting
classes in classpath. Exception : java.lang.NoClassDefFoundError:
org/apache/log/format/Formatter
2003-09-20 11:28:04,859 - Trying to use logger class
org.apache.velocity.runtime.log.SimpleLog4JLogSystem
2003-09-20 11:28:04,859 - Using logger class
org.apache.velocity.runtime.log.SimpleLog4JLogSystem
2003-09-20 11:28:04,869 - Default ResourceManager initializing. (class
org.apache.velocity.runtime.resource.ResourceManagerImpl)
2003-09-20 11:28:04,879 - Resource Loader Instantiated:
org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader
2003-09-20 11:28:04,879 - ClasspathResourceLoader : initialization
starting.
2003-09-20 11:28:04,879 - ClasspathResourceLoader : initialization
complete.
2003-09-20 11:28:04,889 - ResourceCache : initialized. (class
org.apache.velocity.runtime.resource.ResourceCacheImpl)
2003-09-20 11:28:04,889 - Default ResourceManager initialization
complete.
2003-09-20 11:28:04,889 - Loaded System Directive:
org.apache.velocity.runtime.directive.Literal
2003-09-20 11:28:04,899 - Loaded System Directive:
org.apache.velocity.runtime.directive.Macro
2003-09-20 11:28:04,899 - Loaded System Directive:
org.apache.velocity.runtime.directive.Parse
2003-09-20 11:28:04,909 - Loaded System Directive:
org.apache.velocity.runtime.directive.Include
2003-09-20 11:28:04,909 - Loaded System Directive:
org.apache.velocity.runtime.directive.Foreach
2003-09-20 11:28:05,019 - Created: 20 parsers.
2003-09-20 11:28:05,019 - Velocimacro : initialization starting.
2003-09-20 11:28:05,019 - Velocimacro : adding VMs from VM library
template : VM_global_library.vm
2003-09-20 11:28:05,029 - ResourceManager : unable to find resource
'VM_global_library.vm' in any resource loader.
2003-09-20 11:28:05,029 - Velocimacro : error using  VM library template
VM_global_library.vm :
org.apache.velocity.exception.ResourceNotFoundException: Unable to find
resource 'VM_global_library.vm'
2003-09-20 11:28:05,029 - Velocimacro :  VM library template macro
registration complete.
2003-09-20 11:28:05,029 - Velocimacro : allowInline = true : VMs can be
defined inline in templates
2003-09-20 11:28:05,029 - Velocimacro : allowInlineToOverride = false :
VMs defined inline may NOT replace previous VM definitions
2003-09-20 11:28:05,029 - Velocimacro : allowInlineLocal = false : VMs
defined inline will be  global in scope if allowed.
2003-09-20 11:28:05,029 - Velocimacro : messages on  : VM system will
output logging messages
2003-09-20 11:28:05,029 - Velocimacro : autoload off  : VM system will
not automatically reload global library macros
2003-09-20 11:28:05,029 - Velocimacro : initialization complete.
2003-09-20 11:28:05,029 - Velocity successfully started.
2003-09-20 11:28:05,430 - ResourceManager : found
ojb/repository/Control.vm with loader
org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader
2003-09-20 11:28:05,460 - ResourceManager : found
ojb/repository/MainRepository.vm with loader
org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader
2003-09-20 11:28:05,460 -
org.apache.velocity.runtime.exception.ReferenceException: reference :
template = ojb/repository/MainRepository.vm [line 16,column 15] :
$ojbPlatform is not a valid reference.
2003-09-20 11:28:05,460 -
org.apache.velocity.runtime.exception.ReferenceException: reference :
template = ojb/repository/MainRepository.vm [line 17,column 17] :
${jdbcLevel} is not a valid reference.
2003-09-20 11:28:05,460 -
org.apache.velocity.runtime.exception.ReferenceException: reference :
template = ojb/repository/MainRepository.vm [line 21,column 13] :
$databaseDriver is not a valid reference.
2003-09-20 11:28:05,460 -
org.apache.velocity.runtime.exception.ReferenceException: reference :
template = ojb/repository/MainRepository.vm [line 23,column 18] :
$database is not a valid reference.
2003-09-20 11:28:05,460 -
org.apache.velocity.runtime.exception.ReferenceException: reference :
template = ojb/repository/MainRepository.vm [line 24,column 14] :
$databaseName is not a valid reference.
2003-09-20 11:28:05,460 -
org.apache.velocity.runtime.exception.ReferenceException: reference :
template = ojb/repository/MainRepository.vm [line 26,column 15] :
$databaseUser is not a valid reference.
2003-09-20 11:28:05,520 - ResourceManager : found
ojb/repository/Repository.vm with loader
org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader
2003-09-20 11:28:05,540 - Left side ($col.size) of '!=' operation has
null value. Operation not possible. ojb/repository/Repository.vm [line
62, column 24]

I defined the database references in my mysql.profile and set the
profile to mysql in build.profile.

Here is my complete build.xml file if you need it:
<project name="OjbJdoTest" default="makeRepository"
basedir="c:/Dev/OjbJdoTest">

  <property file="build.properties"/>
  <property file="mysql.profile"/>

  <property name="javalibs" location="c:/JavaLibs" />
  <property name="ojbDir" location="${javalibs}/db-ojb-1.0.rc4" />
  <property name="build-torque" location="${ojbDir}/build-torque.xml" />
  <property name="xdocletDir" location="${javalibs}/xdoclet-1.2b3" />
  <property name="ojbDocletJar"
location="${javalibs}/db-ojb-1.0.rc4/lib/xdoclet-ojb-module-1.2b3-dev.ja
r" />
  <property name="jdoriDir" location="${javalibs}/jdori-1_0" />

  <path id="build-classpath">
    <fileset dir="${ojbDir}/lib">
      <include name="*.jar"/>
     </fileset> 
    <fileset dir="${xdocletDir}/lib">
      <include name="*.jar"/>
     </fileset> 
    <fileset dir="${jdoriDir}/src">
      <include name="*.jar"/>
     </fileset> 
     <pathelement location="${ojbDocletJar}" />
  </path> 

  <target name="clean">
    <delete dir="build"/>
    <delete dir="lib"/>
    <delete file="velocity.log"/>
  </target>

  <target name="prepare" depends="clean">
    <mkdir dir="lib"/>
    <copy todir="lib">
      <fileset dir="${ojbDir}/lib"/>
    </copy>
  </target>
  
  <target name="processOjbDoclets" depends="prepare">
    <taskdef name="ojbdoclet"
classname="xdoclet.modules.ojb.OjbDocletTask"
classpathref="build-classpath"/>
    <ojbdoclet destdir="build">
      <fileset dir="src">
        <include name="persistent/*.java"/>
       </fileset> 
      <ojbrepository destinationFile="repository_user.xml"/>
      <torqueschema databaseName="ojbJdoTest"
destinationFile="project-schema.xml"/>
    </ojbdoclet>
  </target> 

  <target name="processJdoDoclets" depends="processOjbDoclets">
    <taskdef name="jdodoclet"
classname="xdoclet.modules.jdo.JdoDocletTask"
classpathref="build-classpath"/>
    <jdodoclet destdir="build">
      <fileset dir="src">
        <include name="persistent/*.java"/>
      </fileset> 
      <jdometadata jdospec="1.0" generation="class"/>
    </jdodoclet>
  </target> 

  <target name="enhancePersistentClasses" depends="processJdoDoclets">

    <pathconvert property="enhancerFiles" pathsep=" ">
      <path id="enhancerFiles">
        <fileset dir="classes">
          <include name="persistent/*.class"/>
        </fileset> 
        <fileset dir="build">
          <include name="persistent/*.jdo"/>
        </fileset> 
      </path> 
    </pathconvert>
    <java fork="yes" failonerror="yes"
      classname="com.sun.jdori.enhancer.Main"
classpathref="build-classpath">
      <arg line="-v -f -d build/classes ${enhancerFiles}" />
    </java>
  </target> 

  <target name="makeDbSchema" depends="enhancePersistentClasses">
    <ant dir="." antfile="${build-torque}"
target="project-sql-classpath">
      <property name="schemaDirectory" value="build"/>
      <property name="outputDirectory" value="build"/>
    </ant>
  </target>

  <target name="makeRepository" depends="makeDbSchema">
    <ant dir="." antfile="${build-torque}"
target="project-ojb-repository-classpath">
      <property name="schemaDirectory" value="build"/>
      <property name="outputDirectory" value="build"/>
    </ant>
  </target>

</project>

Any ideas?

Thanks,
	Neil.


--
Neil Aggarwal, JAMM Consulting, (972)612-6056, www.JAMMConsulting.com
FREE! Valuable info on how your business can reduce operating costs by 
17% or more in 6 months or less! => http://newsletter.JAMMConsulting.com


---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org


Re: Problem building repository (Posting again)

Posted by Danilo Tommasina <dt...@risksys.com>.
Hi,
the velocity templates are quite buggy, you will have to learn a little 
of velocity scripting and patch the scripts yourself (it is not that 
complicated)
I did it, however the velocity scripts we now use, contains several 
customisations for our project, so the object model is generated with 
several extra features that makes our velociy scripts no longer for 
general use, sorry.
How to customise the .vm scripts: download latest torque src release 
(yes the torque sources, not the OJB sources).
In directory (referring to torque 3.01) templates/ojb you will find all 
OJB related .vm scripts.

now make sure that the controlTemplate attribute in the build-torque.xml 
tasks is set to the right path.

So here a little analisys of your error log.


> 2003-09-20 11:28:04,859 - Trying to use logger class
> org.apache.velocity.runtime.log.AvalonLogSystem
> 2003-09-20 11:28:04,859 - Couldn't find class
> org.apache.velocity.runtime.log.AvalonLogSystem or necessary supporting
> classes in classpath. Exception : java.lang.NoClassDefFoundError:
> org/apache/log/format/Formatter
> 2003-09-20 11:28:04,859 - Trying to use logger class
> org.apache.velocity.runtime.log.SimpleLog4JLogSystem
> 2003-09-20 11:28:04,859 - Using logger class
> org.apache.velocity.runtime.log.SimpleLog4JLogSystem


This is nothing tragic, it seems that class 
org.apache.log.format.Formatter is not found and the 
SimpleLog4JLogSystem is used instead.

> org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader
> 2003-09-20 11:28:05,460 -
> org.apache.velocity.runtime.exception.ReferenceException: reference :
> template = ojb/repository/MainRepository.vm [line 16,column 15] :
> $ojbPlatform is not a valid reference.
> 2003-09-20 11:28:05,460 -
> org.apache.velocity.runtime.exception.ReferenceException: reference :
> template = ojb/repository/MainRepository.vm [line 17,column 17] :
> ${jdbcLevel} is not a valid reference.
> 2003-09-20 11:28:05,460 -
> org.apache.velocity.runtime.exception.ReferenceException: reference :
> template = ojb/repository/MainRepository.vm [line 21,column 13] :
> $databaseDriver is not a valid reference.
> 2003-09-20 11:28:05,460 -
> org.apache.velocity.runtime.exception.ReferenceException: reference :
> template = ojb/repository/MainRepository.vm [line 23,column 18] :
> $database is not a valid reference.
> 2003-09-20 11:28:05,460 -
> org.apache.velocity.runtime.exception.ReferenceException: reference :
> template = ojb/repository/MainRepository.vm [line 24,column 14] :
> $databaseName is not a valid reference.
> 2003-09-20 11:28:05,460 -
> org.apache.velocity.runtime.exception.ReferenceException: reference :
> template = ojb/repository/MainRepository.vm [line 26,column 15] :
> $databaseUser is not a valid reference.
> 2003-09-20 11:28:05,520 - ResourceManager : found
> ojb/repository/Repository.vm with loader
> org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader
> 2003-09-20 11:28:05,540 - Left side ($col.size) of '!=' operation has
> null value. Operation not possible. ojb/repository/Repository.vm [line
> 62, column 24]

Several varibles are not found, try to use following mysql.profile.

since I did several changes to the .vm scripts, I don't know if all 
these variable are really needed for your requirements, but it may help...


//***************************

# -------------------------------------------------------------------
# T O R Q U E  C O N F I G U R A T I O N  F I L E
# -------------------------------------------------------------------
torque.project = <prj_name>

# -------------------------------------------------------------------
#  T A R G E T  D A T A B A S E
#   axion, cloudscape, db2, db2400, hypersonic, interbase, mssql,
#   mysql, oracle, postgresql, sapdb, sybase
# -------------------------------------------------------------------
torque.database = mysql

# -------------------------------------------------------------------
#  D A T A B A S E  S E T T I N G S
# -------------------------------------------------------------------
torque.database.driver= <your_db_driver>
torque.database.createUrl = <complete_conn_url>
torque.database.buildUrl = <complete_conn_url>
torque.database.url = <complete_conn_url>
torque.database.schema = ....
torque.database.user = ....
torque.database.password = ....
torque.database.host = ....
torque.sameJavaName = false
torque.schema.ojb.excludes = internal-schema.xml
torque.schema.dir = ${ojb.schemadir}
torque.ojb.dir = ${ojb.omdir}
torque.templatePath = ${torque.builddir}/templates

#These values are needed by ojb/repository/Control.vm
ojbPlatform = MySQL
jdbcLevel = 2.0
urlProtocol = jdbc
urlSubprotocol = mysql
databaseName = <reduced_conn_url>
#Set this to true if using a DataSource
ojbUseJNDI = false
ojbJNDISource = <DS_JNDI_name>
ojbUseInterface = false
useAutoCommit = 2
jcdAlias = ${torque.project}_jcdAlias

# -------------------------------------------------------------------
#
#  O B J E C T  M O D E L  I N F O R M A T I O N
#
# -------------------------------------------------------------------
# These settings will allow you to customize the way your
# Peer-based object model is created.
# -------------------------------------------------------------------
# addGetByNameMethod
#   If true, Torque adds methods to get database fields by name/position.
#
# addIntakeRetrievable
#   If true, the data objects will implement Intake's Retrievable
#   interface
#
# addSaveMethod
#   If true, Torque adds tracking code to determine how to save objects.
#
# addTimeStamp
#   If true, Torque true puts time stamps in generated om files.
#
# basePrefix
#   A string to pre-pend to the file names of base data and peer objects.
#
# complexObjectModel
#   If true, Torque generates data objects with collection support and
#   methods to easily retreive foreign key relationships.
#
# targetPackage
#   Sets the Java package the om files will generated to, e.g.
#   "com.company.project.om".
#
# useClasspath
#   If true, Torque will not look in the <code>templatePath</code> 
directory,
#   for templates, but instead load them from the classpath, allowing 
you to
#   use Torque without extracted it from the jar.
#
# useManagers
#   If true, Torque will generate Manager classes that use JCS for caching.
#   Still considered experimental.
# -------------------------------------------------------------------

torque.targetPackage = <your_target_package>

torque.addGetByNameMethod = true
torque.addIntakeRetrievable = false
torque.addSaveMethod = true
torque.addTimeStamp = true
torque.basePrefix = Base
torque.complexObjectModel = true
torque.useClasspath = false
torque.useManagers = false

//********************************


bye
danilo


---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org