I followed some tutorials and created a SpringMVC webapp in eclipse.
I tried to deploy it under a remotely running server but I failed and don't know why?
Here is what I did: under the following directory: /fs/sda4/project/workspace/SpringMVC
I executed the following maven command:
/opt/apache-maven-2.2.1/bin/mvn -Dmaven.test.skip=true clean install
The build was successful.
Then I copied the following war file
/fs/sda4/project/workspace/SpringMVC/target/SpringMVC.war
to the server, more precisely here:
/usr/pkg/tomcat/webapps/
Now I expect that after starting Tomcat the following URL should take me to the opening page.
https://gaya.aac.com:8843/SpringMVC/
But it does not, instead it gives me a http status 404, the requested resource is not available.
here is the relevant log of tomcat startup:
INFO: Starting service Catalina
Jun 18, 2014 11:46:27 AM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.53
Jun 18, 2014 11:46:27 AM org.apache.catalina.startup.HostConfig deployWAR
INFO: Deploying web application archive /usr/pkg/tomcat-rusznak/webapps/SpringMVC.war
[WebappClassLoader#4c01acb7] info AspectJ Weaver Version 1.7.3 built on Thursday Jun 13, 2013 at 19:41:31 GMT
[WebappClassLoader#4c01acb7] info register classloader org.apache.catalina.loader.WebappClassLoader#4c01acb7
[WebappClassLoader#4c01acb7] info no configuration found. Disabling weaver for class loader org.apache.catalina.loader.WebappClassLoader#4c01acb7
Jun 18, 2014 11:46:29 AM org.apache.catalina.core.ApplicationContext log
INFO: Initializing Spring root WebApplicationContext
Jun 18, 2014 11:46:29 AM org.springframework.web.context.ContextLoader initWebApplicationContext
INFO: Root WebApplicationContext: initialization started
Jun 18, 2014 11:46:29 AM org.springframework.context.support.AbstractApplicationContext prepareRefresh
INFO: Refreshing Root WebApplicationContext: startup date [Wed Jun 18 11:46:29 CEST 2014]; root of context hierarchy
Jun 18, 2014 11:46:29 AM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from ServletContext resource [/WEB-INF/mvc-dispatcher-servlet.xml]
Jun 18, 2014 11:46:29 AM org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider registerDefaultFilters
INFO: JSR-250 'javax.annotation.ManagedBean' found and supported for component scanning
Jun 18, 2014 11:46:29 AM org.springframework.beans.factory.support.DefaultListableBeanFactory preInstantiateSingletons
INFO: Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory#1b3c0cef: defining beans [helloController,org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,org.springframework.web.servlet.view.InternalResourceViewResolver#0]; root of factory hierarchy
Jun 18, 2014 11:46:29 AM org.springframework.web.context.ContextLoader initWebApplicationContext
INFO: Root WebApplicationContext: initialization completed in 455 ms
Jun 18, 2014 11:46:29 AM org.apache.catalina.core.ApplicationContext log
INFO: Initializing Spring FrameworkServlet 'mvc-dispatcher'
Jun 18, 2014 11:46:29 AM org.springframework.web.servlet.FrameworkServlet initServletBean
INFO: FrameworkServlet 'mvc-dispatcher': initialization started
Jun 18, 2014 11:46:29 AM org.springframework.context.support.AbstractApplicationContext prepareRefresh
INFO: Refreshing WebApplicationContext for namespace 'mvc-dispatcher-servlet': startup date [Wed Jun 18 11:46:29 CEST 2014]; parent: Root WebApplicationContext
Jun 18, 2014 11:46:29 AM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from ServletContext resource [/WEB-INF/mvc-dispatcher-servlet.xml]
Jun 18, 2014 11:46:29 AM org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider registerDefaultFilters
INFO: JSR-250 'javax.annotation.ManagedBean' found and supported for component scanning
Jun 18, 2014 11:46:29 AM org.springframework.beans.factory.support.DefaultListableBeanFactory preInstantiateSingletons
INFO: Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory#463e0db0: defining beans [helloController,org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,org.springframework.web.servlet.view.InternalResourceViewResolver#0]; parent: org.springframework.beans.factory.support.DefaultListableBeanFactory#1b3c0cef
Jun 18, 2014 11:46:30 AM org.springframework.web.servlet.handler.AbstractUrlHandlerMapping registerHandler
INFO: Mapped URL path [/welcome] onto handler 'helloController'
Jun 18, 2014 11:46:30 AM org.springframework.web.servlet.handler.AbstractUrlHandlerMapping registerHandler
INFO: Mapped URL path [/welcome.*] onto handler 'helloController'
Jun 18, 2014 11:46:30 AM org.springframework.web.servlet.handler.AbstractUrlHandlerMapping registerHandler
INFO: Mapped URL path [/welcome/] onto handler 'helloController'
Jun 18, 2014 11:46:30 AM org.springframework.web.servlet.FrameworkServlet initServletBean
INFO: FrameworkServlet 'mvc-dispatcher': initialization completed in 343 ms
Jun 18, 2014 11:46:30 AM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-8843"]
Jun 18, 2014 11:46:30 AM org.apache.catalina.startup.Catalina start
INFO: Server startup in 2341 ms
Jun 18, 2014 11:49:16 AM org.springframework.web.servlet.DispatcherServlet noHandlerFound
WARNING: No mapping found for HTTP request with URI [/SpringMVC/] in DispatcherServlet with name 'mvc-dispatcher'
Jun 18, 2014 11:49:22 AM org.springframework.web.servlet.DispatcherServlet noHandlerFound
WARNING: No mapping found for HTTP request with URI [/SpringMVC/WEB-INF/pages/hello.jsp] in DispatcherServlet with name 'mvc-dispatcher'
Jun 18, 2014 11:50:00 AM org.springframework.web.servlet.DispatcherServlet noHandlerFound
WARNING: No mapping found for HTTP request with URI [/SpringMVC/] in DispatcherServlet with name 'mvc-dispatcher'
Jun 18, 2014 11:50:06 AM org.springframework.web.servlet.DispatcherServlet noHandlerFound
WARNING: No mapping found for HTTP request with URI [/SpringMVC/WEB-INF/pages/hello.jsp] in DispatcherServlet with name 'mvc-dispatcher'
Jun 18, 2014 11:53:20 AM org.springframework.web.servlet.DispatcherServlet noHandlerFound
WARNING: No mapping found for HTTP request with URI [/SpringMVC/WEB-INF/pages/hello.jsp] in DispatcherServlet with name 'mvc-dispatcher'
Jun 18, 2014 11:53:58 AM org.springframework.web.servlet.DispatcherServlet noHandlerFound
WARNING: No mapping found for HTTP request with URI [/SpringMVC/] in DispatcherServlet with name 'mvc-dispatcher'
Jun 18, 2014 12:31:27 PM org.springframework.web.servlet.DispatcherServlet noHandlerFound
WARNING: No mapping found for HTTP request with URI [/SpringMVC/WEB-INF/pages/hello.jsp] in DispatcherServlet with name 'mvc-dispatche
here is the web.xml
<web-app id="WebApp_ID" version="2.4"
xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<display-name>Spring Web MVC Application</display-name>
<servlet>
<servlet-name>mvc-dispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>mvc-dispatcher</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/mvc-dispatcher-servlet.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
and here is mvc-dispatcher.servlet
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
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/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd">
<context:component-scan base-package="com.mkyong.common.controller" />
<bean
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix">
<value>/WEB-INF/pages/</value>
</property>
<property name="suffix">
<value>.jsp</value>
</property>
</bean>
You did not define mappings correctly:
See http://docs.spring.io/spring/docs/3.0.0.M3/reference/html/ch16s04.html
Related
I've been extensively looking for a very very simple way to display the tomcat ERRORS/WARNINGS logs in my eclipse terminal console, I cannot proceed with my development, because I can't see what error or warnings tomcat might be telling me, here is a sample server log output where I suspect a "no mapping found for http request with uri in dispatcherservlet", but does not being shown in the output
Sep 04, 2014 2:19:43 PM org.apache.catalina.core.AprLifecycleListener init
INFO: Loaded APR based Apache Tomcat Native library 1.1.30 using APR version 1.4.8.
Sep 04, 2014 2:19:43 PM org.apache.catalina.core.AprLifecycleListener init
INFO: APR capabilities: IPv6 [true], sendfile [true], accept filters [false], random [true].
Sep 04, 2014 2:19:43 PM org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.j2ee.server:OnlineStudentRegistration' did not find a matching property.
Sep 04, 2014 2:19:43 PM org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.j2ee.server:Spring.MVC' did not find a matching property.
Sep 04, 2014 2:19:44 PM org.apache.catalina.core.AprLifecycleListener initializeSSL
INFO: OpenSSL successfully initialized (OpenSSL 1.0.1g 7 Apr 2014)
Sep 04, 2014 2:19:44 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-apr-8080"]
Sep 04, 2014 2:19:44 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["ajp-apr-8009"]
Sep 04, 2014 2:19:44 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 1799 ms
Sep 04, 2014 2:19:44 PM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
Sep 04, 2014 2:19:44 PM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/8.0.9
Sep 04, 2014 2:19:45 PM org.apache.catalina.util.SessionIdGenerator createSecureRandom
INFO: Creation of SecureRandom instance for session ID generation using [SHA1PRNG] took [107] milliseconds.
Sep 04, 2014 2:19:48 PM org.apache.catalina.core.ApplicationContext log
INFO: No Spring WebApplicationInitializer types detected on classpath
Sep 04, 2014 2:19:49 PM org.apache.catalina.core.ApplicationContext log
INFO: Initializing Spring FrameworkServlet 'dispatcher'
Sep 04, 2014 2:19:49 PM org.springframework.web.servlet.DispatcherServlet initServletBean
INFO: FrameworkServlet 'dispatcher': initialization started
Sep 04, 2014 2:19:49 PM org.springframework.web.context.support.XmlWebApplicationContext prepareRefresh
INFO: Refreshing WebApplicationContext for namespace 'dispatcher-servlet': startup date [Thu Sep 04 14:19:49 PDT 2014]; root of context hierarchy
Sep 04, 2014 2:19:49 PM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from ServletContext resource [/WEB-INF/dispatcher-servlet.xml]
Sep 04, 2014 2:19:51 PM org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping registerHandlerMethod
INFO: Mapped "{[/addStudent],methods=[POST],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public org.springframework.web.servlet.ModelAndView com.osr.controllers.StudentLoginController.studentLogin(com.osr.domain.Student,org.springframework.validation.BindingResult)
Sep 04, 2014 2:19:51 PM org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping registerHandlerMethod
INFO: Mapped "{[/],methods=[GET],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public org.springframework.web.servlet.ModelAndView com.osr.controllers.StudentLoginController.student()
Sep 04, 2014 2:19:51 PM org.springframework.web.servlet.DispatcherServlet initServletBean
INFO: FrameworkServlet 'dispatcher': initialization completed in 2417 ms
Sep 04, 2014 2:19:56 PM org.apache.catalina.core.ApplicationContext log
INFO: No Spring WebApplicationInitializer types detected on classpath
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.
Sep 04, 2014 2:19:56 PM org.apache.catalina.core.ApplicationContext log
INFO: Initializing Spring root WebApplicationContext
Sep 04, 2014 2:19:57 PM org.apache.catalina.core.ApplicationContext log
INFO: Initializing Spring FrameworkServlet 'dispatcher'
Sep 04, 2014 2:19:59 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-apr-8080"]
Sep 04, 2014 2:19:59 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-apr-8009"]
Sep 04, 2014 2:19:59 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 14373 ms
is there any configuration with tomcat? or eclipse I am missing here?
Try this instead
right click on your project, and click run as...
you will find something occurs on your console. I think it may be a bug!
i am trying to integrate spring mvc +jersey
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">
<display-name>Archetype Created Web Application</display-name>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:/jpaContext.xml
classpath:/applicationContext.xml
</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<servlet>
<servlet-name>SpringApplication</servlet-name>
<servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>javax.ws.rs.Application</param-name>
<param-value>orgProfiles.webserviceJersey.MyApplication</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>SpringApplication</servlet-name>
<url-pattern>/ws/*</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>orgProfilesServlet</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/config/servlet-config.xml</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>orgProfilesServlet</servlet-name>
<url-pattern>*.html</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>orgProfilesServlet</servlet-name>
<url-pattern>*.json</url-pattern>
</servlet-mapping>
</web-app>
applicationContext.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"
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.xsd"
>
<bean id="greetingService" class="orgProfiles.webserviceJersey.GreetingServiceImpl"/>
<bean class="orgProfiles.webserviceJersey.DateTimeService" scope="request"/>
<bean class="orgProfiles.webserviceJersey.SpringSingletonResource"/>
<bean class="orgProfiles.webserviceJersey.SpringRequestResource" scope="request"/>
<bean class="orgProfiles.webserviceJersey.CustomExceptionMapper"/>
</beans>
when i try to run the application it will end up with the following error message :
Aug 28, 2014 1:16:16 PM org.apache.catalina.core.AprLifecycleListener init
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: /usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib
Aug 28, 2014 1:16:17 PM org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.j2ee.server:orgProfiles' did not find a matching property.
Aug 28, 2014 1:16:17 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-bio-8080"]
Aug 28, 2014 1:16:17 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["ajp-bio-8009"]
Aug 28, 2014 1:16:17 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 1366 ms
Aug 28, 2014 1:16:17 PM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
Aug 28, 2014 1:16:17 PM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.54
Aug 28, 2014 1:16:24 PM org.apache.catalina.core.ApplicationContext log
INFO: Spring WebApplicationInitializers detected on classpath: [org.glassfish.jersey.server.spring.SpringWebApplicationInitializer#30e65807]
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.
Aug 28, 2014 1:16:24 PM org.apache.catalina.core.ApplicationContext log
INFO: Initializing Spring root WebApplicationContext
Aug 28, 2014 1:16:25 PM org.apache.catalina.core.StandardContext loadOnStartup
SEVERE: Servlet /orgProfiles threw load() exception
java.lang.ClassNotFoundException: orgProfiles.src.main.java.webserviceJersey.MyApplication
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1720)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1571)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:190)
at org.glassfish.jersey.internal.util.ReflectionHelper$7.run(ReflectionHelper.java:407)
at org.glassfish.jersey.internal.util.ReflectionHelper$7.run(ReflectionHelper.java:397)
at java.security.AccessController.doPrivileged(Native Method)
at org.glassfish.jersey.servlet.WebComponent.createResourceConfig(WebComponent.java:463)
at org.glassfish.jersey.servlet.WebComponent.<init>(WebComponent.java:302)
at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:170)
at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:358)
at javax.servlet.GenericServlet.init(GenericServlet.java:158)
at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1284)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1197)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1087)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5210)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5493)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
Aug 28, 2014 1:16:25 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-8080"]
Aug 28, 2014 1:16:25 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-bio-8009"]
Aug 28, 2014 1:16:25 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 8375 ms
How can i resolve this issue ?
According to your beans name orgProfiles.src.main.java.webserviceJersey.MyApplication should be orgProfiles.webserviceJersey.MyApplication
I am new to J2EE and I want to create a restful webservice so I follow a tutorial and based on that I've created a simple Dynamic web application project in eclipse (Kepler Service Release 1) then I add the jersey 1.8 libraries and I've configured the appache tomcat (apache-tomcat-7.0.50) with eclipse then after adding a index.html I can see the http://localhost:8080/myproject/ page content ,
but I get error 404 (nt found) with this url
http://localhost:8080/myproject/api/v1/status
and
http://localhost:8080/myproject/api/v1/status/version
this is the java resource file
package myproject;
import javax.ws.rs.*;
import javax.ws.rs.core.MediaType;
#Path("/v1/status/*")
public class v1_status {
private static final String api_version = "00.01.00";
#GET
#Produces(MediaType.TEXT_HTML)
public String returnName(){
return "<p>Web Services</p>";
}
#Path("/version")
#GET
#Produces(MediaType.TEXT_HTML)
public String returnVersion()
{
return "<p>Web Services</p>" + api_version;
}
}
and this is the 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>myproject</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>Jersey REST Service</servlet-name>
<servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
<init-param>
<!-- com.sun.jersey.config.property.packages
jersey.config.server.provider.packages -->
<param-name>com.sun.jersey.config.property.packages</param-name>
<param-value>myproject</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Jersey REST Service</servlet-name>
<url-pattern>/api/*</url-pattern>
</servlet-mapping>
</web-app>
I have tested the jersey version 2 , but when I add the 2 version tomcat gets me error in starting phase ...
what's wrong here ? I've saw other threads in stackoverflow about this issue but i cant figure out how should I solve the problem becasue everythings looks fine in the project but final result is not.
this is the tomcat startup log
Feb 15, 2014 5:04:50 PM org.apache.catalina.core.AprLifecycleListener init
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Program Files (x86)\Java\jre6\bin;.;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;E:\oracle\product\10.2.0\client_2\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;E:\Program Files\MATLAB\R2013a\runtime\win64;E:\Program Files\MATLAB\R2013a\bin
Feb 15, 2014 5:04:50 PM org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:myproject' did not find a matching property.
Feb 15, 2014 5:04:51 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-bio-8080"]
Feb 15, 2014 5:04:51 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["ajp-bio-8009"]
Feb 15, 2014 5:04:51 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 720 ms
Feb 15, 2014 5:04:51 PM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
Feb 15, 2014 5:04:51 PM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.50
Feb 15, 2014 5:04:51 PM org.apache.tomcat.websocket.server.WsSci onStartup
INFO: JSR 356 WebSocket (Java WebSocket 1.0) support is not available when running on Java 6. To suppress this message, run Tomcat on Java 7, remove the WebSocket JARs from $CATALINA_HOME/lib or add the WebSocketJARs to the tomcat.util.scan.DefaultJarScanner.jarsToSkip property in $CATALINA_BASE/conf/catalina.properties. Note that the deprecated Tomcat 7 WebSocket API will be available.
Feb 15, 2014 5:04:52 PM com.sun.jersey.api.core.servlet.WebAppResourceConfig init
INFO: Scanning for root resource and provider classes in the Web app resource paths:
/WEB-INF/lib
/WEB-INF/classes
Feb 15, 2014 5:04:52 PM com.sun.jersey.api.core.ScanningResourceConfig logClasses
INFO: Root resource classes found:
class myproject.v1_status
Feb 15, 2014 5:04:52 PM com.sun.jersey.api.core.ScanningResourceConfig logClasses
INFO: Provider classes found:
class org.codehaus.jackson.jaxrs.JsonParseExceptionMapper
class org.codehaus.jackson.jaxrs.JacksonJsonProvider
class org.codehaus.jackson.jaxrs.JacksonJaxbJsonProvider
class org.codehaus.jackson.jaxrs.JsonMappingExceptionMapper
Feb 15, 2014 5:04:53 PM com.sun.jersey.server.impl.application.WebApplicationImpl _initiate
INFO: Initiating Jersey application, version 'Jersey: 1.18 11/22/2013 01:21 AM'
Feb 15, 2014 5:04:53 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-8080"]
Feb 15, 2014 5:04:54 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-bio-8009"]
Feb 15, 2014 5:04:54 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 2836 ms
Solved, the asterisk (*) in the #Path("/v1/status/*") was the cause of problem
after removing it , I get correct result , so it should be #Path("/v1/status/") ...
I tried to to load a simple example of spring mvc with a simple jsp but failed with the following error: No mapping found for HTTP request with URI [/SpringHello/WEB-INF/jsp/hello.jsp] I'm using Spring 3.2.2. I really appreciate your help here. I tried several thing but still it seems that I can not map my jsp page in the controller.
I've looked through other answers on here as best I can, but nothing seems to exactly fit my issue/solve my problem. Essentially.
I feel like I have the mapping done correctly, but obviously I don't. So here I'll post any files that seem like they may be relevant.
My controller class is:
package net.viralpatel.spring3.controller;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
#Controller
#RequestMapping("/hello")
public class HelloController{
#RequestMapping(method = RequestMethod.GET)
public String printHello(ModelMap model) {
System.out.println("Hello Spring MVC Framework!**********************");
model.addAttribute("message", "Hello Spring MVC Framework!");
return "hello";
}
}
My web.xml file is:
<?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>Spring3MVC</display-name>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring-servlet.xml</param-value>
</context-param>
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
<servlet>
<servlet-name>spring</servlet-name>
<servlet-class>
org.springframework.web.servlet.DispatcherServlet
</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>spring</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
</web-app>
My spring-servlet.xml file is:
<?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="net.viralpatel.spring3.controller" />
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix">
<value>/WEB-INF/jsp/</value>
</property>
<property name="suffix">
<value>.jsp</value>
</property>
</bean>
</beans>
My hello.jsp is:
<html>
<head>
<title>Spring 3.0 MVC Series: Hello World - ViralPatel.net</title>
</head>
<body>
${message}
</body>
</html>
I am trying to run my hello.jsp with "http:ipAddress:8080/SpringHello/hello" but I am getting "HTTP Status 404 - /SpringHello/hello" .
Inside log it gave warning:
Oct 16, 2013 10:08:30 PM org.apache.coyote.http11.Http11Protocol init
INFO: Initializing Coyote HTTP/1.1 on http-8080
Oct 16, 2013 10:08:30 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 457 ms
Oct 16, 2013 10:08:30 PM org.apache.catalina.core.StandardService start
INFO: Starting service Catalina
Oct 16, 2013 10:08:30 PM org.apache.catalina.core.StandardEngine start
INFO: Starting Servlet Engine: Apache Tomcat/5.5.4
Oct 16, 2013 10:08:30 PM org.apache.catalina.core.StandardHost start
INFO: XML validation disabled
Oct 16, 2013 10:08:30 PM org.apache.catalina.core.ApplicationContext log
INFO: Initializing Spring root WebApplicationContext
Oct 16, 2013 10:08:30 PM org.springframework.web.context.ContextLoader initWebApplicationContext
INFO: Root WebApplicationContext: initialization started
Oct 16, 2013 10:08:30 PM org.springframework.context.support.AbstractApplicationContext prepareRefresh
INFO: Refreshing Root WebApplicationContext: startup date [Wed Oct 16 22:08:30 IST 2013]; root of context hierarchy
Oct 16, 2013 10:08:30 PM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from ServletContext resource [/WEB-INF/spring-servlet.xml]
Oct 16, 2013 10:08:31 PM org.springframework.beans.factory.support.DefaultListableBeanFactory preInstantiateSingletons
INFO: Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory#973f09: defining beans [helloController,org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,org.springframework.web.servlet.view.InternalResourceViewResolver#0,org.springframework.context.annotation.ConfigurationClassPostProcessor$ImportAwareBeanPostProcessor#0]; root of factory hierarchy
Oct 16, 2013 10:08:31 PM org.springframework.web.context.ContextLoader initWebApplicationContext
INFO: Root WebApplicationContext: initialization completed in 668 ms
Oct 16, 2013 10:08:31 PM org.apache.catalina.core.ApplicationContext log
INFO: Initializing Spring FrameworkServlet 'spring'
Oct 16, 2013 10:08:31 PM org.springframework.web.servlet.FrameworkServlet initServletBean
INFO: FrameworkServlet 'spring': initialization started
Oct 16, 2013 10:08:31 PM org.springframework.context.support.AbstractApplicationContext prepareRefresh
INFO: Refreshing WebApplicationContext for namespace 'spring-servlet': startup date [Wed Oct 16 22:08:31 IST 2013]; parent: Root WebApplicationContext
Oct 16, 2013 10:08:31 PM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from ServletContext resource [/WEB-INF/spring-servlet.xml]
Oct 16, 2013 10:08:31 PM org.springframework.beans.factory.support.DefaultListableBeanFactory preInstantiateSingletons
INFO: Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory#119510f: defining beans [helloController,org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,org.springframework.web.servlet.view.InternalResourceViewResolver#0,org.springframework.context.annotation.ConfigurationClassPostProcessor$ImportAwareBeanPostProcessor#0]; parent: org.springframework.beans.factory.support.DefaultListableBeanFactory#973f09
Oct 16, 2013 10:08:31 PM org.springframework.web.servlet.handler.AbstractUrlHandlerMapping registerHandler
INFO: Mapped URL path [/hello] onto handler 'helloController'
Oct 16, 2013 10:08:31 PM org.springframework.web.servlet.handler.AbstractUrlHandlerMapping registerHandler
INFO: Mapped URL path [/hello.*] onto handler 'helloController'
Oct 16, 2013 10:08:31 PM org.springframework.web.servlet.handler.AbstractUrlHandlerMapping registerHandler
INFO: Mapped URL path [/hello/] onto handler 'helloController'
Oct 16, 2013 10:08:31 PM org.springframework.web.servlet.FrameworkServlet initServletBean
INFO: FrameworkServlet 'spring': initialization completed in 349 ms
Oct 16, 2013 10:08:32 PM org.apache.catalina.core.ApplicationContext log
INFO: Initializing Spring FrameworkServlet 'spring'
Oct 16, 2013 10:08:32 PM org.springframework.web.servlet.FrameworkServlet initServletBean
INFO: FrameworkServlet 'spring': initialization started
Oct 16, 2013 10:08:32 PM org.springframework.context.support.AbstractApplicationContext prepareRefresh
INFO: Refreshing WebApplicationContext for namespace 'spring-servlet': startup date [Wed Oct 16 22:08:32 IST 2013]; root of context hierarchy
Oct 16, 2013 10:08:32 PM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from ServletContext resource [/WEB-INF/spring-servlet.xml]
Oct 16, 2013 10:08:32 PM org.springframework.beans.factory.support.DefaultListableBeanFactory preInstantiateSingletons
INFO: Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory#f2ad66: defining beans [helloWorldController,org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,viewResolver,org.springframework.context.annotation.ConfigurationClassPostProcessor$ImportAwareBeanPostProcessor#0]; root of factory hierarchy
Oct 16, 2013 10:08:32 PM org.springframework.web.servlet.handler.AbstractUrlHandlerMapping registerHandler
INFO: Mapped URL path [/hello] onto handler 'helloWorldController'
Oct 16, 2013 10:08:32 PM org.springframework.web.servlet.handler.AbstractUrlHandlerMapping registerHandler
INFO: Mapped URL path [/hello.*] onto handler 'helloWorldController'
Oct 16, 2013 10:08:32 PM org.springframework.web.servlet.handler.AbstractUrlHandlerMapping registerHandler
INFO: Mapped URL path [/hello/] onto handler 'helloWorldController'
Oct 16, 2013 10:08:32 PM org.springframework.web.servlet.FrameworkServlet initServletBean
INFO: FrameworkServlet 'spring': initialization completed in 689 ms
Oct 16, 2013 10:08:32 PM org.apache.coyote.http11.Http11Protocol start
INFO: Starting Coyote HTTP/1.1 on http-8080
Oct 16, 2013 10:08:32 PM org.apache.jk.common.ChannelSocket init
INFO: JK2: ajp13 listening on /0.0.0.0:8009
Oct 16, 2013 10:08:32 PM org.apache.jk.server.JkMain start
INFO: Jk running ID=0 time=0/17 config=null
Oct 16, 2013 10:08:32 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 2613 ms
Hello Spring MVC Framework!**********************
Oct 16, 2013 10:08:42 PM org.springframework.web.servlet.DispatcherServlet noHandlerFound
WARNING: No mapping found for HTTP request with URI [/SpringHello/WEB-INF/jsp/hello.jsp] in DispatcherServlet with name 'spring'
Please help me I am new in Spring,I have spent more than 3 days for solving this problem.
You have no handler for the path /SpringHello/WEB-INF/jsp/hello.jsp. You should be sending your request to
/SpringHello/hello
which is mapped by your HelloController class.
I can do grails test run-war and everything works fine, but grails test -Dserver.port=8099 run-war gives me this error:
Running Grails application..
[delete] Deleting: C:\nsl\target\tomcat-out.txt
[delete] Deleting: C:\nsl\target\tomcat-err.txt
[java] Java Result: 1
java.lang.RuntimeException: tomcat exited prematurely with code '1' (error output: 'Aug 18, 2011 12:44:10 PM org.apache.coyote.http11.Http11Protocol init
INFO: Initializing Coyote HTTP/1.1 on http-localhost%2F127.0.0.1-8099
Aug 18, 2011 12:44:10 PM org.apache.catalina.core.StandardService start
INFO: Starting service Tomcat
Aug 18, 2011 12:44:10 PM org.apache.catalina.core.StandardEngine start
INFO: Starting Servlet Engine: Apache Tomcat/6.0-snapshot
Aug 18, 2011 12:44:10 PM org.apache.catalina.startup.ContextConfig defaultWebConfig
INFO: No default web.xml
Aug 18, 2011 12:44:11 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jsp/jstl/core is already defined
Aug 18, 2011 12:44:11 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jsp/jstl/fmt is already defined
Aug 18, 2011 12:44:11 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://www.springframework.org/tags is already defined
Aug 18, 2011 12:44:12 PM org.apache.catalina.core.ApplicationContext log
INFO: Initializing Spring root WebApplicationContext
LifecycleException: service.getName(): "Tomcat"; Protocol handler start failed: java.lang.NullPointerException
at org.apache.catalina.connector.Connector.start(Connector.java:1137)
at org.apache.catalina.core.StandardService.start(StandardService.java:530)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:708)
at org.apache.catalina.startup.Tomcat.start(Tomcat.java:286)
at org.grails.tomcat.IsolatedTomcat.main(IsolatedTomcat.java:101)
Error loading Tomcat: service.getName(): "Tomcat"; Protocol handler start failed: java.lang.NullPointerException
')
at org.grails.tomcat.TomcatServer.start(TomcatServer.groovy:183)
at grails.web.container.EmbeddableServer$start.call(Unknown Source)
at _GrailsRun_groovy$_run_closure5_closure12.doCall(_GrailsRun_groovy:158)
at _GrailsRun_groovy$_run_closure5_closure12.doCall(_GrailsRun_groovy)
at _GrailsSettings_groovy$_run_closure10.doCall(_GrailsSettings_groovy:280)
at _GrailsSettings_groovy$_run_closure10.call(_GrailsSettings_groovy)
at _GrailsRun_groovy$_run_closure5.doCall(_GrailsRun_groovy:149)
at _GrailsRun_groovy$_run_closure5.call(_GrailsRun_groovy)
at _GrailsRun_groovy.runWar(_GrailsRun_groovy:125)
at _GrailsRun_groovy.this$4$runWar(_GrailsRun_groovy)
at _GrailsRun_groovy$_run_closure3.doCall(_GrailsRun_groovy:73)
at RunWar$_run_closure1.doCall(RunWar:49)
at gant.Gant$_dispatch_closure5.doCall(Gant.groovy:381)
at gant.Gant$_dispatch_closure7.doCall(Gant.groovy:415)
at gant.Gant$_dispatch_closure7.doCall(Gant.groovy)
at gant.Gant.withBuildListeners(Gant.groovy:427)
at gant.Gant.this$2$withBuildListeners(Gant.groovy)
at gant.Gant$this$2$withBuildListeners.callCurrent(Unknown Source)
at gant.Gant.dispatch(Gant.groovy:415)
at gant.Gant.this$2$dispatch(Gant.groovy)
at gant.Gant.invokeMethod(Gant.groovy)
at gant.Gant.executeTargets(Gant.groovy:590)
at gant.Gant.executeTargets(Gant.groovy:589)
Server failed to start: java.lang.RuntimeException: tomcat exited prematurely with code '1' (error output: 'Aug 18, 2011 12:44:10 PM org.apache.coyote.http11.Http11Protocol init
INFO: Initializing Coyote HTTP/1.1 on http-localhost%2F127.0.0.1-8099
Aug 18, 2011 12:44:10 PM org.apache.catalina.core.StandardService start
INFO: Starting service Tomcat
Aug 18, 2011 12:44:10 PM org.apache.catalina.core.StandardEngine start
INFO: Starting Servlet Engine: Apache Tomcat/6.0-snapshot
Aug 18, 2011 12:44:10 PM org.apache.catalina.startup.ContextConfig defaultWebConfig
INFO: No default web.xml
Aug 18, 2011 12:44:11 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jsp/jstl/core is already defined
Aug 18, 2011 12:44:11 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jsp/jstl/fmt is already defined
Aug 18, 2011 12:44:11 PM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://www.springframework.org/tags is already defined
Aug 18, 2011 12:44:12 PM org.apache.catalina.core.ApplicationContext log
INFO: Initializing Spring root WebApplicationContext
LifecycleException: service.getName(): "Tomcat"; Protocol handler start failed: java.lang.NullPointerException
at org.apache.catalina.connector.Connector.start(Connector.java:1137)
at org.apache.catalina.core.StandardService.start(StandardService.java:530)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:708)
at org.apache.catalina.startup.Tomcat.start(Tomcat.java:286)
at org.grails.tomcat.IsolatedTomcat.main(IsolatedTomcat.java:101)
Error loading Tomcat: service.getName(): "Tomcat"; Protocol handler start failed: java.lang.NullPointerException
')
To change the port on which grails loads you can do one of the following...
1. Change the port by launching grails with the following command line entry:
grails -Dserver.port=8099 run-app
2. If you want the application to run on 8099 by default, write the following line in you BuildConfig.groovy file.
grails.server.port.http=8099