We help IT Professionals succeed at work.

Calling an action class from a jar file

dreams4ever
dreams4ever asked
on
Medium Priority
273 Views
Last Modified: 2010-04-01
I have a struts application . I now add a jar file to the lib of the main struts application, the jar file  is another struts application.

Now from the main struts application I have a jsp which calls a form bean and an action class from the second jared struts application .

In my main strutsconfig .xml I have an action mapping for the second action class and the form bean definition .

When I deploy my application I get an error in my server console

<Servlet: "action" failed to preload on startup in Web application: "ABCSYSTEM".
javax.servlet.UnavailableException: Parsing error processing resource path /WEB-INF/struts-config.xml
      at org.apache.struts.action.ActionServlet.handleConfigException(ActionServlet.java:769)
      at org.apache.struts.action.ActionServlet.parseModuleConfigFile(ActionServlet.java:745)
      at org.apache.struts.action.ActionServlet.initModuleConfig(ActionServlet.java:687)
      at org.apache.struts.action.ActionServlet.init(ActionServlet.java:333)
      at javax.servlet.GenericServlet.init(GenericServlet.java:258)

Please Advice

Thanks
Comment
Watch Question

Commented:
the struts-config.xml is not parsed correctly.
Check the tag position, closing etc in the struts-config.xml file.

fargo

Author

Commented:
everythis is closed perfectly

when I add this to the form-beans definition I get this exception

<form-bean name="XYZStrutActionForm" type="com.xyz.simulator.actions.XYZStrutActionForm" />  

when I remove this line I get no exception on my server .

Thanks

Author

Commented:
>> everythis is closed perfectly
 everything is closed perfectly



CERTIFIED EXPERT
Top Expert 2006

Commented:
You need to make sure that the form-bean tag is located in the correct place in the xml file and that it is surrounded by the form-bean tag and also that the class file declared exists and is on the classpath, and that you haven't made a spelling mistake in the declaration of the type attribute, e.g.

...
<struts-config>
    <form-beans>
          <form-bean name="XYZStrutActionForm" type="com.xyz.simulator.actions.XYZStrutActionForm" />  

PS fargo, you really don't need to sign your name on every post! we know it's you by the title of the comment and it just adds redundant extra lines to the thread :-)

Author

Commented:
<form-beans >
  <form-bean name="XYZStrutActionForm" type="com.xyz.simulator.actions.XYZStrutActionForm"/>  
    <form-bean name="loginForm" type="com.abc.ltab.form.LoginForm" />
</form-beans >


The below form bean is called from the jared file . Jar file is in the proper class path. which gives the exception

  <form-bean name="XYZStrutActionForm" type="com.xyz.simulator.actions.XYZStrutActionForm"/>  

Thanks
CERTIFIED EXPERT
Top Expert 2006
Commented:
Okay. If  you are calling the form bean correctly it must mean that the bean cannot be loaded from the classpath. This could mean that the file is not present on the classpath or that there are conflicting versions on the classpath.

Please check that there are no other jars with that file in and that this file is not in the WEB-INF/classes folder either

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts

Commented:
bloodredsun, you are keeping an eye on me -:)
CERTIFIED EXPERT
Top Expert 2006

Commented:
;-)

Author

Commented:
bloodredsun
I dont have any jar files  in my WEB-INF folder

Thanks
CERTIFIED EXPERT
Top Expert 2006

Commented:
And in your WEB-INF/lib folder?

So the bean file is found at WEB-INF/classes/com/xyz/simulator/actions/XYZStrutActionForm.class

and it extends ActionForm, correct?

Author

Commented:
bloodredsun,

  I created the action class and the form bean in my main struts application and called other classes from the jar file which works perfectly

Thanks for all the comments


Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.