Jruby: How to change the application url in war file deployed on glassfish server

266 views Asked by At

I have deployed application on glassfish server. my application is accessible using url localhost:8080/test

Below is the setting in my warble.rb file

Warbler::Config.new do |config|
  config.jar_name = 'test'
  config.webxml.jruby.min.runtimes = 2
  config.webxml.jruby.max.runtimes = 10
  config.includes = FileList['init.rb']
end

The above setting create war file with name "test.war" and so it the application url i.e localhost:8080/test . what i want is i want to keep the file name as it is i.e it should be "test.war" but the application url should be localhost:8080/test_application instead of localhost:8080/test

1

There are 1 answers

0
Rich Drummond On

From the Glassfish Application Deployment Guide (PDF)

When you deploy a web module, if you do not specify a context root, the default is the name of the WAR file without the .war extension. The web module context root must be unique within the server instance.

If you want to change the context root, you must do this in your deployment descriptor. There are several ways to do that, but with warbler the easiest is probably the following (although it is specific to Glassfish).

  1. Create a file called 'glassfish-web.xml' in your Rails application root. It should have the following content:

    <!DOCTYPE glassfish-web-app PUBLIC "-//GlassFish.org//DTD GlassFish Application Server 3.1 Servlet 3.0//EN" "http://glassfish.org/dtds/glassfish-web-app_3_0-1.dtd">
    <glassfish-web-app>
      <context-root>test_application</context-root>
    </glassfish-web-app>
    
  2. Add the following to your warbler config (warble.rb) to ensure that this file gets packaged into your application war's WEB-INFO directory:

    config.webinf_files += FileList["glassfish-web.xml"]
    
  3. Re-warble your application and re-deploy.

  4. It should now be accessible at localhost:8080/test_application.