Deploy to WebSphere - routing problem

I have a Rails 3.0.3 project successfully running with jRuby/Webbrick
using NetBeans 6.9.1. I need to deploy to WebSphere.

I installed a local copy of WAS 7.0 on my PC. I successfully created a
WAR file using Warbler and installed the application into WAS without
problems.

The application failed to run with a 404 missing file error.

I then figured out I need to change the web.xml.erb file to add the
servlet tags for the RackServlet. This change got me further. Now my
start page displays but I get an error at the first AJAX call invoked by
the page.

The error is:

Error 404:
com.ibm.ws.webcontainer.servlet.exception.NoTargetForURIException: No
target servlet configured

Its complaining about the URL called by the AJAX request.

Now I’m stuck. Any ideas?

I found the problem. I installed the application with the context root
“/myApp”. All of my Ajax calls work off the root, which in this case was
“/”.

I changed my Javascript code and passed in the root name so it is
prefixed to all Ajax calls. This worked although I’m not happy with the
solution.

I realize this a Javascript question, but it seems everything should
work off the root no matter how the app is deployed. Is there another
approach I can use to make this work with having to pass in the root?

On Wed, 2010-12-22 at 16:58 +0100, Ken E. wrote:

approach I can use to make this work with having to pass in the root?

If you have static string URLs in your .js files calling things like
Ajax.Request directly, then those URLs won’t magically change if you
switch context roots.

To avoid this, when I need to write javascript that calls Ajax.Request
directly, I always pass in the path and token to the function, like
this:

<%= button_to_function “my_js_function(‘#{mymodel_path(object)}’,
‘#{form_authenticity_token}’)” %>

Then, as routing changes (because of context root or otherwise),
mymodel_path(object) will cover it for me.

Also, since you are using WebSphere, you might want to check out my post
about WebSphere + DB2 + JRuby (it also covers IBM i):
http://nick.kreucher.net/blog/2010/ruby-on-rails-jruby-ibm-i-and-websphere/

  • nick