Load path issues inside jar / external app

View: New views
7 Messages — Rating Filter:   Alert me  

Load path issues inside jar / external app

by steve_molitor :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I'm trying to package some ruby code for running inside spring batch.  I'm using the spring dynamic language bean feature to load ruby classes from files on the class path.  The problem is these ruby files require other files via File.dirname(__FILE__).  That's not working.  What's the best way to package up a bunch of jruby code for running inside a java application, such that the jruby files can require other jruby files?

Thanks,

Steve

Re: Load path issues inside jar / external app

by Nick Sieger-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Mon, Nov 2, 2009 at 4:03 PM, Steve Molitor <stevemolitor@...> wrote:
> I'm trying to package some ruby code for running inside spring batch.  I'm
> using the spring dynamic language bean feature to load ruby classes from
> files on the class path.  The problem is these ruby files require other
> files via File.dirname(__FILE__).  That's not working.  What's the best way
> to package up a bunch of jruby code for running inside a java application,
> such that the jruby files can require other jruby files?
> Thanks,
> Steve

What is the value of __FILE__? Even with __FILE__ set to a file: URL
of a path inside a jar file, typical Rubyisms like you indicate should
be working. If you can illustrate what is failing, that would help;
there might be a bug. Also indicate what version of JRuby you're
using. Some of the bugs related to file: URLs and paths have been
fixed in recent releases.

Cheers,
/Nick

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email



Re: Load path issues inside jar / external app

by Yoko Harada :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Tue, Nov 3, 2009 at 9:35 AM, Nick Sieger <nicksieger@...> wrote:
> On Mon, Nov 2, 2009 at 4:03 PM, Steve Molitor <stevemolitor@...> wrote:
>> I'm trying to package some ruby code for running inside spring batch.  I'm
>> using the spring dynamic language bean feature to load ruby classes from
>> files on the class path.  The problem is these ruby files require other
>> files via File.dirname(__FILE__).  That's not working.  What's the best way
>> to package up a bunch of jruby code for running inside a java application,
>> such that the jruby files can require other jruby files?
>> Thanks,
>> Steve

Did Spring load Ruby scripts from a classpath? If so, I might have got
an error from the same reason.

>
> What is the value of __FILE__? Even with __FILE__ set to a file: URL
> of a path inside a jar file, typical Rubyisms like you indicate should
> be working. If you can illustrate what is failing, that would help;
> there might be a bug. Also indicate what version of JRuby you're
> using. Some of the bugs related to file: URLs and paths have been
> fixed in recent releases.

I haven't figured out what's wrong with that, but __FILE__ doesn't
work when a script is loaded from a  classpath. For example, when I
set all necessary all classapths and load test/test_file.rb from the
classpath, evaluation failed because the error below at the line
"expect = File.read(__FILE__)[0..100]":

Loaded suite -
Started
.................................E.......................
Finished in 2.153 seconds.

  1) Error:
test_file_url(TestFile):
Errno::ENOENT: No such file or directory - File not found - test_file.rb
    test_file.rb:926:in `initialize'
    test_file.rb:926:in `test_file_url'

57 tests, 293 assertions, 0 failures, 1 errors

However, when I read test_file.rb from an absolute path, it worked
well. This happens in trunk version as well. If this should work even
when scripts are loaded from classpath, there might be a bug.

-Yoko

>
> Cheers,
> /Nick
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>    http://xircles.codehaus.org/manage_email
>
>
>

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email



Re: Load path issues inside jar / external app

by steve_molitor :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Yes I had Spring load the scripts from a classpath.   I've worked around the issue by removing the File.dirname(__FILE__) bits from my code.  Instead I specify from the root of the classpath:  'require "path/to/ruby/file" where the directory "path" is on the root of the classpath.  I can do this because it's all my code and not that many files to modify.

I'm still playing around with it; will update if I find anything out.

Steve

On Wed, Nov 4, 2009 at 8:28 AM, Yoko Harada <yokolet@...> wrote:
On Tue, Nov 3, 2009 at 9:35 AM, Nick Sieger <nicksieger@...> wrote:
> On Mon, Nov 2, 2009 at 4:03 PM, Steve Molitor <stevemolitor@...> wrote:
>> I'm trying to package some ruby code for running inside spring batch.  I'm
>> using the spring dynamic language bean feature to load ruby classes from
>> files on the class path.  The problem is these ruby files require other
>> files via File.dirname(__FILE__).  That's not working.  What's the best way
>> to package up a bunch of jruby code for running inside a java application,
>> such that the jruby files can require other jruby files?
>> Thanks,
>> Steve

Did Spring load Ruby scripts from a classpath? If so, I might have got
an error from the same reason.

>
> What is the value of __FILE__? Even with __FILE__ set to a file: URL
> of a path inside a jar file, typical Rubyisms like you indicate should
> be working. If you can illustrate what is failing, that would help;
> there might be a bug. Also indicate what version of JRuby you're
> using. Some of the bugs related to file: URLs and paths have been
> fixed in recent releases.

I haven't figured out what's wrong with that, but __FILE__ doesn't
work when a script is loaded from a  classpath. For example, when I
set all necessary all classapths and load test/test_file.rb from the
classpath, evaluation failed because the error below at the line
"expect = File.read(__FILE__)[0..100]":

Loaded suite -
Started
.................................E.......................
Finished in 2.153 seconds.

 1) Error:
test_file_url(TestFile):
Errno::ENOENT: No such file or directory - File not found - test_file.rb
   test_file.rb:926:in `initialize'
   test_file.rb:926:in `test_file_url'

57 tests, 293 assertions, 0 failures, 1 errors

However, when I read test_file.rb from an absolute path, it worked
well. This happens in trunk version as well. If this should work even
when scripts are loaded from classpath, there might be a bug.

-Yoko

>
> Cheers,
> /Nick
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>    http://xircles.codehaus.org/manage_email
>
>
>

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

   http://xircles.codehaus.org/manage_email




Re: Load path issues inside jar / external app

by steve_molitor :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

One more thing - what's the state of embedding gems in a jar, where the gem includes its own java code in a jar?  I'm trying to use the activerecord-jdbc-adapter inside a spring application where all my ruby code and dependent ruby gems are packaged in a jar (or jars).   However activerecord-jdbc can't load it's java classes:

`class_eval': cannot load Java class jdbc_adapter.JdbcConnectionFactory (NameError)

I'm not surprised it's not working, but I'm not sure what the best solution is.  Should I just copy jdbc_adapter_internal.jar (used internally by the activerecord-jdbc gem) out from under the activerecord-jdbc directory to someplace in my classpath?

Steve

On Wed, Nov 4, 2009 at 10:28 AM, Steve Molitor <stevemolitor@...> wrote:
Yes I had Spring load the scripts from a classpath.   I've worked around the issue by removing the File.dirname(__FILE__) bits from my code.  Instead I specify from the root of the classpath:  'require "path/to/ruby/file" where the directory "path" is on the root of the classpath.  I can do this because it's all my code and not that many files to modify.

I'm still playing around with it; will update if I find anything out.

Steve


On Wed, Nov 4, 2009 at 8:28 AM, Yoko Harada <yokolet@...> wrote:
On Tue, Nov 3, 2009 at 9:35 AM, Nick Sieger <nicksieger@...> wrote:
> On Mon, Nov 2, 2009 at 4:03 PM, Steve Molitor <stevemolitor@...> wrote:
>> I'm trying to package some ruby code for running inside spring batch.  I'm
>> using the spring dynamic language bean feature to load ruby classes from
>> files on the class path.  The problem is these ruby files require other
>> files via File.dirname(__FILE__).  That's not working.  What's the best way
>> to package up a bunch of jruby code for running inside a java application,
>> such that the jruby files can require other jruby files?
>> Thanks,
>> Steve

Did Spring load Ruby scripts from a classpath? If so, I might have got
an error from the same reason.

>
> What is the value of __FILE__? Even with __FILE__ set to a file: URL
> of a path inside a jar file, typical Rubyisms like you indicate should
> be working. If you can illustrate what is failing, that would help;
> there might be a bug. Also indicate what version of JRuby you're
> using. Some of the bugs related to file: URLs and paths have been
> fixed in recent releases.

I haven't figured out what's wrong with that, but __FILE__ doesn't
work when a script is loaded from a  classpath. For example, when I
set all necessary all classapths and load test/test_file.rb from the
classpath, evaluation failed because the error below at the line
"expect = File.read(__FILE__)[0..100]":

Loaded suite -
Started
.................................E.......................
Finished in 2.153 seconds.

 1) Error:
test_file_url(TestFile):
Errno::ENOENT: No such file or directory - File not found - test_file.rb
   test_file.rb:926:in `initialize'
   test_file.rb:926:in `test_file_url'

57 tests, 293 assertions, 0 failures, 1 errors

However, when I read test_file.rb from an absolute path, it worked
well. This happens in trunk version as well. If this should work even
when scripts are loaded from classpath, there might be a bug.

-Yoko

>
> Cheers,
> /Nick
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>    http://xircles.codehaus.org/manage_email
>
>
>

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

   http://xircles.codehaus.org/manage_email





Re: Load path issues inside jar / external app

by Nick Sieger-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Wed, Nov 4, 2009 at 11:07 AM, Steve Molitor <stevemolitor@...> wrote:

> One more thing - what's the state of embedding gems in a jar, where the gem
> includes its own java code in a jar?  I'm trying to use the
> activerecord-jdbc-adapter inside a spring application where all my ruby code
> and dependent ruby gems are packaged in a jar (or jars).   However
> activerecord-jdbc can't load it's java classes:
> `class_eval': cannot load Java class jdbc_adapter.JdbcConnectionFactory
> (NameError)
> I'm not surprised it's not working, but I'm not sure what the best
> solution is.  Should I just copy jdbc_adapter_internal.jar (used internally
> by the activerecord-jdbc gem) out from under the activerecord-jdbc directory
> to someplace in my classpath?

I think better would be to un-jar the contents of the jar into another
jar. There's also the problem that the jdbc adapter code does a
"require 'jdbc_adapter/jdbc_adapter_internal'" which means that you
might have to put an empty 'jdbc_adapter/jdbc_adapter_internal.rb"
file inside your jar as well.

The relevant JIRA is http://jira.codehaus.org/browse/JRUBY-3299. If we
can't find a solution to jars-in-jars, we might need to build a gem
re-packaging solution that takes care of the above for you.

/Nick

>
> Steve
> On Wed, Nov 4, 2009 at 10:28 AM, Steve Molitor <stevemolitor@...>
> wrote:
>>
>> Yes I had Spring load the scripts from a classpath.   I've worked around
>> the issue by removing the File.dirname(__FILE__) bits from my code.  Instead
>> I specify from the root of the classpath:  'require "path/to/ruby/file"
>> where the directory "path" is on the root of the classpath.  I can do this
>> because it's all my code and not that many files to modify.
>> I'm still playing around with it; will update if I find anything out.
>> Steve
>>
>> On Wed, Nov 4, 2009 at 8:28 AM, Yoko Harada <yokolet@...> wrote:
>>>
>>> On Tue, Nov 3, 2009 at 9:35 AM, Nick Sieger <nicksieger@...> wrote:
>>> > On Mon, Nov 2, 2009 at 4:03 PM, Steve Molitor <stevemolitor@...>
>>> > wrote:
>>> >> I'm trying to package some ruby code for running inside spring batch.
>>> >>  I'm
>>> >> using the spring dynamic language bean feature to load ruby classes
>>> >> from
>>> >> files on the class path.  The problem is these ruby files require
>>> >> other
>>> >> files via File.dirname(__FILE__).  That's not working.  What's the
>>> >> best way
>>> >> to package up a bunch of jruby code for running inside a java
>>> >> application,
>>> >> such that the jruby files can require other jruby files?
>>> >> Thanks,
>>> >> Steve
>>>
>>> Did Spring load Ruby scripts from a classpath? If so, I might have got
>>> an error from the same reason.
>>>
>>> >
>>> > What is the value of __FILE__? Even with __FILE__ set to a file: URL
>>> > of a path inside a jar file, typical Rubyisms like you indicate should
>>> > be working. If you can illustrate what is failing, that would help;
>>> > there might be a bug. Also indicate what version of JRuby you're
>>> > using. Some of the bugs related to file: URLs and paths have been
>>> > fixed in recent releases.
>>>
>>> I haven't figured out what's wrong with that, but __FILE__ doesn't
>>> work when a script is loaded from a  classpath. For example, when I
>>> set all necessary all classapths and load test/test_file.rb from the
>>> classpath, evaluation failed because the error below at the line
>>> "expect = File.read(__FILE__)[0..100]":
>>>
>>> Loaded suite -
>>> Started
>>> .................................E.......................
>>> Finished in 2.153 seconds.
>>>
>>>  1) Error:
>>> test_file_url(TestFile):
>>> Errno::ENOENT: No such file or directory - File not found - test_file.rb
>>>    test_file.rb:926:in `initialize'
>>>    test_file.rb:926:in `test_file_url'
>>>
>>> 57 tests, 293 assertions, 0 failures, 1 errors
>>>
>>> However, when I read test_file.rb from an absolute path, it worked
>>> well. This happens in trunk version as well. If this should work even
>>> when scripts are loaded from classpath, there might be a bug.
>>>
>>> -Yoko
>>>
>>> >
>>> > Cheers,
>>> > /Nick
>>> >
>>> > ---------------------------------------------------------------------
>>> > To unsubscribe from this list, please visit:
>>> >
>>> >    http://xircles.codehaus.org/manage_email
>>> >
>>> >
>>> >
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe from this list, please visit:
>>>
>>>    http://xircles.codehaus.org/manage_email
>>>
>>>
>>
>
>

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email



Re: Load path issues inside jar / external app

by steve_molitor :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Thanks for the help.  That got me further but I've hit another snag that has me really confused.  

Background:  I'm running ruby code that uses activerecord against MsSql inside a jar that is loaded inside a spring application.  I'm using a spring dynamic language jruby bean, which kicks everything off.  I've removed the jdbc_adapter_internal.jar from within the jdbc_adapter gem and replaced it with an empty jdbc_adapter_internal.rb.  My ruby code and gems (minus jars in the gems) are jarred up.  This is all running inside tomcat in a WAR, and I put jdbc_adapter_internal.jar and my_ruby_code_with_gem.jar under WEB-INF/lib in the war.

Problem:  I'm getting this when my jruby code tries to establish a connection to the db:

org.springframework.scripting.jruby.JRubyScriptUtils$JRubyExecutionException: uninitialized constant ActiveRecord::ConnectionAdapters::MssqlJdbcConnection; nested exception is org.jruby.exceptions.RaiseException: uninitialized constant ActiveRecord::ConnectionAdapters::MssqlJdbcConnection
at org.springframework.scripting.jruby.JRubyScriptUtils$RubyObjectInvocationHandler.invoke(JRubyScriptUtils.java:184)
...<snip>...

Caused by: org.jruby.exceptions.RaiseException: uninitialized constant ActiveRecord::ConnectionAdapters::MssqlJdbcConnection
at Kernel.raise(file:/Users/steve/src/apache-tomcat-6.0.20/webapps/mercybatch/WEB-INF/lib/remittanceAdvice-1.0.jar!/vendor/gems/activesupport/lib/active_support/dependencies.rb:442)
at ActiveSupport::Dependencies.load_missing_constant(file:/Users/steve/src/apache-tomcat-6.0.20/webapps/mercybatch/WEB-INF/lib/remittanceAdvice-1.0.jar!/vendor/gems/activesupport/lib/active_support/dependencies.rb:77)
at ActiveSupport::Dependencies::ModuleConstMissing.const_missing_with_dependencies(file:/Users/steve/src/apache-tomcat-6.0.20/webapps/mercybatch/WEB-INF/lib/remittanceAdvice-1.0.jar!/vendor/gems/activerecord-jdbc-adapter-0.9.2/lib/jdbc_adapter/jdbc_mssql.rb:35)
at #<Class:01x45192510>.jdbc_connection_class(file:/Users/steve/src/apache-tomcat-6.0.20/webapps/mercybatch/WEB-INF/lib/remittanceAdvice-1.0.jar!/vendor/gems/activerecord-jdbc-adapter-0.9.2/lib/active_record/connection_adapters/jdbc_adapter.rb:462)
at ActiveRecord::ConnectionAdapters::JdbcAdapter.jdbc_connection_class(file:/Users/steve/src/apache-tomcat-6.0.20/webapps/mercybatch/WEB-INF/lib/remittanceAdvice-1.0.jar!/vendor/gems/activerecord-jdbc-adapter-0.9.2/lib/active_record/connection_adapters/jdbc_adapter.rb:452)
at ActiveRecord::ConnectionAdapters::JdbcAdapter.initialize(file:/Users/steve/src/apache-tomcat-6.0.20/webapps/mercybatch/WEB-INF/lib/remittanceAdvice-1.0.jar!/vendor/gems/activerecord-jdbc-adapter-0.9.2/lib/active_record/connection_adapters/jdbc_adapter.rb:49)
at JdbcSpec::ActiveRecordExtensions.jdbc_connection(file:/Users/steve/src/apache-tomcat-6.0.20/webapps/mercybatch/WEB-INF/lib/remittanceAdvice-1.0.jar!/vendor/gems/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb:223)
at ActiveRecord::ConnectionAdapters::ConnectionPool.new_connection(file:/Users/steve/src/apache-tomcat-6.0.20/webapps/mercybatch/WEB-INF/lib/remittanceAdvice-1.0.jar!/vendor/gems/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb:245)
at ActiveRecord::ConnectionAdapters::ConnectionPool.checkout_new_connection(file:/Users/steve/src/apache-tomcat-6.0.20/webapps/mercybatch/WEB-INF/lib/remittanceAdvice-1.0.jar!/vendor/gems/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb:188)
at ActiveRecord::ConnectionAdapters::ConnectionPool.checkout(file:/Users/steve/src/apache-tomcat-6.0.20/webapps/mercybatch/WEB-INF/lib/remittanceAdvice-1.0.jar!/vendor/gems/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb:184)
at Kernel.loop(file:/Users/steve/src/apache-tomcat-6.0.20/webapps/mercybatch/WEB-INF/lib/remittanceAdvice-1.0.jar!/vendor/gems/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb:184)
at ActiveRecord::ConnectionAdapters::ConnectionPool.checkout(file:/Users/steve/src/apache-tomcat-6.0.20/webapps/mercybatch/WEB-INF/lib/jruby-complete-1.3.1.jar!/monitor.rb:191)
at MonitorMixin.mon_synchronize(file:/Users/steve/src/apache-tomcat-6.0.20/webapps/mercybatch/WEB-INF/lib/remittanceAdvice-1.0.jar!/vendor/gems/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb:183)
at ActiveRecord::ConnectionAdapters::ConnectionPool.checkout(file:/Users/steve/src/apache-tomcat-6.0.20/webapps/mercybatch/WEB-INF/lib/remittanceAdvice-1.0.jar!/vendor/gems/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb:98)
at ActiveRecord::ConnectionAdapters::ConnectionPool.connection(file:/Users/steve/src/apache-tomcat-6.0.20/webapps/mercybatch/WEB-INF/lib/remittanceAdvice-1.0.jar!/vendor/gems/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb:326)
at ActiveRecord::ConnectionAdapters::ConnectionHandler.retrieve_connection(file:/Users/steve/src/apache-tomcat-6.0.20/webapps/mercybatch/WEB-INF/lib/remittanceAdvice-1.0.jar!/vendor/gems/activerecord/lib/active_record/connection_adapters/abstract/connection_specification.rb:121)
at #<Class:01x322a0b7b>.retrieve_connection(file:/Users/steve/src/apache-tomcat-6.0.20/webapps/mercybatch/WEB-INF/lib/remittanceAdvice-1.0.jar!/vendor/gems/activerecord/lib/active_record/connection_adapters/abstract/connection_specification.rb:113)
at #<Class:01x322a0b7b>.connection(file:/Users/steve/src/apache-tomcat-6.0.20/webapps/mercybatch/WEB-INF/lib/remittanceAdvice-1.0.jar!/vendor/gems/activerecord/lib/active_record/base.rb:2934)
at #<Class:01x322a0b7b>.quoted_table_name(file:/Users/steve/src/apache-tomcat-6.0.20/webapps/mercybatch/WEB-INF/lib/remittanceAdvice-1.0.jar!/vendor/gems/activerecord/lib/active_record/base.rb:1626)
at #<Class:01x322a0b7b>.construct_finder_sql(file:/Users/steve/src/apache-tomcat-6.0.20/webapps/mercybatch/WEB-INF/lib/remittanceAdvice-1.0.jar!/vendor/gems/activerecord/lib/active_record/base.rb:1490)
at #<Class:01x322a0b7b>.find_every(file:/Users/steve/src/apache-tomcat-6.0.20/webapps/mercybatch/WEB-INF/lib/remittanceAdvice-1.0.jar!/vendor/gems/activerecord/lib/active_record/base.rb:589)
at #<Class:01x322a0b7b>.find(:38)
at RemittanceAdvice::RaItemReader.read(:1)
at (unknown).(unknown)(:1)

I know warbler and jruby-rack gets AR/jdbc adapter and ms sql to work in a WAR, but that isn't really an option for me right now; I'm trying to squeeze in some existing jruby stuff into an existing spring app built by maven.  So I guess I'm going to have to figure out what jruby-rack and warbler do to make this stuff work.

Any help would be greatly appreciated!!!

Steve


On Wed, Nov 4, 2009 at 11:24 AM, Nick Sieger <nicksieger@...> wrote:
On Wed, Nov 4, 2009 at 11:07 AM, Steve Molitor <stevemolitor@...> wrote:
> One more thing - what's the state of embedding gems in a jar, where the gem
> includes its own java code in a jar?  I'm trying to use the
> activerecord-jdbc-adapter inside a spring application where all my ruby code
> and dependent ruby gems are packaged in a jar (or jars).   However
> activerecord-jdbc can't load it's java classes:
> `class_eval': cannot load Java class jdbc_adapter.JdbcConnectionFactory
> (NameError)
> I'm not surprised it's not working, but I'm not sure what the best
> solution is.  Should I just copy jdbc_adapter_internal.jar (used internally
> by the activerecord-jdbc gem) out from under the activerecord-jdbc directory
> to someplace in my classpath?

I think better would be to un-jar the contents of the jar into another
jar. There's also the problem that the jdbc adapter code does a
"require 'jdbc_adapter/jdbc_adapter_internal'" which means that you
might have to put an empty 'jdbc_adapter/jdbc_adapter_internal.rb"
file inside your jar as well.

The relevant JIRA is http://jira.codehaus.org/browse/JRUBY-3299. If we
can't find a solution to jars-in-jars, we might need to build a gem
re-packaging solution that takes care of the above for you.

/Nick

>
> Steve
> On Wed, Nov 4, 2009 at 10:28 AM, Steve Molitor <stevemolitor@...>
> wrote:
>>
>> Yes I had Spring load the scripts from a classpath.   I've worked around
>> the issue by removing the File.dirname(__FILE__) bits from my code.  Instead
>> I specify from the root of the classpath:  'require "path/to/ruby/file"
>> where the directory "path" is on the root of the classpath.  I can do this
>> because it's all my code and not that many files to modify.
>> I'm still playing around with it; will update if I find anything out.
>> Steve
>>
>> On Wed, Nov 4, 2009 at 8:28 AM, Yoko Harada <yokolet@...> wrote:
>>>
>>> On Tue, Nov 3, 2009 at 9:35 AM, Nick Sieger <nicksieger@...> wrote:
>>> > On Mon, Nov 2, 2009 at 4:03 PM, Steve Molitor <stevemolitor@...>
>>> > wrote:
>>> >> I'm trying to package some ruby code for running inside spring batch.
>>> >>  I'm
>>> >> using the spring dynamic language bean feature to load ruby classes
>>> >> from
>>> >> files on the class path.  The problem is these ruby files require
>>> >> other
>>> >> files via File.dirname(__FILE__).  That's not working.  What's the
>>> >> best way
>>> >> to package up a bunch of jruby code for running inside a java
>>> >> application,
>>> >> such that the jruby files can require other jruby files?
>>> >> Thanks,
>>> >> Steve
>>>
>>> Did Spring load Ruby scripts from a classpath? If so, I might have got
>>> an error from the same reason.
>>>
>>> >
>>> > What is the value of __FILE__? Even with __FILE__ set to a file: URL
>>> > of a path inside a jar file, typical Rubyisms like you indicate should
>>> > be working. If you can illustrate what is failing, that would help;
>>> > there might be a bug. Also indicate what version of JRuby you're
>>> > using. Some of the bugs related to file: URLs and paths have been
>>> > fixed in recent releases.
>>>
>>> I haven't figured out what's wrong with that, but __FILE__ doesn't
>>> work when a script is loaded from a  classpath. For example, when I
>>> set all necessary all classapths and load test/test_file.rb from the
>>> classpath, evaluation failed because the error below at the line
>>> "expect = File.read(__FILE__)[0..100]":
>>>
>>> Loaded suite -
>>> Started
>>> .................................E.......................
>>> Finished in 2.153 seconds.
>>>
>>>  1) Error:
>>> test_file_url(TestFile):
>>> Errno::ENOENT: No such file or directory - File not found - test_file.rb
>>>    test_file.rb:926:in `initialize'
>>>    test_file.rb:926:in `test_file_url'
>>>
>>> 57 tests, 293 assertions, 0 failures, 1 errors
>>>
>>> However, when I read test_file.rb from an absolute path, it worked
>>> well. This happens in trunk version as well. If this should work even
>>> when scripts are loaded from classpath, there might be a bug.
>>>
>>> -Yoko
>>>
>>> >
>>> > Cheers,
>>> > /Nick
>>> >
>>> > ---------------------------------------------------------------------
>>> > To unsubscribe from this list, please visit:
>>> >
>>> >    http://xircles.codehaus.org/manage_email
>>> >
>>> >
>>> >
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe from this list, please visit:
>>>
>>>    http://xircles.codehaus.org/manage_email
>>>
>>>
>>
>
>

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

   http://xircles.codehaus.org/manage_email