buildr-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ijonas Kisselbach <ijonas.kisselb...@gmail.com>
Subject problem loading Java classes in extension
Date Mon, 28 Sep 2009 22:25:07 GMT
Hi,

I'm trying to write a extension that exports DDLs using HIbernate's  
schemaexport tool. Although I've added the hibernate-tools dependency  
to the Java.classpath I don't see it downloading the jar and my .m2/ 
repository remains empty of the Hibernate Tools jars.

I've got the following fragment of code in my extension which does all  
the heavy lifting:

     Rake::Task.define_task 'ddl' do |task|
       puts "classpath 1: #{Java.classpath}"
       Java.classpath << "org.hibernate:hibernate-tools:jar:3.2.3.GA"
       puts "classpath 2: #{Java.classpath}"
       Java.load
       puts "classpath 3: #{Java.classpath}"
       puts Java.java.lang.String.new("hello there")
       config_file = Java.java.io.File.new(config_file_path)
       puts config_file.canonicalPath
       config = Java.org.hibernate.cfg.Configuration.configure 
(config_file)

       # config = nil
       schema_export = Java.org.hibernate.tool.hbm2ddl.SchemaExport.new 
(config)
       schema_export.outputFile = output_filename
       schema_export.execute(true, true, false, false)
     end

Producing the following output

** Execute ContentMigrator:ddl
classpath 1: org.apache.ant:ant:jar:1.7.1org.apache.ant:ant- 
launcher:jar:1.7.1org.apache.ant:ant-trax:jar:1.7.1/Users/ijonas/java/ 
jruby-1.3.1/lib/ruby/gems/1.8/gems/buildr-1.3.4-java/lib/buildr/java
classpath 2: org.apache.ant:ant:jar:1.7.1org.apache.ant:ant- 
launcher:jar:1.7.1org.apache.ant:ant-trax:jar:1.7.1/Users/ijonas/java/ 
jruby-1.3.1/lib/ruby/gems/1.8/gems/buildr-1.3.4-java/lib/buildr/ 
javaorg.hibernate:hibernate-tools:jar:3.2.3.GA
classpath 3: org.apache.ant:ant:jar:1.7.1org.apache.ant:ant- 
launcher:jar:1.7.1org.apache.ant:ant-trax:jar:1.7.1/Users/ijonas/java/ 
jruby-1.3.1/lib/ruby/gems/1.8/gems/buildr-1.3.4-java/lib/buildr/ 
javaorg.hibernate:hibernate-tools:jar:3.2.3.GA
hello there
/Users/ijonas/code/v3branch-rails/src/test/resources/ 
testMysql5InnoDBApplicationContext.xml
Buildr aborted!
cannot load Java class org.hibernate.cfg.Configuration
/Users/ijonas/java/jruby-1.3.1/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/ 
rake.rb:472:in `get_proxy_or_package_under_package'
/Users/ijonas/java/jruby-1.3.1/lib/ruby/site_ruby/1.8/builtin/ 
javasupport/java.rb:51:in `method_missing'
ddlexporter.rb:42:in `ddl'
/Users/ijonas/java/jruby-1.3.1/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/ 
rake.rb:615:in `call'

The classpath isn't resolved properly by the looks of things and hence  
the build fails.

Is Java.classpath << "org.hibernate:hibernate-tools:jar:3.2.3.GA" the  
right way of adding a dependency for my extension ? If so, what am I  
doing wrong ?

Many thanks,
Ijonas.


Mime
View raw message