struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From developer researcher <>
Subject Re: Problem using the Spring's AOP in Struts2's Actions with json-plugin
Date Mon, 08 May 2017 19:27:32 GMT
Hello Martin,

First of all thanks for the reply, but I'm not sure if my queries have been
understood. I am using Struts

My main query is: *Is there a way to use Spring AOP in Struts2 Actions
using the "JDK dynamic proxies"? Does anyone have an example?*

Sorry, but I can not find any relationship between your answers and the
exceptions attached in my previous message:

*1. NoSuchMethodException:* The code I'm testing does not have anything
from javax.sql.DataSource

*2. OperationNotSupportedException:* Without using AOP there is no
exception for some namespace. This is very strange because the code in the
advice is simply "System.out.println ()" for testing purposes.


2017-05-06 8:21 GMT-05:00 Martin Gainty <>:

> MG>below
> ________________________________
> From: developer researcher <>
> Sent: Friday, May 5, 2017 10:09 PM
> To: Struts Users Mailing List
> Subject: Problem using the Spring's AOP in Struts2's Actions with
> json-plugin
> Hello,
> I am using Strust 2 <sp?> with spring-plugin and json-plugin to use:
> 1. Injection of dependencies: apparently everything is working well.
> 2. Spring's AOP: works when applied over methods of injected objects in
> the Struts Actions but not when applied over methods of actions (my class
> extends from ActionSupport and I use the @Action annotation at method level)
> MG>spring does not know what ActionSupport as it is a Struts classes
> besides which ActionSupport are not considered
> MG>spring beans which are simple pojos with a no-arg constructor
> reference/html/beans.html
> 7. The IoC container - Spring<
> spring/docs/current/spring-framework-reference/html/beans.html>
> As the preceding diagram shows, the Spring IoC container consumes a form
> of configuration metadata; this configuration metadata represents how you
> as an application ...
> This situation has generated the following questions:
> 1. Are the actions created and managed by Spring or Struts? It's supposed
> to be Spring, but I have this doubt because Spring's AOP is supposed to
> work on Spring beans but in my case it does not work and because I do not
> use the Spring's @Component annotation in the Action class
> MG>correct but you can also specify a spring-bean in spring-beans.xml in
> your classpath e.g.:
> <bean id="springTest" name="springTest" class="org.struts.SpringTest"/>
> 2. Is there a way to use Spring AOP in Struts2 Actions using the "JDK
> dynamic proxies"? I have tested with the following results:
> a) When Spring uses "JDK dynamic proxies" the Struts2 Action is not
> executed and the following exception is thrown: NoSuchMethodException (see
> NoSuchMethodException.txt)
> b) When Spring uses "CGLIB proxy" in an Action whose result is of the
> default type: the Action works correctly
> c) When Spring uses "CGLIB proxy" in an Action whose result is of type
> json: the Struts2 Action is executed but the following exception is thrown:
> OperationNotSupportedException (see OperationNotSupportedException.txt).
> When I do not use AOP this Action works correctly.
> MG>builder.bind does not recognise json result-set as a valid
> is an example of builder.bind
>  org.springframework.mock.jndi.SimpleNamingContextBuilder builder = new
> org.springframework.mock.jndi.SimpleNamingContextBuilder();
>  * DataSource ds = new org.springframework.jdbc.datasource.
> DriverManagerDataSource(...);
>  * builder.bind("java:comp/env/jdbc/myds", ds);
> MG>as of now JSON is not a valid javax.sql.DataSourceHere is Doc:
> <p>In a J2EE container, it is recommended to use a JNDI DataSource
> provided by
>  * the container. Such a javax.sql.DataSource can be exposed as a
> javax.sql.DataSource bean in a Spring
>  * ApplicationContext via {@link org.springframework.jndi.
> JndiObjectFactoryBean},
>  * for seamless switching to and from a local javax.sql.DataSource bean
> like this class.
>  * For tests, you can then either set up a mock JNDI environment through
> Spring's
>  * {@link org.springframework.mock.jndi.SimpleNamingContextBuilder}, or
> switch the
>  * bean definition to a local javax.sql.DataSource(which is simpler and
> thus recommended).
>  *
>  * <p>If you need a "real" connection pool outside of a J2EE container,
> consider
>  * <a href="">Apache Commons
> DBCP</a>
>  * or <a href="">C3P0</a>.
>  * Commons DBCP's BasicDataSource and C3P0's ComboPooledDataSource are full
>  * connection pool beans, supporting the same basic properties as this
> class
>  * plus specific settings (such as minimal/maximal pool size etc).
> mg>JSON is not yet a valid javax.sql.DataSource according to Spring
> MG>also you have not declared a namespace that NamingContext can reference
> which is causing exception
> Thanks

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message