Liferay and JSF2 + Spring integration - spring

I created a new project with Eclipse > Liferay Project > Portlet > JSF 2.x > Primefaces. Then I' m trying to add Spring Bean management to it, by following this demo.
The problem is when deploying to tomcat 7 the generated portlet raises a exception.
Source Document: jndi:/localhost/jsf-test-portlet/WEB-INF/faces-config.xml
Cause: Class 'org.springframework.web.jsf.el.SpringBeanFacesELResolver' is missing a runtime dependency: java.lang.NoClassDefFoundError: org/springframework/beans/factory/access/el/SpringBeanELResolver
If i look into the project 'lib' directory, the jars are in place, the same in the generated WAR. So I don't know where the problem may be originated.
My ivy.xml
<?xml version="1.0"?>
<ivy-module
version="2.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://ant.apache.org/ivy/schemas/ivy.xsd"
>
<info module="portlet_primefaces_tmpl" organisation="com.liferay" />
<dependencies defaultconf="default">
<dependency name="el-api" org="javax.el" rev="2.2" />
<dependency name="jboss-el" org="org.jboss.el" rev="2.0.1.GA" />
<dependency name="jsf-api" org="com.sun.faces" rev="2.1.21" />
<dependency name="jsf-impl" org="com.sun.faces" rev="2.1.21" />
<dependency name="liferay-faces-bridge-api" org="com.liferay.faces" rev="3.1.3-ga4" />
<dependency name="liferay-faces-bridge-impl" org="com.liferay.faces" rev="3.1.3-ga4" />
<dependency name="liferay-faces-portal" org="com.liferay.faces" rev="3.1.3-ga4" />
<dependency name="liferay-faces-util" org="com.liferay.faces" rev="3.1.3-ga4" />
<dependency name="primefaces" org="org.primefaces" rev="3.5" />
<dependency org="org.springframework" name="spring-core" rev="3.2.1.RELEASE"/>
<dependency org="org.springframework" name="spring-web" rev="3.2.1.RELEASE" />
</dependencies>
My web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app 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" version="2.5">
<context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>Development</param-value>
</context-param>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/portlet-context.xml</param-value>
</context-param>
<context-param>
<param-name>com.sun.faces.expressionFactory</param-name>
<param-value>org.jboss.el.ExpressionFactoryImpl</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<listener>
<listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
</listener>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.xhtml</url-pattern>
</servlet-mapping>
<!-- Prevent direct access to Facelet view XHTML by the userAgent (browser). -->
<security-constraint>
<web-resource-collection>
<web-resource-name>Facelet View XHTML</web-resource-name>
<url-pattern>*.xhtml</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>nobody</role-name>
</auth-constraint>
</security-constraint>
<security-role>
<role-name>nobody</role-name>
</security-role>
My faces-config.xml
<?xml version="1.0"?>
<faces-config version="2.1" 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-facesconfig_2_1.xsd">
<lifecycle>
<phase-listener>com.liferay.faces.util.lifecycle.DebugPhaseListener</phase-listener>
</lifecycle>
<application>
<el-resolver>org.springframework.web.jsf.el.SpringBeanFacesELResolver</el-resolver>
</application>

Analyzing the WAR from the demo, I realized that there are 7 Spring JARS in it,
I added those remaining dependencies to my ivy.xml file, then a "clean/deploy" and now it's working. Maybe not all JARS are required but that's the next step, remove those unnecessary.
My ivy.xml now looks like this:
<?xml version="1.0"?>
<ivy-module
version="2.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://ant.apache.org/ivy/schemas/ivy.xsd"
>
<info module="portlet_primefaces_tmpl" organisation="com.liferay" />
<dependencies defaultconf="default">
<dependency name="jboss-el" org="org.jboss.el" rev="2.0.1.GA" />
<dependency name="jsf-api" org="com.sun.faces" rev="2.1.21" />
<dependency name="jsf-impl" org="com.sun.faces" rev="2.1.21" />
<dependency name="liferay-faces-bridge-api" org="com.liferay.faces" rev="3.1.3-ga4" />
<dependency name="liferay-faces-bridge-impl" org="com.liferay.faces" rev="3.1.3-ga4" />
<dependency name="liferay-faces-portal" org="com.liferay.faces" rev="3.1.3-ga4" />
<dependency name="liferay-faces-util" org="com.liferay.faces" rev="3.1.3-ga4" />
<dependency name="primefaces" org="org.primefaces" rev="3.5" />
<!-- Spring dependencies -->
<dependency name="spring-core" org="org.springframework" rev="3.0.7.RELEASE"/>
<dependency name="spring-web" org="org.springframework" rev="3.0.7.RELEASE" />
<dependency name="spring-context" org="org.springframework" rev="3.0.7.RELEASE" />
<dependency name="spring-beans" org="org.springframework" rev="3.0.7.RELEASE" />
<dependency name="spring-expression" org="org.springframework" rev="3.0.7.RELEASE" />
<dependency name="spring-aop" org="org.springframework" rev="3.0.7.RELEASE" />
<dependency name="spring-asm" org="org.springframework" rev="3.0.7.RELEASE" />
</dependencies>

Related

Websphere liberty 19 how override jndi ref sources defined in web.xml

I have ear and in that ear exists two wars.
I have tried but i can not override eny of defined sources in web.xml file.
I wont that server.xml will be my primary configurtion. All of my attempts fails.
Could somebody give me example how to override configuration in web.xml and bnd files ?
My configuration:
server.xml
<?xml version="1.0" encoding="UTF-8"?>
<server description="new server">
<keyStore password="{xor}Lz4sLCg7" />
<!-- Enable features -->
<featureManager>
<feature>jndi-1.0</feature>
<feature>distributedMap-1.0</feature>
<feature>localConnector-1.0</feature>
<feature>beanValidation-2.0</feature>
<feature>json-1.0</feature>
<feature>adminCenter-1.0</feature>
<feature>appSecurity-2.0</feature>
<feature>cdi-2.0</feature>
<!-- <feature>cdi-2.0</feature -->
<feature>jsf-2.3</feature>
<feature>mdb-3.2</feature>
<feature>ejbHome-3.2</feature>
<feature>ejbLite-3.2</feature>
<feature>ejbRemote-3.2</feature>
<feature>jca-1.7</feature>
<feature>jms-2.0</feature>
<feature>ldapRegistry-3.0</feature>
<feature>jaxrs-2.1</feature>
</featureManager>
<authCache initialSize="100" maxSize="50000" timeout="90m" />
<applicationMonitor dropinsEnabled="false" />
<distributedMap id="baseCache" memorySizeInMB="500">
</distributedMap>
<basicRegistry id="basic" realm="LdapRegistry">
<user password="{xor}Ozo5Kiw6LQ==" name="defuser" />
<user password="OO7GVOJC" name="user" id="test" />
</basicRegistry>
<remoteFileAccess>
<writeDir>${server.config.dir}</writeDir>
</remoteFileAccess>
<administrator-role>
<user>user</user>
</administrator-role>
<!-- new properties-->
<jdbcDriver id="DB2_Using_IBM_JCC_Driver" javax.sql.DataSource="com.ibm.db2.jcc.DB2ConnectionPoolDataSource">
<library>
<file name="${DB2_JCC_DRIVER_PATH}/db2jcc4.jar" />
<file name="${UNIVERSAL_JDBC_DRIVER_PATH}/db2jcc_license_cu.jar" />
<file name="${DB2_JCC_DRIVER_PATH}/db2jcc_license_cisuz.jar" />
<file name="${PUREQUERY_PATH}/pdq.jar" />
<file name="${PUREQUERY_PATH}/pdqmgmt.jar" />
</library>
</jdbcDriver>
<dataSource containerAuthDataRef="DB2USER" id="DEFAULT-DB2" jdbcDriverRef="DB2_Using_IBM_JCC_Driver" jndiName="jdbc/DEFAULT-DB2">
<properties.db2.jcc databaseName="D0" description="Default DB2 JCC Driver Datasource" name="DEFAULT-DB2" portNumber="50000" serverName="db2connect.dev.intranet.eu" driverType="2" />
<connectionManager agedTimeout="0" connectionTimeout="180" maxIdleTime="1800" maxPoolSize="10" minPoolSize="1" reapTime="180" />
</dataSource>
<!---ENS-->
<!-- To access this server from a remote client add a host attribute to the following element, e.g. host="*" -->
<httpEndpoint httpPort="9080" httpsPort="9443" id="defaultHttpEndpoint" />
<!-- Automatically expand WAR files and EAR files -->
<applicationManager autoExpand="true" />
<applicationMonitor updateTrigger="mbean" />
<enterpriseApplication id="PRE-EAR" location="${server.config.dir}/apps/expanded/PRE-EAR.ear" name="PRE-EAR" type="ear">
<classloader privateLibraryRef="javassist" commonLibraryRef="javassist" delegation="parentLast" />
<application-bnd>
<security-role name="Authenticated">
<user name="user2" access-id="user2" />
<run-as userid="user" password="test" />
</security-role>
</application-bnd>
</enterpriseApplication>
<logging consoleLogLevel="ERROR" traceFormat="ADVANCED" />
<authData user="TA02113" password="OO7GVOJC" />
</server>
application.xml
<?xml version="1.0" encoding="UTF-8"?>
<application 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/application_5.xsd" version="5">
<display-name>PRE-EAR</display-name>
<module>
<ejb>PRE-BF.jar</ejb>
</module>
<module>
<web>
<web-uri>PRE-WS.war</web-uri>
<context-root>/PRE-WS</context-root>
</web>
</module>
<module>
<web>
<web-uri>PRE-RS.war</web-uri>
<context-root>/PRE-RS</context-root>
</web>
</module>
<module>
<web>
<web-uri>PRE-PF.war</web-uri>
<context-root>/PRE-PF</context-root>
</web>
</module>
<security-role>
<role-name>Authenticated</role-name>
</security-role>
<security-role>
<role-name>Guest</role-name>
</security-role>
<library-directory>lib</library-directory>
</application>
ibm-application-bnd.xml
<?xml version="1.0" encoding="UTF-8"?>
<application-bnd
xmlns="http://websphere.ibm.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://websphere.ibm.com/xml/ns/javaee http://websphere.ibm.com/xml/ns/javaee/ibm-application-bnd_1_0.xsd"
version="1.0">
<security-role name="Authenticated">
<special-subject type="ALL_AUTHENTICATED_IN_TRUSTED_REALMS" />
</security-role>
<security-role name="Guest">
<special-subject type="EVERYONE" />
</security-role>
</application-bnd>
configuaration one of wars
web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="3.1" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd">
<display-name>PRE-RS</display-name>
<servlet>
<servlet-name>cxf</servlet-name>
<servlet-class>
CXFServlet
</servlet-class>
<init-param>
<param-name>javax.ws.rs.Application</param-name>
<param-value>RestApplicationConfig</param-value>
</init-param>
<init-param>
<param-name>jaxrs.address</param-name>
<param-value>/service</param-value>
</init-param>
<init-param>
<param-name>jaxrs.application.address.ignore</param-name>
<param-value>false</param-value>
</init-param>
<init-param>
<param-name>hide-service-list-page</param-name>
<param-value>false</param-value>
</init-param>
<init-param>
<param-name>jaxrs.inInterceptors</param-name>
<param-value>org.apache.cxf.interceptor.LoggingInInterceptor</param-value>
</init-param>
<init-param>
<param-name>jaxrs.outInterceptors</param-name>
<param-value>org.apache.cxf.interceptor.LoggingOutInterceptor</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>cxf</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
<security-role>
<role-name>Authenticated</role-name>
</security-role>
<security-role>
<role-name>Guest</role-name>
</security-role>
<security-constraint>
<web-resource-collection>
<web-resource-name>service</web-resource-name>
<url-pattern>/service/*</url-pattern>
<http-method>GET</http-method>
<http-method>POST</http-method>
<http-method>PUT</http-method>
<http-method>DELETE</http-method>
</web-resource-collection>
<auth-constraint>
<role-name>Authenticated</role-name>
</auth-constraint>
<user-data-constraint>
<transport-guarantee>CONFIDENTIAL</transport-guarantee>
</user-data-constraint>
</security-constraint>
<login-config>
<auth-method>BASIC</auth-method>
<realm-name>customRealm</realm-name>
</login-config>
<resource-ref>
<description />
<res-ref-name>jdbc/defaultDs</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
<res-sharing-scope>Shareable</res-sharing-scope>
</resource-ref>
</web-app>
ibm-web-bnd.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-bnd
xmlns="http://websphere.ibm.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://websphere.ibm.com/xml/ns/javaee http://websphere.ibm.com/xml/ns/javaee/ibm-web-bnd_1_0.xsd"
version="1.0">
<virtual-host name="default_host" />
<resource-ref name="jdbc/defaultDs" binding-name="jdbc/DEFAULT-DB2" />
</web-bnd>
I gets error that DEFAULT-DB2 is not set.
I have chacked and there is no direct jndi binding any of wars does not see datasoruce in jndi direct jdbc/DEFAULT-DB2 but i do not know why.

Spring JPA, JSON, Security Exception No bean named 'springSecurityFilterChain' is defined

I apologize that this is a common question - but I am a bit lost trying to correct my code. I have a JPA/JSON/Spring Security application that is failing to start with the exception: "No bean named 'springSecurityFilterChain' is defined". I have attached my web.xml and security-context xml below. Fromwhat I can work out the later may not being loaded correctly? Any help appreciated. I have been through other questions with no luck
web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
id="WebApp_ID" version="3.0">
<display-name>Application</display-name>
<!-- The definition of the Root Spring Container shared by all Servlets and Filters -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
classpath:root-context.xml
classpath:security-context.xml
</param-value>
</context-param>
<!-- Creates the Spring Container shared by all Servlets and Filters -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<!-- Processes application requests -->
<servlet>
<servlet-name>api</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring/api/servlet-context.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>api</servlet-name>
<url-pattern>/api/*</url-pattern>
</servlet-mapping>
<!-- Spring Security -->
<filter>
<filter-name>springSecurityFilterChain</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>
<filter-mapping>
<filter-name>springSecurityFilterChain</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
security-context.xml (/WEB-INF/spring/api/security-context.xml)
<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/security"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:sec="http://www.springframework.org/schema/security"
xsi:schemaLocation="
http://www.springframework.org/schema/security
http://www.springframework.org/schema/security/spring-security-3.2.xsd
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.0.xsd">
<!-- Rest authentication entry point configuration -->
<http auto-config="true" use-expressions="true" create-session="stateless"
entry-point-ref="restServicesEntryPoint" authentication-manager-ref="authenticationManagerForRest">
<intercept-url pattern="/api/**" />
<sec:form-login authentication-success-handler-ref="mySuccessHandler" />
<sec:access-denied-handler ref="myAuthenticationAccessDeniedHandler" />
<http-basic />
</http>
<!-- Entry point for REST service. -->
<beans:bean id="restServicesEntryPoint" class="foo.bar.RestAuthenticationEntryPoint1" />
<!-- Custom User details service which is provide the user data -->
<beans:bean id="customUserDetailsService" class="foo.bar.CustomUserDetailsService" />
<!-- Connect the custom authentication success handler -->
<beans:bean id="mySuccessHandler" class="foo.bar.RestAuthenticationSuccessHandler" />
<!-- Using Authentication Access Denied handler -->
<beans:bean id="myAuthenticationAccessDeniedHandler" class="foo.bar.RestAuthenticationAccessDeniedHandler" />
<!-- Authentication manager -->
<authentication-manager alias="authenticationManagerForRest">
<authentication-provider user-service-ref="customUserDetailsService" />
</authentication-manager>
<!-- Enable the annotations for defining the secure role -->
<global-method-security secured-annotations="enabled" />
</beans:beans>
SpringSecurityConfig.java
#Configuration
#ImportResource({ "/WEB-INF/spring/security-context.xml" })
#ComponentScan("foo.bar.security")
public class SpringSecurityConfig {
public SpringSecurityConfig() {
super();
}
}

Spring Webflow + MVC resources mapping

I'm trying to make a sample project using spring mvc, webflow and primefaces.
Here is my deployment descriptor (web.xml):
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
<display-name>TestMVC</display-name>
<welcome-file-list>
<welcome-file>/app/testClasses</welcome-file>
</welcome-file-list>
<!-- Context parameters -->
<context-param>
<param-name>log4jConfigLocation</param-name>
<param-value>log4j.properties</param-value>
</context-param>
<context-param>
<param-name>log4jExposeWebAppRoot</param-name>
<param-value>false</param-value>
</context-param>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/applicationContext.xml</param-value>
</context-param>
<!-- Logging -->
<listener>
<listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
</listener>
<!-- Appcontext listener -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<listener>
<listener-class>com.sun.faces.config.ConfigureListener</listener-class>
</listener>
<context-param>
<param-name>javax.faces.DEFAULT_SUFFIX</param-name>
<param-value>.xhtml</param-value>
</context-param>
<context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>Development</param-value>
</context-param>
<context-param>
<param-name>javax.faces.FACELETS_REFRESH_PERIOD</param-name>
<param-value>1</param-value>
</context-param>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.faces</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>appServlet</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/servlet-context.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>appServlet</servlet-name>
<url-pattern>/app/*</url-pattern>
</servlet-mapping>
</web-app>
MVC servlet context:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jaxws="http://cxf.apache.org/jaxws"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:jdbc="http://www.springframework.org/schema/jdbc"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:oxm="http://www.springframework.org/schema/oxm"
xmlns:task="http://www.springframework.org/schema/task"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:webflow-config="http://www.springframework.org/schema/webflow-config"
xmlns:faces="http://www.springframework.org/schema/faces"
xmlns:p="http://www.springframework.org/schema/p"
xsi:schemaLocation="http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-3.2.xsd
http://www.springframework.org/schema/webflow-config http://www.springframework.org/schema/webflow-config/spring-webflow-config-2.3.xsd
http://www.springframework.org/schema/oxm http://www.springframework.org/schema/oxm/spring-oxm-3.2.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd
http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-3.2.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/faces http://www.springframework.org/schema/faces/spring-faces-2.2.xsd
http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.2.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd">
<bean id="facesContextListener" class="org.springframework.faces.webflow.FlowFacesContextLifecycleListener" />
<webflow-config:flow-executor id="flowExecutor">
<webflow-config:flow-execution-listeners>
<webflow-config:listener ref="facesContextListener"/>
</webflow-config:flow-execution-listeners>
</webflow-config:flow-executor>
<faces:flow-builder-services id="flowBuilderServices"/>
<webflow-config:flow-registry id="flowRegistry" flow-builder-services="flowBuilderServices" base-path="/WEB-INF/flows">
<webflow-config:flow-location-pattern value="/**/flow.xml"/>
</webflow-config:flow-registry>
<mvc:annotation-driven />
<mvc:resources location="/, classpath:/META-INF/resources/primefaces/, classpath:/META-INF/resources/primefaces-aristo/" mapping="/javax.faces.resource/**"/>
<context:component-scan base-package="ru.test.controller" />
<bean class="org.springframework.webflow.mvc.servlet.FlowHandlerMapping">
<property name="flowRegistry" ref="flowRegistry" />
</bean>
<bean class="org.springframework.web.servlet.view.UrlBasedViewResolver">
<property name="viewClass" value="org.springframework.faces.mvc.JsfView" />
<property name="prefix" value="/WEB-INF/views/" />
<property name="suffix" value=".xhtml" />
</bean>
<bean class="org.springframework.faces.webflow.JsfFlowHandlerAdapter">
<property name="flowExecutor" ref="flowExecutor" />
</bean>
<bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource" p:basenames="WEB-INF/i18n/messages,WEB-INF/i18n/application" p:fallbackToSystemLocale="false" />
</beans>
The question I have - is it right to make such mappings:
<mvc:resources location="/, classpath:/META-INF/resources/primefaces/, classpath:/META-INF/resources/primefaces-aristo/" mapping="/javax.faces.resource/**"/>
in the MVC servlet context or I'm doing something wrong? In the examples from the book "Pro SPRING 3" there's no such mapping, but if I remove it, I will receive an errors like no mapping found for ".../javax.faces.resource/theme.css" in DispatcherServlet and so on.
I think my way to add mappings is wrong because I don't see images from primefaces-aristo/images anyway.
Versions of libraries are:
Spring faces and webflow: 2.3.0.RELEASE
Spring webmvc: 3.2.3.RELEASE
Primefaces: 4.0
jsf-api and jsf-impl: 2.0.11
Thanks in advance!
UPDATE:
I found an answer myself. The way I used is wrong, tag mvc:resources is used for local resources mapping and to map JSF resources one needs to add
<faces:resources/>
into mvc servlet context.
used pom.xml
<dependency>
<groupId>org.springframework.webflow</groupId>
<artifactId>spring-js</artifactId>
<version>2.4.0.RELEASE</version>
</dependency>
and
<mvc:resources mapping="/web-resources/**/" location="/"/>

spring security. forward after login page

It is snippet from spring security config:
<form-login login-page="/home.jsp"
authentication-failure-url="/loginFailed" default-target-url="/index" />
<logout logout-success-url="/logOut" />
But if I enter successfull I was forward to /logOut
if click log out - go to home.jsp .
if failed login - home.jsp
What is the strange behaviour?
update
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">
<!-- The definition of the Root Spring Container shared by all Servlets
and Filters -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring/root-context.xml</param-value>
</context-param>
<!-- Creates the Spring Container shared by all Servlets and Filters -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<!-- Processes application requests -->
<servlet>
<servlet-name>appServlet</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring/appServlet/servlet-context.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>appServlet</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<filter>
<filter-name>springSecurityFilterChain</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>
<filter-mapping>
<filter-name>springSecurityFilterChain</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<welcome-file-list>
<welcome-file>home.jsp</welcome-file>
</welcome-file-list>
</web-app>
root-context.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:jee="http://www.springframework.org/schema/jee" xmlns:lang="http://www.springframework.org/schema/lang"
xmlns:p="http://www.springframework.org/schema/p" xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee.xsd
http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd">
<!-- Root Context: defines shared resources visible to all other web components -->
<!-- Настраивает управление транзакциями с помощью аннотации #Transactional -->
<!-- -->
<import resource="classpath:spring/BeanConfig.xml" />
<!-- Файл с настройками Security -->
<import resource="security_config.xml" />
<!-- <bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource‌​"> -->
<!-- <property name="basename" value="/WEB-INF/messages/messages" /> -->
<!-- </bean> -->
</beans>
securuty_config.xml
<beans:beans xmlns="http://www.springframework.org/schema/security"
xmlns:beans="http://www.springframework.org/schema/beans" 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-3.1.xsd
http://www.springframework.org/schema/security
http://www.springframework.org/schema/security/spring-security-3.1.xsd">
<http use-expressions="true" >
<intercept-url pattern="/home.jsp" access="permitAll" />
<intercept-url pattern="/*" access="isAuthenticated()"/>
<form-login login-page="/home.jsp"
authentication-failure-url="/loginFailed" default-target-url="/index" />
<logout logout-success-url="/logOut" />
</http>
<authentication-manager>
<authentication-provider ref="provider" />
<!-- <authentication-provider> -->
<!-- <user-service> -->
<!-- <user name="name" authorities="ROLE_USER"/> -->
<!-- </user-service> -->
<!-- </authentication-provider> -->
</authentication-manager>
</beans:beans>
form authenthification fragment:
<form method="POST" action="<c:url value="/j_spring_security_check" />"
Hi #user2740224 can you try in security_config.xml something like this:
<global-method-security secured-annotations="enabled" pre-post-annotations="enabled" />
<http use-expressions="true" >
<intercept-url pattern="/index*" access="isAuthenticated()" />
<form-login login-page="/home" default-target-url="/index" always-use-default-target="true" authentication-failure-url="/loginFailed" />
<logout logout-success-url="/home" delete-cookies="JSESSIONID" invalidate-session="true" />
...
</http>
I hope help you :)

Struts + Spring Integration issue with struts-config.xml

I am trying to integrate Struts with Spring.
Struts alone is working fine. However when I am trying to put:
<plug-in className="org.springframework.web.struts.ContextLoaderPlugIn">
<set-property property="contextConfigLocation"
value="/WEB-INF/lib/WebApplicationSpringContext.xml" />
</plug-in>
<controller processorClass="org.springframework.web.struts.DelegatingRequestProcessor" />
element in side struts-config.xml, The xml start throwing
The content of element type "struts-config" must match "(data-sources?,form-beans?,global-exceptions?,global-
forwards?,action-mappings?,controller?,message-resources*,plug-in*)".
Following is my struts-config.xml:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.1//EN"
"http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd">
<struts-config>
<form-beans>
<form-bean name="userForm"
type="com.sample.form.UserForm" />
</form-beans>
<action-mappings>
<action path="/user" type="com.sample.action.UserAction"
name="userForm" scope="request" validate="true">
<forward name="success" path="/WEB-INF/jsp/welcome.jsp" />
<forward name="failed" path="/WEB-INF/jsp/user.jsp" />
</action>
</action-mappings>
<plug-in className="org.springframework.web.struts.ContextLoaderPlugIn">
<set-property property="contextConfigLocation"
value="/WEB-INF/lib/WebApplicationSpringContext.xml" />
</plug-in>
<controller processorClass="org.springframework.web.struts.DelegatingRequestProcessor" />
</struts-config>
Following is WebApplicationSpringContext.xml
<?xml version="1.0" encoding="UTF-8" ?>
<beans:beans xmlns="http://www.springframework.org/schema/security"
xmlns:beans="http://www.springframework.org/schema/beans" xmlns:p="http://www.springframework.org/schema/p"
xmlns:tx="http://www.springframework.org/schema/tx" 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-3.0.xsd
http://www.springframework.org/schema/jdbc
http://www.springframework.org/schema/jdbc/spring-jdbc-3.0.xsd
http://www.springframework.org/schema/security
http://www.springframework.org/schema/security/spring-security-3.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">
<beans:bean name="/user" id="user"
class="com.sample.action.UserAction">
<beans:constructor-arg index="0" value="sample" />
</beans:bean>
</beans:beans>
I am stuck with struts-config.xml.
The content of element type "struts-config" must match "(data-sources?,form-beans?,global-exceptions?,global-
forwards?,action-mappings?,controller?,message-resources*,plug-in*)".
Try putting:
<controller processorClass=...
above:
<plug-in className="
meaning switch the tags order
Try this:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
<display-name>actionbean</display-name>
<welcome-file-list>
<welcome-file>welcome.html</welcome-file>
</welcome-file-list>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/applicationContext.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<servlet>
<servlet-name>servlet</servlet-name>
<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/struts-config.xml</param-value>
</init-param>
<init-param>
<param-name>debug</param-name>
<param-value>2</param-value>
</init-param>
<init-param>
<param-name>detail</param-name>
<param-value>2</param-value>
</init-param>
<load-on-startup>2</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>servlet</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
<jsp-config>
<taglib>
<taglib-uri>/WEB-INF/struts-bean.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-bean.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/WEB-INF/struts-html.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-html.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/WEB-INF/struts-tiles.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-tiles.tld</taglib-location>
</taglib>
</jsp-config>
</web-app>
I m assuming that you have all correct jar files in build path.

Resources