In Spring MVC 3 on Tomcat 6, I can't seem to get RequestMappings of the form /x/y/z to work. /x/y seems to work fine and that's what all the example in docs show.
For example, why does this work
#RequestMapping(value="/browse/{categoryName}");
but this is doesn't work:
#RequestMapping(value="/browse/category/{categoryName}");
Browsing to http://localhost:8080/myapp/browse/category/books generates a HTTP 404 from Tomcat. The method looks like this:
#Controller
public class BrowseController {
#RequestMapping(value = "/browse/category/{categoryName}", method = RequestMethod.GET)
public String showCategory(#PathVariable("categoryName") String categoryName, Model model) {
model.addAttribute("categoryName", categoryName);
return "Browse";
}
}
I see this message in the Tomcat output window in Netbeans 6.9:
Nov 14, 2010 2:02:03 PM org.springframework.web.servlet.DispatcherServlet noHandlerFound
WARNING: No mapping found for HTTP request with URI [/myapp/browse/category/model] in DispatcherServlet with name 'dispatcher'
EDIT: added more tracing info from the log. Please disregard the timestamps since this questions was edited over two days.
Upon deploying the app:
Nov 15, 2010 9:33:28 PM org.springframework.context.support.AbstractApplicationContext prepareRefresh
INFO: Refreshing WebApplicationContext for namespace 'dispatcher-servlet': startup date [Mon Nov 15 21:33:28 EST 2010]; parent: Root WebApplicationContext
Nov 15, 2010 9:33:28 PM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from ServletContext resource [/WEB-INF/dispatcher-servlet.xml]
Nov 15, 2010 9:33:29 PM org.springframework.beans.factory.support.DefaultListableBeanFactory preInstantiateSingletons
INFO: Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory#143c423: defining beans [browseController,homeController,showController,org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,org.springframework.context.annotation.internalPersistenceAnnotationProcessor,org.springframework.web.servlet.mvc.support.ControllerClassNameHandlerMapping#0,viewResolver]; parent: org.springframework.beans.factory.support.DefaultListableBeanFactory#1ea763a
Nov 15, 2010 9:33:29 PM org.springframework.web.servlet.handler.AbstractUrlHandlerMapping registerHandler
INFO: Mapped URL path [/browse] onto handler 'browseController'
Nov 15, 2010 9:33:29 PM org.springframework.web.servlet.handler.AbstractUrlHandlerMapping registerHandler
INFO: Mapped URL path [/browse/*] onto handler 'browseController'
Nov 15, 2010 9:33:29 PM org.springframework.web.servlet.handler.AbstractUrlHandlerMapping registerHandler
INFO: Mapped URL path [/home] onto handler 'homeController'
Nov 15, 2010 9:33:29 PM org.springframework.web.servlet.handler.AbstractUrlHandlerMapping registerHandler
INFO: Mapped URL path [/home/*] onto handler 'homeController'
Nov 15, 2010 9:33:29 PM org.springframework.web.servlet.handler.AbstractUrlHandlerMapping registerHandler
INFO: Mapped URL path [/show] onto handler 'showController'
Nov 15, 2010 9:33:29 PM org.springframework.web.servlet.handler.AbstractUrlHandlerMapping registerHandler
INFO: Mapped URL path [/show/*] onto handler 'showController'
Nov 15, 2010 9:33:29 PM org.springframework.web.servlet.FrameworkServlet initServletBean
INFO: FrameworkServlet 'dispatcher': initialization completed in 501 ms
When I made the call to http://localhost:8080/myapp/browse/category/model,
Nov 15, 2010 9:34:28 PM org.springframework.web.servlet.DispatcherServlet noHandlerFound
WARNING: No mapping found for HTTP request with URI [/myapp/browse/category/model] in DispatcherServlet with name 'dispatcher'
And here's my web.xml dispatcher config:
<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>/</url-pattern>
</servlet-mapping>
So is there any reason why I URI pattern works but the other doesn't?
You may want to add a request mapping for the browse controller. Try this
#Controller
#RequestMapping("/browse")
public class BrowseController
{
#RequestMapping(value = "/category/{categoryName}", method = RequestMethod.GET)
public String showCategory(#PathVariable("categoryName") String categoryName, Model model)
{
model.addAttribute("categoryName", categoryName);
return "Browse";
}
}
Problem fixed on another thread:
spring-mvc: how to map URI templates in the form of "a/b/{c}"?
Your URL pattern should be /* in the servlet mapping.
Related
dynamic web module version
StackTrace:
Nov 30, 2015 8:44:53 PM org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.j2ee.server:QuoteBuilderAdmin' did not find a matching property.
Nov 30, 2015 8:44:53 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Server version: Apache Tomcat/8.0.28
Nov 30, 2015 8:44:53 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Server built: Oct 7 2015 18:25:21 UTC
Nov 30, 2015 8:44:53 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Server number: 8.0.28.0
Nov 30, 2015 8:44:53 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: OS Name: Windows 8.1
Nov 30, 2015 8:44:53 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: OS Version: 6.3
Nov 30, 2015 8:44:53 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Architecture: amd64
Nov 30, 2015 8:44:53 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Java Home: C:\Program Files\Java\jre1.8.0_51
Nov 30, 2015 8:44:53 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: JVM Version: 1.8.0_51-b16
Nov 30, 2015 8:44:53 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: JVM Vendor: Oracle Corporation
Nov 30, 2015 8:44:53 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: CATALINA_BASE: D:\Balvinder\balvinder\Quote builder\apache-tomcat-8.0.28
Nov 30, 2015 8:44:53 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: CATALINA_HOME: D:\Balvinder\balvinder\Quote builder\apache-tomcat-8.0.28
Nov 30, 2015 8:44:53 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dcatalina.base=D:\Balvinder\balvinder\Quote builder\apache-tomcat-8.0.28
Nov 30, 2015 8:44:53 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dcatalina.home=D:\Balvinder\balvinder\Quote builder\apache-tomcat-8.0.28
Nov 30, 2015 8:44:53 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dwtp.deploy=D:\Balvinder\balvinder\Quote builder\apache-tomcat-8.0.28\wtpwebapps
Nov 30, 2015 8:44:53 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Djava.endorsed.dirs=D:\Balvinder\balvinder\Quote builder\apache-tomcat-8.0.28\endorsed
Nov 30, 2015 8:44:53 PM org.apache.catalina.startup.VersionLoggerListener log
INFO: Command line argument: -Dfile.encoding=Cp1252
Nov 30, 2015 8:44:53 PM org.apache.catalina.core.AprLifecycleListener lifecycleEvent
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\Java\jre1.8.0_51\bin;C:\WINDOWS\Sun\Java\bin;C:\WINDOWS\system32;C:\WINDOWS;C:/Program Files/Java/jre1.8.0_51/bin/server;C:/Program Files/Java/jre1.8.0_51/bin;C:/Program Files/Java/jre1.8.0_51/lib/amd64;C:\ProgramData\Oracle\Java\javapath;C:\Program Files\Broadcom\Broadcom 802.11;;C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files\Hewlett-Packard\SimplePass\;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\TortoiseSVN\bin;D:\Balvinder\software\eclipse;;.
Nov 30, 2015 8:44:54 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-nio-8080"]
Nov 30, 2015 8:44:54 PM org.apache.tomcat.util.net.NioSelectorPool getSharedSelector
INFO: Using a shared selector for servlet write/read
Nov 30, 2015 8:44:54 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["ajp-nio-8009"]
Nov 30, 2015 8:44:54 PM org.apache.tomcat.util.net.NioSelectorPool getSharedSelector
INFO: Using a shared selector for servlet write/read
Nov 30, 2015 8:44:54 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 1111 ms
Nov 30, 2015 8:44:54 PM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
Nov 30, 2015 8:44:54 PM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/8.0.28
Nov 30, 2015 8:44:57 PM org.apache.jasper.servlet.TldScanner scanJars
INFO: 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.
Nov 30, 2015 8:44:57 PM org.apache.catalina.core.ApplicationContext log
INFO: Initializing Spring root WebApplicationContext
Nov 30, 2015 8:44:57 PM org.springframework.web.context.ContextLoader initWebApplicationContext
INFO: Root WebApplicationContext: initialization started
Nov 30, 2015 8:44:57 PM org.springframework.context.support.AbstractApplicationContext prepareRefresh
INFO: Refreshing Root WebApplicationContext: startup date [Mon Nov 30 20:44:57 IST 2015]; root of context hierarchy
Nov 30, 2015 8:44:57 PM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from ServletContext resource [/WEB-INF/spring-dispatcher-servlet.xml]
Nov 30, 2015 8:44:58 PM org.springframework.beans.factory.support.DefaultListableBeanFactory preInstantiateSingletons
INFO: Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory#3cd78871: defining beans [login,user,messageSource,viewResolver]; root of factory hierarchy
Nov 30, 2015 8:44:58 PM org.springframework.web.context.ContextLoader initWebApplicationContext
INFO: Root WebApplicationContext: initialization completed in 619 ms
Nov 30, 2015 8:44:58 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory D:\Balvinder\balvinder\Quote builder\apache-tomcat-8.0.28\webapps\docs
Nov 30, 2015 8:44:58 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deployment of web application directory D:\Balvinder\balvinder\Quote builder\apache-tomcat-8.0.28\webapps\docs has finished in 30 ms
Nov 30, 2015 8:44:58 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory D:\Balvinder\balvinder\Quote builder\apache-tomcat-8.0.28\webapps\examples
Nov 30, 2015 8:44:58 PM org.apache.catalina.core.ApplicationContext log
INFO: ContextListener: contextInitialized()
Nov 30, 2015 8:44:58 PM org.apache.catalina.core.ApplicationContext log
INFO: SessionListener: contextInitialized()
Nov 30, 2015 8:44:58 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deployment of web application directory D:\Balvinder\balvinder\Quote builder\apache-tomcat-8.0.28\webapps\examples has finished in 345 ms
Nov 30, 2015 8:44:58 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory D:\Balvinder\balvinder\Quote builder\apache-tomcat-8.0.28\webapps\host-manager
Nov 30, 2015 8:44:58 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deployment of web application directory D:\Balvinder\balvinder\Quote builder\apache-tomcat-8.0.28\webapps\host-manager has finished in 40 ms
Nov 30, 2015 8:44:58 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory D:\Balvinder\balvinder\Quote builder\apache-tomcat-8.0.28\webapps\manager
Nov 30, 2015 8:44:58 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deployment of web application directory D:\Balvinder\balvinder\Quote builder\apache-tomcat-8.0.28\webapps\manager has finished in 33 ms
Nov 30, 2015 8:44:58 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory D:\Balvinder\balvinder\Quote builder\apache-tomcat-8.0.28\webapps\ROOT
Nov 30, 2015 8:44:58 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deployment of web application directory D:\Balvinder\balvinder\Quote builder\apache-tomcat-8.0.28\webapps\ROOT has finished in 23 ms
Nov 30, 2015 8:44:58 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-nio-8080"]
Nov 30, 2015 8:44:58 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-nio-8009"]
Nov 30, 2015 8:44:58 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 4546 ms
Nov 30, 2015 8:45:06 PM org.apache.catalina.core.ApplicationContext log
INFO: Initializing Spring FrameworkServlet 'spring-dispatcher'
Nov 30, 2015 8:45:06 PM org.springframework.web.servlet.FrameworkServlet initServletBean
INFO: FrameworkServlet 'spring-dispatcher': initialization started
Nov 30, 2015 8:45:06 PM org.springframework.context.support.AbstractApplicationContext prepareRefresh
INFO: Refreshing WebApplicationContext for namespace 'spring-dispatcher-servlet': startup date [Mon Nov 30 20:45:06 IST 2015]; parent: Root WebApplicationContext
Nov 30, 2015 8:45:06 PM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from ServletContext resource [/WEB-INF/spring-dispatcher-servlet.xml]
Nov 30, 2015 8:45:06 PM org.springframework.beans.factory.support.DefaultListableBeanFactory preInstantiateSingletons
INFO: Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory#3ac24067: defining beans [login,user,messageSource,viewResolver]; parent: org.springframework.beans.factory.support.DefaultListableBeanFactory#3cd78871
Nov 30, 2015 8:45:06 PM org.springframework.web.servlet.handler.AbstractUrlHandlerMapping registerHandler
INFO: Mapped URL path [/login] onto handler 'login'
Nov 30, 2015 8:45:06 PM org.springframework.web.servlet.handler.AbstractUrlHandlerMapping registerHandler
INFO: Mapped URL path [/login.*] onto handler 'login'
Nov 30, 2015 8:45:06 PM org.springframework.web.servlet.handler.AbstractUrlHandlerMapping registerHandler
INFO: Mapped URL path [/login/] onto handler 'login'
Nov 30, 2015 8:45:06 PM org.springframework.web.servlet.handler.AbstractUrlHandlerMapping registerHandler
INFO: Mapped URL path [/changePasswordRequest] onto handler 'login'
Nov 30, 2015 8:45:06 PM org.springframework.web.servlet.handler.AbstractUrlHandlerMapping registerHandler
INFO: Mapped URL path [/changePasswordRequest.*] onto handler 'login'
Nov 30, 2015 8:45:06 PM org.springframework.web.servlet.handler.AbstractUrlHandlerMapping registerHandler
INFO: Mapped URL path [/changePasswordRequest/] onto handler 'login'
Nov 30, 2015 8:45:06 PM org.springframework.web.servlet.handler.AbstractUrlHandlerMapping registerHandler
INFO: Mapped URL path [/resetPasswordSendMail] onto handler 'login'
Nov 30, 2015 8:45:06 PM org.springframework.web.servlet.handler.AbstractUrlHandlerMapping registerHandler
INFO: Mapped URL path [/resetPasswordSendMail.*] onto handler 'login'
Nov 30, 2015 8:45:06 PM org.springframework.web.servlet.handler.AbstractUrlHandlerMapping registerHandler
INFO: Mapped URL path [/resetPasswordSendMail/] onto handler 'login'
Nov 30, 2015 8:45:06 PM org.springframework.web.servlet.handler.AbstractUrlHandlerMapping registerHandler
INFO: Mapped URL path [/changePassword] onto handler 'login'
Nov 30, 2015 8:45:06 PM org.springframework.web.servlet.handler.AbstractUrlHandlerMapping registerHandler
INFO: Mapped URL path [/changePassword.*] onto handler 'login'
Nov 30, 2015 8:45:06 PM org.springframework.web.servlet.handler.AbstractUrlHandlerMapping registerHandler
INFO: Mapped URL path [/changePassword/] onto handler 'login'
Nov 30, 2015 8:45:06 PM org.springframework.web.servlet.handler.AbstractUrlHandlerMapping registerHandler
INFO: Mapped URL path [/logOutPage] onto handler 'login'
Nov 30, 2015 8:45:06 PM org.springframework.web.servlet.handler.AbstractUrlHandlerMapping registerHandler
INFO: Mapped URL path [/logOutPage.*] onto handler 'login'
Nov 30, 2015 8:45:06 PM org.springframework.web.servlet.handler.AbstractUrlHandlerMapping registerHandler
INFO: Mapped URL path [/logOutPage/] onto handler 'login'
Nov 30, 2015 8:45:06 PM org.springframework.web.servlet.handler.AbstractUrlHandlerMapping registerHandler
INFO: Mapped URL path [/resetPassword] onto handler 'login'
Nov 30, 2015 8:45:06 PM org.springframework.web.servlet.handler.AbstractUrlHandlerMapping registerHandler
INFO: Mapped URL path [/resetPassword.*] onto handler 'login'
Nov 30, 2015 8:45:06 PM org.springframework.web.servlet.handler.AbstractUrlHandlerMapping registerHandler
INFO: Mapped URL path [/resetPassword/] onto handler 'login'
Nov 30, 2015 8:45:06 PM org.springframework.web.servlet.handler.AbstractUrlHandlerMapping registerHandler
INFO: Mapped URL path [/editUser] onto handler 'user'
Nov 30, 2015 8:45:06 PM org.springframework.web.servlet.handler.AbstractUrlHandlerMapping registerHandler
INFO: Mapped URL path [/editUser.*] onto handler 'user'
Nov 30, 2015 8:45:06 PM org.springframework.web.servlet.handler.AbstractUrlHandlerMapping registerHandler
INFO: Mapped URL path [/editUser/] onto handler 'user'
Nov 30, 2015 8:45:06 PM org.springframework.web.servlet.handler.AbstractUrlHandlerMapping registerHandler
INFO: Mapped URL path [/CreateUser] onto handler 'user'
Nov 30, 2015 8:45:06 PM org.springframework.web.servlet.handler.AbstractUrlHandlerMapping registerHandler
INFO: Mapped URL path [/CreateUser.*] onto handler 'user'
Nov 30, 2015 8:45:06 PM org.springframework.web.servlet.handler.AbstractUrlHandlerMapping registerHandler
INFO: Mapped URL path [/CreateUser/] onto handler 'user'
Nov 30, 2015 8:45:06 PM org.springframework.web.servlet.handler.AbstractUrlHandlerMapping registerHandler
INFO: Mapped URL path [/saveUser] onto handler 'user'
Nov 30, 2015 8:45:06 PM org.springframework.web.servlet.handler.AbstractUrlHandlerMapping registerHandler
INFO: Mapped URL path [/saveUser.*] onto handler 'user'
Nov 30, 2015 8:45:06 PM org.springframework.web.servlet.handler.AbstractUrlHandlerMapping registerHandler
INFO: Mapped URL path [/saveUser/] onto handler 'user'
Nov 30, 2015 8:45:06 PM org.springframework.web.servlet.FrameworkServlet initServletBean
INFO: FrameworkServlet 'spring-dispatcher': initialization completed in 177 ms
Nov 30, 2015 8:45:06 PM org.springframework.web.servlet.DispatcherServlet noHandlerFound
WARNING: No mapping found for HTTP request with URI [/QuoteBuilderAdmin/] in DispatcherServlet with name 'spring-dispatcher'
My code is
Web.xml:
<web-app 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_3_0.xsd"
version="3.0">
<display-name>Archetype Created Web Application</display-name>
<servlet>
<servlet-name>spring-dispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
</servlet>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring-dispatcher-servlet.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<servlet-mapping>
<servlet-name>spring-dispatcher</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>default</servlet-name>
<url-pattern>*.css</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>default</servlet-name>
<url-pattern>*.js</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>default</servlet-name>
<url-pattern>*.gif</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>default</servlet-name>
<url-pattern>*.jpg</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>default</servlet-name>
<url-pattern>*.png</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>/WEB-INF/index.jsp</welcome-file>
</welcome-file-list>
And pom.xml is
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.logiquebrain</groupId>
<artifactId>QuoteBuilderAdmin</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>QuoteBuilderAdmin Maven Webapp</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>3.0.7.RELEASE</version>
</dependency>
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>2.9</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.37</version>
</dependency>
<!-- Hibernate core -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>5.0.2.Final</version>
</dependency>
<!-- optional -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-osgi</artifactId>
<version>5.0.2.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-envers</artifactId>
<version>5.0.2.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-c3p0</artifactId>
<version>5.0.2.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-proxool</artifactId>
<version>5.0.2.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-infinispan</artifactId>
<version>5.0.2.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-ehcache</artifactId>
<version>5.0.2.Final</version>
</dependency>
</dependencies>
<build>
<finalName>QuoteBuilderAdmin</finalName>
</build>
And spring-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"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
<bean id="login" class="controller.LoginController" />
<bean id="user" class="controller.UserController" />
<bean id="messageSource"
class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
<property name="basenames" value="WEB-INF/properties/messages" />
</bean>
<bean id="viewResolver"
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix">
<value>/WEB-INF/jsp/</value>
</property>
<property name="suffix">
<value>.jsp</value>
</property>
</bean>
I am using tomcat 8.0.
while compiling i am getting the following error:
I am getting error as(In problems: 2 error)enter image description here:
- Description Resource Path Location Type JavaServer Faces 1.2 can not
be installed : One or more constraints have not been
satisfied. QuoteBuilderAdmin line 1 Maven Java EE Configuration
Problem
- Description Resource Path Location Type JavaServer Faces 1.2 requires
Dynamic Web Module 2.5 or newer. QuoteBuilderAdmin line 1 Maven Java
EE Configuration Problem
Please help me to run my project.
Thanks in advance.
Ok this is always a problem for spring beginners, there could be tons of similar problems out there, but every time I type this issue, I always end up reading indirect solutions which I cannot understand, just like what the title said, I cannot resolve views(jsp) inside my WEB-INF/views folder, if i map the page using the file name.
Update: I've been searching extensively with a noHandlerFound/NoMapping Found for a URI problem, I just learned that the controller class name will be resolved by ControllerClassNameHandlerMapping removing the controller and lowercasing the non-controller name and it will be used as the url,
but I CANT still get to load my very simple page in start-up, and no matter where I search there are always tutorials that gives the same example, it does not work. please I need help here.. :(
ProductsHomeController.java (Controller class)
#Controller
public class ProductsHomeController{
#RequestMapping(value = "/productsHome", method = RequestMethod.GET)
public ModelAndView welcome() {
return new ModelAndView("productsHome");
}
xml configuration (XML configuration for MVC annotation and InternalResourceViewResolver)
<mvc:annotation-driven />
<context:component-scan base-package="edu.controllers" />
<bean
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="viewClass"
value="org.springframework.web.servlet.view.JstlView" />
<property name="prefix" value="/WEB-INF/views/" />
<property name="suffix" value=".jsp" />
</bean>
web.xml
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/applicationContext-service.xml
/WEB-INF/applicationContext-repository.xml
</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener- class>
</listener>
<servlet>
<servlet-name>dispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/dispatcher-servlet.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>dispatcher</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
Everytime I run this very simple web application on start,
The servlet resolves the view and display the content of the page by this URL
http://localhost:8080/ProductsHome/
but when I refresh the page, it results into a 404 error
and I need to manually type the file name of the jsp to resolve the view
http://localhost:8080/ProductsHome/productsHome
This is the kind of code I always see in the tutorials I'm reading especially spring-recipe book, but I cannot make it work the way it was said in the book, I expect that on the first start-up the dispatcher-servlet will resolve the views and displaying the page with this URL below
how can I make this work? any help would be greatly appreciated.
http://localhost:8080/ProductsHome/productsHome/home
here is the server log I get so far, I'm currently searching what I need to add to eclipse to show any error
Sep 04, 2014 11:37:09 AM 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 11:37:09 AM org.apache.catalina.core.AprLifecycleListener init
INFO: APR capabilities: IPv6 [true], sendfile [true], accept filters [false], random [true].
Sep 04, 2014 11:37:09 AM 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 11:37:09 AM 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 11:37:10 AM org.apache.catalina.core.AprLifecycleListener initializeSSL
INFO: OpenSSL successfully initialized (OpenSSL 1.0.1g 7 Apr 2014)
Sep 04, 2014 11:37:10 AM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-apr-8080"]
Sep 04, 2014 11:37:10 AM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["ajp-apr-8009"]
Sep 04, 2014 11:37:10 AM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 1875 ms
Sep 04, 2014 11:37:10 AM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
Sep 04, 2014 11:37:10 AM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/8.0.9
Sep 04, 2014 11:37:11 AM org.apache.catalina.util.SessionIdGenerator createSecureRandom
INFO: Creation of SecureRandom instance for session ID generation using [SHA1PRNG] took [133] milliseconds.
Sep 04, 2014 11:37:14 AM org.apache.catalina.core.ApplicationContext log
INFO: No Spring WebApplicationInitializer types detected on classpath
Sep 04, 2014 11:37:14 AM org.apache.catalina.core.ApplicationContext log
INFO: Initializing Spring FrameworkServlet 'dispatcher'
Sep 04, 2014 11:37:14 AM org.springframework.web.servlet.DispatcherServlet initServletBean
INFO: FrameworkServlet 'dispatcher': initialization started
Sep 04, 2014 11:37:14 AM org.springframework.web.context.support.XmlWebApplicationContext prepareRefresh
INFO: Refreshing WebApplicationContext for namespace 'dispatcher-servlet': startup date [Thu Sep 04 11:37:14 PDT 2014]; root of context hierarchy
Sep 04, 2014 11:37:15 AM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from ServletContext resource [/WEB-INF/dispatcher-servlet.xml]
Sep 04, 2014 11:37:16 AM 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 11:37:16 AM 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 11:37:17 AM org.springframework.web.servlet.DispatcherServlet initServletBean
INFO: FrameworkServlet 'dispatcher': initialization completed in 2180 ms
Sep 04, 2014 11:37:21 AM org.apache.catalina.core.ApplicationContext log
INFO: No Spring WebApplicationInitializer types detected on classpath
Sep 04, 2014 11:37:21 AM org.apache.catalina.core.ApplicationContext log
INFO: Initializing Spring root WebApplicationContext
log4j:WARN No appenders could be found for logger (org.springframework.web.context.ContextLoader).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
Sep 04, 2014 11:37:22 AM org.apache.catalina.core.ApplicationContext log
INFO: Initializing Spring FrameworkServlet 'dispatcher'
Sep 04, 2014 11:37:23 AM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-apr-8080"]
Sep 04, 2014 11:37:23 AM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-apr-8009"]
Sep 04, 2014 11:37:23 AM org.apache.catalina.startup.Catalina start
INFO: Server startup in 13063 ms
I thing the controller should be
#Controller
#RequestMapping(value = "/welcome")
public class WelcomeController {
#RequestMapping(method = RequestMethod.GET)
public ModelAndView welcome() {
return new ModelAndView("productsHome");
}
put the welcome-file-list in web.xml
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
in the file index.jsp , file index.jsp in the WEB-INF directory
<%#page contentType="text/html" pageEncoding="UTF-8"%>
<% response.sendRedirect("welcome"); %>
change the servlet-mapping
<servlet-mapping>
<servlet-name>dispatcher</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
make sure that productsHome.jsp is in the /WEB-INF/views/ directory
The problem is with the servlet mapping.
<servlet-mapping>
<servlet-name>dispatcher</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
I realize this question has been asked countless times, but none of the solutions appear to be working for my situation.
I have a basic Spring-WS app I'm putting together with a single servlet context. I can see that both the #Component annotated class and the properties file are both getting picked up on startup as shown by the logs below. However, my #Value annotated String is coming back as null.
Does anyone see anything wrong with the way I've set this up? Please feel free to ask for any additional information I may have left out.
Going forward, what are the best methods I can use to investigate issues like this I encounter in the future?
directmail-manager-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:sws="http://www.springframework.org/schema/web-services"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/web-services http://www.springframework.org/schema/web-services/web-services-2.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.xxx.direct.mailserver"/>
<context:property-placeholder location="classpath:manager.properties"/>
<sws:annotation-driven/>
<sws:dynamic-wsdl id="manager" portTypeName="EcwDirect"
locationUri="/mailerManagerService/" targetNamespace="http://obfuscated.com/direct/definitions">
<sws:xsd location="/WEB-INF/mailManagerRequest.xsd" />
</sws:dynamic-wsdl>
</beans>
web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app
version="3.0"
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_3_0.xsd">
<display-name>xxxxxxxxx</display-name>
<servlet>
<servlet-name>directmail-manager</servlet-name>
<servlet-class>org.springframework.ws.transport.http.MessageDispatcherServlet</servlet-class>
<init-param>
<param-name>transformWsdlLocations</param-name>
<param-value>true</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>directmail-manager</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
</web-app>
manager.properties:
mailserver.url="localhost"
My annotated class:
package com.xxx.direct.mailserver;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
#Component
public class TelnetMailServerUserController implements MailServerUserController {
#Autowired
#Value("${mailserver.url}")
String mailserverUrl;
#Override
public void addUser(String username, String password) {
System.out.println("server URL:" + mailserverUrl);
}
}
class that uses this class:
#Service
public class MailManagerService {
//TODO: craft and return response
public void registerNewUser(List<Element> usersToAdd) {
MailServerUserController userController = new TelnetMailServerUserController();
//TODO: add users fo realz
for(Element user : usersToAdd) {
String emailAddress = user.getChildText("emailAddress", MailManagerEndpoint.NAMESPACE);
String password = user.getChildText("password", MailManagerEndpoint.NAMESPACE);
//TODO: log this:
System.out.println("user " + emailAddress + " added");
userController.addUser(emailAddress, password);
//TODO: add to database
}
}
}
logs:
Apr 23, 2014 11:54:41 AM com.springsource.tcserver.security.PropertyDecoder <init>
INFO: tc Runtime property decoder using memory-based key
Apr 23, 2014 11:54:42 AM com.springsource.tcserver.security.PropertyDecoder <init>
INFO: tcServer Runtime property decoder has been initialized in 261 ms
Apr 23, 2014 11:54:42 AM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-bio-8080"]
Apr 23, 2014 11:54:42 AM com.springsource.tcserver.serviceability.rmi.JmxSocketListener init
INFO: Started up JMX registry on 127.0.0.1:6969 in 128 ms
Apr 23, 2014 11:54:42 AM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 959 ms
Apr 23, 2014 11:54:42 AM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
Apr 23, 2014 11:54:42 AM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: VMware vFabric tc Runtime 2.9.3.RELEASE/7.0.42.A.RELEASE
Apr 23, 2014 11:54:42 AM org.apache.catalina.startup.HostConfig deployDescriptor
INFO: Deploying configuration descriptor C:\springsource\vfabric-tc-server-developer-2.9.3.RELEASE\base-instance\conf\Catalina\localhost\ROOT.xml
Apr 23, 2014 11:54:42 AM org.apache.catalina.startup.SetContextPropertiesRule begin
WARNING: [SetContextPropertiesRule]{Context} Setting property 'source' to 'org.eclipse.jst.jee.server:mail-server-manager' did not find a matching property.
Apr 23, 2014 11:54:44 AM org.apache.catalina.core.ApplicationContext log
INFO: No Spring WebApplicationInitializer types detected on classpath
Apr 23, 2014 11:54:44 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory C:\springsource\vfabric-tc-server-developer-2.9.3.RELEASE\base-instance\webapps\manager
Apr 23, 2014 11:54:44 AM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-8080"]
Apr 23, 2014 11:54:44 AM org.apache.catalina.startup.Catalina start
INFO: Server startup in 1319 ms
Apr 23, 2014 11:54:44 AM org.apache.catalina.core.ApplicationContext log
INFO: Initializing Spring FrameworkServlet 'directmail-manager'
Apr 23, 2014 11:54:44 AM org.springframework.web.servlet.FrameworkServlet initServletBean
INFO: FrameworkServlet 'directmail-manager': initialization started
Apr 23, 2014 11:54:44 AM org.springframework.context.support.AbstractApplicationContext prepareRefresh
INFO: Refreshing WebApplicationContext for namespace 'directmail-manager-servlet': startup date [Wed Apr 23 11:54:44 EDT 2014]; root of context hierarchy
Apr 23, 2014 11:54:44 AM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from ServletContext resource [/WEB-INF/directmail-manager-servlet.xml]
Apr 23, 2014 11:54:44 AM org.springframework.core.io.support.PropertiesLoaderSupport loadProperties
INFO: Loading properties file from class path resource [manager.properties]
Apr 23, 2014 11:54:45 AM org.springframework.ws.soap.addressing.server.AbstractAddressingEndpointMapping afterPropertiesSet
INFO: Supporting [WS-Addressing August 2004, WS-Addressing 1.0]
Apr 23, 2014 11:54:45 AM org.springframework.beans.factory.support.DefaultListableBeanFactory preInstantiateSingletons
INFO: Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory#7c0f6d9: defining beans [mailManagerEndpoint,mailManagerService,telnetMailServerUserController,org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,org.springframework.beans.factory.config.PropertyPlaceholderConfigurer#0,org.springframework.ws.server.endpoint.mapping.PayloadRootAnnotationMethodEndpointMapping#0,org.springframework.ws.soap.server.endpoint.mapping.SoapActionAnnotationMethodEndpointMapping#0,org.springframework.ws.soap.addressing.server.AnnotationActionEndpointMapping#0,org.springframework.ws.server.endpoint.adapter.method.dom.DomPayloadMethodProcessor#0,org.springframework.ws.server.endpoint.adapter.method.SourcePayloadMethodProcessor#0,org.springframework.ws.server.endpoint.adapter.method.jaxb.XmlRootElementPayloadMethodProcessor#0,org.springframework.ws.server.endpoint.adapter.method.jaxb.JaxbElementPayloadMethodProcessor#0,org.springframework.ws.server.endpoint.adapter.method.dom.JDomPayloadMethodProcessor#0,org.springframework.ws.server.endpoint.adapter.DefaultMethodEndpointAdapter#0,org.springframework.ws.soap.server.endpoint.SoapFaultAnnotationExceptionResolver#0,org.springframework.ws.soap.server.endpoint.SimpleSoapExceptionResolver#0,org.springframework.xml.xsd.SimpleXsdSchema#0,manager,org.springframework.context.annotation.ConfigurationClassPostProcessor.importAwareProcessor]; root of factory hierarchy
Apr 23, 2014 11:54:45 AM org.springframework.ws.soap.saaj.SaajSoapMessageFactory afterPropertiesSet
INFO: Creating SAAJ 1.3 MessageFactory with SOAP 1.1 Protocol
Apr 23, 2014 11:54:45 AM org.springframework.web.servlet.FrameworkServlet initServletBean
INFO: FrameworkServlet 'directmail-manager': initialization completed in 1012 ms
user test added
server URL:null
You aren't using a Spring managed bean. You are creating an object yourself.
MailServerUserController userController = new TelnetMailServerUserController();
In this case, Spring is not involved in processing the #Value annotated field (or anything else for that matter).
Instead, get the bean from the context, inject it.
#Autowired
private MailServerUserController userController;
So I'm new with this JSF stuff and thought I write some code just to see how it works. Actually I did things like here in this tutorial. But I'm not even able to do the simplest thing.
To keep things clear I just made one class:
#ManagedBean
#SessionScoped
public class Bean implements Serializable {
private static final long serialVersionUID = 1L;
public final String TEXT = "Bean";
}
my index.xhtml:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:p="http://xmlns.jcp.org/jsf/passthrough">
<head>
<meta charset="UTF-8"/>
<title>JEE</title>
</head>
<body>
<h3>Output1: <h:outputText value="#{Bean.TEXT}"/></h3>
<h4>Output2: #{Bean.TEXT}</h4>
</body>
</html>
If I start this on Eclipse I dont get any output for Bean.TEXT , like if I would not have any access to this class:
So there should be some text after Output1 and Output2. I don't see any exceptions regarding the Bean class. How do I debug stuff like this? Any suggestions?
PS:
Here my web.xml (I made it somehow like in the tutorial):
<?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>JavaEE</display-name>
<welcome-file-list>
<welcome-file>index.xhtml</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>Servlet Class</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Servlet Class</servlet-name>
<url-pattern>/faces/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>Servlet Class</servlet-name>
<url-pattern>*.xhtml</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>Servlet Class</servlet-name>
<url-pattern>*.faces</url-pattern>
</servlet-mapping>
</web-app>
Console output:
Dec 24, 2013 3:36:18 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
Dec 24, 2013 3:36:18 PM org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:JavaEE' did not find a matching property.
Dec 24, 2013 3:36:18 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-bio-8080"]
Dec 24, 2013 3:36:18 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["ajp-bio-8009"]
Dec 24, 2013 3:36:18 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 573 ms
Dec 24, 2013 3:36:18 PM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
Dec 24, 2013 3:36:18 PM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.47
Dec 24, 2013 3:36:20 PM com.sun.faces.config.ConfigureListener contextInitialized
INFO: Initializing Mojarra 2.2.4 ( 20131003-1354 https://svn.java.net/svn/mojarra~svn/tags/2.2.4#12574) for context '/JavaEE'
Dec 24, 2013 3:36:20 PM com.sun.faces.spi.InjectionProviderFactory createInstance
INFO: JSF1048: PostConstruct/PreDestroy annotations present. ManagedBeans methods marked with these annotations will have said annotations processed.
Dec 24, 2013 3:36:21 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-8080"]
Dec 24, 2013 3:36:21 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-bio-8009"]
Dec 24, 2013 3:36:21 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 2284 ms
Within EL context you access beans via names that were previously declared by means of annotations or configuration file. If you don't specify name element of #ManagedBean annotation then it'll become the simple class name with the first letter decapitalized (if two initial letters are not uppercase). In your case the bean can be accessed as #{bean} while you tried to access it as #{Bean} which is wrong (but could have worked if you declared it as #ManagedBean(name="Bean")).
Also, it's worth noting that it is a common practice to have only one mapping for the faces servlet and that is *.xhtml, so you'd be better off if you removed the three specified servlet mappings from your web.xml and left only one.
I am getting "The resource identified by this request is only capable of generating responses with characteristics not acceptable according to the request "accept" headers." (http status 406 )error while trying to get item_id parameter from url like this:
http://localhost:8080/products/edit_item.html?item_id=3
Then I will get item_id and get that single item data from database. I am using Spring 3.2.4 Tomcat 7 and eclipse kepler. My controller method is:
#RequestMapping(value="edit_item",method=RequestMethod.GET, params="item_id")
public #ResponseBody ModelAndView editItem(#RequestParam(value="item_id") int item_id)
{
//do things with item_id
}
I have searched web and saw problems about json. My problem is very simple I just need to get single value from url. I am new to spring maybe this can be so easy issue for you, but I couldn't make it.
And the configuration file spring-servlet.xml 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">
<import resource="./Ekle/Beans.xml" />
<context:component-scan
base-package="Ekle" />
<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/Ekle/" />
<property name="suffix" value=".jsp" />
</bean>
</beans>
And this is my stacktrace:
Sep 22, 2013 10:31:59 AM 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\Java\jre7\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:\Program Files\Common Files\Microsoft Shared\Windows Live;C:\Program Files (x86)\Common Files\Microsoft Shared\Windows Live;C:\Program Files (x86)\AMD APP\bin\x86_64;C:\Program Files (x86)\AMD APP\bin\x86;C:\Program Files\Broadcom\Broadcom 802.11 Network Adapter\Driver;;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;C:\Program Files (x86)\Windows Live\Shared;c:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\;c:\Program Files\Microsoft SQL Server\100\Tools\Binn\;c:\Program Files\Microsoft SQL Server\100\DTS\Binn\;C:\Program Files\apache-maven-3.1.0\bin;C:\Program Files\Java\jdk1.7.0_17\bin;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;C:\Program Files\apache-maven-3.1.0\bin;C:\Program Files\Java\jdk1.7.0_17\bin;.
Sep 22, 2013 10:31:59 AM org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:DomainYonetim' did not find a matching property.
Sep 22, 2013 10:31:59 AM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-bio-8080"]
Sep 22, 2013 10:31:59 AM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["ajp-bio-8009"]
Sep 22, 2013 10:31:59 AM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 747 ms
Sep 22, 2013 10:31:59 AM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
Sep 22, 2013 10:31:59 AM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.42
Sep 22, 2013 10:32:02 AM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jstl/core_rt is already defined
Sep 22, 2013 10:32:02 AM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jstl/core is already defined
Sep 22, 2013 10:32:02 AM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jsp/jstl/core is already defined
Sep 22, 2013 10:32:02 AM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jstl/fmt_rt is already defined
Sep 22, 2013 10:32:02 AM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jstl/fmt is already defined
Sep 22, 2013 10:32:02 AM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jsp/jstl/fmt is already defined
Sep 22, 2013 10:32:02 AM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jsp/jstl/functions is already defined
Sep 22, 2013 10:32:02 AM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://jakarta.apache.org/taglibs/standard/permittedTaglibs is already defined
Sep 22, 2013 10:32:02 AM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://jakarta.apache.org/taglibs/standard/scriptfree is already defined
Sep 22, 2013 10:32:02 AM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jstl/sql_rt is already defined
Sep 22, 2013 10:32:02 AM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jstl/sql is already defined
Sep 22, 2013 10:32:02 AM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jsp/jstl/sql is already defined
Sep 22, 2013 10:32:02 AM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jstl/xml_rt is already defined
Sep 22, 2013 10:32:02 AM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jstl/xml is already defined
Sep 22, 2013 10:32:02 AM org.apache.catalina.startup.TaglibUriRule body
INFO: TLD skipped. URI: http://java.sun.com/jsp/jstl/xml is already defined
Sep 22, 2013 10:32:02 AM org.apache.catalina.core.ApplicationContext log
INFO: No Spring WebApplicationInitializer types detected on classpath
Sep 22, 2013 10:32:02 AM org.apache.catalina.core.ApplicationContext log
INFO: Initializing Spring FrameworkServlet 'spring'
Sep 22, 2013 10:32:02 AM org.springframework.web.servlet.DispatcherServlet initServletBean
INFO: FrameworkServlet 'spring': initialization started
Sep 22, 2013 10:32:02 AM org.springframework.web.context.support.XmlWebApplicationContext prepareRefresh
INFO: Refreshing WebApplicationContext for namespace 'spring-servlet': startup date [Sun Sep 22 10:32:02 PDT 2013]; root of context hierarchy
Sep 22, 2013 10:32:02 AM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from ServletContext resource [/WEB-INF/spring-servlet.xml]
Sep 22, 2013 10:32:02 AM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from ServletContext resource [/WEB-INF/Ekle/Beans.xml]
Sep 22, 2013 10:32:02 AM org.springframework.jdbc.datasource.DriverManagerDataSource setDriverClassName
INFO: Loaded JDBC driver: com.mysql.jdbc.Driver
Sep 22, 2013 10:32:03 AM org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping registerHandler
INFO: Mapped URL path [/DomainEkle] onto handler 'domainEkleController'
Sep 22, 2013 10:32:03 AM org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping registerHandler
INFO: Mapped URL path [/DomainEkle.*] onto handler 'domainEkleController'
Sep 22, 2013 10:32:03 AM org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping registerHandler
INFO: Mapped URL path [/DomainEkle/] onto handler 'domainEkleController'
Sep 22, 2013 10:32:03 AM org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping registerHandler
INFO: Mapped URL path [/domain_list] onto handler 'domainEkleController'
Sep 22, 2013 10:32:03 AM org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping registerHandler
INFO: Mapped URL path [/domain_list.*] onto handler 'domainEkleController'
Sep 22, 2013 10:32:03 AM org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping registerHandler
INFO: Mapped URL path [/domain_list/] onto handler 'domainEkleController'
Sep 22, 2013 10:32:03 AM org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping registerHandler
INFO: Mapped URL path [/memur_ekle] onto handler 'memurController'
Sep 22, 2013 10:32:03 AM org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping registerHandler
INFO: Mapped URL path [/memur_ekle.*] onto handler 'memurController'
Sep 22, 2013 10:32:03 AM org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping registerHandler
INFO: Mapped URL path [/memur_ekle/] onto handler 'memurController'
Sep 22, 2013 10:32:03 AM org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping registerHandler
INFO: Mapped URL path [/memur_list] onto handler 'memurController'
Sep 22, 2013 10:32:03 AM org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping registerHandler
INFO: Mapped URL path [/memur_list.*] onto handler 'memurController'
Sep 22, 2013 10:32:03 AM org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping registerHandler
INFO: Mapped URL path [/memur_list/] onto handler 'memurController'
Sep 22, 2013 10:32:03 AM org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping registerHandler
INFO: Mapped URL path [/sunucu_ekle] onto handler 'sunucuKontroller'
Sep 22, 2013 10:32:03 AM org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping registerHandler
INFO: Mapped URL path [/sunucu_ekle.*] onto handler 'sunucuKontroller'
Sep 22, 2013 10:32:03 AM org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping registerHandler
INFO: Mapped URL path [/sunucu_ekle/] onto handler 'sunucuKontroller'
Sep 22, 2013 10:32:03 AM org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping registerHandler
INFO: Mapped URL path [/sunucu_list] onto handler 'sunucuKontroller'
Sep 22, 2013 10:32:03 AM org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping registerHandler
INFO: Mapped URL path [/sunucu_list.*] onto handler 'sunucuKontroller'
Sep 22, 2013 10:32:03 AM org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping registerHandler
INFO: Mapped URL path [/sunucu_list/] onto handler 'sunucuKontroller'
Sep 22, 2013 10:32:03 AM org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping registerHandler
INFO: Mapped URL path [/sunucu_duzenle] onto handler 'sunucuKontroller'
Sep 22, 2013 10:32:03 AM org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping registerHandler
INFO: Mapped URL path [/sunucu_duzenle.*] onto handler 'sunucuKontroller'
Sep 22, 2013 10:32:03 AM org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping registerHandler
INFO: Mapped URL path [/sunucu_duzenle/] onto handler 'sunucuKontroller'
Sep 22, 2013 10:32:03 AM org.springframework.web.servlet.DispatcherServlet initServletBean
INFO: FrameworkServlet 'spring': initialization completed in 1088 ms
Sep 22, 2013 10:32:03 AM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-8080"]
Sep 22, 2013 10:32:03 AM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-bio-8009"]
Sep 22, 2013 10:32:03 AM org.apache.catalina.startup.Catalina start