404 on simple spring app on tomcat
I keep getting a 404 while trying to apply SSL to my Simple Spring app called SpringEncrypted.
The root website (which is the tomcat welcome page) works with both http and https,
but whenever I try to access http://localhost:8080/SpringEncrypted or https://localhost:8443/SpringEncrypted,
it always give me a 404 error, I figured it might be a directory problem but i'm not familiar with how tomcat deploys its directory, and because it worked when I tried it on Eclipse. I'm hoping this might be a common problem people encounter with spring/tomcat combination.
Helps would be appreciated :]
Here's the directory structure that I have inside the .war file located on the Tomcat webapps folder:
(META-INF)
-- manifest.mf
(WEB-INF)
---web.xml
---doraemon-servlet.xml
---logging.properties
---(classes)
------com/kernn/spring3/controller/helloWorldController.class
------com/kernn/spring3/controller/helloWorldController.java
---(lib)
hello.html
hello.jsp
index.jsp
I'm using Tomcat 7, Spring 3.1.2, and JDK 6
web.xml
Code:
<?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_2_5.xsd"
id="WebApp_ID" version="2.5">
<display-name>Spring Encrypted</display-name>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>doraemon</servlet-name>
<servlet-class>
org.springframework.web.servlet.DispatcherServlet
</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>doraemon</servlet-name>
<url-pattern>*.html</url-pattern>
</servlet-mapping>
<!--listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener-->
<!--listener>
<listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
</listener-->
<!--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-->
</web-app>
doraemon-servlet.xml
Code:
<?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:util="http://www.springframework.org/schema/util"
xmlns:security="http://www.springframework.org/schema/security"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/util
http://www.springframework.org/schema/util/spring-util-3.0.xsd
http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.0.xsd">
<security:http auto-config="true">
<security:intercept-url pattern="/styles/**" filters="none"/>
<security:intercept-url pattern="/admin/**" access="ROLE_SUPERADMIN, ROLE_STANDARD" requires-channel="https"/>
<security:intercept-url pattern="/login*" access="IS_AUTHENTICATED_ANONYMOUSLY" requires-channel="https"/>
<security:intercept-url pattern="/**" requires-channel="any" access="IS_AUTHENTICATED_ANONYMOUSLY"/>
<security:form-login login-page="/login.dhtml" authentication-failure-url="/login_fail.dhtml?error=1"/>
<security:logout logout-url="/j_spring_security_logout" logout-success-url="/login.dhtml"/>
<security:port-mappings>
<security:port-mapping http="8090" https="8443"/>
<security:port-mapping http="8080" https="8443"/>
</security:port-mappings>
</security:http>
<bean id="channelProcessingFilter" class="org.springframework.security.web.access.channel.ChannelProcessingFilter">
<property name="channelDecisionManager">
<bean class="org.springframework.security.web.access.channel.ChannelDecisionManagerImpl">
<property name="channelProcessors">
<util:list>
<bean class="org.springframework.security.web.access.channel.SecureChannelProcessor"/>
<bean class="org.springframework.security.web.access.channel.InsecureChannelProcessor"/>
</util:list>
</property>
</bean>
</property>
<property name="securityMetadataSource">
<bean class=" org.springframework.security.web.access.intercept.DefaultFilterInvocationSecurityMetadataSource">
<constructor-arg>
<bean class="org.springframework.security.web.util.AntUrlPathMatcher"/>
</constructor-arg>
<constructor-arg>
<util:map map-class="java.util.LinkedHashMap">
<entry>
<key>
<bean class="org.springframework.security.web.access.intercept.RequestKey">
<constructor-arg value="/admin/**/**"/>
</bean>
</key>
<util:list>
<bean class="org.springframework.security.access.SecurityConfig">
<constructor-arg value="REQUIRES_SECURE_CHANNEL"/>
</bean>
</util:list>
</entry>
<entry>
<key>
<bean class="org.springframework.security.web.access.intercept.RequestKey">
<constructor-arg value="/**"/>
</bean>
</key>
<util:list>
<bean class="org.springframework.security.access.SecurityConfig">
<constructor-arg value="REQUIRES_INSECURE_CHANNEL"/>
</bean>
</util:list>
</entry>
</util:map>
</constructor-arg>
</bean>
</property>
</bean>
</beans>