Thanks for your offer of help Brad and sorry these files are so big.
I do have a habit of editing my posts occassionally through Nabble so maybe
that is causing me to post twice?
Currently a lack of skill prevents me from setting a break point on the
SpringObjectFactory.buildBean() but that is somethig I can start looking
into tomorrow. It is somethig I know I should learn but never seem to find
the time to get around too.
I have posted the various files you mentioned below in case you have time to
look at them (I don't have a struts.properties):
======================
struts.xml
I have removed all actions except the one I am trying to get working with
spring. It is on the package at the top of the file in package
'authenticatedwithssl' The struts results doesn't seem to have come across
correctly in the formatting and is missing some nodes but it is valid in my
real struts.xml file and works correctly.
======================
<struts>
<constant name="struts.i18n.reload" value="true" />
<constant name="struts.devMode" value="true" />
<constant name="struts.configuration.xml.reload" value="true" />
<constant name="struts.ui.theme" value="css_xhtml" />
<constant name="struts.objectFactory" value="spring" />
<constant name="struts.action.extension" value="action" />
<package name="authenticatedwithssl" extends="struts-default"
namespace="/authenticatedwithssl">
<interceptors>
<interceptor
class="uk.co.prodia.prosoc.struts2.interceptor.InterceptorAddUserToSession"
name="addUserToSession" />
<interceptor-stack name="addUserToSessionStack">
<interceptor-ref name="addUserToSession"/>
<interceptor-ref name="defaultStack"/>
</interceptor-stack>
</interceptors>
<default-interceptor-ref name="addUserToSessionStack"/>
<action name="update-email!*"
class="springManagedProsocActionUpdateEmail" method="{1}">
<result
name="input">/WEB-INF/page/user/authenticatedwithssl/update-email.jsp</result>
<result name="error" type="redirectAction">
error
/unsecured
</result>
<result name="success" type="redirectAction">
success
/unsecured
</result>
</action>
</package>
<package name="root" extends="struts-default" namespace="/">
<interceptors>
<interceptor
class="uk.co.prodia.prosoc.struts2.interceptor.InterceptorAddUserToSession"
name="addUserToSession" />
<interceptor-stack name="addUserToSessionStack">
<interceptor-ref name="addUserToSession"/>
<interceptor-ref name="defaultStack"/>
</interceptor-stack>
</interceptors>
<default-interceptor-ref name="addUserToSessionStack"/>
</package>
<package name="unsecured-page" extends="struts-default"
namespace="/unsecured">
<interceptors>
<interceptor
class="uk.co.prodia.prosoc.struts2.interceptor.InterceptorAddUserToSession"
name="addUserToSession" />
<interceptor-stack name="addUserToSessionStack">
<interceptor-ref name="addUserToSession"/>
<interceptor-ref name="defaultStack"/>
</interceptor-stack>
</interceptors>
<default-interceptor-ref name="addUserToSessionStack"/>
</package>
<package name="sslsecured" extends="struts-default"
namespace="/sslsecured">
<interceptors>
<interceptor
class="uk.co.prodia.prosoc.struts2.interceptor.InterceptorAddUserToSession"
name="addUserToSession" />
<interceptor-stack name="addUserToSessionStack">
<interceptor-ref name="addUserToSession"/>
<interceptor-ref name="defaultStack"/>
</interceptor-stack>
</interceptors>
<default-interceptor-ref name="addUserToSessionStack"/>
</package>
<package name="authenticated" extends="struts-default"
namespace="/authenticated">
<interceptors>
<interceptor
class="uk.co.prodia.prosoc.struts2.interceptor.InterceptorAddUserToSession"
name="addUserToSession" />
<interceptor-stack name="addUserToSessionStack">
<interceptor-ref name="addUserToSession"/>
<interceptor-ref name="defaultStack"/>
</interceptor-stack>
</interceptors>
<default-interceptor-ref name="addUserToSessionStack"/>
</package>
<package name="test" extends="struts-default" namespace="/test">
<interceptors>
<interceptor
class="uk.co.prodia.prosoc.struts2.interceptor.InterceptorAddUserToSession"
name="addUserToSession" />
<interceptor-stack name="addUserToSessionStack">
<interceptor-ref name="addUserToSession"/>
<interceptor-ref name="defaultStack"/>
</interceptor-stack>
</interceptors>
<default-interceptor-ref name="addUserToSessionStack"/>
</package>
</struts>
======================
spring-config
which is called prosoc-spring-beans.xml within my app.
======================
<!--
XA datasource for the prosoc root context
-->
<bean id="dataSourceProsoc"
class="com.atomikos.jdbc.AtomikosDataSourceBean" init-method="init"
destroy-method="close">
<property
name="uniqueResourceName"><value>XADBMSProsoc</value></property>
<property
name="xaDataSourceClassName"><value>com.mysql.jdbc.jdbc2.optional.MysqlXADataSource</value></property>
<property name="xaProperties">
<props>
<prop key="databaseName">prosoc</prop>
<prop key="serverName">localhost</prop>
<prop key="port">3306</prop>
<prop key="user">prosoc</prop>
<prop key="password">prosoc-</prop>
<prop key="url">jdbc:mysql://localhost:3306/prosoc</prop>
</props>
</property>
<property name="minPoolSize"><value>1</value></property>
</bean>
<!--
XA datasource for the prosocForum context
-->
<bean id="dataSourceProsocForum"
class="com.atomikos.jdbc.AtomikosDataSourceBean" init-method="init"
destroy-method="close">
<property
name="uniqueResourceName"><value>XADBMSProsocForum</value></property>
<property
name="xaDataSourceClassName"><value>com.mysql.jdbc.jdbc2.optional.MysqlXADataSource</value></property>
<property name="xaProperties">
<props>
<prop key="databaseName">prosoc</prop>
<prop key="serverName">localhost</prop>
<prop key="port">3306</prop>
<prop key="user">prosoc</prop>
<prop key="password">prosoc-</prop>
<prop
key="url">jdbc:mysql://localhost:3306/prosoc_forum</prop>
</props>
</property>
<property name="minPoolSize"><value>1</value></property>
</bean>
<!--
SessionFactory for the prosoc root context
-->
<bean id="sessionFactoryProsoc"
class="
org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="useTransactionAwareDataSource" value="true"/>
<property name="dataSource"><ref bean="dataSourceProsoc"/></property>
<property name="mappingResources">
<list>
<value>uk/co/prodia/prosoc/user/User.hbm.xml</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop
key="hibernate.dialect">
org.hibernate.dialect.MySQLInnoDBDialect</prop>
<prop key="hibernate.connection.isolation">3</prop>
<prop
key="hibernate.current_session_context_class">jta</prop>
<prop
key="hibernate.transaction.factory_class">
org.hibernate.transaction.JTATransactionFactory</prop>
<prop
key="hibernate.transaction.manager_lookup_class">com.atomikos.icatch.jta.hibernate3.TransactionManagerLookup</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.hbm2ddl.auto">update</prop>
</props>
</property>
</bean>
<!--
SessionFactory for the prosocForum context
-->
<bean id="sessionFactoryProsocForum"
class="
org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="useTransactionAwareDataSource" value="true"/>
<property name="dataSource"><ref
bean="dataSourceProsocForum"/></property>
<property name="mappingResources">
<list>
<value>uk/co/prodia/prosoc/forum/mvnforum/MVNForumMember.hbm.xml</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<!-- If hibernate.dialect causes a problem switch it to
org.hibernate.dialect.MySQLDialect -->
<prop
key="hibernate.dialect">
org.hibernate.dialect.MySQLInnoDBDialect</prop>
<prop key="hibernate.connection.isolation">3</prop>
<prop
key="hibernate.current_session_context_class">jta</prop>
<prop
key="hibernate.transaction.factory_class">
org.hibernate.transaction.JTATransactionFactory</prop>
<prop
key="hibernate.transaction.manager_lookup_class">com.atomikos.icatch.jta.hibernate3.TransactionManagerLookup</prop>
<prop key="hibernate.show_sql">true</prop>
</props>
</property>
</bean>
<bean id="atomikosTransactionManager"
class="com.atomikos.icatch.jta.UserTransactionManager" init-method="init"
destroy-method="close">
<property name="forceShutdown"><value>true</value></property>
<property name="startupTransactionService" value="true"/>
</bean>
<bean id="atomikosUserTransaction"
class="com.atomikos.icatch.jta.UserTransactionImp">
<property name="transactionTimeout"><value>300</value></property>
</bean>
<bean id="transactionManager"
class="
org.springframework.transaction.jta.JtaTransactionManager">
<property name="transactionManager"><ref
bean="atomikosTransactionManager"/></property>
<property name="userTransaction"><ref
bean="atomikosUserTransaction"/></property>
</bean>
<bean id="hibernateTemplate"
class="
org.springframework.orm.hibernate3.HibernateTemplate">
<property name="sessionFactory"><ref
bean="sessionFactoryProsoc"/></property>
</bean>
<bean id="prosocUser"
class="uk.co.prodia.prosoc.persistence.hibernate.DAOUserImpl">
<property name="sessionFactory" ref="sessionFactoryProsoc"/>
</bean>
<bean id="prosocForumUser"
class="uk.co.prodia.prosoc.forum.mvnforum.persistance.hibernate.DAOMVNForumMemberImpl">
<property name="sessionFactory" ref="sessionFactoryProsocForum"/>
</bean>
<bean id="springManagedProsocActionUpdateEmail"
class="uk.co.prodia.prosoc.struts2.action.ActionUpdateEmail"
scope="prototype">
</bean>
<bean
class="
org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor"/>
<tx:annotation-driven transaction-manager="transactionManager"/>
</beans>
======================
applicationContext-security.xml
=====================
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:sec="http://www.springframework.org/schema/security"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/security
http://www.springframework.org/schema/security/spring-security-2.0.1.xsd">
<sec:global-method-security secured-annotations="enabled">
</sec:global-method-security>
<!--
This element creates an instance of
org.springframework.security.util.FilterChainProxy
-->
<sec:http entry-point-ref="casProcessingFilterEntryPoint">
<sec:intercept-url pattern="/unsecured/**" requires-channel="http"/>
<sec:intercept-url pattern="/unsecured/login!returnToOriginalPage**"
access="ROLE_LOGIN" requires-channel="http"/>
<sec:intercept-url pattern="/sslsecured/**"
requires-channel="https"/>
<sec:intercept-url pattern="/authenticated/**" access="ROLE_LOGIN"
requires-channel="http"/>
<!--<sec:intercept-url pattern="/authenticatedwithssl/**"
access="ROLE_LOGIN" requires-channel="https"/>-->
<sec:intercept-url pattern="/**.action" requires-channel="http"/>
</sec:http>
<!--
Start CAS - Central Authentication Service (JASIG)
-->
<bean id="casProcessingFilterEntryPoint"
class="uk.co.prodia.prosoc.security.spring.cas.CasProcessingFilterEntryPoint">
<property name="loginUrl"
value="https://localhost:8443/prosoc/cas/login"/>
<property name="serviceProperties" ref="serviceProperties"/>
</bean>
<bean id="serviceProperties"
class="org.springframework.security.ui.cas.ServiceProperties">
<property name="service"
value="http://localhost:8080/prosoc/j_spring_cas_security_check"/>
<property name="sendRenew" value="false"/>
</bean>
<bean id="casProcessingFilter"
class="org.springframework.security.ui.cas.CasProcessingFilter">
<sec:custom-filter after="CAS_PROCESSING_FILTER"/>
<property name="authenticationManager" ref="authenticationManager"/>
<property name="authenticationFailureUrl"
value="http://localhost:8080/prosoc/unsecured/error.action"/>
<property name="defaultTargetUrl" value="/"/>
</bean>
<sec:authentication-manager alias="authenticationManager"/>
<bean id="casAuthenticationProvider"
class="org.springframework.security.providers.cas.CasAuthenticationProvider">
<sec:custom-authentication-provider />
<property name="userDetailsService" ref="userDetailsService"/>
<property name="serviceProperties" ref="serviceProperties" />
<property name="ticketValidator">
<bean
class="org.jasig.cas.client.validation.Cas20ServiceTicketValidator">
<constructor-arg index="0"
value="https://localhost:8443/prosoc/cas" />
<property name="proxyGrantingTicketStorage"
ref="proxyGrantingTicketStorage" /><!-- Don't think this is needed -->
</bean>
</property>
<property name="key" value="key_prosoc"/>
</bean>
<bean id="CASUnprotectedPageFilter"
class="uk.co.prodia.prosoc.security.spring.cas.CASUnprotectedPageFilter">
<property name="ignoreFilesOfType"
value="css,js,gif,jpg,png,swf,pdf" />
<property name="loginPage" value="login!goToLogin" />
<sec:custom-filter after="SWITCH_USER_FILTER"/>
</bean>
<bean id="RemoveSavedRequestKeyFilter"
class="uk.co.prodia.prosoc.security.spring.RemoveSavedRequestKeyFilter">
<property name="doNotRunFor"
value="/prosoc/forum/mvnforum/myprofile" />
<sec:custom-filter after="PRE_AUTH_FILTER"/>
</bean>
<bean id="proxyGrantingTicketStorage"
class="org.jasig.cas.client.proxy.ProxyGrantingTicketStorageImpl" />
<bean id="userDetailsService"
class="uk.co.prodia.prosoc.security.spring.cas.login.SpringSecurityUserDetailsService"/>
<bean id="singleSignOutFilter"
class="org.jasig.cas.client.session.SingleSignOutFilter">
<sec:custom-filter before="CONCURRENT_SESSION_FILTER"/>
</bean>
</beans>
======================
web.xml
-------
I have removed parts such as welcome-file list
and one Servlet which is quite large and whose purpose
is to configure a CAPTCHA.
======================
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
version="2.4">
<display-name>prosoc</display-name>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/applicationContext-security.xml</param-value>
</context-param>
<filter>
<filter-name>springSecurityFilterChain</filter-name>
<filter-class>
org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>
<filter>
<filter-name>struts2</filter-name>
<filter-class>
org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
</filter>
<filter-mapping>
<filter-name>springSecurityFilterChain</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
<dispatcher>REQUEST</dispatcher>
<dispatcher>FORWARD</dispatcher>
</filter-mapping>
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<servlet>
<servlet-name>ProsocConfig</servlet-name>
<servlet-class>uk.co.prodia.prosoc.Config</servlet-class>
<init-param>
<param-name>web.xml-display-name-not-defined-message</param-name>
<param-value>
Please define the display-name node in your web.xml with the
name of your web application.
</param-value>
</init-param>
<init-param>
<param-name>log4j-config-file</param-name>
<param-value>/WEB-INF/classes/log4j.xml</param-value>
</init-param>
<init-param>
<param-name>prosoc-spring-beans-definition-file</param-name>
<!--
This is stored in /WEB-INF/classes but Spring will automatically
find
it on the classpath so we only need to give the file name and not
the
full path.
-->
<param-value>prosoc-spring-beans.xml</param-value>
</init-param>
<init-param>
<param-name>application-properties-file</param-name>
<param-value>prosoc.properties</param-value><!-- Must be in
/WEB-INF/classes -->
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
</web-app>
--
Sent from the Struts - User mailing list archive at Nabble.com.
Please help a struggling newbie, and first time mailing list user.
The following Netbeans 6.0 project is using Glassfish.
Directory listing:
TS_6
TS_6/src/
TS_6/src/conf/
TS_6/src/conf/MANIFEST.MF
TS_6/src/java/
TS_6/src/java/HelloWorld.java
TS_6/src/java/struts.xml
TS_6/src/java/ts/
TS_6/src/java/ts/BaseAction.java
TS_6/src/java/ts/Login.java
TS_6/src/java/ts/ts_struts.xml
TS_6/test/
TS_6/web/
TS_6/web/HelloWorld.jsp
TS_6/web/index.html
TS_6/web/index.jsp
TS_6/web/jsp/
TS_6/web/jsp/login.jsp
TS_6/web/jsp/login_error.jsp
TS_6/web/jsp/login_input.jsp
TS_6/web/jsp/login_success.jsp
TS_6/web/WEB-INF/
TS_6/web/WEB-INF/sun-web.xml
TS_6/web/WEB-INF/web.xml
TS_6/web/WEB-INF/lib/
TS_6/web/WEB-INF/lib/commons-fileupload-1.2.1.jar
TS_6/web/WEB-INF/lib/commons-io-1.3.2.jar
TS_6/web/WEB-INF/lib/commons-logging-1.0.4.jar
TS_6/web/WEB-INF/lib/freemarker-2.3.12.jar
TS_6/web/WEB-INF/lib/ognl-2.6.11.jar
TS_6/web/WEB-INF/lib/struts2-core-2.1.2.jar
TS_6/web/WEB-INF/lib/xwork-2.1.1.jar
Below find the files that I view as being involved in my problem
web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<filter>
<filter-name>struts2</filter-name>
<filter-class>
org.apache.struts2.dispatcher.FilterDispatcher</filter-cla
ss>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
struts.xml
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<include file="ts/ts_struts.xml"/>
<package name="hello" extends="struts-default">
<action name="HelloWorld" class="HelloWorld">
<result>/HelloWorld.jsp</result>
</action>
</package>
</struts>
ts_struts.xml
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<package name="ts" namespace="/ts" extends="struts-default">
<action name="Login" class="ts.Login">
<result name="success">/jsp/login_success.jsp</result>
<result name="input">/jsp/login_input.jsp</result>
<result name="error">/jsp/login_error.jsp</result>
</action>
</package>
</struts>
index.html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<META HTTP-EQUIV="Refresh" CONTENT="0;URL=ts/Login.action">
</head>
<body>
<p>Loading ...</p>
</body>
</html>
Login.java
package ts;
public class Login extends BaseAction {
public String execute() throws Exception {
if (isInvalid(getUsername())) {
return INPUT;
}
if (isInvalid(getPassword())) {
return INPUT;
}
return SUCCESS;
}
private boolean isInvalid(String value) {
return (value == null || value.length() == 0);
}
private String username;
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
private String password;
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
}
BaseAction.java
package ts;
import
com.opensymphony.xwork2.ActionSupport;
public class BaseAction extends ActionSupport {
}
login_input.jsp
<%@(protected)
language="java"
contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1" %>
<%@(protected)"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=UTF-8">
<title>Login Input</title>
</head>
<body>
<h1>/jsp/login_input.jsp</h1>
<h2>Input Page</h2>
</body>
</html>
RUN...
http://localhost:8080/TS_6/
yields this url...
http://localhost:8080/TS_6/ts/Login.action
which displays...
/jsp/login_input.jsp
Input Page
This all seems wired up well enough for the Login action to find the
mapped jsp
BUT...
When I edit the same jsp by adding a form...
login_input.jsp
<%@(protected)
language="java"
contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1" %>
<%@(protected)"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=UTF-8">
<title>Login Input</title>
</head>
<body>
<h1>/jsp/login_input.jsp</h1>
<h2>Input Page</h2>
<s:form action="Login" namespace="/ts">
<s:textfield key="username"/>
<s:password key="password" />
<s:submit/>
</s:form>
</body>
</html>
And execute again,
http://localhost:8080/TS_6/ts/Login.action
there is an exception...
java.lang.IllegalArgumentException: URI is not hierarchical
What is it with the <s:form> tag that is causing this error?
What does the error log entry mean?
java.lang.IllegalArgumentException: URI is not hierarchical
Thanks for any help, I've tried many times to work this out, and I just
can't see the forest through the trees.