File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes Struts and Spring Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts and Spring" Watch "Struts and Spring" New topic
Author

Struts and Spring

A. Kosrus
Greenhorn

Joined: Apr 28, 2008
Posts: 7
Hi,
i try to integrate spring in a struts application. So the first thing was to change dtd 2.2 to

to add spring listener:

As soon as i added the listener tag context loading for my web app fails:

I don't realy understand what this exception means.

I am using java 1.4, Tomcat/4.1.36, Struts 1.x and Spring 2.x

Can anyone help?

Regards,

ak
Jimmy Clark
Ranch Hand

Joined: Apr 16, 2008
Posts: 2187
I don't see it in your post. Did you add the Spring libraries to the classpath? The stack trace you posted looks like it is coming from an XML parsing error. Make sure that your XML file do not have errors.

I am using java 1.4, Tomcat/4.1.36, Struts 1.x and Spring 2.x


If possible, upgrade Tomcat to the lastest version.
A. Kosrus
Greenhorn

Joined: Apr 28, 2008
Posts: 7
Hello James,

Originally posted by James Clark:
I don't see it in your post. Did you add the Spring libraries to the classpath? The stack trace you posted looks like it is coming from an XML parsing error. Make sure that your XML file do not have errors.

If possible, upgrade Tomcat to the lastest version.


I added spring.jar to the classpath. The parsing error only appears when i add the listener-tag to the web.xml. Without it everything is fine.
In the moment i cannot upgrade Tomcat.

Any other suggestions?

Regards,

ak
Alaa Nassef
Ranch Hand

Joined: Jan 28, 2008
Posts: 460
I think that the error is due to that you did not specify the location(s) of the spring config file(s) like this



Visit my blog: http://jnassef.blogspot.com/
A. Kosrus
Greenhorn

Joined: Apr 28, 2008
Posts: 7
Hi Alaa,

Originally posted by Alaa Nassef:
I think that the error is due to that you did not specify the location(s) of the spring config file(s) like this



i specified config location like other config files(struts-config):



Other ideas?

Regards,

ak
Alaa Nassef
Ranch Hand

Joined: Jan 28, 2008
Posts: 460
I googled a little bit and found this page, and here's what caught my attention
You need to use org.springframework.web.context.request.RequestContextListener, which is the "Listener for Servlet 2.4+ containers. Exposes the request to the current thread, through both LocaleContextHolder and RequestContextHolder"
. You are using servlet 2.3 on tomcat 4.1. I'd say to upgrade to servlet 2.4. Never used 2.3 in my life so can't help you a lot there. Hope this is the cause of your problem
A. Kosrus
Greenhorn

Joined: Apr 28, 2008
Posts: 7
Hi,

yes, i think you might be right! I will try to fix that and try again. Thank you for your help!

Regards,

ak
A. Kosrus
Greenhorn

Joined: Apr 28, 2008
Posts: 7
Hi again,

i found a solution for my problem:


This is all in web.xml. Further i added following to faces-config.xml:


Now all managed beans go to applicationContext.xml. To use the managed beans (now under Spring control) use the <id="yourBean"> in your jsp pages.

Regards,

ak
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

"Arndt K.",
Please check your private messages regarding an important administrative matter.
-Ben


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Alaa Nassef
Ranch Hand

Joined: Jan 28, 2008
Posts: 460
I believe that I once read somewhere that spring listeners don't work in J2EE 1.3 and to use filters instead. I just remembered this now
A. Kosrus
Greenhorn

Joined: Apr 28, 2008
Posts: 7
Hi,

the listener is working fine. I also removed the filter from the web.xml. The application just needs to startup Spring application context.

Regards,

ak
[ April 30, 2008: Message edited by: A. Kosrus ]
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Struts and Spring
 
Similar Threads
Unable to restart by application on Tomcat Server
problem in struts-config.xml
Problem in BeerAdvice
Problem in Struts : Error 404 : servlet action as unavailable
Error while running tomcat