15 Replies Latest reply on Sep 24, 2013 10:36 AM by Alexander Babichev

    Deploy war file to WebSphere

    Jeffrey Cookle

      Thanks to Alexander in my previous post, I was able to generate a war file using jRuby on Windows.  I then tested it out using tomcat on my local machine and it works out perfectly.  For our production application servers, we use WebSphere 7 and 8. We would prefer to deploy to Websphere in our environment, which is already there, instead of setting up new servers for RhoConnect.  The war file deploys fine to websphere without errors, but when I try to run, I get the following error:

       

      org.jruby.rack.RackInitializationException: missing run or map statement from /www/INTAPP_RHO/lwi/conf/org.eclipse.osgi/bundles/198/1/bundlefile/WEB-INF/gems/gems/rack-1.5.2/lib/rack/builder.rb:133:in `to_app' from :1:in `(root)' at org.jruby.rack.RackInitializationException.wrap(RackInitializationException.java:29)

       

      I have been looking around and found a posting back in 2008 about JRuby and Websphere and possible changes needed to the web.xml.erb file to get it to work properly on Websphere => http://www.jairrillo.com/blog/2008/07/24/deploying-jruby-application-on-tomcat-glassfish-and-websphere-61/  

       

      I tried that as well and still no luck.   I will keep looking, but wondering if anyone has some ideas or has it working on websphere.

       

      Thank you!

        • Re: Deploy war file to WebSphere

          Can you do a simple test and verify that a bare-bone sinatra app is running on WebSphere? Under jruby

           

          1. Create bare-bone sinatra-based app:

          $ mkdir test_war

          $ cd test_war


          1.1 Create my_app.rb

          require "sinatra/base"

          class MyApp < Sinatra::Base

            get '/' do

              "Hello from MyApp!"

            end

            # $0 is the executed file

            # __FILE__ is the current file

            run! if __FILE__ == $0

          end

           

          1.2 Create config.ru

          require "./my_app"

          run MyApp

           

          1.3 Create Gemfile

          source 'http://rubygems.org'

          gem 'sinatra'

          gem 'warbler'

           

          1.4 Configure warbler

          $ warble config

          And replace generated 'config/warble.rb file' by

          Warbler::Config.new do |config|

          config.dirs = %w(config)

            config.includes = FileList["./*"]

            config.excludes = FileList["./*.war"]

          end

           

          2. Create war

          $ bundle

          $ bundle exec warble executable war

          and test it

          $ java -jar test_war.war

          You should see in browser url 'localhost:8080' text 'Hello from MyApp!'

           

          3. Deploy test_war.war to websphere. Do you see the same result?

            • Re: Deploy war file to WebSphere
              Jeffrey Cookle

              Good Morning Alexander, thanks for the reply.   

               

              I tried the instructions you provided above.   I was able to run the war file using java -jar test_war.war on windows.   I tried my other rhoconnect war file I was working with as well and that works also on windows using java -jar.(correction.. my rhoconnect war file using java -jar to run on windows also gets the license error I mention below).

               

              When I deploy to websphere, I get the same error I do with the rhoconnect project that it is missing the run or map statement.

               

              <!--StartFragment-->Caused by: org.jruby.exceptions.RaiseException: (RuntimeError) missing run or map statement

                at RUBY.to_app(/www/INTAPP_RHO/lwi/conf/org.eclipse.osgi/bundles/199/1/bundlefile/WEB-INF/gems/gems/rack-1.5.2/lib/rack/builder.rb:134)

                at RUBY.(root)(<web.xml>:1<!--EndFragment-->

               

              If I modify the web.xml (after it has been deployed) to something like this:

              <context-param><param-name>rackup</param-name>

              <param-value>

                  require 'rubygems'

                  require "./my_app"

                  run MyApp

                </param-value>

              </context-param>

               

              I don't see any errors in the log file, but keep getting 404 errors trying to bring up the application.  Not sure what to change the web.xml to in order for it to work properly.  I have tried other suggestions from on forums with jRuby and no  luck so far.


              I have been working with different options on this using jRuby and RhoConnect Beta.  A concern of mine is even if we get this working, on both my windows and linux environment with running the project using jRuby and Rhoconnect or with the war file deployed to WebSphere(after playing around with the web.xml) I get the error about verifying the license. jRuby just doesn't appear to work properly with RhoConnect   It seems that openssl/jruby-openssl is having an issue with decrypting the license and stops the process. 

              C:/jruby-1.7.4/lib/ruby/gems/shared/gems/rack-1.5.2/lib/rack/builder.rb:40:in `parse_file'

              C:/jruby-1.7.4/lib/ruby/gems/shared/gems/rack-1.5.2/lib/rack/server.rb:277:in `build_app_and_options_from_config'

              C:/jruby-1.7.4/lib/ruby/gems/shared/gems/rack-1.5.2/lib/rack/server.rb:199:in `app'

              C:/jruby-1.7.4/lib/ruby/gems/shared/gems/rack-1.5.2/lib/rack/server.rb:314:in `wrapped_app'

              C:/jruby-1.7.4/lib/ruby/gems/shared/gems/rack-1.5.2/lib/rack/server.rb:250:in `start'

              C:/jruby-1.7.4/lib/ruby/gems/shared/gems/rack-1.5.2/lib/rack/server.rb:141:in `start'

              org/jruby/RubyKernel.java:1073:in `load'

              C:\jruby-1.7.4\bin\rackup:23:in `(root)'

              Rhoconnect::LicenseException: Error verifying license.

                                       initialize at C:/jruby-1.7.4/lib/ruby/gems/shared/gems/rhoconnect-4.0.0.beta.24/lib/rhoconnect/license.rb:37

                                        bootstrap at C:/jruby-1.7.4/lib/ruby/gems/shared/gems/rhoconnect-4.0.0.beta.24/lib/rhoconnect.rb:119

                                           (root) at C:/jruby-1.7.4/lib/ruby/gems/shared/gems/rhoconnect-4.0.0.beta.24/lib/rhoconnect/application/init.rb:31

                                          require at org/jruby/RubyKernel.java:1054

                                           (root) at C:/Rhoprojects/plantdev/rhoconnect_jruby/config.ru:1

                                    instance_eval at org/jruby/RubyBasicObject.java:1735

                                  new_from_string at C:/Rhoprojects/plantdev/rhoconnect_jruby/config.ru:2

                                       initialize at C:/jruby-1.7.4/lib/ruby/gems/shared/gems/rack-1.5.2/lib/rack/builder.rb:55

               

              Thank you for your assistance and let me know if you have any additional thoughts on the web.xml.

                • Re: Deploy war file to WebSphere

                  Your results shows that the problem is not in war file, but in WebSphere configuration. I have zero experience with that server, but I can guess that server routes all requests to some other place and you see 404 errors. On Tomcat to run rhoconnect app you need to make it be the default app. Probably, you should to the same with WebSphere. I think you know better then me how to do it.

                    • Re: Deploy war file to WebSphere
                      Jeffrey Cookle

                      Hi,  would you be able to assist with the other error, the license file error?  That error appears when running the rhoconnect war file with java -jar, like you had me test above, or when I create a new project with RhoConnect and JRuby and try to run it, or when I build the war file and attempt to deploy that in Websphere.    Just wondering if anybody else is encountering this issue.  If you create a new RhoConnect application, create a model, start redis, and then rhoconnect all within jRuby, you get the license error, same as when I create a war file and deploy.     If I can resolve this issue, then I feel I can use my modified web.xml and get it to work.

                       

                      Thanks!

                        • Re: Deploy war file to WebSphere

                          I wish I knew how to reproduce license issue you encountered.

                           

                          I have jruby-1.7.4, and rhoconnect (4.0.0.beta.63) with all deps. Here are my steps:

                           

                          $ rvm use jruby

                          $ rhoconnect app rhoapp

                          $ cd rhoapp

                          $ rhoconnect war

                          $ java -jar rhoapp.war

                           

                          Then in browser I see rhoconnect console at http://localhost:8080/console with default 10 licenses and no issues at all.

                            • Re: Deploy war file to WebSphere
                              Jeffrey Cookle

                              I am not sure then.  That is exactly what I do on either our Linux x86, Linux power, or Windows 7 environment and get the same error across those, even if I create the project from scratch on each one.  I was using beta 24 and switched to the 4.0.0 recently with JRuby 1.7.4 and jdk1.6.0_31 and also tried jdk1.7.0_40. 

                               

                              Can I ask what version of Java are you running on and are you 32 or 64?  And what OS? 

                               

                              Thanks

                                • Re: Deploy war file to WebSphere

                                  I use Mac OS X with the following java and jruby:

                                   

                                  $ java -version

                                  java version "1.6.0_51"

                                  Java(TM) SE Runtime Environment (build 1.6.0_51-b11-457-11M4509)

                                  Java HotSpot(TM) 64-Bit Server VM (build 20.51-b01-457, mixed mode)

                                  $ ruby -v

                                  jruby 1.7.4 (1.9.3p392) 2013-05-16 2390d3b on Java HotSpot(TM) 64-Bit Server VM 1.6.0_51-b11-457-11M4509 [darwin-x86_64]

                                   

                                  On Fedora 19 I have both OpenJDK and Oracle JDK. If i select OpenJDK, then no license problems:

                                  $ java -version
                                    java version "1.7.0_40"
                                    OpenJDK Runtime Environment (fedora-2.4.2.1.fc19-x86_64 u40-b60)
                                    OpenJDK 64-Bit Server VM (build 24.0-b56, mixed mode)
                                   
                                  $ rhoconnect start

                                    ...
                                    Starting rhoconnect in jruby environment...
                                    [5459][05:20:52.041 PM 2013-09-20] Rhoconnect Server v4.0.0.beta.63 started...
                                    [5459][05:20:52.888 PM 2013-09-20] No `package.json` detected, disabling
                                    JavaScript support.
                                    Puma 1.6.3 starting...
                                    * Min threads: 0, max threads: 16
                                    * Environment: development
                                    * Listening on tcp://0.0.0.0:9292

                                   

                                  But if select Oracle JDK, then I have problems:

                                  $ java -version
                                    java version "1.7.0_40"
                                    Java(TM) SE Runtime Environment (build 1.7.0_40-b43)
                                    Java HotSpot(TM) 64-Bit Server VM (build 24.0-b56, mixed mode)
                                   
                                  $ rhoconnect start

                                    ...
                                    Starting rhoconnect in jruby environment...
                                    [5551][05:22:43.313 PM 2013-09-20] Rhoconnect Server v4.0.0.beta.63 started...
                                    [5551][05:22:44.411 PM 2013-09-20] Illegal key size or default parameters: possibly you need to install Java Cryptography Extension
                                    (JCE) Unlimited Strength Jurisdiction Policy Files for your JRE
                                    [5551][05:22:44.411 PM 2013-09-20]
                                    org/jruby/ext/openssl/Cipher.java:684:in `update'
                                    /home/shura/.rvm/gems/jruby-1.7.4/gems/rhoconnect-4.0.0.beta.63/lib/rhoconnect/license.rb:81:in
                                    `_decrypt'
                                    /home/shura/.rvm/gems/jruby-1.7.4/gems/rhoconnect-4.0.0.beta.63/lib/rhoconnect/license.rb:33:in
                                    `initialize'
                                    /home/shura/.rvm/gems/jruby-1.7.4/gems/rhoconnect-4.0.0.beta.63/lib/rhoconnect.rb:120:in
                                    `bootstrap'
                                    /home/shura/.rvm/gems/jruby-1.7.4/gems/rhoconnect-4.0.0.beta.63/lib/rhoconnect/application/init.rb:31:in
                                    `(root)'
                                    org/jruby/RubyKernel.java:1054:in `require'
                                    /home/shura/tmp/jrhoapp/config.ru:1:in `(root)'
                                    org/jruby/RubyBasicObject.java:1735:in `instance_eval'
                                    /home/shura/tmp/jrhoapp/config.ru:2:in `new_from_string'
                                    /home/shura/.rvm/gems/jruby-1.7.4/gems/rack-1.5.2/lib/rack/builder.rb:55:in
                                    `initialize'
                                    org/jruby/RubyKernel.java:1093:in `eval'
                                    /home/shura/tmp/jrhoapp/config.ru:0:in `new_from_string'
                                    /home/shura/.rvm/gems/jruby-1.7.4/gems/rack-1.5.2/lib/rack/builder.rb:49:in
                                    `new_from_string'
                                    /home/shura/.rvm/gems/jruby-1.7.4/gems/rack-1.5.2/lib/rack/builder.rb:40:in
                                    `parse_file'
                                    /home/shura/.rvm/gems/jruby-1.7.4/gems/rack-1.5.2/lib/rack/server.rb:277:in
                                    `build_app_and_options_from_config'
                                    /home/shura/.rvm/gems/jruby-1.7.4/gems/rack-1.5.2/lib/rack/server.rb:199:in
                                    `app'
                                    /home/shura/.rvm/gems/jruby-1.7.4/gems/rack-1.5.2/lib/rack/server.rb:314:in
                                    `wrapped_app'
                                    /home/shura/.rvm/gems/jruby-1.7.4/gems/rack-1.5.2/lib/rack/server.rb:250:in
                                    `start'
                                    /home/shura/.rvm/gems/jruby-1.7.4/gems/rack-1.5.2/lib/rack/server.rb:141:in
                                    `start'
                                    org/jruby/RubyKernel.java:1073:in `load'
                                    /home/shura/.rvm/gems/jruby-1.7.4/gems/rack-1.5.2/bin/rackup:4:in `(root)'
                                    org/jruby/RubyKernel.java:1093:in `eval'
                                    /home/shura/.rvm/gems/jruby-1.7.4/bin/ruby_noexec_wrapper:14:in `(root)'
                                    Rhoconnect::LicenseException: Error verifying license.
                                                              initialize at
                                    /home/shura/.rvm/gems/jruby-1.7.4/gems/rhoconnect-4.0.0.beta.63/lib/rhoconnect/license.rb:37
                                                               bootstrap at
                                    /home/shura/.rvm/gems/jruby-1.7.4/gems/rhoconnect-4.0.0.beta.63/lib/rhoconnect.rb:120
                                                                  (root) at
                                    /home/shura/.rvm/gems/jruby-1.7.4/gems/rhoconnect-4.0.0.beta.63/lib/rhoconnect/application/init.rb:31
                                                                 require at org/jruby/RubyKernel.java:1054
                                                                  (root) at /home/shura/tmp/jrhoapp/config.ru:1
                                                           instance_eval at org/jruby/RubyBasicObject.java:1735
                                                         new_from_string at /home/shura/tmp/jrhoapp/config.ru:2
                                                              initialize at
                                    /home/shura/.rvm/gems/jruby-1.7.4/gems/rack-1.5.2/lib/rack/builder.rb:55
                                                                    eval at org/jruby/RubyKernel.java:1093
                                                         new_from_string at /home/shura/tmp/jrhoapp/config.ru:0
                                                         new_from_string at
                                    /home/shura/.rvm/gems/jruby-1.7.4/gems/rack-1.5.2/lib/rack/builder.rb:49
                                                              parse_file at
                                    /home/shura/.rvm/gems/jruby-1.7.4/gems/rack-1.5.2/lib/rack/builder.rb:40
                                       build_app_and_options_from_config at
                                    /home/shura/.rvm/gems/jruby-1.7.4/gems/rack-1.5.2/lib/rack/server.rb:277
                                                                     app at
                                    /home/shura/.rvm/gems/jruby-1.7.4/gems/rack-1.5.2/lib/rack/server.rb:199
                                                             wrapped_app at
                                    /home/shura/.rvm/gems/jruby-1.7.4/gems/rack-1.5.2/lib/rack/server.rb:314
                                                                   start at
                                    /home/shura/.rvm/gems/jruby-1.7.4/gems/rack-1.5.2/lib/rack/server.rb:250
                                                                   start at
                                    /home/shura/.rvm/gems/jruby-1.7.4/gems/rack-1.5.2/lib/rack/server.rb:141
                                                                    load at org/jruby/RubyKernel.java:1073
                                                                  (root) at
                                    /home/shura/.rvm/gems/jruby-1.7.4/gems/rack-1.5.2/bin/rackup:4
                                                                    eval at org/jruby/RubyKernel.java:1093
                                                                  (root) at
                                    /home/shura/.rvm/gems/jruby-1.7.4/bin/ruby_noexec_wrapper:14

                                    • Re: Deploy war file to WebSphere
                                      Jeffrey Cookle

                                      Thanks Alexander for verifying that there is an issue with JRuby and Oracle JDK and RhoConnect.

                                       

                                      So, does that mean that the documentation is incorrect with JRuby and RhoConnect and that it only works with Open JDK for all platforms?    Will this get resolved soon to work with Oracle JDK?

                                        • Re: Deploy war file to WebSphere

                                          Rhoconnect works perfectly fine with Oracle JDK and JRuby only if Unlimited Strength Java(TM) Cryptography Extension Policy Files installed.

                                          In my case (JDK7) I downloaded UnlimitedJCEPolicyJDK7.zip file and copied policy files to JDK security directory:

                                          $ cp local_policy.jar $JAVA_HOME/jre/lib/security

                                          $ cp US_export_policy.jar $JAVA_HOME/jre/lib/security


                                          As soon as you do the same steps, your problems with license will be gone.

                                           

                                          Open Java and JDK packaged for Mac include strong policy files, but Oracle one not.

                                          I'll update docs and make a note about jce policy files.

                                            • Re: Deploy war file to WebSphere
                                              Jeffrey Cookle

                                              ***I posted this earlier this morning, but may have found a combination that works on windows to get around this, I will get back to you***

                                               

                                              On Windows, RhoConnects gives you that message that you need to install the Unlmited Strength for Java.  I had downloaded both Java 6 and 7 patches for Oracle JDK and applied them earlier while trying to get this working. 

                                               

                                              I decided to reinstall several of my Oracle JDK's that JRuby was using and got the the message that I needed to install the unlimited strength for Java after running my project.  I then applied the patch and still get the following license error on Windows, doesn't seem to make a difference if I installed JDK 6/7 and applied patches for either of those.  I will see if I apply the jce patch on Linux if that helps.

                                               

                                              [9224][04:59:35.966 AM 2013-09-23] Given final block not properly padded

                                              [9224][04:59:35.967 AM 2013-09-23] org/jruby/ext/openssl/Cipher.java:757:in `final'

                                              C:/jruby-1.7.4/lib/ruby/gems/shared/gems/rhoconnect-4.0.0/lib/rhoconnect/license.rb:82:in `_decrypt'

                                              C:/jruby-1.7.4/lib/ruby/gems/shared/gems/rhoconnect-4.0.0/lib/rhoconnect/license.rb:33:in `initialize'

                                              C:/jruby-1.7.4/lib/ruby/gems/shared/gems/rhoconnect-4.0.0/lib/rhoconnect.rb:117:in `bootstrap'

                                              C:/jruby-1.7.4/lib/ruby/gems/shared/gems/rhoconnect-4.0.0/lib/rhoconnect/application/init.rb:31:in `(root)'

                                              org/jruby/RubyKernel.java:1054:in `require'

                                              C:/Rhoprojects/plantdev/rhoconnect_jruby/config.ru:1:in `(root)'

                                              org/jruby/RubyBasicObject.java:1735:in `instance_eval'

                                              C:/Rhoprojects/plantdev/rhoconnect_jruby/config.ru:2:in `new_from_string'

                                              C:/jruby-1.7.4/lib/ruby/gems/shared/gems/rack-1.5.2/lib/rack/builder.rb:55:in `initialize'

                                              org/jruby/RubyKernel.java:1093:in `eval'

                                              C:/Rhoprojects/plantdev/rhoconnect_jruby/config.ru:0:in `new_from_string'

                                              C:/jruby-1.7.4/lib/ruby/gems/shared/gems/rack-1.5.2/lib/rack/builder.rb:49:in `new_from_sRhoconnect::LicenseException: Error verifying license.

                                                                       initialize at C:/jruby-1.7.4/lib/ruby/gems/shared/gems/rhoconnect-4.0.0/lib/rhoconnect/license.rb:37

                                                                        bootstrap at C:/jruby-1.7.4/lib/ruby/gems/shared/gems/rhoconnect-4.0.0/lib/rhoconnect.rb:117

                                                                           (root) at C:/jruby-1.7.4/lib/ruby/gems/shared/gems/rhoconnect-4.0.0/lib/rhoconnect/application/init.rb:31

                                               

                                               

                                              Thank you

                                                • Re: Deploy war file to WebSphere

                                                  I was able to run rhoconnect on windows 7. The main perk was white spaces in user account I used. When I created another account without whites, I got app running (openssl fails to find java some bouncycastle classes).

                                                  Here's a link to doc: 

                                                  https://docs.google.com/document/d/1croYH5blbAAiO7cP_TvxX85gBT8qkRx8ZTU5xHGcHTM/pub

                                                    • Re: Deploy war file to WebSphere
                                                      Jeffrey Cookle


                                                      Thanks, I was finally able to get it to work on Windows 7 by applying the patch on all JDK's (1.7 and 1.6) that were on my machine.  So, it has to be the configuration on my machine. JRuby said it was associated to the 1.6 but my home was 1.7.   I will also test out your approach.


                                                      I was also able to get the sample Sinatra application working on Websphere using this as the web.xml:

                                                       

                                                      <?xml version="1.0" encoding="UTF-8"?><web-app id="WebApp_ID" version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">

                                                      <context-param>
                                                        <param-name>rackup</param-name>
                                                        <param-value>
                                                             require "./my_app"
                                                             run MyApp
                                                        </param-value>
                                                      </context-param>


                                                        <listener>
                                                          <listener-class>org.jruby.rack.RackServletContextListener</listener-class>
                                                        </listener>

                                                        <servlet> 
                                                          <servlet-name>Rails</servlet-name> 
                                                          <servlet-class>org.jruby.rack.RackServlet</servlet-class> 
                                                        </servlet> 
                                                       
                                                        <servlet-mapping> 
                                                          <servlet-name>Rails</servlet-name> 
                                                          <url-pattern>/*</url-pattern> 
                                                        </servlet-mapping>
                                                       
                                                        <listener>
                                                          <listener-class>org.jruby.rack.RackServletContextListener</listener-class>
                                                        </listener>
                                                      </web-app>

                                                       

                                                       

                                                      I am waiting for our Linux group to apply the JCE patch on the JDK on that box before I can continue with JRuby on Linux, but am working on getting the JRuby RhoConnect war file working on websphere.  Getting close using the example above.

                                                       

                                                      Making progress.  Thanks!

                                                  • Re: Deploy war file to WebSphere
                                                    Jeffrey Cookle

                                                    Success with RhoConnect on WebSphere.  Just need to start testing, here is the web.xml below.    If we can get redis as a deployable war file, that would really help out our environment and keep everything running in websphere at each location.  

                                                     

                                                     

                                                     

                                                    <?xml version="1.0" encoding="UTF-8"?><web-app>

                                                     

                                                    <context-param><param-name>rackup</param-name>

                                                     

                                                    <param-value>

                                                     

                                                    require 'rubygems'

                                                     

                                                    require 'rhoconnect/application/init'

                                                    run Rhoconnect.app

                                                     

                                                    </param-value>

                                                     

                                                    </context-param>

                                                     

                                                      

                                                     

                                                    <listener>

                                                     

                                                    <listener-class>org.jruby.rack.RackServletContextListener</listener-class>

                                                     

                                                    </listener>

                                                     

                                                    <servlet>

                                                     

                                                    <servlet-name>Rails</servlet-name>

                                                     

                                                    <servlet-class>org.jruby.rack.RackServlet</servlet-class>

                                                     

                                                    </servlet>

                                                     

                                                     

                                                     

                                                    <servlet-mapping>

                                                     

                                                    <servlet-name>Rails</servlet-name>

                                                     

                                                    <url-pattern>/*</url-pattern>

                                                     

                                                    </servlet-mapping>

                                                     

                                                     

                                                     

                                                    <listener>

                                                     

                                                    <listener-class>org.jruby.rack.RackServletContextListener</listener-class>

                                                     

                                                    </listener>

                                                     

                                                    </web-app>