Forum: JRuby Require java class seems to fail when dploying as .war

Posted by Maarten Mortier (maartenm)
on 2010-03-03 11:11
(Received via mailing list)
Dir["lib/extensions/*.jar"].each do |jar|
     puts jar
     val = require jar
     puts val.to_s
end

require 'lib/classes.jar'

require 'exceptions'

class ApplicationController < ActionController::Base
  include Java
  include Exceptions
  #include_class 'MIPS'
  java_import 'MyClass'


1. When I don't use a .war file but deploy from an Eclipse Tomcat 
server, I get:

INFO: Server startup in 9572 ms
lib/extensions/aia.jar

lib/extensions/base.jar

lib/extensions/esboegen.jar

lib/extensions/o4glrt.jar

lib/extensions/o4glrth.jar

As you can see, no "false" or "true" is printed.
But, everything works.

2. When I deploy as .war file under Tomcat,

I get "true" for each of these requires printed as well.
And I get the error that "MyClass" could not be linked because of a
missing dependency (it seems as if the requires didn't work and the
classes are not loaded as ruby extensions).


Does anybody know what's going on? Is the wrong 'require' used when
deployed as .war file or something?

--
Maarten

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

    http://xircles.codehaus.org/manage_email
Posted by Justin Coyne (justincoyne)
on 2010-03-03 14:31
(Received via mailing list)
I think I know what's going on here.  Your working directory when
running under tomcat is not what you assume it is.  You need to set
the lib paths relative to the context root.  I think you can find this
set as a java property.

-Justin


On Wed, Mar 3, 2010 at 4:11 AM, Maarten Mortier
<maarten.mortier@gmail.com> wrote:
> class ApplicationController < ActionController::Base
>
>
>
> --
> Maarten
>
> ---------------------------------------------------------------------
> 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
Posted by Charles Nutter (headius)
on 2010-03-03 14:49
(Received via mailing list)
On Wed, Mar 3, 2010 at 7:31 AM, Justin Coyne <digger250@gmail.com> 
wrote:
> I think I know what's going on here.  Your working directory when
> running under tomcat is not what you assume it is.  You need to set
> the lib paths relative to the context root.  I think you can find this
> set as a java property.

Another option would be putting the jar files in the normal WAR file
location (WEB-INF/lib) so they'll be picked up by Tomcat
automatically. In that case, you would not do the jar requires.

I'm not sure of the current recommendation for how to have both
command-line and WAR-file deploys work the same without a lot of
fiddling with jar requires and classpath, though.

- Charlie

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

    http://xircles.codehaus.org/manage_email
Posted by Maarten Mortier (maartenm)
on 2010-03-03 15:41
(Received via mailing list)
It worked by configuring them explictly in warble.rb.

There were several subdirectories in (WEB-INF/)lib that contained the 
.jar's.
These subdirectories were also copied into the .war file, so I thought
I did not have to explictly add them in the warble.rb config file.
I was wrong, you need to add jars of all subdirectories there too.

Thank you,

On Wed, Mar 3, 2010 at 2:48 PM, Charles Oliver Nutter
<headius@headius.com> wrote:
> I'm not sure of the current recommendation for how to have both
>
>

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

    http://xircles.codehaus.org/manage_email
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.