• Post Reply Bookmark Topic Watch Topic
  • New Topic

Struts2 ERROR Dispatcher Dispatcher initialization failed  RSS feed

 
Richard Carrot
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi I'm trying to get a simple struts 2 application to run using eclipse oxygen, java 9 and tomcat 8.5. Upon running tomcat I'm getting the following error:



I'm using the following filter org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter
 
Dave Tolls
Ranch Foreman
Posts: 3061
37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is the root cause:
Caused by: java.lang.ClassNotFoundException: org.apache.struts2.views.gxp.inject.InjectedObjectContainer

So, is the InjectedObjectContainer class on the class path at runtime?
Is the jar file it is in being deployed to the webapps/<your app>/WEB-INF/lib directory in Tomcat?
 
Richard Carrot
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dave Tolls wrote:
So, is the InjectedObjectContainer class on the class path at runtime?


I dont have an InjectedObjectContainer class. Not sure I understand that?

Dave Tolls wrote:Is the jar file it is in being deployed to the webapps/<your app>/WEB-INF/lib directory in Tomcat?


I downloaded Struts-2.5.13 and added all the .jars (probably don't need all them for helloWorld) to the build path. The build path contains these and

JRE System Library [jre-9.0.1]
Apache Tomcar v8.5 [Apache Tomcat v.8.5]
Web App Libraries
EAR Libraries

none of which are ticked.

cheers
 
Dave Tolls
Ranch Foreman
Posts: 3061
37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, there's this old thread from here:
https://coderanch.com/t/544629/framework/java-lang-ClassNotFoundException-org-apache

That might point you to which jar files you actually need to include.
 
Richard Carrot
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dave Tolls wrote:Well, there's this old thread from here:
https://coderanch.com/t/544629/framework/java-lang-ClassNotFoundException-org-apache

That might point you to which jar files you actually need to include.


Thanks, that did help. I have cut down the number of .jars added to WEB-INF lib however I have a new error now using the following .jars

commons-fileupload-1.3.3.jar
commons-io-2.5.jar
commons-lang-2.4.jar
commons-logging-1.1.3.jar
freemarker-2.3.23.jar
javaassist-3.20.0-GA.jar
ognl-3.1.15.jar
struts2-core-2.5.13.jar

Running Java 9 & Tomcat 8.5 with the web.xml struts 2 dispatcher filter setup like

org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter

Am now getting the following error:



Perhaps I need other .jars that I'm not aware of. I've been following a tutorial on Struts2 here
 
Richard Carrot
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok I have just added a few other jars to my build path:

Build path is as follows:

commons-fileupload-1.3.3.jar
commons-io-2.5.jar
commons-lang-2.4.jar
commons-logging-1.1.3.jar
freemarker-2.3.23.jar
javaassist-3.20.0-GA.jar
ognl-3.1.15.jar
struts2-core-2.5.13.jar
commons-lang3-3.6.jar
jcl-over-sl4j-1.7.6.jar
log4j-api-2.8.2.jar
slf4j-api-1.7.12.jar

Tomcat starts and then throws and HTTP500 file invalid path exception



 
Richard Carrot
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
newest error now as follows:

 
Dave Tolls
Ranch Foreman
Posts: 3061
37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
findjars.com can come in handy here, if only for a pointer as to which jar you might be missing.

Plugging in the missing class and I get this result page.
 
Dave Tolls
Ranch Foreman
Posts: 3061
37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Note that findjars may well be out of date (it doesn't mention the 2.5 jar in there), or maybe the class has been removed, and you have some mismatch between jar versions.
 
Richard Carrot
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have spent ages trying to get this work now. I have tried numerous configurations and I still can't get it to work.

I'm currently stuck back on a previous error that I posted.



I have tried all the filter options

  <!--   org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter -->
    <!-- org.apache.struts2.dispatcher.FilterDispatcher -->
           org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter

as I read that this has been deprecated and I should be using the last version with the latest version of struts.

I download the struts 2.3.4 package and tried to use a selection of jars from that .zip, didn't work.

I'm using the following .jars

commons-beanutils-1.9.2.jar
commons-fileupload-1.3.3.jar
commons-io-2.5.jar
commons-lang-2.4.jar
commons-lang3-3.6.jar
commons-logging-1.1.3.jar
freemarker-2.3.23.jar
javassist-3.20.0-GA.jar
jcl-over-sl4j-1.7.6.jar
log4j-api-2.8.2.jar
ognl-3.1.15.jar
sl4j-api-1.7.12.jar
struts2-core-2.5.13.jar
xwork-core-2.3.4.1-sources.jar (This .jar is not part of the latest struts \lib folder, I downloaded it separately)
asm-5.2.jar
asm-commons-5.2.jar
asm-tree-5.2.jar

Feel like I've been going round in circles for hours...
   
 
Dave Tolls
Ranch Foreman
Posts: 3061
37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Looking at that tutorial I notice there's no date for it, which is annoying as you can't tell which version of Struts it was aimed at.
2.5 only came out as a release 18 months ago, so it's possible that tutorial is out of date.
 
Richard Carrot
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dave Tolls wrote:Looking at that tutorial I notice there's no date for it, which is annoying as you can't tell which version of Struts it was aimed at.
2.5 only came out as a release 18 months ago, so it's possible that tutorial is out of date.


Yes, the tutorial is out of date. Getting the following error still:


 
Richard Carrot
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Right I have found a group of jars from an example folder that I added to the build path and tomcat has started with no immediate errors. I also land on an index.jsp however when I envoke an action from a form on the index.jsp it takes me to a 404 not found with no error message in the console. I guess that means that struts isn't really working after all. I'm very confused now. The .jars that stopped immediate tomcat errors are as follows:

commons-fileupload-1.2.2.jar
commons-io-2.0.1.jar
commons-lang-2.5.jar
commons-logging-1.1.1.jar
commons-logging-api.1.1.jar
freemarker-2.3.18.jar
javassist-3.11.0.GA.jar
ognl-3.0.4.jar
struts2-dojo-plugin-2.3.1.2.jar
xwork-core-2.3.1.2.jar
commons-lang3-3.2jar
struts2-core-2.5.13.jar

I was wondering whether anyone could shed on light on my new problem?
 
Dave Tolls
Ranch Foreman
Posts: 3061
37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You'll need to show us the URL that the browser is trying to access, and also the mapping(s) you expect it to have called.
There'll be a small mismatch somewhere.
 
Richard Carrot
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For something that should be quite straight forward getting struts to work has been a pain in the arse.

After some fishing on stackoverflow here

I found that JDK9 and struts are not friends...so I kept on trying to get this to work and downloaded JDK1.8, that didnt work either. Does anyone else have problems running with struts if they dont could someone let me know what configuration they are running please. Im back getting a SEVERE exception starting filter struts2

 
Dave Tolls
Ranch Foreman
Posts: 3061
37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your struts setup was working a couple of posts ago, at least so far as it actually starting up is concerned.

All that looked to be in error was some action mappings.
 
Dave Tolls
Ranch Foreman
Posts: 3061
37
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One thing I always try and suggest is to go to the horses mouth.
Apache are far more likely to keep their documentation and How-To's up to date than some random tutorial.

With that in mind, this is the Getting Started page at Apache for Struts.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!