Return-Path: Delivered-To: apmail-buildr-users-archive@www.apache.org Received: (qmail 35487 invoked from network); 28 Sep 2009 22:31:14 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 28 Sep 2009 22:31:14 -0000 Received: (qmail 69810 invoked by uid 500); 28 Sep 2009 22:31:13 -0000 Delivered-To: apmail-buildr-users-archive@buildr.apache.org Received: (qmail 69749 invoked by uid 500); 28 Sep 2009 22:31:13 -0000 Mailing-List: contact users-help@buildr.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@buildr.apache.org Delivered-To: mailing list users@buildr.apache.org Received: (qmail 69671 invoked by uid 99); 28 Sep 2009 22:31:13 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 28 Sep 2009 22:31:13 +0000 X-ASF-Spam-Status: No, hits=2.2 required=10.0 tests=HTML_MESSAGE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of djspiewak@gmail.com designates 209.85.210.190 as permitted sender) Received: from [209.85.210.190] (HELO mail-yx0-f190.google.com) (209.85.210.190) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 28 Sep 2009 22:31:06 +0000 Received: by yxe28 with SMTP id 28so5390487yxe.19 for ; Mon, 28 Sep 2009 15:30:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :from:date:message-id:subject:to:content-type; bh=ysKhAY7Kn/0hxMGc+FPcWcbvBiZuzQ3G1Ip7/S9HRFU=; b=GUer1USc++reCljdiovLErOrKGmuoiXtW2jpBSUItlPEvE6QHgD3Pfj5+DVtwXseIz 2rSsVTePrbus2bwJT2Sd7TVjjlAu/Dafdt3hQthvqRSwTFabUW4CMDHD0tsepYeZGh0I iG9wsqp1+Z7Q32as5UJxQmkCRltRP+yuq3grQ= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; b=dXN5o/VCzeBNUxz1LDTd/F75vLiTDOFVSjnYFBFf/WSt1ijOeqMpDPLyefHlMQ28Lu QXzmdsDBg8j1yvNgbkxqxsAzThzIXw3X2rh9DyKVuJJI99uHbBhRfvTEPlOk3nx+nCky ZOaKL5v3gx9sSapjjLWvvG7bIk67cQgKxzghk= MIME-Version: 1.0 Received: by 10.150.244.4 with SMTP id r4mr1890622ybh.127.1254177045073; Mon, 28 Sep 2009 15:30:45 -0700 (PDT) In-Reply-To: <81F636E7-D408-49D8-851F-7F9FD610DAA1@gmail.com> References: <81F636E7-D408-49D8-851F-7F9FD610DAA1@gmail.com> From: Daniel Spiewak Date: Mon, 28 Sep 2009 17:30:25 -0500 Message-ID: <5c99d0330909281530h7669013v773aeb131f764ac8@mail.gmail.com> Subject: Re: problem loading Java classes in extension To: users@buildr.apache.org Content-Type: multipart/alternative; boundary=000e0cd25d1441d1b70474aad93d X-Virus-Checked: Checked by ClamAV on apache.org --000e0cd25d1441d1b70474aad93d Content-Type: text/plain; charset=UTF-8 I *think* your treatment of Java.classpath is just fine, but to be safe you could wrap each artifact String in artifact(...).invoke Probably isn't necessary though... The problem is actually that you haven't invoked Java.load. More importantly, even if you did perform the invocation, it has probably been invoked previous to that point in the code (when the task is executed), meaning that your classpath additions will not be recognized. Try sticking the Java.classpath mutations somewhere in the static scope. They should be executed when your extension is *loaded*. Then, invoke Java.load within the task just before you call the Hibernate class. Rule of thumb: add to classpath as *early* as possible, invoke load as *late * as possible. Daniel On Mon, Sep 28, 2009 at 5:25 PM, Ijonas Kisselbach < ijonas.kisselbach@gmail.com> wrote: > 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. > > --000e0cd25d1441d1b70474aad93d--