• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Struts application throws error

 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I have a web dynamic Struts project which throws error on running.

Project tree:


Code snippets:
1. LoginAction



2. struts.xml:


3. web.xml



error.jsp



success.jsp:




Index.jsp


JAR files are in lib folder and configured.

However when i run the project, it gives me following error:


Struts Problem Report
Struts has detected an unhandled exception:

Messages:
File: org/apache/struts2/impl/StrutsActionProxy.java
Line number: 69


--------------------------------------------------------------------------------

Stacktraces
java.lang.NullPointerException
org.apache.struts2.impl.StrutsActionProxy.getErrorMessage(StrutsActionProxy.java:69)
com.opensymphony.xwork2.DefaultActionProxy.prepare(DefaultActionProxy.java:185)
org.apache.struts2.impl.StrutsActionProxy.prepare(StrutsActionProxy.java:63)
org.apache.struts2.impl.StrutsActionProxyFactory.createActionProxy(StrutsActionProxyFactory.java:37)
com.opensymphony.xwork2.DefaultActionProxyFactory.createActionProxy(DefaultActionProxyFactory.java:58)
org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:552)
org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:434)
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:240)
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:164)
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:462)
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:562)
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:395)
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:250)
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:188)
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:166)
org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:302)
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:885)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907)
java.lang.Thread.run(Thread.java:619)

Any help will be appreciated.


StrutsProjectExplorer.PNG
[Thumbnail for StrutsProjectExplorer.PNG]
 
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I see a couple of things wrong:
In web.xml, FilterDispatcher is deprecated. Use StrutsPrepareAndExecuteFilter.
In struts.xml, you include struts-default.xml. This is unnecessary. Your package declaration also does not declare a namespace.
 
Khushi Sing
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Joe Ess ,

Thankyou for taking time to reply.
- I modified filter class to "<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>" as you asked.
- Removed 'include file="struts-default.xml'.
- Provided name space for package '<package name="com" extends="struts-default" namespace="/">'.

Modified struts.xml:




Modified web.xml:




I still get this error:



Web container is Tomcat 7. Non-struts type web applications are running fine, problem with struts project only.
Is there anything else i need to do to run this project?
Regards
 
Joe Ess
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It looks like you are entering a URL that does not correspond to an action:

This is odd because you have a default.jsp in your project and declared as a welcome file in web.xml. Try removing the welcome files that don't exist.
I know at some point it was not possible to use a JSP (actually a servlet) as a welcome file and at some point the servlet specification permitted this, but I don't know off the top of my head which version of the specification and Tomcat allow it. Perhaps change your welcome file to a plain HTML page. Also look at your Tomcat logs to see if there is another problem preventing the application from deploying properly. Tomcat also has a built-in manager that can tell you if the application is available.
 
Khushi Sing
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I really what went wrong. Just to test,made 2 mini dynamic web page project to construct a struts app. 1 works and another does not, though methodology is same.
Working struts project configuration( helloworld application from tutorials point):
web.xml (webcontent>web-inf>web.xml)
/******web.xml code begins*********************************************************/

/********************web.xml ends*********************************/
index.jsp, welcome file configured in web.xml. File location: WebContent>index.jsp
/******************index.jsp begins*****************************/

/*******************index.jsp ends**************************************/
struts.xml. File Location: WebContent>web-inf>classes>struts.xml
/*************************struts.xml begins***********************************/

/***********************************struts.xml ends****************/
Action class, HelloWorldAction. File location: JavaResources> src>com.tutorialspoint.struts2
/*****************HelloWorldAction.java begins****************/

/***************HelloWorldAction ends****************/
HelloWorld.jsp, file location: WebContent>HelloWorld.jsp
/*****************HelloWorld begins******************/

/**************Hello World ends*********************************/
Built path for struts2 jar files in WebContent>WebINF>lib folder.
Deployed the project in web-apps folder of apache tomacat.
On running this project it runs perfectly. But when i run another mini project in same way, same configurations it does not work. i have checked for possible mistakes but they dont work...
Heres the code:
web.xml (webcontent>web-inf>web.xml)
/******web.xml*********************************************************/

/**************web.xml ends********************************/
index.jsp, welcome file configured in web.xml. File location: WebContent>index.jsp
/******************index.jsp begins*****************************/

/*********************index.jsp ends******************************/
struts.xml. File Location: WebContent>web-inf>classes>struts.xml
/*************************struts.xml begins***********************************/

/*****************struts.xml ends********************/
Action class, "ActionClass.java". File location: JavaResources> src>com.unit>ActionClass.java
/*****************ActionClass.java begins****************/

/****************ActionClass ends*****************/
Success.jsp. File location: WebContent>WEB-INF>Success.jsp
/*****************Success.jsp begins******************/

/***************Success.jsp ends*****************/

I have used same jar files in lib folder Same way of deployment. Yet it gives an error:

Why is Hello-World working and the next project isn't when done in same way..? I don't see anything wrong with Action class. I am using eclipse indigo and am not keen on using paid versions of eclipse, so available capabilities is not a very good idea. If any one can help it would be great. Thank-you.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic