aspose file tools*
The moose likes Struts and the fly likes Struts configuration issue Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts configuration issue" Watch "Struts configuration issue" New topic
Author

Struts configuration issue

M P N Vignesh
Greenhorn

Joined: Jun 07, 2005
Posts: 11
Hi all

I am configuring a struts enabled web application using ColdFusion MX. Please do not ignore this thread as it is ColdFusion, because I feel the issue I have is a generic one and could happen in any J2EE servers. I have already posted this in ColdFusion forum but I feel the issue has got to do with struts. Also please do not suggest alternatives for ColdFusion, because that is the only application server we have and I wanted to use Struts. I followed this article about Struts on ColdFusion (http://www.macromedia.com/devnet/mx/coldfusion/articles/struts.html).

After following all the configuration steps and I tried http://localhost:8500/do/welcome, I get "503 null" error. But the CF application server is running fine and it displays other pure ColdFusion pages.

I am new to struts and I feel that there is a problem in loading the ActionServlet. Following the error and configuration information, if you need more information please let me know. I would highly appreciate your help.

These are the error messages I found in the coldfusion log file:

03/06 12:13:48 error Could not pre-load servlet: action
javax.servlet.UnavailableException
at org.apache.struts.action.ActionServlet.init(ActionServlet.java:399)
at javax.servlet.GenericServlet.init(GenericServlet.java:258)
at jrun.servlet.WebApplicationService.loadServlet(WebApplicationService.java:1243)
at jrun.servlet.WebApplicationService.preloadServlets(WebApplicationService.java:790)
at jrun.servlet.WebApplicationService.postStart(WebApplicationService.java:297)
at jrun.ea.EnterpriseApplication.start(EnterpriseApplication.java:203)
at jrun.deployment.DeployerService.initModules(DeployerService.java:710)
at jrun.deployment.DeployerService.createWatchedDeployment(DeployerService.java:242)
at jrun.deployment.DeployerService.deploy(DeployerService.java:430)
at jrun.deployment.DeployerService.handleEvent(DeployerService.java:381)
at jrunx.kernel.JRunServiceDeployer.fireEvent(JRunServiceDeployer.java:710)
at jrunx.kernel.JRunServiceDeployer.deployServices(JRunServiceDeployer.java:111)
at jrunx.kernel.DeploymentService.loadServices(DeploymentService.java:46)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:1628)
at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:1523)
at jrunx.kernel.JRun.startServer(JRun.java:575)
at jrunx.kernel.JRun.<init>(JRun.java:493)
at jrunx.kernel.JRun$1.run(JRun.java:346)
at java.security.AccessController.doPrivileged(Native Method)
at jrunx.kernel.JRun.start(JRun.java:343)
at jrunx.kernel.JRun.startByNTService(JRun.java:427)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at jrunx.kernel.JRun.invoke(JRun.java:180)
at jrunx.kernel.JRun.main(JRun.java:168)

03/06 12:14:34 error
javax.servlet.UnavailableException
at org.apache.struts.action.ActionServlet.init(ActionServlet.java:399)
at javax.servlet.GenericServlet.init(GenericServlet.java:258)
at jrun.servlet.WebApplicationService.loadServlet(WebApplicationService.java:1243)
at jrun.servlet.JRunRequestDispatcher.init(JRunRequestDispatcher.java:748)
at jrun.servlet.JRunRequestDispatcher.<init>(JRunRequestDispatcher.java:98)
at jrun.servlet.WebApplicationService.getDispatcher(WebApplicationService.java:866)
at jrun.servlet.ServletEngineService$1.fetch(ServletEngineService.java:511)
at jrunx.util.Cache.get(Cache.java:116)
at jrun.servlet.ServletEngineService.dispatch(ServletEngineService.java:523)
at jrun.servlet.http.WebService.invokeRunnable(WebService.java:172)
at jrunx.scheduler.ThreadPool$DownstreamMetrics.invokeRunnable(ThreadPool.java:349)
at jrunx.scheduler.ThreadPool$ThreadThrottle.invokeRunnable(ThreadPool.java:457)
at jrunx.scheduler.ThreadPool$UpstreamMetrics.invokeRunnable(ThreadPool.java:295)
at jrunx.scheduler.WorkerThread.run(WorkerThread.java:66)

This is action-mapping excerpt of struts-config.xml:

<action-mappings>
<action path="/loginUser"
type="com.macromedia.article.actions.LoginUserAction"
name="LoginForm">
<forward name="success" path="/cfm/welcome.cfm"/>
<forward name="failure" path="/cfm/login.cfm"/>
</action>
<action path="/logoutUser"
type="com.macromedia.article.actions.LogoutUserAction">
<forward name="success" path="/cfm/login.cfm"/>
</action>
<action path="/welcome"
type="org.apache.struts.actions.ForwardAction"
parameter="/cfm/login.cfm"/>

</action-mappings>

Following is the excerpt included in the web.xml file:

<servlet>
<servlet-name>action</servlet-name>
<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/struts-config.xml</param-value>
</init-param>
<init-param>
<param-name>debug</param-name>
<param-value>2</param-value>
</init-param>
<init-param>
<param-name>detail</param-name>
<param-value>2</param-value>
</init-param>
<init-param>
<param-name>application</param-name>
<param-value>ApplicationResources</param-value>
</init-param>
<load-on-startup>2</load-on-startup>
</servlet>

<!-- Standard Action Servlet Mapping -->
<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>/do/*</url-pattern>
</servlet-mapping>

<!-- Struts Tag Library Descriptors -->
<taglib>
<taglib-uri>struts-bean</taglib-uri>
<taglib-location>/WEB-INF/lib/struts-bean.tld</taglib-location>
</taglib>

<taglib>
<taglib-uri>struts-html</taglib-uri>
<taglib-location>/WEB-INF/lib/struts-html.tld</taglib-location>
</taglib>

<taglib>
<taglib-uri>struts-logic</taglib-uri>
<taglib-location>/WEB-INF/lib/struts-logic.tld</taglib-location>
</taglib>

<taglib>
<taglib-uri>struts-nested</taglib-uri>
<taglib-location>/WEB-INF/lib/struts-nested.tld</taglib-location>
</taglib>

This is how I have configured and I am using ColdFusion MX 7.

1. Downloaded Struts 1.3.5 and placed all the struts jar files in [CfusionMX/wwwroot]/WEB-INF/lib folder.
2. Downloaded Tomcat 4.1.34 and placed servlet.jar in [CfusionMX/wwwroot]/WEB-INF/lib folder.
3. Downloaded Xalan-j 2.7.0 and placed xalan.jar in [CfusionMX/wwwroot]/WEB-INF/lib folder.
4. Downloaded Xerces-j 2.9.0 and placed xercesImpl.jar in [CfusionMX/wwwroot]/WEB-INF/lib folder.
5. Placed struts-bean.tld, struts-html.tld, struts-logic.tld, struts-nested.tld in [CfusionMX/wwwroot]/WEB-INF/tlds folder.
6. Enabled session variables using J2EE.
7. Edited web.xml as required.
8. Placed struts-config.xml in [CfusionMX/wwwroot]/WEB-INF folder.
9. Placed *.cfm files in [CfusionMX/wwwroot]/cfm folder.
10. Compiled and jarred the package of all the java classes and placed the jar file in [CfusionMX/wwwroot]/WEB-INF/lib folder.
11. Placed accounts.dat in [CfusionMX/wwwroot]/WEB-INF/classes folder.

Am I going wrong anywhere? Please help.

Vignesh
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61774
    
  67

"Vignesh M.P.N.",

There aren't many rules that you need to worry about here on the Ranch, but one that we take very seriously regards the use of proper names. Please take a look at the JavaRanch Naming Policy and adjust your display name to match it.

In particular, your display name must be a first and a last name separated by a space character, and must not be obviously fictitious.

Thanks!
bear
JavaRanch Sheriff


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
You are correct in assuming that the problem is that the Struts ActionServlet isn't initializing properly. Since I have a copy of the sourc code (so do you.. it comes with the download), I checked to see what was at lie 399, which is where the stack trace says it's failing. Here it is

From the message, it looks like you may have missed one or more of the jar files upon which the Struts jar file is dependent. Try including all the jar files in the lib directory that comes with the download.

Another observation: I checked out the article you refer to and saw that the author was using Struts version 1.0.2 - a very old version. If you can't get it to work with Struts 1.3.5, you may want to try it with an older version.

I'm afraid you're pretty much on your own on this. I've been moderating this forum for a while and haven't come across a single other person trying to use Struts with ColdFusion. You say you don't want us to try and convince you to change app servers, so I won't. I'll just remind you that Tomcat is free and runs any version of Struts without nearly so much hassle.


Merrill
Consultant, Sima Solutions
M P N Vignesh
Greenhorn

Joined: Jun 07, 2005
Posts: 11
Hi Merrill Higginson:

Thanks for your response. I shall try them and get back to you sooner.

Yes I am aware Tomcat server and have worked on them. But my company had been using ColdFusion for years and my proposal to use complete j2ee architecture was turned down. So I had convinced them to use the architecture as you saw in that article, as my background is very much in Java! Also am an intern so don't have much to say!

I am also afraid that I am the only one working on this, but I am focussed in pulling this off, else I have to settle with a complete ColdFusion solution.

Thanks for your advice.
Vignesh
M P N Vignesh
Greenhorn

Joined: Jun 07, 2005
Posts: 11
Originally posted by Bear Bibeault:
"Vignesh M.P.N.",

There aren't many rules that you need to worry about here on the Ranch, but one that we take very seriously regards the use of proper names. Please take a look at the JavaRanch Naming Policy and adjust your display name to match it.

In particular, your display name must be a first and a last name separated by a space character, and must not be obviously fictitious.

Thanks!
bear
JavaRanch Sheriff


Hi

Vignesh M.P.N. is infact my real name. "M.P.N." are my initials and this is how my name is printed in my school certificates! It is common in india to use initials rather than last name. But yes, I do have last name after coming to US, but still am recognized my by initials rather than my last name.

Thanks
Vignesh
M P N Vignesh
Greenhorn

Joined: Jun 07, 2005
Posts: 11
Originally posted by Merrill Higginson:
From the message, it looks like you may have missed one or more of the jar files upon which the Struts jar file is dependent. Try including all the jar files in the lib directory that comes with the download.


Thanks. I tried including all the jar files from struts and also referred the struts dependency document. But still I get the same error.

The error could also be because of incompatibility in the versions of the libraries?

ColdFusion MX 7 already comes with commons-beanutils.jar 1.6 and I noticed that the struts 1.3.5 comes with commons-beanutils.jar 1.7.

So I found that struts version (1.2.9) is compatible with commons-beanutils.jar 1.6. There is a confusion in this too. The manifest file of the Beanutils jar file says it is 1.6, but the struts 1.2.9 documentation says the Beanutils version is 1.7. Which one do I go by?!

Manifest-Version: 1.0
Ant-Version: Apache Ant 1.5.3
Created-By: 1.4.1_01-b01 (Sun Microsystems Inc.)
Extension-Name: org.apache.commons.beanutils
Specification-Title: Jakarta Commons Beanutils
Specification-Vendor: Apache Software Foundation
Specification-Version: 1.6
Implementation-Title: org.apache.commons.beanutils
Implementation-Vendor: Apache Software Foundation
Implementation-Version: 1.6

So now I am in the look out for all version-compatible jars.

Merrill: Am I moving in the right direction?

Thanks
Vignesh
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
You don't even know for sure that this problem is caused by a jar compatibility issue. I'd suggest trying to set it up so that you can attach your JVM to a debugger such as the one in Eclipse. That way you can step through the code in ActionServlet and find out exactly what is going wrong. If you don't know how to attach source code to the struts jar file in Eclipse, see this link.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Struts configuration issue