0

Hi i created a maven project for spring.After i created project the final product is .war file. Then i upload it with using tomcat manager.But i cannot access or show page...!! it gives me following error enter image description here

web.xml

<!-- Reads request input using UTF-8 encoding -->
    <filter>
        <filter-name>characterEncodingFilter</filter-name>
        <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
        <init-param>
            <param-name>encoding</param-name>
            <param-value>UTF-8</param-value>
        </init-param>
        <init-param>
            <param-name>forceEncoding</param-name>
            <param-value>true</param-value>
        </init-param>
    </filter>

    <filter-mapping>
        <filter-name>characterEncodingFilter</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>
    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>/WEB-INF/spring-context-data.xml</param-value>
    </context-param>

    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>

    <servlet>
        <servlet-name>dispatcher</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <init-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>
            /WEB-INF/spring-context-web.xml,
             /WEB-INF/spring-context-data.xml,
             /WEB-INF/spring-security.xml
            </param-value>

        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>

    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>
             /WEB-INF/spring-context-web.xml,
             /WEB-INF/spring-context-data.xml,
             /WEB-INF/spring-security.xml
        </param-value>
    </context-param>

    <servlet-mapping>
        <servlet-name>dispatcher</servlet-name>
        <url-pattern>/*</url-pattern>
    </servlet-mapping>
    <!-- <servlet>
            <servlet-name>RealEstate</servlet-name>
            <servlet-class>com.Servlet1</servlet-class>
    </servlet>
    <servlet-mapping>
        <servlet-name>RealEstate</servlet-name>
        <url-pattern>/</url-pattern>
    </servlet-mapping> -->
<!-- Handles all requests into the application -->
    <servlet>
        <servlet-name>Spring MVC Dispatcher Servlet</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <init-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>
                /WEB-INF/spring-context-web.xml
            </param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>

    <servlet-mapping>
        <servlet-name>Spring MVC Dispatcher Servlet</servlet-name>
        <url-pattern>/</url-pattern>
    </servlet-mapping>
    <filter>

        <filter-name>methodFilter</filter-name>
        <filter-class>org.springframework.web.filter.HiddenHttpMethodFilter</filter-class>
    </filter>

    <filter-mapping>
        <filter-name>methodFilter</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-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>

    <welcome-file-list>

        <welcome-file>index.html</welcome-file>

    </welcome-file-list>

pom.xml

<plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.3.2</version>
                <configuration>
                    <source>1.7</source>
                    <target>1.7</target>
                </configuration>
            </plugin>


            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>tomcat-maven-plugin</artifactId>
                <configuration>
                    <url>http://localhost:8080/manager/html</url>
                    <server>tomcat7</server>
                    <path>/RealEstate</path>
                </configuration>
            </plugin>

controller

@RequestMapping("/home")
    public String getHomePage() {

        return "/index";
    }
boycod3
  • 5,033
  • 11
  • 58
  • 87
  • 1
    `index` != `index.html`. – Michael-O May 28 '14 at 09:53
  • sorry it index not index.html .i just made a mistake – boycod3 May 28 '14 at 09:55
  • Change your code then. – Michael-O May 28 '14 at 09:55
  • can you tell me whats the problem??? – boycod3 May 28 '14 at 10:03
  • it gives me SEVERE: Context initialization failed org.springframework.beans.factory.BeanDefinitionStoreException: Failed to read candidate component class: file [C:\Users\Tyz-Pc\Desktop\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\RealEstate\WEB-INF\classes\com\habitz\realestate\controller\AdminController.class]; nested exception is java.lang.IncompatibleClassChangeError: class org.springframework.core.type.classreading.ClassMetadataReadingVisitor has interface org.springframework.asm.ClassVisitor as super class – boycod3 May 28 '14 at 10:11
  • this is related to versions incompatibility and may be if you compiled yourself a binary, http://stackoverflow.com/questions/1980452/what-causes-java-lang-incompatibleclasschangeerror – Laabidi Raissi May 28 '14 at 10:13
  • it show error on controller workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\RealEstate\WEB-INF\classes\com\habitz\realestate\controller\AdminController.class]; nested exception is java.lang.IncompatibleClassChangeError: class org.springframework.core.type.classreading.ClassMetadataReadingVisitor has interface org.springframework.asm.ClassVisitor as super class – boycod3 May 28 '14 at 10:59

2 Answers2

0

You url pattern doesnt serve your home request; remove star from it like below :

 <filter-mapping>
    <filter-name>characterEncodingFilter</filter-name>
    <url-pattern>/</url-pattern>
 </filter-mapping>

With this url pattern works with every url. Do it for other url patterns as well.

Pramod S. Nikam
  • 4,271
  • 4
  • 38
  • 62
0

You should post the dispatch servlet xml configuration file (spring-context-web.xml). There you should configure the view resolver like this:

<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <property name="viewClass" value="org.springframework.web.servlet.view.JstlView"/>
        <property name="prefix" value="/WEB-INF/views/" />
        <property name="suffix" value=".jsp" />
        <property name="order" value="2" /> 
</bean>
Mike Argyriou
  • 1,250
  • 2
  • 18
  • 30