Unexpected behaviour occur when I hit same url? - java

I am making a simple program of spring actually I am getting fine result when I run the program on eclipse (eclipse default browser).But when I run the same url on my browser it say resource not available .
Here is my images .
Here is my code
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" 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>FirstWebProject</display-name>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>crunchify</servlet-name>
<servlet-class>
org.springframework.web.servlet.DispatcherServlet
</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>crunchify</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
</web-app>
![crunchify-servlet.xml][2]
<?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:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd">
<context:component-scan
base-package="com.crunchify.controller" />
<bean id="viewResolver"
class="org.springframework.web.servlet.view.UrlBasedViewResolver">
<property name="viewClass"
value="org.springframework.web.servlet.view.JstlView" />
<property name="prefix" value="/WEB-INF/jsp/" />
<property name="suffix" value=".jsp" />
</bean>
</beans>
package com.crunchify.controller;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
#Controller
public class CrunchifyHelloWorld {
#RequestMapping("/welcome")
public ModelAndView helloWorld() {
String message = "<br><div align='center'>" + "<h1>Hello World, Spring 3.2.1 Example by Crunchify.com<h1> <br>";
message += "<a href='http://crunchify.com/category/java-web-development-tutorial/'>More Examples</a>";
return new ModelAndView("welcome", "message", message);
}
}
![enter code here][4]
![<html>
<head>
<title>Spring 3.2.1 MVC Series: Index - Crunchify.com</title>
</head>
<body>
<br>
<div align='center'>
<h2>
Your 1st Spring MCV Example <br> <br>
Click here to See Welcome Message...
</h2>
<br> by Crunchify.com
</div>
</body>
</html>][5]
13:25:00,259 INFO [AbstractJBossASServerBase] Server Configuration:
JBOSS_HOME URL: file:/F:/naveendata/setupfile/jboss-6.0.0.M1/
Bootstrap: $JBOSS_HOME\server/default/conf/bootstrap.xml
Common Base: $JBOSS_HOME\common/
Common Library: $JBOSS_HOME\common/lib/
Server Name: default
Server Base: $JBOSS_HOME\server/
Server Library: $JBOSS_HOME\server/default/lib/
Server Config: $JBOSS_HOME\server/default/conf/
Server Home: $JBOSS_HOME\server/default/
Server Data: $JBOSS_HOME\server/default/data/
Server Log: $JBOSS_HOME\server/default/log/
Server Temp: $JBOSS_HOME\server/default/tmp/
13:25:00,266 INFO [AbstractServer] Starting: JBossAS [6.0.0.M1 (build: SVNTag=JBoss_6_0_0_M1 date=200912040958)]
13:25:00,507 INFO [AbstractMCServerBase] Starting Microcontainer, Main bootstrapURL=file:/F:/naveendata/setupfile/jboss-6.0.0.M1/server/default/conf/bootstrap.xml
13:25:00,771 INFO [VFSCacheFactory] Initializing VFSCache [org.jboss.virtual.plugins.cache.CombinedVFSCache]
13:25:00,773 INFO [VFSCacheFactory] Using VFSCache [CombinedVFSCache[real-cache: null]]
13:25:00,897 INFO [CopyMechanism] VFS temp dir: F:\naveendata\setupfile\jboss-6.0.0.M1\server\default\tmp
13:25:00,898 INFO [ZipEntryContext] VFS force nested jars copy-mode is enabled.
13:25:01,329 INFO [ServerInfo] Java version: 1.7.0_25,Oracle Corporation
13:25:01,329 INFO [ServerInfo] Java Runtime: Java(TM) SE Runtime Environment (build 1.7.0_25-b17)
13:25:01,329 INFO [ServerInfo] Java VM: Java HotSpot(TM) Client VM 23.25-b01,Oracle Corporation
13:25:01,329 INFO [ServerInfo] OS-System: Windows 7 6.1,x86
13:25:01,329 INFO [ServerInfo] VM arguments: -Dprogram.name=run.bat -Xms128m -Xmx512m -XX:MaxPermSize=256m -Dfile.encoding=Cp1252
13:25:01,346 INFO [JMXKernel] Legacy JMX core initialized
13:25:02,690 INFO [Log4jService$URLWatchTimerTask] Configuring from URL: resource:jboss-log4j.xml
13:25:02,729 INFO [WebService] Using RMI server codebase: http://127.0.0.1:8083/
13:25:04,779 INFO [AbstractServerConfig] JBoss Web Services - Native Server
13:25:04,779 INFO [AbstractServerConfig] 3.2.1.GA
13:25:08,154 INFO [LogNotificationListener] Adding notification listener for logging mbean "jboss.system:service=Logging,type=Log4jService" to server org.jboss.mx.server.MBeanServerImpl#430f4[ defaultDomain='null' ]
13:25:13,978 INFO [JMXConnectorServerService] JMX Connector server: service:jmx:rmi://127.0.0.1/jndi/rmi://127.0.0.1:1090/jmxconnector
13:25:14,038 INFO [MailService] Mail Service bound to java:/Mail
13:25:14,996 WARN [JBossASSecurityMetadataStore] WARNING! POTENTIAL SECURITY RISK. It has been detected that the MessageSucker component which sucks messages from one node to another has not had its password changed from the installation default. Please see the JBoss Messaging user guide for instructions on how to do this.
13:25:15,083 INFO [TransactionManagerService] JBossTS Transaction Service (JTA version - tag:JBOSSTS_4_6_1_GA) - JBoss Inc.
13:25:15,083 INFO [TransactionManagerService] Setting up property manager MBean and JMX layer
13:25:15,245 INFO [TransactionManagerService] Initializing recovery manager
13:25:15,310 INFO [TransactionManagerService] Recovery manager configured
13:25:15,310 INFO [TransactionManagerService] Binding TransactionManager JNDI Reference
13:25:15,324 INFO [TransactionManagerService] Starting transaction recovery manager
13:25:15,880 INFO [AprLifecycleListener] The Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Program Files\Java\jre7\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:/Program Files/Java/jre6/bin/client;C:/Program Files/Java/jre6/bin;C:/Program Files/Java/jre6/lib/i386;C:\Program Files\Java\jre6\bin;;H:\setupfile\eclipse;;.
13:25:15,911 INFO [Http11Protocol] Initializing Coyote HTTP/1.1 on http-127.0.0.1-8080
13:25:15,914 INFO [AjpProtocol] Initializing Coyote AJP/1.3 on ajp-127.0.0.1-8009
13:25:15,924 INFO [StandardService] Starting service jboss.web
13:25:15,925 INFO [StandardEngine] Starting Servlet Engine: JBoss Web/2.1.6.GA
13:25:15,951 INFO [Catalina] Server startup in 36 ms
13:25:15,962 INFO [TomcatDeployment] deploy, ctxPath=/invoker
13:25:16,233 INFO [TomcatDeployment] deploy, ctxPath=/jbossws
13:25:16,249 INFO [TomcatDeployment] deploy, ctxPath=/web-console
13:25:16,411 INFO [RARDeployment] Required license terms exist, view vfszip:/F:/naveendata/setupfile/jboss-6.0.0.M1/server/default/deploy/jboss-local-jdbc.rar/META-INF/ra.xml
13:25:16,417 INFO [RARDeployment] Required license terms exist, view vfszip:/F:/naveendata/setupfile/jboss-6.0.0.M1/server/default/deploy/jboss-xa-jdbc.rar/META-INF/ra.xml
13:25:16,422 INFO [RARDeployment] Required license terms exist, view vfszip:/F:/naveendata/setupfile/jboss-6.0.0.M1/server/default/deploy/jms-ra.rar/META-INF/ra.xml
13:25:16,428 INFO [RARDeployment] Required license terms exist, view vfszip:/F:/naveendata/setupfile/jboss-6.0.0.M1/server/default/deploy/mail-ra.rar/META-INF/ra.xml
13:25:16,439 INFO [RARDeployment] Required license terms exist, view vfszip:/F:/naveendata/setupfile/jboss-6.0.0.M1/server/default/deploy/quartz-ra.rar/META-INF/ra.xml
13:25:16,478 INFO [SimpleThreadPool] Job execution threads will use class loader of thread: Thread-2
13:25:16,493 INFO [QuartzScheduler] Quartz Scheduler v.1.5.2 created.
13:25:16,495 INFO [RAMJobStore] RAMJobStore initialized.
13:25:16,495 INFO [StdSchedulerFactory] Quartz scheduler 'DefaultQuartzScheduler' initialized from default resource file in Quartz package: 'quartz.properties'
13:25:16,495 INFO [StdSchedulerFactory] Quartz scheduler version: 1.5.2
13:25:16,495 INFO [QuartzScheduler] Scheduler DefaultQuartzScheduler_$_NON_CLUSTERED started.
13:25:16,574 INFO [ConnectionFactoryBindingService] Bound ConnectionManager 'jboss.jca:service=DataSourceBinding,name=firstGroupAdminConsoleDS' to JNDI name 'java:firstGroupAdminConsoleDS'
13:25:16,593 INFO [ConnectionFactoryBindingService] Bound ConnectionManager 'jboss.jca:service=DataSourceBinding,name=firstGroupRailAppDS' to JNDI name 'java:firstGroupRailAppDS'
13:25:17,177 INFO [ConnectionFactoryBindingService] Bound ConnectionManager 'jboss.jca:service=DataSourceBinding,name=DefaultDS' to JNDI name 'java:DefaultDS'
13:25:17,369 INFO [ServerPeer] JBoss Messaging 1.4.3.GA server [0] started
13:25:17,434 INFO [ConnectionFactory] Connector bisocket://127.0.0.1:4457 has leasing enabled, lease period 10000 milliseconds
13:25:17,434 INFO [ConnectionFactory] org.jboss.jms.server.connectionfactory.ConnectionFactory#498624 started
13:25:17,434 INFO [ConnectionFactory] Connector bisocket://127.0.0.1:4457 has leasing enabled, lease period 10000 milliseconds
13:25:17,434 INFO [ConnectionFactory] org.jboss.jms.server.connectionfactory.ConnectionFactory#134d4c started
13:25:17,435 INFO [ConnectionFactoryJNDIMapper] supportsFailover attribute is true on connection factory: jboss.messaging.connectionfactory:service=ClusteredConnectionFactory but post office is non clustered. So connection factory will *not* support failover
13:25:17,435 INFO [ConnectionFactoryJNDIMapper] supportsLoadBalancing attribute is true on connection factory: jboss.messaging.connectionfactory:service=ClusteredConnectionFactory but post office is non clustered. So connection factory will *not* support load balancing
13:25:17,435 INFO [ConnectionFactory] Connector bisocket://127.0.0.1:4457 has leasing enabled, lease period 10000 milliseconds
13:25:17,435 INFO [ConnectionFactory] org.jboss.jms.server.connectionfactory.ConnectionFactory#1025dc5 started
13:25:17,443 INFO [QueueService] Queue[/queue/ExpiryQueue] started, fullSize=200000, pageSize=2000, downCacheSize=2000
13:25:17,444 INFO [QueueService] Queue[/queue/DLQ] started, fullSize=200000, pageSize=2000, downCacheSize=2000
13:25:17,488 INFO [ConnectionFactoryBindingService] Bound ConnectionManager 'jboss.jca:service=ConnectionFactoryBinding,name=JmsXA' to JNDI name 'java:JmsXA'
13:25:17,559 INFO [TomcatDeployment] deploy, ctxPath=/admin-console
13:25:17,616 ERROR [MyfacesConfig] Both MyFaces and the RI are on your classpath. Please make sure to use only one of the two JSF-implementations.
13:25:17,777 WARN [LocaleUtils] Locale name in faces-config.xml null or empty, setting locale to default locale : en_US
13:25:19,218 INFO [TomcatDeployment] deploy, ctxPath=/FirstWebProject
13:25:19,294 INFO [[/FirstWebProject]] Initializing Spring FrameworkServlet 'crunchify'
13:25:19,650 INFO [TomcatDeployment] deploy, ctxPath=/
13:25:19,675 INFO [TomcatDeployment] deploy, ctxPath=/jmx-console
13:25:19,704 INFO [TomcatDeployment] deploy, ctxPath=/zmeu
13:25:19,738 INFO [ProfileServiceBootstrap] Loading profile: ProfileKey#b167ca[domain=default, server=default, name=default]
13:25:19,744 INFO [Http11Protocol] Starting Coyote HTTP/1.1 on http-127.0.0.1-8080
13:25:19,756 INFO [AjpProtocol] Starting Coyote AJP/1.3 on ajp-127.0.0.1-8009
13:25:19,760 INFO [AbstractServer] JBossAS [6.0.0.M1 (build: SVNTag=JBoss_6_0_0_M1 date=200912040958)] Started in 19s:493ms
13:25:35,794 WARN [PageNotFound] No mapping found for HTTP request with URI [/FirstWebProject/] in DispatcherServlet with name 'crunchify'
13:25:46,241 WARN [PageNotFound] No mapping found for HTTP request with URI [/FirstWebProject/index] in DispatcherServlet with name 'crunchify'
13:26:50,674 WARN [PageNotFound] No mapping found for HTTP request with URI [/FirstWebProject/] in DispatcherServlet with name 'crunchify'

Related

How to deploy a camel java DSL servlet on Tomcat server?

I have found several examples of camel servlet for tomcat server using spring DSL, I want to use Java DSL and create a RouteBuilder as shown below. This servlet works as expected on Jetty when I run using mvn jetty:run command, but doesn't work with tomcat server.
import org.apache.camel.Exchange;
import org.apache.camel.Processor;
import org.apache.camel.builder.RouteBuilder;
public class DefaultRouteBuilder extends RouteBuilder {
#Override
public void configure() throws Exception {
System.out.println("DefaultRouter");
from("servlet:hello?matchOnUriPrefix=true").process(new Processor() {
public void process(Exchange exchange) throws Exception {
String contentType = exchange.getIn().getHeader(Exchange.CONTENT_TYPE, String.class);
String path = exchange.getIn().getHeader(Exchange.HTTP_URI, String.class);
path = path.substring(path.lastIndexOf("/"));
exchange.getOut().setHeader(Exchange.CONTENT_TYPE, contentType + "; charset=UTF-8");
exchange.getOut().setHeader("PATH", path);
exchange.getOut().setBody("<b>Hello World</b>");
}
});
}
}
As per my understanding my web.xml looks like this
<?xml version="1.0" encoding="ISO-8859-1"?>
<webapp>
<display-name>camel-servlet</display-name>
<context-param>
<param-name>name</param-name>
<param-value>MyCamel</param-value>
</context-param>
<context-param>
<param-name>routeBuilder-MyRoute</param-name>
<param-value>org.apache.camel.community.so.servletlistener.DefaultRouteBuilder</param-value>
</context-param>
<listener>
<listener-class>org.apache.camel.component.servletlistener.JndiCamelServletContextListener</listener-class>
</listener>
<servlet>
<servlet-name>CamelServlet</servlet-name>
<servlet-class>org.apache.camel.component.servlet.CamelHttpTransportServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>CamelServlet</servlet-name>
<url-pattern>/camel/*</url-pattern>
</servlet-mapping>
</webapp>
Edit:
Logs from mvn jetty:run command -
[INFO] Scanning elapsed time=1409ms
[INFO] DefaultSessionIdManager workerName=node0
[INFO] No SessionScavenger set, using defaults
[INFO] node0 Scavenging every 660000ms
2022-07-19 11:15:39,454 [main ] INFO CamelServletContextListener - CamelContextServletListener initializing ...
DefaultRouter
2022-07-19 11:15:39,797 [main ] INFO ServletCamelContext - Apache Camel 2.25.0 (CamelContext: MyCamel) is starting
2022-07-19 11:15:39,804 [main ] INFO ManagedManagementStrategy - JMX is enabled
2022-07-19 11:15:40,094 [main ] INFO DefaultTypeConverter - Type converters loaded (core: 195, classpath: 9)
2022-07-19 11:15:40,233 [main ] INFO ServletCamelContext - StreamCaching is not in use. If using streams then its recommended to enable stream caching. See more details at http://camel.apache.org/stream-caching.html
2022-07-19 11:15:40,272 [main ] INFO ServletCamelContext - Route: route1 started and consuming from: servlet:/hello?matchOnUriPrefix=true
2022-07-19 11:15:40,274 [main ] INFO ServletCamelContext - Total 1 routes, of which 1 are started
2022-07-19 11:15:40,276 [main ] INFO ServletCamelContext - Apache Camel 2.25.0 (CamelContext: MyCamel) started in 0.483 seconds
2022-07-19 11:15:40,277 [main ] INFO CamelServletContextListener - CamelContextServletListener initialized
2022-07-19 11:15:40,316 [main ] INFO CamelHttpTransportServlet - Initialized CamelHttpTransportServlet[name=CamelServlet, contextPath=/camel-example-servlet]
[INFO] Started o.e.j.m.p.JettyWebAppContext#2764c546{Camel Servlet Example,/camel-example-servlet,file:///C:/Users/rrdoshi/Downloads/camel-example-servlet/src/main/webapp/,AVAILABLE}{file:///C:/Users/rrdoshi/Downloads/camel-example-servlet/src/main/webapp/}
[INFO] Started ServerConnector#2b73bd6b{HTTP/1.1,[http/1.1]}{0.0.0.0:8080}
[INFO] Started #8097ms
[INFO] Started Jetty Server
For tomcat deployment, I am placing the war file in tomcat webapps directory and executing startup.bat
19-Jul-2022 11:21:21.403 INFO [main] org.apache.jasper.servlet.TldScanner.scanJars At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
19-Jul-2022 11:21:21.576 WARNING [main] org.apache.catalina.util.SessionIdGeneratorBase.createSecureRandom Creation of SecureRandom instance for session ID generation using [SHA1PRNG] took [146] milliseconds.
19-Jul-2022 11:21:21.596 INFO [main] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [C:\Users\rrdoshi\Downloads\apache-tomcat-9.0.64-windows-x64\apache-tomcat-9.0.64\webapps\ApacheCamelDemoServlet]
19-Jul-2022 11:21:21.645 INFO [main] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [C:\Users\rrdoshi\Downloads\apache-tomcat-9.0.64-windows-x64\apache-tomcat-9.0.64\webapps\ApacheCamelDemoServlet] has finished in [49] ms
19-Jul-2022 11:21:21.646 INFO [main] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [C:\Users\rrdoshi\Downloads\apache-tomcat-9.0.64-windows-x64\apache-tomcat-9.0.64\webapps\docs]
19-Jul-2022 11:21:21.671 INFO [main] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [C:\Users\rrdoshi\Downloads\apache-tomcat-9.0.64-windows-x64\apache-tomcat-9.0.64\webapps\docs] has finished in [25] ms
19-Jul-2022 11:21:21.672 INFO [main] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [C:\Users\rrdoshi\Downloads\apache-tomcat-9.0.64-windows-x64\apache-tomcat-9.0.64\webapps\examples]
19-Jul-2022 11:21:22.097 INFO [main] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [C:\Users\rrdoshi\Downloads\apache-tomcat-9.0.64-windows-x64\apache-tomcat-9.0.64\webapps\examples] has finished in [425] ms
19-Jul-2022 11:21:22.099 INFO [main] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [C:\Users\rrdoshi\Downloads\apache-tomcat-9.0.64-windows-x64\apache-tomcat-9.0.64\webapps\host-manager]
19-Jul-2022 11:21:22.135 INFO [main] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [C:\Users\rrdoshi\Downloads\apache-tomcat-9.0.64-windows-x64\apache-tomcat-9.0.64\webapps\host-manager] has finished in [36] ms
19-Jul-2022 11:21:22.136 INFO [main] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [C:\Users\rrdoshi\Downloads\apache-tomcat-9.0.64-windows-x64\apache-tomcat-9.0.64\webapps\manager]
19-Jul-2022 11:21:22.175 INFO [main] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [C:\Users\rrdoshi\Downloads\apache-tomcat-9.0.64-windows-x64\apache-tomcat-9.0.64\webapps\manager] has finished in [38] ms
19-Jul-2022 11:21:22.175 INFO [main] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [C:\Users\rrdoshi\Downloads\apache-tomcat-9.0.64-windows-x64\apache-tomcat-9.0.64\webapps\ROOT]
19-Jul-2022 11:21:22.202 INFO [main] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [C:\Users\rrdoshi\Downloads\apache-tomcat-9.0.64-windows-x64\apache-tomcat-9.0.64\webapps\ROOT] has finished in [26] ms
19-Jul-2022 11:21:22.205 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["http-nio-8088"]
19-Jul-2022 11:21:22.224 INFO [main] org.apache.catalina.startup.Catalina.start Server startup in [2721] milliseconds
access logs
127.0.0.1 - - [19/Jul/2022:11:23:51 +0530] "GET /camel-servlet/ HTTP/1.1" 200 1675
127.0.0.1 - - [19/Jul/2022:11:24:01 +0530] "GET /camel-servlet/camel/hello HTTP/1.1" 404 784
localhost logs
19-Jul-2022 11:21:22.085 INFO [main] org.apache.catalina.core.ApplicationContext.log ContextListener: contextInitialized()
19-Jul-2022 11:21:22.085 INFO [main] org.apache.catalina.core.ApplicationContext.log SessionListener: contextInitialized()
19-Jul-2022 11:21:22.087 INFO [main] org.apache.catalina.core.ApplicationContext.log ContextListener: attributeAdded('StockTicker', 'async.Stockticker#68ab0936')
The WAR file is getting deployed but there are no error logs. There are no logs regarding camelContext starting up.

SpringMVC get 404 error

I get 404 error in my browser, after I start my tomcat :
I type in localhost:8080/mvc/hello or localhost:8080/mvc/hello.jsp
But if I type in localhost:8080, it is normal, can access:
In my springmvc-servlet.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:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.1.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-4.1.xsd">
<!-- scan the package and the sub package -->
<context:component-scan base-package="com.ypd.springmvcdemo"/>
<!-- don't handle the static resource -->
<mvc:default-servlet-handler />
<!-- if you use annotation you must configure following setting -->
<mvc:annotation-driven />
<!-- configure the InternalResourceViewResolver -->
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver" id="internalResourceViewResolver">
<property name="prefix" value="/WEB-INF/jsp/" />
<property name="suffix" value=".jsp" />
</bean>
</beans>
And in my MVCController.java:
#Controller
#RequestMapping("/mvc")
public class MVCController {
#RequestMapping("/hello")
public String hello() {
return "hello";
}
}
In my web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app 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"
version="3.1">
<!--configure the setting of springmvcDispatcherServlet and configure the mapping-->
<servlet>
<servlet-name>springmvc</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:springmvc-servlet.xml</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>springmvc</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
</web-app>
This is my page of hello.jsp:
(I am sorry about the springmvc-servlet.xml's position, I have locate it to under the resource library)
UPDATE - 1:
I am so sorry about it, there is a mistake when I post this snapshot, in my issue project, the web folder has no blue dot on it.See my answer I find the issue with it.
Update image:
So, where is the mistake?
EDIT
My hello.jsp:
<%# page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>Title</title>
</head>
<body>
Hello, world, jack loly!
</body>
</html>
EDIT
Logs looks like correct:
[2017-03-20 03:06:48,255] Artifact SpringMVCDemo:war exploded: Server is not connected. Deploy is not available.
Connected to the target VM, address: '127.0.0.1:51764', transport: 'socket'
20-Mar-2017 15:06:50.080 info [main] org.apache.catalina.startup.VersionLoggerListener.log Server version: Apache Tomcat/9.0.0.M17
20-Mar-2017 15:06:50.085 info [main] org.apache.catalina.startup.VersionLoggerListener.log Server built: Jan 10 2017 20:59:20 UTC
20-Mar-2017 15:06:50.085 info [main] org.apache.catalina.startup.VersionLoggerListener.log Server number: 9.0.0.0
20-Mar-2017 15:06:50.085 info [main] org.apache.catalina.startup.VersionLoggerListener.log OS Name: Mac OS X
20-Mar-2017 15:06:50.088 info [main] org.apache.catalina.startup.VersionLoggerListener.log OS Version: 10.12.2
20-Mar-2017 15:06:50.089 info [main] org.apache.catalina.startup.VersionLoggerListener.log Architecture: x86_64
20-Mar-2017 15:06:50.089 info [main] org.apache.catalina.startup.VersionLoggerListener.log Java Home: /Library/Java/JavaVirtualMachines/jdk1.8.0_121.jdk/Contents/Home/jre
20-Mar-2017 15:06:50.089 info [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Version: 1.8.0_121-b13
20-Mar-2017 15:06:50.089 info [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Vendor: Oracle Corporation
20-Mar-2017 15:06:50.089 info [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_BASE: /Users/jack/Library/Caches/IntelliJIdea2016.3/tomcat/Tomcat_9_0_0_M17_SpringMVCDemo
20-Mar-2017 15:06:50.090 info [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_HOME: /Users/jack/Library/Tomcat9
20-Mar-2017 15:06:50.091 info [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.config.file=/Users/jack/Library/Caches/IntelliJIdea2016.3/tomcat/Tomcat_9_0_0_M17_SpringMVCDemo/conf/logging.properties
20-Mar-2017 15:06:50.091 info [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
20-Mar-2017 15:06:50.091 info [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -agentlib:jdwp=transport=dt_socket,address=127.0.0.1:51764,suspend=y,server=n
20-Mar-2017 15:06:50.091 info [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.management.jmxremote=
20-Mar-2017 15:06:50.092 info [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.management.jmxremote.port=1099
20-Mar-2017 15:06:50.093 info [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.management.jmxremote.ssl=false
20-Mar-2017 15:06:50.093 info [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcom.sun.management.jmxremote.authenticate=false
20-Mar-2017 15:06:50.093 info [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.rmi.server.hostname=127.0.0.1
20-Mar-2017 15:06:50.093 info [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djdk.tls.ephemeralDHKeySize=2048
20-Mar-2017 15:06:50.093 info [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.protocol.handler.pkgs=org.apache.catalina.webresources
20-Mar-2017 15:06:50.093 info [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.base=/Users/jack/Library/Caches/IntelliJIdea2016.3/tomcat/Tomcat_9_0_0_M17_SpringMVCDemo
20-Mar-2017 15:06:50.094 info [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.home=/Users/jack/Library/Tomcat9
20-Mar-2017 15:06:50.094 info [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.io.tmpdir=/Users/jack/Library/Tomcat9/temp
20-Mar-2017 15:06:50.094 info [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: /Users/jack/Library/Java/Extensions:/Library/Java/Extensions:/Network/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java:.
20-Mar-2017 15:06:50.527 info [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["http-nio-8080"]
20-Mar-2017 15:06:50.560 info [main] org.apache.tomcat.util.net.NioSelectorPool.getSharedSelector Using a shared selector for servlet write/read
20-Mar-2017 15:06:50.563 info [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["ajp-nio-8009"]
20-Mar-2017 15:06:50.565 info [main] org.apache.tomcat.util.net.NioSelectorPool.getSharedSelector Using a shared selector for servlet write/read
20-Mar-2017 15:06:50.581 info [main] org.apache.catalina.startup.Catalina.load Initialization processed in 1455 ms
20-Mar-2017 15:06:50.709 info [main] org.apache.catalina.core.StandardService.startInternal Starting service Catalina
20-Mar-2017 15:06:50.709 info [main] org.apache.catalina.core.StandardEngine.startInternal Starting Servlet Engine: Apache Tomcat/9.0.0.M17
20-Mar-2017 15:06:50.745 info [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler [http-nio-8080]
20-Mar-2017 15:06:50.766 info [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler [ajp-nio-8009]
20-Mar-2017 15:06:50.769 info [main] org.apache.catalina.startup.Catalina.start Server startup in 187 ms
Connected to server
[2017-03-20 03:06:51,046] Artifact SpringMVCDemo:war exploded: Artifact is being deployed, please wait...
[2017-03-20 03:06:51,751] Artifact SpringMVCDemo:war exploded: Artifact is deployed successfully
[2017-03-20 03:06:51,751] Artifact SpringMVCDemo:war exploded: Deploy took 705 milliseconds
20-Mar-2017 15:07:00.750 info [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory /Users/jack/Library/Tomcat9/webapps/manager
20-Mar-2017 15:07:00.802 info [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory /Users/jack/Library/Tomcat9/webapps/manager has finished in 52 ms
EDIT
My tomcat deployment config:
EDIT -2
I think your tomcat deployment configuration is not all okay. your application context should be the context from where you are going to load your application and tell tomcat to dispatch all request within that context.
e.g. your Application Context: could be /helloApp. Now when you will start tomcat, your application would be loaded at localhost:8080/helloApp/. And this is your application root context. Now if you hit at localhost:8080/helloApp/mvc/hello, you are expected to see your content.
Put your springmvc-servlet.xml file in the WEB-INF and change lines of web.xml
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:springmvc-servlet.xml</param-value>
</init-param>
To
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/springmvc-servlet.xml</param-value>
</init-param>
There are couple of things to notice.
No project name specified in url
URL should be : http://localhost:8080/SpringMVCDemo/mvc/hello
Why are you mentioning two RequestMapping(mvc,hello) for only one page.You can remove #RequestMapping(value="/mvc") and keep #RequestMapping("/hello") on hello() method.
Update:
add load-on-startup in web.xml
<servlet>
<servlet-name>springmvc</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:springmvc-servlet.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
At last, I find the issue I was lost. See my question -> UPDATE -1
No blue dot on it means Web Source Dictory is incorrect. See below image I find the issue.
So I delete the red directory, and then re-choose the web directory:
Then in my project, I can see the blue dot on web directory now:
And then I restart tomcat, I success:

Deployed Tomcat app on Openshift returns 404

I've deployed my app under following url: https://migawka-hatak.rhcloud.com/,
but constantly I get a 404 status.
The same app works on my local Tomcat or Jetty. When accessing localhost:8080/ROOT/ it returns the default Openshift index page.
From the logs on openshift I can see that it's started:
INFO: Starting Servlet Engine: Apache Tomcat/7.0.54
Nov 05, 2014 4:14:32 AM org.apache.catalina.startup.HostConfig deployWAR
INFO: Deploying web application archive /var/lib/openshift/5458e7d3500446ea91000597/app-root/runtime/dependencies/jbosse
ws/webapps/ROOT.war
SLF4J: The requested version 1.5.8 by your slf4j binding is not compatible with [1.6]
SLF4J: See http://www.slf4j.org/codes.html#version_mismatch for further details.
47 [localhost-startStop-1] INFO org.quartz.impl.StdSchedulerFactory - Using default implementation for ThreadExecutor
53 [localhost-startStop-1] INFO org.quartz.simpl.SimpleThreadPool - Job execution threads will use class loader of threa
d: localhost-startStop-1
148 [localhost-startStop-1] INFO org.quartz.core.SchedulerSignalerImpl - Initialized Scheduler Signaller of type: class
org.quartz.core.SchedulerSignalerImpl
150 [localhost-startStop-1] INFO org.quartz.core.QuartzScheduler - Quartz Scheduler v.2.2.1 created.
158 [localhost-startStop-1] INFO org.quartz.simpl.RAMJobStore - RAMJobStore initialized.
160 [localhost-startStop-1] INFO org.quartz.core.QuartzScheduler - Scheduler meta-data: Quartz Scheduler (v2.2.1) 'Defau
ltQuartzScheduler' with instanceId 'NON_CLUSTERED'
Scheduler class: 'org.quartz.core.QuartzScheduler' - running locally.
NOT STARTED.
Currently in standby mode.
Number of jobs executed: 0
Using thread pool 'org.quartz.simpl.SimpleThreadPool' - with 10 threads.
Using job-store 'org.quartz.simpl.RAMJobStore' - which does not support persistence. and is not clustered.
161 [localhost-startStop-1] INFO org.quartz.impl.StdSchedulerFactory - Quartz scheduler 'DefaultQuartzScheduler' initial
ized from default resource file in Quartz package: 'quartz.properties'
161 [localhost-startStop-1] INFO org.quartz.impl.StdSchedulerFactory - Quartz scheduler version: 2.2.1
Nov 05, 2014 4:14:40 AM org.apache.catalina.startup.HostConfig deployWAR
INFO: Deployment of web application archive /var/lib/openshift/5458e7d3500446ea91000597/app-root/runtime/dependencies/jb
ossews/webapps/ROOT.war has finished in 7,523 ms
Nov 05, 2014 4:14:40 AM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-127.9.148.1-8080"]
Nov 05, 2014 4:14:40 AM org.apache.catalina.startup.Catalina start
INFO: Server startup in 7825 ms
I'm using quartz in the context listener, also my app is based on the RestEasy framework.
Any idea what is going on?
I've solved problem, by recreating app from scratch, only difference is that I've used web.xml from from tmplate instead of mine.
What is different on web.xml now:
<web-app version="3.0"
xmlns="java.sun.com/xml/ns/javaee"
xmlns:xsi="w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="java.sun.com/xml/ns/javaee java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
metadata-complete="false">
</web-app>

Spring 3.2 MVC - Cannot match URL with Controller

I'm trying to start a new application from scratch with Spring 3.2, and I got the 404 error when I try to get access to my Controller. Here is my configuration:
WEB-INF
web.xml
web-context.xml
web.xml:
<!DOCTYPE web-app PUBLIC
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd" >
<web-app>
<display-name>Archetype Created Web Application</display-name>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/application-context.xml
</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<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/web-context.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>appServlet</servlet-name>
<url-pattern>/deblan/*</url-pattern>
</servlet-mapping>
</web-app>
web-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:mvc="http://www.springframework.org/schema/mvc"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd">
<context:component-scan base-package="com.deboralandini.web.controllers"/>
<mvc:annotation-driven/>
<beans>
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/views/"/>
<property name="suffix" value=".jsp"/>
</bean>
</beans>
</beans>
My controller:
package com.deboralandini.web.controllers;
import ...;
#Controller
#RequestMapping("cuenta")
public class CuentaController {
#Autowired
private CuentaService cuentaService;
...
#RequestMapping(value = "/cCuenta")
public String cCuenta(Model model){
return "crearCuenta";
}
...
}
My index.jsp:
<%# taglib prefix="sf" uri="http://www.springframework.org/tags/form" %>
<html>
<body>
<h2>BlaBla</h2>
<br/>
Crear Cuenta
</body>
</html>
Unfortunately, when I click the link, I get:
Status HTTP 404 - /deblan/cuenta/cCuenta
The browser tries to make a GET to http://localhost:8080/deblan/cuenta/cCuenta, but I cannot get in my controller. I debugged the controller and in fact is not entering there, so: Whats my newbie error?
Thanks in advance
Marcos
Edit: this is my output:
"C:\...\App\tomcat8\bin\catalina.bat" run
[2014-10-21 08:57:21,069] Artifact DebLan:war: Server is not connected. Deploy is not available.
Using CATALINA_BASE: ...
Connected to the target VM, address: '127.0.0.1:64352', transport: 'socket'
21-Oct-2014 20:57:21.743 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server version: Apache Tomcat/8.0.14
21-Oct-2014 20:57:21.745 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server built: Sep 24 2014 09:01:51
21-Oct-2014 20:57:21.745 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server number: 8.0.14.0
21-Oct-2014 20:57:21.745 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Name: Windows 8.1
21-Oct-2014 20:57:21.745 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Version: 6.3
21-Oct-2014 20:57:21.745 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Architecture: amd64
21-Oct-2014 20:57:21.745 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Version: 1.7.0_55-b13
21-Oct-2014 20:57:21.745 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Vendor: Oracle Corporation
21-Oct-2014 20:57:21.924 INFO [main] org.apache.catalina.core.AprLifecycleListener.init Cargada la biblioteca nativa APR de Apache Tomcat 1.1.31 con la versiĆ³n APR 1.4.8.
21-Oct-2014 20:57:21.924 INFO [main] org.apache.catalina.core.AprLifecycleListener.init Capacidades APR: IPv6 [true], enviar fichero [true], aceptar filtros [false], aleatorio [true].
21-Oct-2014 20:57:22.551 INFO [main] org.apache.catalina.core.AprLifecycleListener.initializeSSL OpenSSL inicializado correctamente (OpenSSL 1.0.1h 5 Jun 2014)
21-Oct-2014 20:57:22.649 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["http-apr-8080"]
21-Oct-2014 20:57:22.662 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["ajp-apr-8009"]
21-Oct-2014 20:57:22.664 INFO [main] org.apache.catalina.startup.Catalina.load Initialization processed in 992 ms
21-Oct-2014 20:57:22.695 INFO [main] org.apache.catalina.core.StandardService.startInternal Arrancando servicio Catalina
21-Oct-2014 20:57:22.695 INFO [main] org.apache.catalina.core.StandardEngine.startInternal Starting Servlet Engine: Apache Tomcat/8.0.14
21-Oct-2014 20:57:22.708 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["http-apr-8080"]
21-Oct-2014 20:57:22.719 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["ajp-apr-8009"]
21-Oct-2014 20:57:22.722 INFO [main] org.apache.catalina.startup.Catalina.start Server startup in 57 ms
Connected to server
[2014-10-21 08:57:23,165] Artifact DebLan:war: Artifact is being deployed, please wait...
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
log4j:WARN No appenders could be found for logger (org.jboss.logging).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
[2014-10-21 08:57:32,003] Artifact DebLan:war: Artifact is deployed successfully
[2014-10-21 08:57:32,003] Artifact DebLan:war: Deploy took 8,838 milliseconds
21-Oct-2014 20:57:32.712 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Despliegue del directorio C:...\App\tomcat8\webapps\manager de la aplicaciĆ³n web
21-Oct-2014 20:57:32.762 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory C:...\App\tomcat8\webapps\manager has finished in 50 ms
If deblan is the context root then don't put it in the servlet mapping. You've got this url:
http://localhost:8080/deblan/cuenta/cCuenta
if you've deployed this app with deblan as the context root then:
http://localhost:8080/deblan
takes you to your app
/cuenta/cCuenta
now maps to your controller, so try:
<servlet-mapping>
<servlet-name>appServlet</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
Which means http://localhost:8080/deblan + whatever comes after.

Why is my simple springmvc web application shutting down Jetty?

Looking at my log files of a simple springmvc application (the homecontroller index action outputs 'hello world'), it seems the site is shutting down for some reason?
I simply pushed my .war file to the jetty_home/webapps folder, and started the jetty service.
ubuntu#ip-10-123-44-55:/usr/share/jetty/logs$ cat 2011_11_01.stderrout.log.022538550
2011-11-01 02:15:26.080:INFO::jetty-6.1.24
2011-11-01 02:15:26.192:INFO::Deploy /etc/jetty/contexts/javadoc.xml -> org.mortbay.jetty.handler.ContextHandler#8b819f{/javadoc,file:/usr/share/jetty/javadoc}
2011-11-01 02:15:26.338:INFO::Extract file:/var/lib/jetty/webapps/springmvc.war to /var/cache/jetty/data/Jetty__8080_springmvc.war__springmvc__s1aryk/webapp
2011-11-01 02:15:26.821:INFO::NO JSP Support for /springmvc, did not find org.apache.jasper.servlet.JspServlet
2011-11-01 02:15:28.245:INFO:/springmvc:Initializing Spring FrameworkServlet 'springmvc'
0 [main] INFO org.springframework.web.servlet.DispatcherServlet - FrameworkServlet 'springmvc': initialization started
69 [main] INFO org.springframework.web.context.support.XmlWebApplicationContext - Refreshing WebApplicationContext for namespace 'springmvc-servlet': startup date [Tue Nov 01 02:15:28 UTC 2011]; root of context hierarchy
145 [main] INFO org.springframework.beans.factory.xml.XmlBeanDefinitionReader - Loading XML bean definitions from ServletContext resource [/WEB-INF/spring/servlet-context.xml]
504 [main] INFO org.springframework.context.annotation.ClassPathBeanDefinitionScanner - JSR-330 'javax.inject.Named' annotation found and supported for component scanning
795 [main] INFO org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor - JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
853 [main] INFO org.springframework.beans.factory.support.DefaultListableBeanFactory - Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory#1cd107f: defining beans [homeController,org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping#0,org.springframework.format.support.FormattingConversionServiceFactoryBean#0,org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter#0,org.springframework.web.servlet.handler.MappedInterceptor#0]; root of factory hierarchy
1064 [main] INFO org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping - Root mapping to handler 'homeController'
1446 [main] INFO org.springframework.web.servlet.DispatcherServlet - FrameworkServlet 'springmvc': initialization completed in 1445 ms
2011-11-01 02:15:29.738:INFO::NO JSP Support for , did not find org.apache.jasper.servlet.JspServlet
2011-11-01 02:15:29.746:INFO::Opened /var/log/jetty/2011_11_01.request.log
2011-11-01 02:15:29.810:INFO::Started SelectChannelConnector#:8080
hello, world!
2011-11-01 02:24:01.775:INFO::Shutdown hook executing
2011-11-01 02:24:01.775:INFO::Graceful shutdown SelectChannelConnector#:8080
2011-11-01 02:24:01.828:INFO::Graceful shutdown org.mortbay.jetty.handler.ContextHandler#8b819f{/javadoc,file:/usr/share/jetty/javadoc}
2011-11-01 02:24:01.828:INFO::Graceful shutdown org.mortbay.jetty.webapp.WebAppContext#caf0ed{/springmvc,file:/var/lib/jetty/webapps/springmvc.war}
2011-11-01 02:24:01.828:INFO::Graceful shutdown org.mortbay.jetty.webapp.WebAppContext#18f6559{,file:/var/lib/jetty/webapps/root/}
2011-11-01 02:24:02.828:INFO::Stopped SelectChannelConnector#:8080
2011-11-01 02:24:02.829:INFO:/springmvc:Destroying Spring FrameworkServlet 'springmvc'
514583 [Shutdown] INFO org.springframework.web.context.support.XmlWebApplicationContext - Closing WebApplicationContext for namespace 'springmvc-servlet': startup date [Tue Nov 01 02:15:28 UTC 2011]; root of context hierarchy
514584 [Shutdown] INFO org.springframework.beans.factory.support.DefaultListableBeanFactory - Destroying singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory#1cd107f: defining beans [homeController,org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping#0,org.springframework.format.support.FormattingConversionServiceFactoryBean#0,org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter#0,org.springframework.web.servlet.handler.MappedInterceptor#0]; root of factory hierarchy
2011-11-01 02:24:02.834:INFO::Shutdown hook complete
This is a IntelliJ .war file that was built using a maven project.
This is my first deploy so please don't assume I know what I'm doing :)
Update
Actually it seems to be up, when I do a wget localhost:8080/springmvc/ I get the message:
Resolving localhost... 127.0.0.1
Connecting to localhost|127.0.0.1|:8080... connected.
HTTP request sent, awaiting response... 500 JSP support not configured
2011-11-01 02:33:34 ERROR 500: JSP support not configured.
For some reason this isn't working on jetty, it worked fine on tomcat?
if this is a maven project add the yetty plugin to your pom file
<plugins>
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>maven-jetty-plugin</artifactId>
<version>6.1.10</version>
</plugin>
</plugins>
then execute the following command
mvn jetty:run
According to this link
Jetty does not implement JSP directly. Instead it uses a servlet to provide this functionality required by the servle specification. [...] the companion of 2.5 servlet specification is the 2.1 JSP specification
So you need a jar with JSP.
If you're using Jetty 6 within the maven plugin I imagine that the dependency that Peter Szanto answered will solve it. On the other hand, if you are using it as part of your application you'll need to add an appropriate jsp jar.
For example for a Maven project using Jetty 6.1 you can include in the pom.xml:
<dependency>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jsp-2.1</artifactId>
<version>6.1.14</version>
</dependency>

Categories

Resources