You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by rocks <de...@yahoo.com> on 2010/05/21 19:05:45 UTC
Struts2+Spring2+Interceptor+Invalid action class configuration that
references an unknown class named
Dear,
Apologize the posting same subject, but I did not find any solution so far.
I am developing a web application based on struts 2.1.8.1+ spring 2+
hibernate 3 + tomcat 5.5. There is requisite library like
struts2-convention-plugin-2.1.8.1.jar in my classpath.
For authentication I am using struts interceptor.
Below are my configuration files.
struts.xml :=
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<constant name="struts.objectFactory" value="spring" />
<constant name="struts.devMode" value="false" />
<constant name="struts.action.extension" value="do"/>
<constant name="struts.objectFactory.spring.autoWire"
value="AUTOWIRE_BY_NAME"/>
<!-- Add packages here -->
<package name="dafault" extends="struts-default">
<result-types>
<result-type name="tiles"
class="org.apache.struts2.views.tiles.TilesResult" />
</result-types>
<interceptors>
<interceptor name="loginInterceptor"
class="com.ncr.framework.interceptor.LoginInterceptor"/>
<interceptor-stack name="capabilityStack">
<interceptor-ref name="defaultStack"/>
<interceptor-ref name="loginInterceptor"/>
</interceptor-stack>
</interceptors>
<default-interceptor-ref name="capabilityStack"/>
<action name="logon" class="loginAction" method="execute">
<result name="success" type="tiles">page.Login</result>
</action>
</package>
</struts>
applicationContext.xml :-
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans SYSTEM "WEB-INF/spring-beans-2.0.dtd">
<beans>
<bean id="loginAction" scope="prototype"
class="com.ncr.user.actions.LoginAction">
<constructor-arg ref="adminService" />
</bean>
</beans>
LoginInterceptor.java
public class LoginInterceptor extends AbstractInterceptor {
public String intercept(ActionInvocation invocation) throws Exception {
ActionContext context = invocation.getInvocationContext();
Map<String, Object> contextMap = context.getContextMap();
HttpServletRequestWrapper request = (HttpServletRequestWrapper) contextMap
.get(HTTP_REQUEST);
synchronized (request) {
ThreadContext.setRequest(request);
UserInfo userInfo = UserContext.getCurrentUserInfo();
if (userInfo == null
&& !"authenticate".equals(contextMap.get(ACTION_NAME))) {
return "logon";
}
return invocation.invoke();
}
}}
When I hit url http://localhost:8080/mytest/logon.do it throws an error.
java.lang.RuntimeException: Invalid action class configuration that
references an unknown class named [loginAction]
org.apache.struts2.convention.ConventionsServiceImpl.determineResultPath(ConventionsServiceImpl.java:100)
org.apache.struts2.convention.ConventionUnknownHandler.determinePath(ConventionUnknownHandler.java:385)
org.apache.struts2.convention.ConventionUnknownHandler.handleUnknownResult(ConventionUnknownHandler.java:274)
com.opensymphony.xwork2.DefaultUnknownHandlerManager.handleUnknownResult(DefaultUnknownHandlerManager.java:76)
com.opensymphony.xwork2.DefaultActionInvocation.createResult(DefaultActionInvocation.java:215)
com.opensymphony.xwork2.DefaultActionInvocation.executeResult(DefaultActionInvocation.java:356)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:266)
com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:165)
As per my investigation, I found that ClassLoaderUtils's below method could
not return class name for 'loginAction'. There should be some way for to map
'loginAction' to the class com.ncr.user.actions.LoginAction.
public static Class loadClass(String className, Class callingClass)
throws ClassNotFoundException {
try {
return Thread.currentThread().getContextClassLoader().loadClass(
className);
} catch (ClassNotFoundException e) {
try {
return Class.forName(className);
} catch (ClassNotFoundException ex) {
try {
return ClassLoaderUtils.class.getClassLoader().loadClass(
className);
} catch (ClassNotFoundException exc) {
return callingClass.getClassLoader().loadClass(className);
}
}
}
}
When I remove the entry '<default-interceptor-ref name="capabilityStack"/>'
from struts.xml then it's working perfectly fine i.e desired page is coming.
I also noticed that in the classes variable of
Thread.currentThread().getContextClassLoader()(WebappClassLoader) which is
private contains class com.ncr.user.actions.LoginAction but i did not find
any way to get it.
Your kind guesture is appreciated.
-Dev
--
View this message in context: http://old.nabble.com/Struts2%2BSpring2%2BInterceptor%2BInvalid-action-class-configuration-that-references-an-unknown-class-named-tp28636590p28636590.html
Sent from the Struts - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Struts2+Spring2+Interceptor+Invalid action class configuration
that references an unknown class named
Posted by rocks <de...@yahoo.com>.
Thanks Wes for reply. I figured out that we can only forward to jsp not to
action from interceptor.
So Now I am forwarding to jsp from interceptor and it's working fine. Below
is my changed code in struts.xml and LoginInterceptor.java.
<p>[code]
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<constant name="struts.objectFactory" value="spring" />
<constant name="struts.action.extension" value="do"/>
<constant name="struts.objectFactory.spring.autoWire"
value="AUTOWIRE_BY_NAME"/>
<!-- Add packages here -->
<package name="dafault" extends="struts-default">
<result-types>
<result-type name="tiles"
class="org.apache.struts2.views.tiles.TilesResult" />
</result-types>
<interceptors>
<interceptor name="loginInterceptor"
class="com.ncr.framework.interceptor.LoginInterceptor"/>
<interceptor-stack name="capabilityStack">
<interceptor-ref name="defaultStack"/>
<interceptor-ref name="loginInterceptor"/>
</interceptor-stack>
</interceptors>
<default-interceptor-ref name="capabilityStack"/>
<global-results>
<result name="loginPage" type="tiles">page.Login</result>
</global-results>
<action name="logon" class="loginAction" method="execute">
<result name="success" type="tiles">page.Login</result>
</action>
</package>
</struts>
LoginInterceptor.java
public class LoginInterceptor extends AbstractInterceptor {
public String intercept(ActionInvocation invocation) throws Exception {
ActionContext context = invocation.getInvocationContext();
Map<String, Object> contextMap = context.getContextMap();
HttpServletRequestWrapper request =
(HttpServletRequestWrapper) contextMap
.get(HTTP_REQUEST);
synchronized (request) {
ThreadContext.setRequest(request);
UserInfo userInfo =
UserContext.getCurrentUserInfo();
if (userInfo == null
&&
!"authenticate".equals(contextMap.get(ACTION_NAME))) {
return "logonPage";
}
return invocation.invoke();
}
}}
<p>
Regards,
Devendra
Wes Wannemacher wrote:
>
> On Tue, May 25, 2010 at 8:47 AM, rocks <de...@yahoo.com>
> wrote:
>> Martin,
>>
>> I haven't get any response from Wes [:(].
>>
>
> Sorry I didn't notice that I was being called out directly :)... I was
> out of town, in a magical place that my children really enjoyed, but
> unfortunately charged $9.99 / day for internet access[1]
>
> I am still trying to catch up on a lot of email (it's amazing how far
> behind you can get on email when you're cut off for only a few days).
> I haven't read your message thoroughly, and I can't promise that I
> will right away. But, I do have an example that might help[2]. If it
> doesn't help, post back here, there are tons of users on this list
> combining struts2, spring and hibernate. If you didn't get many
> responses before, you probably haven't posted enough details or the
> description of your problem was too vague.
>
> [1]
> http://disneyworld.disney.go.com/resorts/contemporary-resort/services-amenities/
> [2]
> http://code.google.com/p/struts2inpractice/source/browse/#svn/trunk/ch04ex01
> (check the ch04ex01 project)
>
> -Wes
> --
> Wes Wannemacher
>
> Head Engineer, WanTii, Inc.
> Need Training? Struts, Spring, Maven, Tomcat...
> Ask me for a quote!
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
>
--
View this message in context: http://old.nabble.com/Struts2%2BSpring2%2BInterceptor%2BInvalid-action-class-configuration-that-references-an-unknown-class-named-tp28636590p28680342.html
Sent from the Struts - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Struts2+Spring2+Interceptor+Invalid action class configuration
that references an unknown class named
Posted by Wes Wannemacher <we...@wantii.com>.
On Tue, May 25, 2010 at 8:47 AM, rocks <de...@yahoo.com> wrote:
> Martin,
>
> I haven't get any response from Wes [:(].
>
Sorry I didn't notice that I was being called out directly :)... I was
out of town, in a magical place that my children really enjoyed, but
unfortunately charged $9.99 / day for internet access[1]
I am still trying to catch up on a lot of email (it's amazing how far
behind you can get on email when you're cut off for only a few days).
I haven't read your message thoroughly, and I can't promise that I
will right away. But, I do have an example that might help[2]. If it
doesn't help, post back here, there are tons of users on this list
combining struts2, spring and hibernate. If you didn't get many
responses before, you probably haven't posted enough details or the
description of your problem was too vague.
[1] http://disneyworld.disney.go.com/resorts/contemporary-resort/services-amenities/
[2] http://code.google.com/p/struts2inpractice/source/browse/#svn/trunk/ch04ex01
(check the ch04ex01 project)
-Wes
--
Wes Wannemacher
Head Engineer, WanTii, Inc.
Need Training? Struts, Spring, Maven, Tomcat...
Ask me for a quote!
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
RE: Struts2+Spring2+Interceptor+Invalid action class configuration
that references an unknown class named
Posted by rocks <de...@yahoo.com>.
Martin,
I haven't get any response from Wes [:(].
Guys,
Please let me know if any one has clue on the below issue.
Regards,
Devendra
mgainty wrote:
>
>
> Devendra
>
>
>
> did you contact the local struts resource as suggested..?
>
> Martin--
> ______________________________________________
> Verzicht und Vertraulichkeitanmerkung
>
>
> Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene
> Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte
> Weiterleitung oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht
> dient lediglich dem Austausch von Informationen und entfaltet keine
> rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von
> E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen.
>
>
>
>> Date: Fri, 21 May 2010 19:53:42 -0700
>> From: devendra_tiwari12345@yahoo.com
>> To: user@struts.apache.org
>> Subject: Re: Struts2+Spring2+Interceptor+Invalid action class
>> configuration that references an unknown class named
>>
>>
>>
>>
>> >
>> > Hantsy Bai-2 wrote:
>> >>
>> >> 于 2010/5/22 1:05, rocks 写道:
>> >>> Dear,
>> >>>
>> >>> Apologize the posting same subject, but I did not find any solution
>> so
>> >>> far.
>> >>> I am developing a web application based on struts 2.1.8.1+ spring 2+
>> >>> hibernate 3 + tomcat 5.5. There is requisite library like
>> >>> struts2-convention-plugin-2.1.8.1.jar in my classpath.
>> >>>
>> >>> For authentication I am using struts interceptor.
>> >>> Below are my configuration files.
>> >>>
>> >>> struts.xml :=
>> >>>
>> >>> <?xml version="1.0" encoding="UTF-8" ?>
>> >>> <!DOCTYPE struts PUBLIC
>> >>> "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
>> >>> "http://struts.apache.org/dtds/struts-2.0.dtd">
>> >>>
>> >>>
>> >>> <struts>
>> >>> <constant name="struts.objectFactory" value="spring" />
>> >>> <constant name="struts.devMode" value="false" />
>> >>> <constant name="struts.action.extension" value="do"/>
>> >>> <constant name="struts.objectFactory.spring.autoWire"
>> >>> value="AUTOWIRE_BY_NAME"/>
>> >>>
>> >>> <!-- Add packages here -->
>> >>> <package name="dafault" extends="struts-default">
>> >>>
>> >>> <result-types>
>> >>> <result-type name="tiles"
>> >>> class="org.apache.struts2.views.tiles.TilesResult" />
>> >>> </result-types>
>> >>>
>> >>> <interceptors>
>> >>> <interceptor name="loginInterceptor"
>> >>> class="com.ncr.framework.interceptor.LoginInterceptor"/>
>> >>>
>> >>> <interceptor-stack name="capabilityStack">
>> >>> <interceptor-ref name="defaultStack"/>
>> >>> <interceptor-ref name="loginInterceptor"/>
>> >>> </interceptor-stack>
>> >>>
>> >>> </interceptors>
>> >>>
>> >>> <default-interceptor-ref name="capabilityStack"/>
>> >>>
>> >>> <action name="logon" class="loginAction" method="execute">
>> >>> <result name="success" type="tiles">page.Login</result>
>> >>> </action>
>> >>> </package>
>> >>> </struts>
>> >>>
>> >>> applicationContext.xml :-
>> >>>
>> >>> <?xml version="1.0" encoding="UTF-8"?>
>> >>> <!DOCTYPE beans SYSTEM "WEB-INF/spring-beans-2.0.dtd">
>> >>> <beans>
>> >>> <bean id="loginAction" scope="prototype"
>> >>> class="com.ncr.user.actions.LoginAction">
>> >>> <constructor-arg ref="adminService" />
>> >>> </bean>
>> >>> </beans>
>> >>>
>> >>> LoginInterceptor.java
>> >>>
>> >>> public class LoginInterceptor extends AbstractInterceptor {
>> >>> public String intercept(ActionInvocation invocation) throws Exception
>> {
>> >>> ActionContext context = invocation.getInvocationContext();
>> >>> Map<String, Object> contextMap = context.getContextMap();
>> >>> HttpServletRequestWrapper request = (HttpServletRequestWrapper)
>> >>> contextMap
>> >>> .get(HTTP_REQUEST);
>> >>> synchronized (request) {
>> >>> ThreadContext.setRequest(request);
>> >>> UserInfo userInfo = UserContext.getCurrentUserInfo();
>> >>>
>> >>> if (userInfo == null
>> >>> && !"authenticate".equals(contextMap.get(ACTION_NAME))) {
>> >>> return "logon";
>> >>> }
>> >>> return invocation.invoke();
>> >>> }
>> >>> }}
>> >>>
>> >>> When I hit url http://localhost:8080/mytest/logon.do it throws an
>> error.
>> >>>
>> >>> java.lang.RuntimeException: Invalid action class configuration that
>> >>> references an unknown class named [loginAction]
>> >>>
>> >>>
>> org.apache.struts2.convention.ConventionsServiceImpl.determineResultPath(ConventionsServiceImpl.java:100)
>> >>>
>> >>>
>> org.apache.struts2.convention.ConventionUnknownHandler.determinePath(ConventionUnknownHandler.java:385)
>> >>>
>> >>>
>> org.apache.struts2.convention.ConventionUnknownHandler.handleUnknownResult(ConventionUnknownHandler.java:274)
>> >>>
>> >>>
>> com.opensymphony.xwork2.DefaultUnknownHandlerManager.handleUnknownResult(DefaultUnknownHandlerManager.java:76)
>> >>>
>> >>>
>> com.opensymphony.xwork2.DefaultActionInvocation.createResult(DefaultActionInvocation.java:215)
>> >>>
>> >>>
>> com.opensymphony.xwork2.DefaultActionInvocation.executeResult(DefaultActionInvocation.java:356)
>> >>>
>> >>>
>> com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:266)
>> >>>
>> >>>
>> com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:165)
>> >>>
>> >>>
>> >>> As per my investigation, I found that ClassLoaderUtils's below method
>> >>> could
>> >>> not return class name for 'loginAction'. There should be some way for
>> to
>> >>> map
>> >>> 'loginAction' to the class com.ncr.user.actions.LoginAction.
>> >>>
>> >>> public static Class loadClass(String className, Class callingClass)
>> >>> throws ClassNotFoundException {
>> >>> try {
>> >>>
>> >>> return Thread.currentThread().getContextClassLoader().loadClass(
>> >>> className);
>> >>> } catch (ClassNotFoundException e) {
>> >>> try {
>> >>> return Class.forName(className);
>> >>> } catch (ClassNotFoundException ex) {
>> >>> try {
>> >>> return ClassLoaderUtils.class.getClassLoader().loadClass(
>> >>> className);
>> >>> } catch (ClassNotFoundException exc) {
>> >>> return callingClass.getClassLoader().loadClass(className);
>> >>> }
>> >>> }
>> >>> }
>> >>> }
>> >>>
>> >>> When I remove the entry '<default-interceptor-ref
>> >>> name="capabilityStack"/>'
>> >>> from struts.xml then it's working perfectly fine i.e desired page is
>> >>> coming.
>> >>>
>> >>> I also noticed that in the classes variable of
>> >>> Thread.currentThread().getContextClassLoader()(WebappClassLoader)
>> which
>> >>> is
>> >>> private contains class com.ncr.user.actions.LoginAction but i did not
>> >>> find
>> >>> any way to get it.
>> >>>
>> >>> Your kind guesture is appreciated.
>> >>>
>> >>> -Dev
>> >>>
>> >> Convention plugin provide annotation configration for struts2 instead
>> of
>> >> the XML configuration.
>> >> But it is optional, if you do not use it, there is no need add it to
>> >> your project. From you provided, I do not know the content of
>> >> LoginAction.
>> >>
>> >>
>> >>
>> >>
>> >> ---------------------------------------------------------------------
>> >> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> >> For additional commands, e-mail: user-help@struts.apache.org
>> >>
>> >>
>> >>
>> >
>> > Thanks Hantsy for quick reply. Right now I want to work with XML, may
>> be
>> > switch to annotations later. FYI, when I don't use interceptor it's
>> workly
>> > perfectly. so it seems there is disconnect with spring object factory
>> and
>> > ClassLoaderUtils.
>> >
>> > Here is content of LoginAction.
>> >
>> > package com.ncr.user.actions;
>> >
>> > import com.ncr.ncr.module.IAdminModule;
>> > import com.ncr.user.forms.UserForm;
>> > import com.opensymphony.xwork2.ActionSupport;
>> >
>> > public class LoginAction extends ActionSupport {
>> > public LoginAction(IAdminModule adminModule) {
>> > this.adminModule = adminModule;
>> > userForm = new UserForm();
>> > }
>> >
>> > private UserForm userForm = null;
>> >
>> > private IAdminModule adminModule = null;
>> >
>> > public UserForm getUserForm() {
>> > return userForm;
>> > }
>> >
>> > public String execute() throws Exception {
>> > System.out.println("hello execute");
>> > return SUCCESS;
>> > }
>> > }
>> >
>> --
>> View this message in context:
>> http://old.nabble.com/Struts2%2BSpring2%2BInterceptor%2BInvalid-action-class-configuration-that-references-an-unknown-class-named-tp28636590p28640776.html
>> Sent from the Struts - User mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>
> _________________________________________________________________
> Hotmail is redefining busy with tools for the New Busy. Get more from your
> inbox.
> http://www.windowslive.com/campaign/thenewbusy?ocid=PID28326::T:WLMTAGL:ON:WL:en-US:WM_HMP:042010_2
>
--
View this message in context: http://old.nabble.com/Struts2%2BSpring2%2BInterceptor%2BInvalid-action-class-configuration-that-references-an-unknown-class-named-tp28636590p28667913.html
Sent from the Struts - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
RE: Struts2+Spring2+Interceptor+Invalid action class configuration
that references an unknown class named
Posted by Martin Gainty <mg...@hotmail.com>.
Devendra
did you contact the local struts resource as suggested..?
Martin--
______________________________________________
Verzicht und Vertraulichkeitanmerkung
Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich dem Austausch von Informationen und entfaltet keine rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen.
> Date: Fri, 21 May 2010 19:53:42 -0700
> From: devendra_tiwari12345@yahoo.com
> To: user@struts.apache.org
> Subject: Re: Struts2+Spring2+Interceptor+Invalid action class configuration that references an unknown class named
>
>
>
>
> >
> > Hantsy Bai-2 wrote:
> >>
> >> 于 2010/5/22 1:05, rocks 写道:
> >>> Dear,
> >>>
> >>> Apologize the posting same subject, but I did not find any solution so
> >>> far.
> >>> I am developing a web application based on struts 2.1.8.1+ spring 2+
> >>> hibernate 3 + tomcat 5.5. There is requisite library like
> >>> struts2-convention-plugin-2.1.8.1.jar in my classpath.
> >>>
> >>> For authentication I am using struts interceptor.
> >>> Below are my configuration files.
> >>>
> >>> struts.xml :=
> >>>
> >>> <?xml version="1.0" encoding="UTF-8" ?>
> >>> <!DOCTYPE struts PUBLIC
> >>> "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
> >>> "http://struts.apache.org/dtds/struts-2.0.dtd">
> >>>
> >>>
> >>> <struts>
> >>> <constant name="struts.objectFactory" value="spring" />
> >>> <constant name="struts.devMode" value="false" />
> >>> <constant name="struts.action.extension" value="do"/>
> >>> <constant name="struts.objectFactory.spring.autoWire"
> >>> value="AUTOWIRE_BY_NAME"/>
> >>>
> >>> <!-- Add packages here -->
> >>> <package name="dafault" extends="struts-default">
> >>>
> >>> <result-types>
> >>> <result-type name="tiles"
> >>> class="org.apache.struts2.views.tiles.TilesResult" />
> >>> </result-types>
> >>>
> >>> <interceptors>
> >>> <interceptor name="loginInterceptor"
> >>> class="com.ncr.framework.interceptor.LoginInterceptor"/>
> >>>
> >>> <interceptor-stack name="capabilityStack">
> >>> <interceptor-ref name="defaultStack"/>
> >>> <interceptor-ref name="loginInterceptor"/>
> >>> </interceptor-stack>
> >>>
> >>> </interceptors>
> >>>
> >>> <default-interceptor-ref name="capabilityStack"/>
> >>>
> >>> <action name="logon" class="loginAction" method="execute">
> >>> <result name="success" type="tiles">page.Login</result>
> >>> </action>
> >>> </package>
> >>> </struts>
> >>>
> >>> applicationContext.xml :-
> >>>
> >>> <?xml version="1.0" encoding="UTF-8"?>
> >>> <!DOCTYPE beans SYSTEM "WEB-INF/spring-beans-2.0.dtd">
> >>> <beans>
> >>> <bean id="loginAction" scope="prototype"
> >>> class="com.ncr.user.actions.LoginAction">
> >>> <constructor-arg ref="adminService" />
> >>> </bean>
> >>> </beans>
> >>>
> >>> LoginInterceptor.java
> >>>
> >>> public class LoginInterceptor extends AbstractInterceptor {
> >>> public String intercept(ActionInvocation invocation) throws Exception {
> >>> ActionContext context = invocation.getInvocationContext();
> >>> Map<String, Object> contextMap = context.getContextMap();
> >>> HttpServletRequestWrapper request = (HttpServletRequestWrapper)
> >>> contextMap
> >>> .get(HTTP_REQUEST);
> >>> synchronized (request) {
> >>> ThreadContext.setRequest(request);
> >>> UserInfo userInfo = UserContext.getCurrentUserInfo();
> >>>
> >>> if (userInfo == null
> >>> && !"authenticate".equals(contextMap.get(ACTION_NAME))) {
> >>> return "logon";
> >>> }
> >>> return invocation.invoke();
> >>> }
> >>> }}
> >>>
> >>> When I hit url http://localhost:8080/mytest/logon.do it throws an error.
> >>>
> >>> java.lang.RuntimeException: Invalid action class configuration that
> >>> references an unknown class named [loginAction]
> >>>
> >>> org.apache.struts2.convention.ConventionsServiceImpl.determineResultPath(ConventionsServiceImpl.java:100)
> >>>
> >>> org.apache.struts2.convention.ConventionUnknownHandler.determinePath(ConventionUnknownHandler.java:385)
> >>>
> >>> org.apache.struts2.convention.ConventionUnknownHandler.handleUnknownResult(ConventionUnknownHandler.java:274)
> >>>
> >>> com.opensymphony.xwork2.DefaultUnknownHandlerManager.handleUnknownResult(DefaultUnknownHandlerManager.java:76)
> >>>
> >>> com.opensymphony.xwork2.DefaultActionInvocation.createResult(DefaultActionInvocation.java:215)
> >>>
> >>> com.opensymphony.xwork2.DefaultActionInvocation.executeResult(DefaultActionInvocation.java:356)
> >>>
> >>> com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:266)
> >>>
> >>> com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:165)
> >>>
> >>>
> >>> As per my investigation, I found that ClassLoaderUtils's below method
> >>> could
> >>> not return class name for 'loginAction'. There should be some way for to
> >>> map
> >>> 'loginAction' to the class com.ncr.user.actions.LoginAction.
> >>>
> >>> public static Class loadClass(String className, Class callingClass)
> >>> throws ClassNotFoundException {
> >>> try {
> >>>
> >>> return Thread.currentThread().getContextClassLoader().loadClass(
> >>> className);
> >>> } catch (ClassNotFoundException e) {
> >>> try {
> >>> return Class.forName(className);
> >>> } catch (ClassNotFoundException ex) {
> >>> try {
> >>> return ClassLoaderUtils.class.getClassLoader().loadClass(
> >>> className);
> >>> } catch (ClassNotFoundException exc) {
> >>> return callingClass.getClassLoader().loadClass(className);
> >>> }
> >>> }
> >>> }
> >>> }
> >>>
> >>> When I remove the entry '<default-interceptor-ref
> >>> name="capabilityStack"/>'
> >>> from struts.xml then it's working perfectly fine i.e desired page is
> >>> coming.
> >>>
> >>> I also noticed that in the classes variable of
> >>> Thread.currentThread().getContextClassLoader()(WebappClassLoader) which
> >>> is
> >>> private contains class com.ncr.user.actions.LoginAction but i did not
> >>> find
> >>> any way to get it.
> >>>
> >>> Your kind guesture is appreciated.
> >>>
> >>> -Dev
> >>>
> >> Convention plugin provide annotation configration for struts2 instead of
> >> the XML configuration.
> >> But it is optional, if you do not use it, there is no need add it to
> >> your project. From you provided, I do not know the content of
> >> LoginAction.
> >>
> >>
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> >> For additional commands, e-mail: user-help@struts.apache.org
> >>
> >>
> >>
> >
> > Thanks Hantsy for quick reply. Right now I want to work with XML, may be
> > switch to annotations later. FYI, when I don't use interceptor it's workly
> > perfectly. so it seems there is disconnect with spring object factory and
> > ClassLoaderUtils.
> >
> > Here is content of LoginAction.
> >
> > package com.ncr.user.actions;
> >
> > import com.ncr.ncr.module.IAdminModule;
> > import com.ncr.user.forms.UserForm;
> > import com.opensymphony.xwork2.ActionSupport;
> >
> > public class LoginAction extends ActionSupport {
> > public LoginAction(IAdminModule adminModule) {
> > this.adminModule = adminModule;
> > userForm = new UserForm();
> > }
> >
> > private UserForm userForm = null;
> >
> > private IAdminModule adminModule = null;
> >
> > public UserForm getUserForm() {
> > return userForm;
> > }
> >
> > public String execute() throws Exception {
> > System.out.println("hello execute");
> > return SUCCESS;
> > }
> > }
> >
> --
> View this message in context: http://old.nabble.com/Struts2%2BSpring2%2BInterceptor%2BInvalid-action-class-configuration-that-references-an-unknown-class-named-tp28636590p28640776.html
> Sent from the Struts - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
_________________________________________________________________
Hotmail is redefining busy with tools for the New Busy. Get more from your inbox.
http://www.windowslive.com/campaign/thenewbusy?ocid=PID28326::T:WLMTAGL:ON:WL:en-US:WM_HMP:042010_2
Re: Struts2+Spring2+Interceptor+Invalid action class configuration
that references an unknown class named
Posted by rocks <de...@yahoo.com>.
>
> Hantsy Bai-2 wrote:
>>
>> 于 2010/5/22 1:05, rocks 写道:
>>> Dear,
>>>
>>> Apologize the posting same subject, but I did not find any solution so
>>> far.
>>> I am developing a web application based on struts 2.1.8.1+ spring 2+
>>> hibernate 3 + tomcat 5.5. There is requisite library like
>>> struts2-convention-plugin-2.1.8.1.jar in my classpath.
>>>
>>> For authentication I am using struts interceptor.
>>> Below are my configuration files.
>>>
>>> struts.xml :=
>>>
>>> <?xml version="1.0" encoding="UTF-8" ?>
>>> <!DOCTYPE struts PUBLIC
>>> "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
>>> "http://struts.apache.org/dtds/struts-2.0.dtd">
>>>
>>>
>>> <struts>
>>> <constant name="struts.objectFactory" value="spring" />
>>> <constant name="struts.devMode" value="false" />
>>> <constant name="struts.action.extension" value="do"/>
>>> <constant name="struts.objectFactory.spring.autoWire"
>>> value="AUTOWIRE_BY_NAME"/>
>>>
>>> <!-- Add packages here -->
>>> <package name="dafault" extends="struts-default">
>>>
>>> <result-types>
>>> <result-type name="tiles"
>>> class="org.apache.struts2.views.tiles.TilesResult" />
>>> </result-types>
>>>
>>> <interceptors>
>>> <interceptor name="loginInterceptor"
>>> class="com.ncr.framework.interceptor.LoginInterceptor"/>
>>>
>>> <interceptor-stack name="capabilityStack">
>>> <interceptor-ref name="defaultStack"/>
>>> <interceptor-ref name="loginInterceptor"/>
>>> </interceptor-stack>
>>>
>>> </interceptors>
>>>
>>> <default-interceptor-ref name="capabilityStack"/>
>>>
>>> <action name="logon" class="loginAction" method="execute">
>>> <result name="success" type="tiles">page.Login</result>
>>> </action>
>>> </package>
>>> </struts>
>>>
>>> applicationContext.xml :-
>>>
>>> <?xml version="1.0" encoding="UTF-8"?>
>>> <!DOCTYPE beans SYSTEM "WEB-INF/spring-beans-2.0.dtd">
>>> <beans>
>>> <bean id="loginAction" scope="prototype"
>>> class="com.ncr.user.actions.LoginAction">
>>> <constructor-arg ref="adminService" />
>>> </bean>
>>> </beans>
>>>
>>> LoginInterceptor.java
>>>
>>> public class LoginInterceptor extends AbstractInterceptor {
>>> public String intercept(ActionInvocation invocation) throws Exception {
>>> ActionContext context = invocation.getInvocationContext();
>>> Map<String, Object> contextMap = context.getContextMap();
>>> HttpServletRequestWrapper request = (HttpServletRequestWrapper)
>>> contextMap
>>> .get(HTTP_REQUEST);
>>> synchronized (request) {
>>> ThreadContext.setRequest(request);
>>> UserInfo userInfo = UserContext.getCurrentUserInfo();
>>>
>>> if (userInfo == null
>>> && !"authenticate".equals(contextMap.get(ACTION_NAME))) {
>>> return "logon";
>>> }
>>> return invocation.invoke();
>>> }
>>> }}
>>>
>>> When I hit url http://localhost:8080/mytest/logon.do it throws an error.
>>>
>>> java.lang.RuntimeException: Invalid action class configuration that
>>> references an unknown class named [loginAction]
>>>
>>> org.apache.struts2.convention.ConventionsServiceImpl.determineResultPath(ConventionsServiceImpl.java:100)
>>>
>>> org.apache.struts2.convention.ConventionUnknownHandler.determinePath(ConventionUnknownHandler.java:385)
>>>
>>> org.apache.struts2.convention.ConventionUnknownHandler.handleUnknownResult(ConventionUnknownHandler.java:274)
>>>
>>> com.opensymphony.xwork2.DefaultUnknownHandlerManager.handleUnknownResult(DefaultUnknownHandlerManager.java:76)
>>>
>>> com.opensymphony.xwork2.DefaultActionInvocation.createResult(DefaultActionInvocation.java:215)
>>>
>>> com.opensymphony.xwork2.DefaultActionInvocation.executeResult(DefaultActionInvocation.java:356)
>>>
>>> com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:266)
>>>
>>> com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:165)
>>>
>>>
>>> As per my investigation, I found that ClassLoaderUtils's below method
>>> could
>>> not return class name for 'loginAction'. There should be some way for to
>>> map
>>> 'loginAction' to the class com.ncr.user.actions.LoginAction.
>>>
>>> public static Class loadClass(String className, Class callingClass)
>>> throws ClassNotFoundException {
>>> try {
>>>
>>> return Thread.currentThread().getContextClassLoader().loadClass(
>>> className);
>>> } catch (ClassNotFoundException e) {
>>> try {
>>> return Class.forName(className);
>>> } catch (ClassNotFoundException ex) {
>>> try {
>>> return ClassLoaderUtils.class.getClassLoader().loadClass(
>>> className);
>>> } catch (ClassNotFoundException exc) {
>>> return callingClass.getClassLoader().loadClass(className);
>>> }
>>> }
>>> }
>>> }
>>>
>>> When I remove the entry '<default-interceptor-ref
>>> name="capabilityStack"/>'
>>> from struts.xml then it's working perfectly fine i.e desired page is
>>> coming.
>>>
>>> I also noticed that in the classes variable of
>>> Thread.currentThread().getContextClassLoader()(WebappClassLoader) which
>>> is
>>> private contains class com.ncr.user.actions.LoginAction but i did not
>>> find
>>> any way to get it.
>>>
>>> Your kind guesture is appreciated.
>>>
>>> -Dev
>>>
>> Convention plugin provide annotation configration for struts2 instead of
>> the XML configuration.
>> But it is optional, if you do not use it, there is no need add it to
>> your project. From you provided, I do not know the content of
>> LoginAction.
>>
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
>>
>
> Thanks Hantsy for quick reply. Right now I want to work with XML, may be
> switch to annotations later. FYI, when I don't use interceptor it's workly
> perfectly. so it seems there is disconnect with spring object factory and
> ClassLoaderUtils.
>
> Here is content of LoginAction.
>
> package com.ncr.user.actions;
>
> import com.ncr.ncr.module.IAdminModule;
> import com.ncr.user.forms.UserForm;
> import com.opensymphony.xwork2.ActionSupport;
>
> public class LoginAction extends ActionSupport {
> public LoginAction(IAdminModule adminModule) {
> this.adminModule = adminModule;
> userForm = new UserForm();
> }
>
> private UserForm userForm = null;
>
> private IAdminModule adminModule = null;
>
> public UserForm getUserForm() {
> return userForm;
> }
>
> public String execute() throws Exception {
> System.out.println("hello execute");
> return SUCCESS;
> }
> }
>
--
View this message in context: http://old.nabble.com/Struts2%2BSpring2%2BInterceptor%2BInvalid-action-class-configuration-that-references-an-unknown-class-named-tp28636590p28640776.html
Sent from the Struts - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Struts2+Spring2+Interceptor+Invalid action class configuration
that references an unknown class named
Posted by Hantsy Bai <ha...@gmail.com>.
于 2010/5/22 1:05, rocks 写道:
> Dear,
>
> Apologize the posting same subject, but I did not find any solution so far.
> I am developing a web application based on struts 2.1.8.1+ spring 2+
> hibernate 3 + tomcat 5.5. There is requisite library like
> struts2-convention-plugin-2.1.8.1.jar in my classpath.
>
> For authentication I am using struts interceptor.
> Below are my configuration files.
>
> struts.xml :=
>
> <?xml version="1.0" encoding="UTF-8" ?>
> <!DOCTYPE struts PUBLIC
> "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
> "http://struts.apache.org/dtds/struts-2.0.dtd">
>
>
> <struts>
> <constant name="struts.objectFactory" value="spring" />
> <constant name="struts.devMode" value="false" />
> <constant name="struts.action.extension" value="do"/>
> <constant name="struts.objectFactory.spring.autoWire"
> value="AUTOWIRE_BY_NAME"/>
>
> <!-- Add packages here -->
> <package name="dafault" extends="struts-default">
>
> <result-types>
> <result-type name="tiles"
> class="org.apache.struts2.views.tiles.TilesResult" />
> </result-types>
>
> <interceptors>
> <interceptor name="loginInterceptor"
> class="com.ncr.framework.interceptor.LoginInterceptor"/>
>
> <interceptor-stack name="capabilityStack">
> <interceptor-ref name="defaultStack"/>
> <interceptor-ref name="loginInterceptor"/>
> </interceptor-stack>
>
> </interceptors>
>
> <default-interceptor-ref name="capabilityStack"/>
>
> <action name="logon" class="loginAction" method="execute">
> <result name="success" type="tiles">page.Login</result>
> </action>
> </package>
> </struts>
>
> applicationContext.xml :-
>
> <?xml version="1.0" encoding="UTF-8"?>
> <!DOCTYPE beans SYSTEM "WEB-INF/spring-beans-2.0.dtd">
> <beans>
> <bean id="loginAction" scope="prototype"
> class="com.ncr.user.actions.LoginAction">
> <constructor-arg ref="adminService" />
> </bean>
> </beans>
>
> LoginInterceptor.java
>
> public class LoginInterceptor extends AbstractInterceptor {
> public String intercept(ActionInvocation invocation) throws Exception {
> ActionContext context = invocation.getInvocationContext();
> Map<String, Object> contextMap = context.getContextMap();
> HttpServletRequestWrapper request = (HttpServletRequestWrapper) contextMap
> .get(HTTP_REQUEST);
> synchronized (request) {
> ThreadContext.setRequest(request);
> UserInfo userInfo = UserContext.getCurrentUserInfo();
>
> if (userInfo == null
> && !"authenticate".equals(contextMap.get(ACTION_NAME))) {
> return "logon";
> }
> return invocation.invoke();
> }
> }}
>
> When I hit url http://localhost:8080/mytest/logon.do it throws an error.
>
> java.lang.RuntimeException: Invalid action class configuration that
> references an unknown class named [loginAction]
>
> org.apache.struts2.convention.ConventionsServiceImpl.determineResultPath(ConventionsServiceImpl.java:100)
>
> org.apache.struts2.convention.ConventionUnknownHandler.determinePath(ConventionUnknownHandler.java:385)
>
> org.apache.struts2.convention.ConventionUnknownHandler.handleUnknownResult(ConventionUnknownHandler.java:274)
>
> com.opensymphony.xwork2.DefaultUnknownHandlerManager.handleUnknownResult(DefaultUnknownHandlerManager.java:76)
>
> com.opensymphony.xwork2.DefaultActionInvocation.createResult(DefaultActionInvocation.java:215)
>
> com.opensymphony.xwork2.DefaultActionInvocation.executeResult(DefaultActionInvocation.java:356)
>
> com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:266)
>
> com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:165)
>
>
> As per my investigation, I found that ClassLoaderUtils's below method could
> not return class name for 'loginAction'. There should be some way for to map
> 'loginAction' to the class com.ncr.user.actions.LoginAction.
>
> public static Class loadClass(String className, Class callingClass)
> throws ClassNotFoundException {
> try {
>
> return Thread.currentThread().getContextClassLoader().loadClass(
> className);
> } catch (ClassNotFoundException e) {
> try {
> return Class.forName(className);
> } catch (ClassNotFoundException ex) {
> try {
> return ClassLoaderUtils.class.getClassLoader().loadClass(
> className);
> } catch (ClassNotFoundException exc) {
> return callingClass.getClassLoader().loadClass(className);
> }
> }
> }
> }
>
> When I remove the entry '<default-interceptor-ref name="capabilityStack"/>'
> from struts.xml then it's working perfectly fine i.e desired page is coming.
>
> I also noticed that in the classes variable of
> Thread.currentThread().getContextClassLoader()(WebappClassLoader) which is
> private contains class com.ncr.user.actions.LoginAction but i did not find
> any way to get it.
>
> Your kind guesture is appreciated.
>
> -Dev
>
Convention plugin provide annotation configration for struts2 instead of
the XML configuration.
But it is optional, if you do not use it, there is no need add it to
your project. From you provided, I do not know the content of LoginAction.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org