0

My spring application is working on local machine properly. But, on deploying it on a VM, it is giving HTTP Status 404 error.

On VM:

http://serverIP:8080/Project/index.jsp

It is giving HTTP 404 error.

web.xml

<servlet>
    <servlet-name>dispatcher</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <load-on-startup>2</load-on-startup>
</servlet>
<servlet-mapping>
    <servlet-name>dispatcher</servlet-name>
    <url-pattern>*.htm</url-pattern>
</servlet-mapping>

<filter>
    <filter-name>osivf</filter-name>
    <filter-class>org.springframework.orm.hibernate4.support.OpenSessionInViewFilter</filter-class>
</filter>

<filter-mapping>
    <filter-name>osivf</filter-name>
    <servlet-name>dispatcher</servlet-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>

<welcome-file-list>
    <welcome-file>/index.htm</welcome-file>
</welcome-file-list>

dispatcher-servlet.xml

indexController

<bean id="viewResolver"
      class="org.springframework.web.servlet.view.InternalResourceViewResolver"
      p:prefix="/WEB-INF/jsp/"
      p:suffix=".jsp" />


<bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
    <property name="maxUploadSize" value="10000000"/>
</bean>


<!--
The index controller.
-->
<bean name="indexController"
      class="org.springframework.web.servlet.mvc.ParameterizableViewController"
      p:viewName="index" />


<!--  <bean id="hibernateTemplate" class="org.springframework.orm.hibernate4.HibernateTemplate">
    <constructor-arg name="sessionFactory" ref="sessionFactory" />
</bean>-->

<!--<bean id="dao" class="food.db.DAO" />-->

Can somebody please help me here?

Jitendra
  • 1
  • 1

1 Answers1

0

you are accessing the deployed application with in the VM than you donot need the VM ip , try with http://localhost:8080/Project/index.jsp

if you want to access the deployed application on vm from your local system, than you need to forward the port from vm to local system like

step 1. open the vm setting
Step 2. Go to the Network tab .
Step 3. In forwarded port need to define host port 8080 and guest port 8080
Step 4. start the VM.

http://<VM IP>:8080/Project/index.jsp

rikki
  • 51
  • 9
  • Actually, I am trying to host it on EC2 VM. On my local machine, Below is url. http://localhost:8080/index.htm. But, same is not working on EC2 VM – Jitendra Jul 30 '16 at 17:23
  • I am using tomcat server on ec2 VM for hosting it. I put my war file into webapps folder. And started tomcat server. http://serverIP:8080/index.jsp will give default tomcat page. I tried accessing my application page with http://serverIP:8080/Project/index.jsp or http://serverIP:8080/Project/index.htm, Both are giving 404 error. – Jitendra Jul 30 '16 at 17:37
  • serverIP is accessible from your system..? And are you able to see the tomcat home page after starting the tomcat server?. – rikki Jul 31 '16 at 11:24
  • Yes. Server IP is pingable. And able to see the tomcat home page. – Jitendra Jul 31 '16 at 19:17
  • while you start the tomcat on ec2 , please check the logs as well, is the application deploy successful or not ?? – rikki Aug 01 '16 at 11:26
  • Tomcat is running properly. "service tomcat7 start". This will start the tomcat service on EC2 linux VM. I am able to see tomcat home page. – Jitendra Aug 01 '16 at 16:23
  • you need to check the tomcat server log while starting the tomcat because you have copy the war file into the webapps folder in the tomcat directory right so you need to check the log while starting the log and let me know the application is deployed successfully or not ..?? – rikki Aug 02 '16 at 09:11
  • Yeah checked the logs. There was some version conflict. Resolved. Thanks for your help. – Jitendra Aug 03 '16 at 09:22