Spring No mapping found for HTTP request with URI - spring

I looked at everypost related with this problem and tried nearly all of them. I'm getting this error. I also have created an empty Spring Maven MVC project and duplicated view and controller and named them as example.jsp and ExampleController.java etc. Shortly, I can not get any respond from Tomcat. I do not know it has anything to do with it but I' also getting and error at the beginning of Console log.
Thanks in advance...
Console log beginning warning (I do not know it has an affect on this problem):
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:SpitterSpring' did not find a matching property.
Here is my actual part of error:
Tem 11, 2014 4:55:32 PM org.springframework.web.servlet.handler.SimpleUrlHandlerMapping registerHandler
INFO: Mapped URL path [/resources/**] onto handler 'org.springframework.web.servlet.resource.ResourceHttpRequestHandler#0'
Tem 11, 2014 4:55:32 PM org.springframework.web.servlet.DispatcherServlet initServletBean
INFO: FrameworkServlet 'appServlet': initialization completed in 885 ms
Tem 11, 2014 4:55:32 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-8080"]
Tem 11, 2014 4:55:32 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-bio-8009"]
Tem 11, 2014 4:55:32 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 9260 ms
Tem 11, 2014 4:55:34 PM org.springframework.web.servlet.PageNotFound noHandlerFound
WARNING: No mapping found for HTTP request with URI [/spitter/] in DispatcherServlet with name 'appServlet'
Tem 11, 2014 4:55:39 PM org.springframework.web.servlet.PageNotFound noHandlerFound
WARNING: No mapping found for HTTP request with URI [/spitter/spitter/deneme] in DispatcherServlet with name 'appServlet'
Tem 11, 2014 4:55:45 PM org.springframework.web.servlet.PageNotFound noHandlerFound
WARNING: No mapping found for HTTP request with URI [/spitter/deneme] in DispatcherServlet with name 'appServlet'
Tem 11, 2014 4:55:52 PM org.springframework.web.servlet.PageNotFound noHandlerFound
WARNING: No mapping found for HTTP request with URI [/spitter/deneme] in DispatcherServlet with name 'appServlet'
Here is my 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">
<!-- The definition of the Root Spring Container shared by all Servlets
and Filters -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring/application-config.xml</param-value>
</context-param>
<!-- Creates the Spring Container shared by all Servlets and Filters -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<!-- Processes application requests -->
<servlet>
<servlet-name>appServlet</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring/appServlet/servlet-context.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>appServlet</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
</web-app>
Here is my servlet-context.xml file
<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/mvc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd
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">
<!-- DispatcherServlet Context: defines this servlet's request-processing infrastructure -->
<!-- Enables the Spring MVC #Controller programming model -->
<annotation-driven />
<context:component-scan base-package="com.ex.spitter.mvc" />
<!-- Handles HTTP GET requests for /resources/** by efficiently serving up static resources in the ${webappRoot}/resources directory -->
<resources mapping="/resources/**" location="/resources/" />
<!-- Resolves views selected for rendering by #Controllers to .jsp resources in the /WEB-INF/views directory -->
<beans:bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<beans:property name="prefix" value="/WEB-INF/views/" />
<beans:property name="suffix" value=".jsp" />
</beans:bean>
</beans:beans>
Here is my com.ex.spitter.mvc -> HomeController:
package com.ex.spitter.mvc;
import java.util.Map;
import javax.inject.Inject;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import com.ex.spitter.service.SpitterService;
#Controller
public class HomeController {
private SpitterService spitterService;
#Inject
public HomeController(SpitterService spitterService) {
this.spitterService = spitterService;
}
#RequestMapping(value = { "/", "/home" }, method = RequestMethod.GET)
public String showHomePage(Map<String, Object> model) {
model.put("spittles", spitterService.getRecentSpittles(spittlesPerPage));
return "home";
}
// <start id="spittlesPerPage"/>
public static final int DEFAULT_SPITTLES_PER_PAGE = 25;
private int spittlesPerPage = DEFAULT_SPITTLES_PER_PAGE;
public void setSpittlesPerPage(int spittlesPerPage) {
this.spittlesPerPage = spittlesPerPage;
}
public int getSpittlesPerPage() {
return spittlesPerPage;
}
// <end id="spittlesPerPage"/>
}

The problem was not solved but I changed my workspace and try to do it copy the codes. Besides, I will try to use a different version of Tomcat or install a Jboss

Related

I wrote a simple spring MVC program using maven which is throwing 404 error when i click the login button to redirect

Jul 18, 2017 8:45:43 PM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions INFO: Loading XML bean definitions from ServletContext resource [/WEB-INF/hello-servlet.xml] Jul 18, 2017 8:45:44 PM org.springframework.web.servlet.DispatcherServlet initServletBean INFO: FrameworkServlet 'hello': initialization completed in 580 ms Jul 18, 2017 8:45:44 PM org.springframework.web.servlet.PageNotFound noHandlerFound WARNING: No mapping found for HTTP request with URI [/HelloWorld/faisal] in DispatcherServlet with name 'hello'
hello-servlet.xml
you need to load ApplicationContext.xml in web.xml file, you can use sample bellow code for adding ApplicationContext.xml in web.xml
<servlet>
<servlet-name>myServlet</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:ApplicationContext.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
First if you want to get any response from your controller with your method declared as VOID you don't go to get any response, your method is printing in console the string faisl. Then if you want to get the index page that prints "faisal" you need to declare the controller like this:
#Controller
public class MainClass {
#RequestMapping(value="/faisal", method=RequestMethod.GET)
public ModelAndView getIndex(){
return new ModelAndView("index", "msg", "Hello Faisal");
}
}
in your hello-servlet.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns = "http://www.springframework.org/schema/beans"
xmlns:ctx = "http://www.springframework.org/schema/context"
xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance"
xmlns:mvc = "http://www.springframework.org/schema/mvc"
xsi:schemaLocation = "http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-2.5.xsd">
<ctx:component-scan base-package="com.faisal"></ctx:component-scan>
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/" />
<property name="suffix" value=".jsp" />
</bean>
</beans>
now the InternalViewResolver is looking for your index.jsp view that you have declared under /WEB-INF/
In your index.jsp you can do the next to print the message that you has mapped to your view:
<body>
<h1>${msg}</h1>
</body>
${msg} is the key that you are passing in the controller the value is Hello faisal then if you open the url
/HelloWorld/faisal
in your view you should be able to see Hello Faisal
Regards,

Spring controllers not found

I am unable to call spring MVC controller. Everytime I hit it, it says not found.
My files are as following.
Web.xml
<servlet>
<servlet-name>spring</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet
</servlet-class>
<load-on-startup>1</load-on-startup>
<async-supported>true</async-supported>
</servlet>
<servlet-mapping>
<servlet-name>spring</servlet-name>
<url-pattern>/gk1</url-pattern>
</servlet-mapping>
spring-servlet.xml
<mvc:annotation-driven />
<context:component-scan base-package="com.gkool" />
<bean
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix">
<value>/WEB-INF/views/</value>
</property>
<property name="suffix">
<value>.jsp</value>
</property>
<property name="viewClass"
value="org.springframework.web.servlet.view.JstlView" />
</bean>
<mvc:resources mapping="/resources/**" location="/resources/" />
</beans>
My controller file
package com.gkool;
#Controller
#RequestMapping("/score")
public class ScoreController {
Logger log = Logger.getLogger(ScoreController.class);
#RequestMapping(value = "", method = RequestMethod.GET)
public String printWelcome(ModelMap model) {
model.addAttribute("message", "Spring 3 MVC Hello World");
return "hello";
}
#RequestMapping(value = "/hello/{name}", method = RequestMethod.GET)
public ModelAndView hello(#PathVariable("name") String name) {
ModelAndView model = new ModelAndView();
model.setViewName("hello");
model.addObject("msg", name);
return model;
}
}
when I start sever and hit URL http://localhost:8080/gk1/score or http://localhost:8080/gk1/score/hello/anoop It gives error code 404 not found.
P.S. /gk1 is module name in tomcat.
When I start the tomcat server it gives following logs
org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping registerHandlerMethod
INFO: Mapped "{[/score/hello/{name}],methods=[GET],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public org.springframework.web.servlet.ModelAndView com.gkool.ScoreController.hello(java.lang.String)
Feb 07, 2017 10:37:11 PM org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping registerHandlerMethod
INFO: Mapped "{[/score],methods=[GET],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public java.lang.String com.gkool.ScoreController.printWelcome(org.springframework.ui.ModelMap)
Feb 07, 2017 10:37:12 PM org.springframework.web.servlet.handler.SimpleUrlHandlerMapping registerHandler
INFO: Mapped URL path [/resources/**] onto handler 'org.springframework.web.servlet.resource.ResourceHttpRequestHandler#0'
That means it identifies a mapped URL as /score/hello/{name} but when I start my server in debug and put a debugger breakpoint in the controller method, the debug control doesn't come there.
can anyone please help?
Check if you've defined the context web within the tomcat configuration of your application:
<Context docBase="/path/to/myapp.war" path="/myContext" reloadable="true"/>
Now execute the request like this:
http://localhost:8080/myContext/gk1/score/hello/anoop
But if you've defined like:
<Context docBase="/path/to/myapp.war" path="/gk1" reloadable="true"/>
Then in the web.xml servlet configuration you just have to define the servlet mapping like this:
<servlet-mapping>
<servlet-name>spring</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
Fix your Spring configuration.
<mvc:annotation-driven />
is a configuration element.
This is required for Spring to "find" your controllers:
<context:component-scan base-package="your.controller.package"/>
Per the Sotirios Delimanolis comment, the following configuration
<servlet-mapping>
<servlet-name>spring</servlet-name>
<url-pattern>/gk1</url-pattern>
</servlet-mapping>
Tells tomcat to send requests with exactly match this URL: http://localhost:8080/gk1 to the spring servlet.
<servlet-mapping>
<servlet-name>spring</servlet-name>
<url-pattern>/gk1/*</url-pattern>
</servlet-mapping>
Which tells tomcat to send any request that starts with the URL http://localhost:8080/gk1 to spring.
The * is the difference between: "exactly match" and "starts with".

404 error while running Spring MVC webapp

While I am running the spring mvc dynamic web-app.It does not give any exception
in console but 404 error in browser and in console these I got.
INFO: Loading XML bean definitions from ServletContext resource [/WEB-
INF/troubleshootApplicationContext.xml]
11-Apr-2016 08:47:59 org.springframework.web.context.ContextLoader
initWebApplicationContext
INFO: Root WebApplicationContext: initialization completed in 360 ms
11-Apr-2016 08:47:59 org.apache.catalina.core.ApplicationContext log
INFO: Initializing Spring FrameworkServlet 'HelloWeb'
11-Apr-2016 08:47:59 org.springframework.web.servlet.FrameworkServlet
initServletBean
INFO: FrameworkServlet 'HelloWeb': initialization started
11-Apr-2016 08:47:59
org.springframework.context.support.AbstractApplicationContext
prepareRefresh
INFO: Refreshing WebApplicationContext for namespace 'HelloWeb-servlet':
startup
date [Mon Apr 11 08:47:59 BST 2016]; parent: Root WebApplicationContext
11-Apr-2016 08:47:59
org.springframework.beans.factory.xml.XmlBeanDefinitionReader
loadBeanDefinitions
INFO: Loading XML bean definitions from ServletContext resource [/WEB-
INF/dispatcher-servlet.xml]
11-Apr-2016 08:47:59
org.springframework.web.servlet.handler.AbstractUrlHandlerMapping
registerHandler
INFO: Mapped URL path [/hello] onto handler 'troubleController'
11-Apr-2016 08:47:59
org.springframework.web.servlet.handler.AbstractUrlHandlerMapping
registerHandler
INFO: Mapped URL path [/hello.*] onto handler 'troubleController'
11-Apr-2016 08:47:59
org.springframework.web.servlet.handler.AbstractUrlHandlerMapping
registerHandler
INFO: Mapped URL path [/hello/] onto handler 'troubleController'
11-Apr-2016 08:47:59 org.springframework.web.servlet.FrameworkServlet
initServletBean
INFO: FrameworkServlet 'HelloWeb': initialization completed in 495 ms
11-Apr-2016 08:47:59 org.apache.coyote.http11.Http11Protocol start
INFO: Starting Coyote HTTP/1.1 on http-8080
11-Apr-2016 08:47:59 org.apache.jk.common.ChannelSocket init
INFO: JK: ajp13 listening on /0.0.0.0:8009
11-Apr-2016 08:47:59 org.apache.jk.server.JkMain start
INFO: Jk running ID=0 time=0/21 config=null
11-Apr-2016 08:47:59 org.apache.catalina.startup.Catalina start
INFO: Server startup in 1490 ms
11-Apr-2016 08:48:00 org.springframework.web.servlet.DispatcherServlet
noHandlerFound
WARNING: No mapping found for HTTP request with URI [/TS_WEB_APP/] in
DispatcherServlet with name 'HelloWeb'
Web.xml
====
<display-name>Spring MVC Application</display-name>
<servlet>
<servlet-name>HelloWeb</servlet-name>
<servlet-class>
org.springframework.web.servlet.DispatcherServlet
</servlet-class>
<load-on-startup>1</load-on-startup>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/dispatcher-servlet.xml</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>HelloWeb</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
<listener>
<listener-
class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
</web-app>
dispatcher-servlet.xml
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/" />
<property name="suffix" value=".jsp" />
Here is the controller that i used
#Controller
//#RequestMapping("/hello")
public class TroubleController {
#RequestMapping(value = "/hello")
public String printHello(ModelMap model) {
model.addAttribute("message", "Hello Spring MVC Framework!");
return "hello11";
}
}
you have mapped all the URL's containing /hello to the troubleController , so in order to check that response , you could try and hit localhost:8080/YourWebAppName/hello , and replace the YourWebAppName with your web application project name.
The error that you get , indicates that for the URL /TS_WEB_APP/ there has not been set up any #RequestMapping to any controller
dispatcher servlet
==========
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.2.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-4.2.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.2.xsd">
<mvc:annotation-driven />
<context:component-scan base-package="com.myriad.ihc.controller" />
<bean id="viewResolver"
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/views/" />
<property name="suffix" value=".jsp" />
</bean>
Web.xml
==========
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_5.xsd">
Spring MVC Application
index.jsp
<servlet-name>HelloWeb</servlet-name>
<servlet-class>
org.springframework.web.servlet.DispatcherServlet
</servlet-class>
<load-on-startup>1</load-on-startup>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/dispatcher-servlet.xml</param-value>
<servlet-name>HelloWeb</servlet-name>
<url-pattern>/*</url-pattern>
This is my controller class and also i changed my my jsp page location to /WEB-INF/
#Controller
public class TroubleController {
#RequestMapping(value = "/hello")
public String printHello(ModelMap model) {
model.addAttribute("message", "Hello Spring MVC Framework!");
return "hello11";
}
}

Web Session Replication with HazelCast in Grails - HazelcastSerializationException

I'm trying to do session replication with hazelcast in grails application as given in Hazelcast docs.
Grails version: 1.2.1
Hazelcast: 2.5.1 (Opensource edition)
I'm getting com.hazelcast.nio.HazelcastSerializationException: java.io.NotSerializableException: org.springframework.beans.factory.annotation.QualifierAnnotationAutowireCandidateResolver when login.
All the domain objects that are added to session are serialized. But org.springframework.beans.factory.annotation.QualifierAnnotationAutowireCandidateResolver is from spring framework. How can i serialize classes from springframework?.
Please help on configuring properly with spring and spring security in grails app.
Log when application is started:
Running Grails application..
loading security config ...
Feb 18, 2016 9:04:11 PM com.hazelcast.config.UrlXmlConfig
INFO: Configuring Hazelcast from 'jndi:/localhost/WEB-INF/hazelcast.xml'.
Feb 18, 2016 9:04:11 PM com.hazelcast.impl.AddressPicker
INFO: Prefer IPv4 stack is true.
Feb 18, 2016 9:04:11 PM com.hazelcast.impl.AddressPicker
INFO: Picked Address[192.168.43.68]:5702, using socket ServerSocket[addr=/0.0.0.0,localport=5702], bind any local is true
Feb 18, 2016 9:04:12 PM com.hazelcast.system
INFO: [192.168.43.68]:5702 [dev] Hazelcast Community Edition 2.5.1 (20130427) starting at Address[192.168.43.68]:5702
Feb 18, 2016 9:04:12 PM com.hazelcast.system
INFO: [192.168.43.68]:5702 [dev] Copyright (C) 2008-2013 Hazelcast.com
Feb 18, 2016 9:04:12 PM com.hazelcast.impl.LifecycleServiceImpl
INFO: [192.168.43.68]:5702 [dev] Address[192.168.43.68]:5702 is STARTING
Feb 18, 2016 9:04:12 PM com.hazelcast.impl.MulticastJoiner
INFO: [192.168.43.68]:5702 [dev] Connecting to master node: Address[192.168.43.68]:5701
Feb 18, 2016 9:04:12 PM com.hazelcast.nio.ConnectionManager
INFO: [192.168.43.68]:5702 [dev] 57981 accepted socket connection from /192.168.43.68:5701
Feb 18, 2016 9:04:18 PM com.hazelcast.cluster.ClusterManager
INFO: [192.168.43.68]:5702 [dev]
Members [2] {
Member [192.168.43.68]:5701
Member [192.168.43.68]:5702 this
}
Feb 18, 2016 9:04:19 PM com.hazelcast.impl.LifecycleServiceImpl
INFO: [192.168.43.68]:5702 [dev] Address[192.168.43.68]:5702 is STARTED
Server running. Browse to http://localhost:8090/
Once I logged in I'm getting HazelcastSerializationException.
Stacktrace:
Feb 18, 2016 9:04:27 PM com.hazelcast.impl.FactoryImpl
WARNING: [192.168.43.68]:5702 [dev] Destroying unknown instance name: a:my-sessions_HZ64E63E3B97D348738114474A17CA7CCE
Feb 18, 2016 9:04:27 PM com.hazelcast.impl.FactoryImpl
WARNING: [192.168.43.68]:5702 [dev] Destroying unknown instance name: a:my-sessions_HZ64E63E3B97D348738114474A17CA7CCE
[/].[default][21:04:27,561][http-8090-4] Servlet.service() for servlet default threw exception
com.hazelcast.nio.HazelcastSerializationException: java.io.NotSerializableException: org.springframework.beans.factory.annotation.QualifierAnnotationAutowireCandidateResolver
at com.hazelcast.nio.AbstractSerializer.toByte(AbstractSerializer.java:111)
at com.hazelcast.nio.AbstractSerializer.toByteArray(AbstractSerializer.java:139)
at com.hazelcast.nio.Serializer.writeObject(Serializer.java:56)
...
Caused by: java.io.NotSerializableException: org.springframework.beans.factory.annotation.QualifierAnnotationAutowireCandidateResolver
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1164)
at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1518)
at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1483)
organization.ErrorController[21:04:27,754][http-8090-4] Exception in Controller; Cause=java.io.NotSerializableException: org.springframework.beans.factory.annotation.QualifierAnnotationAutowireCandidateResolver, Message=org.springframework.beans.factory.annotation.QualifierAnnotationAutowireCandidateResolver, forwardURI=/j_spring_security_check
org.codehaus.groovy.grails.web.errors.GrailsWrappedRuntimeException: org.springframework.beans.factory.annotation.QualifierAnnotationAutowireCandidateResolver
at java.lang.Thread.run(Thread.java:662)
Caused by: com.hazelcast.nio.HazelcastSerializationException: java.io.NotSerializableException: org.springframework.beans.factory.annotation.QualifierAnnotationAutowireCandidateResolver
at com.hazelcast.nio.AbstractSerializer.toByte(AbstractSerializer.java:111)
Process finished with exit code -1
User Domain Class:
class User implements Serializable {
def authenticateService
//domain properties
boolean isAccessingOwnProfile(){
User user = authenticateService.userDomain()
if(user?.id?.toString()?.equalsIgnoreCase(id?.toString())){
return true
}else {
return false
}
}
}
With this i got
com.hazelcast.nio.HazelcastSerializationException: java.io.NotSerializableException: org.grails.plugins.springsecurity.service.AuthenticateService
So i did a quick fix by creating AuthenticateService as below
package com.example
class AuthenticateService extends org.grails.plugins.springsecurity.service.AuthenticateService implements Serializable {
}
after this i'm getting same exception in QualifierAnnotationAutowireCandidateResolver class
Config files:
/src/templates/war/web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app 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">
<filter>
<filter-name>hazelcast-filter</filter-name>
<filter-class>com.hazelcast.web.WebFilter</filter-class>
<init-param>
<param-name>map-name</param-name>
<param-value>my-sessions</param-value>
</init-param>
<init-param>
<param-name>config-location</param-name>
<param-value>/WEB-INF/hazelcast.xml</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>hazelcast-filter</filter-name>
<url-pattern>/*</url-pattern>
<dispatcher>FORWARD</dispatcher>
<dispatcher>INCLUDE</dispatcher>
<dispatcher>REQUEST</dispatcher>
</filter-mapping>
<listener>
<listener-class>com.hazelcast.web.SessionListener</listener-class>
</listener>
<display-name>/#grails.project.key#</display-name>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/applicationContext.xml</param-value>
</context-param>
<context-param>
<param-name>webAppRootKey</param-name>
<param-value>#grails.project.key#</param-value>
</context-param>
<filter>
<filter-name>sitemesh</filter-name>
<filter-class>org.codehaus.groovy.grails.web.sitemesh.GrailsPageFilter</filter-class>
</filter>
<filter>
<filter-name>charEncodingFilter</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
<init-param>
<param-name>targetBeanName</param-name>
<param-value>characterEncodingFilter</param-value>
</init-param>
<init-param>
<param-name>targetFilterLifecycle</param-name>
<param-value>true</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>charEncodingFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>sitemesh</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<listener>
<listener-class>org.codehaus.groovy.grails.web.util.Log4jConfigListener</listener-class>
</listener>
<listener>
<listener-class>org.codehaus.groovy.grails.web.context.GrailsContextLoaderListener</listener-class>
</listener>
<!-- Grails dispatcher servlet -->
<servlet>
<servlet-name>grails</servlet-name>
<servlet-class>org.codehaus.groovy.grails.web.servlet.GrailsDispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<!-- The Groovy Server Pages servlet -->
<servlet>
<servlet-name>gsp</servlet-name>
<servlet-class>org.codehaus.groovy.grails.web.pages.GroovyPagesServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>gsp</servlet-name>
<url-pattern>*.gsp</url-pattern>
</servlet-mapping>
<welcome-file-list>
<!--
The order of the welcome pages is important. JBoss deployment will
break if index.gsp is first in the list.
-->
<welcome-file>index.html</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>index.gsp</welcome-file>
</welcome-file-list>
<jsp-config>
<taglib>
<taglib-uri>http://java.sun.com/jsp/jstl/core</taglib-uri>
<taglib-location>/WEB-INF/tld/c.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>http://java.sun.com/jsp/jstl/fmt</taglib-uri>
<taglib-location>/WEB-INF/tld/fmt.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>http://www.springframework.org/tags</taglib-uri>
<taglib-location>/WEB-INF/tld/spring.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>http://grails.codehaus.org/tags</taglib-uri>
<taglib-location>/WEB-INF/tld/grails.tld</taglib-location>
</taglib>
</jsp-config>
</web-app>
/WEB-INF/hazelcast.xml
<?xml version="1.0" encoding="UTF-8"?>
<hazelcast xsi:schemaLocation="http://www.hazelcast.com/schema/config hazelcast-config-2.5.xsd"
xmlns="http://www.hazelcast.com/schema/config"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<group>
<name>dev</name>
<password>dev-pass</password>
</group>
<network>
<port auto-increment="true">5701</port>
<join>
<multicast enabled="true">
<multicast-group>224.2.2.3</multicast-group>
<multicast-port>54327</multicast-port>
</multicast>
<tcp-ip enabled="false">
<interface>127.0.0.1</interface>
</tcp-ip>
<aws enabled="false">
<access-key>my-access-key</access-key>
<secret-key>my-secret-key</secret-key>
<!--optional, default is us-east-1 -->
<region>us-west-1</region>
<!-- optional, only instances belonging to this group will be discovered, default will try all running instances -->
<security-group-name>hazelcast-sg</security-group-name>
<tag-key>type</tag-key>
<tag-value>hz-nodes</tag-value>
</aws>
</join>
<interfaces enabled="false">
<interface>10.10.1.*</interface>
</interfaces>
<ssl enabled="false" />
<socket-interceptor enabled="false" />
<symmetric-encryption enabled="false">
<algorithm>PBEWithMD5AndDES</algorithm>
<!-- salt value to use when generating the secret key -->
<salt>thesalt</salt>
<!-- pass phrase to use when generating the secret key -->
<password>thepass</password>
<!-- iteration count to use when generating the secret key -->
<iteration-count>19</iteration-count>
</symmetric-encryption>
<asymmetric-encryption enabled="false">
<!-- encryption algorithm -->
<algorithm>RSA/NONE/PKCS1PADDING</algorithm>
<!-- private key password -->
<keyPassword>thekeypass</keyPassword>
<!-- private key alias -->
<keyAlias>local</keyAlias>
<!-- key store type -->
<storeType>JKS</storeType>
<!-- key store password -->
<storePassword>thestorepass</storePassword>
<!-- path to the key store -->
<storePath>keystore</storePath>
</asymmetric-encryption>
</network>
<partition-group enabled="false"/>
<management-center enabled="false" update-interval="3" >http://localhost:9999</management-center>
<executor-service>
<core-pool-size>16</core-pool-size>
<max-pool-size>64</max-pool-size>
<keep-alive-seconds>60</keep-alive-seconds>
</executor-service>
<queue name="default">
<max-size-per-jvm>0</max-size-per-jvm>
<backing-map-ref>default</backing-map-ref>
</queue>
<map name="default">
<backup-count>1</backup-count>
<time-to-live-seconds>0</time-to-live-seconds>
<max-idle-seconds>0</max-idle-seconds>
<eviction-policy>NONE</eviction-policy>
<max-size policy="cluster_wide_map_size">0</max-size>
<eviction-percentage>25</eviction-percentage>
<merge-policy>hz.ADD_NEW_ENTRY</merge-policy>
</map>
</hazelcast>
The exception is because of injecting service in domain class that implements Serializable interface.
I removed service injection in Domain class and tried logged in.
User domain class after removing dependency injection
class User implements Serializable {
// Removed authenticateService injection
//def authenticateService
//domain properties
/*boolean isAccessingOwnProfile(){
User user = authenticateService.userDomain()
if(user?.id?.toString()?.equalsIgnoreCase(id?.toString())){
return true
}else {
return false
}
}*/
}
and also removed custom AuthenticateService, that implements Serializable.
Now i can login to 1 instance and the session was replicated remaining instances.

Mapping issues with Spring-webmvc [duplicate]

This question already has answers here:
Why does Spring MVC respond with a 404 and report "No mapping found for HTTP request with URI [...] in DispatcherServlet"?
(13 answers)
Closed 5 years ago.
In setting up a Spring app (packaged as a WAR and hosted via Tomcat) I'm getting a 404 and the following error when I try to visit 'localhost:8080':
4479 [http-bio-8080-exec-1] WARN org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/WEB-INF/pages/index.html] in DispatcherServlet with name 'spring'
There is most definitely a /WEB-INF/pages/index.html file.
Here's my web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app 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">
<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>
Additionally, here's my spring-servlet.xml file:
<?xml version="1.0" encoding="UTF-8"?>
<beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
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.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd">
<context:component-scan base-package="com.company.app.controller" />
<mvc:annotation-driven />
<bean
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value= "/WEB-INF/pages/"/>
<property name="suffix" value=".html"/>
</bean>
</beans>
And the get method from my controller:
package com.company.app.controller;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
#Controller
public class SplashController {
#RequestMapping(value="/", method=RequestMethod.GET)
public String index() {
return "index";
}
}
So, what's wrong with my configuration?
Additionally: I'd like to include my console output from Spring's initial setup, maybe it will provide a clue or two as to what is missing:
0 [localhost-startStop-1] INFO org.springframework.web.context.ContextLoader - Root WebApplicationContext: initialization started
92 [localhost-startStop-1] INFO org.springframework.web.context.support.XmlWebApplicationContext - Refreshing Root WebApplicationContext: startup date [Sun Jan 26 16:16:57 EST 2014]; root of context hierarchy
147 [localhost-startStop-1] INFO org.springframework.beans.factory.xml.XmlBeanDefinitionReader - Loading XML bean definitions from ServletContext resource [/WEB-INF/spring-servlet.xml]
776 [localhost-startStop-1] INFO org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping - Mapped "{[/],methods=[GET],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public java.lang.String com.company.app.controller.SplashController.index()
1547 [localhost-startStop-1] INFO org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping - Root mapping to handler 'splashController'
1771 [localhost-startStop-1] INFO org.springframework.web.context.ContextLoader - Root WebApplicationContext: initialization completed in 1770 ms
Jan 26, 2014 4:16:59 PM org.apache.catalina.core.ApplicationContext log
INFO: Initializing Spring FrameworkServlet 'spring'
1809 [localhost-startStop-1] INFO org.springframework.web.servlet.DispatcherServlet - FrameworkServlet 'spring': initialization started
1813 [localhost-startStop-1] INFO org.springframework.web.context.support.XmlWebApplicationContext - Refreshing WebApplicationContext for namespace 'spring-servlet': startup date [Sun Jan 26 16:16:59 EST 2014]; parent: Root WebApplicationContext
1817 [localhost-startStop-1] INFO org.springframework.beans.factory.xml.XmlBeanDefinitionReader - Loading XML bean definitions from ServletContext resource [/WEB-INF/spring-servlet.xml]
1947 [localhost-startStop-1] INFO org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping - Mapped "{[/],methods=[GET],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public java.lang.String com.company.app.controller.SplashController.index()
2164 [localhost-startStop-1] INFO org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping - Root mapping to handler 'splashController'
2205 [localhost-startStop-1] INFO org.springframework.web.servlet.DispatcherServlet - FrameworkServlet 'spring': initialization completed in 396 ms
For whatever reason, changing the servlet-mapping portion of my web.xml to this solved the problem:
<servlet-mapping>
<servlet-name>spring</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
I use Spring 3.2.3 release. Try this configuration:
Correct web.xml:
<servlet-mapping>
<servlet-name>Spring</servlet-name>
<url-pattern>*.html</url-pattern>
</servlet-mapping>
Correct Spring-servlet.xml:
<context:component-scan base-package="your.package.controller"/>
<bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping"/>
<bean id="internalViewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver"
p:viewClass="org.springframework.web.servlet.view.JstlView"
p:prefix="/WEB-INF/jsp/"
p:suffix=".jsp"/>
<bean class="org.springframework.web.servlet.view.BeanNameViewResolver"/>
Correct mapping annotacion:
#RequestMapping(value="/index", method=RequestMethod.GET)
And create index.jsp file.
I also faced the same problem when a friend of mine suggest me to check for the package declaration.
After I knew for which package the definition of the controller request mapping and context:component-scan base-package to check for I saw it was not the same and after giving it the proper package name it started to work.
Check for the following snippet in your Spring config file
<context:component-scan base-package="your package name" >

Resources