I'm trying to build a very simple web-app, where a template xhtml file is placed in a jar placed in the WEB-INF/lib folder. The structure of this jar is as follows:
META-INF/
faces-config.xml
resources
template.xhtml
The content of my index.xhtml is as follows
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:f="http://xmlns.jcp.org/jsf/core">
<ui:composition template="/template.xhtml">
<ui:define name="content">
<h1>Hello World</h1>
</ui:define>
</ui:composition>
</html>
And finally, my web.xml
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
version="3.1">
<context-param>
<description>For Apache MyFaces: need to refresh transient build or an IllegalStateException may occur in visitTree.</description>
<param-name>org.apache.myfaces.REFRESH_TRANSIENT_BUILD_ON_PSS_PRESERVE_STATE</param-name>
<param-value>true</param-value>
</context-param>
<servlet>
<servlet-name>FacesServlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>FacesServlet</servlet-name>
<url-pattern>*.xhtml</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>30</session-timeout>
</session-config>
<welcome-file-list>
<welcome-file>index.xhtml</welcome-file>
</welcome-file-list>
</web-app>
I'm using a TomEE 7.0.2 server, which uses a MyFaces 2.2.11 implementation. Still, I'm getting a java.io.FileNotFoundException:
java.io.FileNotFoundException: /template.xhtml Not Found in ExternalContext as a Resource
at org.apache.myfaces.view.facelets.impl.DefaultFaceletFactory.resolveURL(DefaultFaceletFactory.java:308)
at org.apache.myfaces.view.facelets.impl.DefaultFacelet.getRelativePath(DefaultFacelet.java:470)
at org.apache.myfaces.view.facelets.impl.DefaultFacelet.include(DefaultFacelet.java:552)
at org.apache.myfaces.view.facelets.impl.DefaultFaceletContext.includeFacelet(DefaultFaceletContext.java:240)
at org.apache.myfaces.view.facelets.tag.ui.CompositionHandler.apply(CompositionHandler.java:151)
at org.apache.myfaces.view.facelets.compiler.NamespaceHandler.apply(NamespaceHandler.java:59)
at org.apache.myfaces.view.facelets.compiler.EncodingHandler.apply(EncodingHandler.java:48)
at org.apache.myfaces.view.facelets.impl.DefaultFacelet.apply(DefaultFacelet.java:189)
at org.apache.myfaces.view.facelets.FaceletViewDeclarationLanguage.buildView(FaceletViewDeclarationLanguage.java:477)
at org.apache.myfaces.lifecycle.RenderResponseExecutor.execute(RenderResponseExecutor.java:78)
at org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:267)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:200)
What am I missing?
Related
I've been trying to learn how to develop a Spring Web application and can't seem to get it working. Using the Spring Tool Suite, I created a new Spring Project using the Simple Spring Web Maven template, which basically is comprised of four files:
index.jsp:
<!DOCTYPE html>
<%# page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%# taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%# taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<html>
<head>
<meta charset="utf-8">
<title>Welcome</title>
</head>
<body>
<c:url value="/showMessage.html" var="messageUrl" />
Click to enter
</body>
</html>
/WEB-INF/web.xml:
<?xml version="1.0" encoding="ISO-8859-1"?>
<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_2_5.xsd"
id="WebApp_ID" version="2.5">
<display-name>spring-web-test</display-name>
<!--
- Location of the XML file that defines the root application context.
- Applied by ContextLoaderListener.
-->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:spring/application-config.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<!--
- Servlet that dispatches request to registered handlers (Controller implementations).
-->
<servlet>
<servlet-name>dispatcherServlet</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/mvc-config.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>dispatcherServlet</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
</web-app>
/WEB-INF/mvc-config.xml:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/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">
<!-- Uncomment and your base-package here:
<context:component-scan
base-package="org.springframework.samples.web"/> -->
<mvc:annotation-driven />
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<!-- Example: a logical view name of 'showMessage' is mapped to '/WEB-INF/jsp/showMessage.jsp' -->
<property name="prefix" value="/WEB-INF/view/"/>
<property name="suffix" value=".jsp"/>
</bean>
</beans>
/WEB-INF/view/showMessage.jsp:
<!DOCTYPE html>
<%# page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<html>
<head>
<meta charset="utf-8">
<title>Welcome</title>
</head>
<body>
<h2>${message}</h2>
</body>
</html>
This all seemed simple and basic enough, so I built it using Maven and packaged it into a WAR file. I then deployed it to a local TomEE 7 server, went to http://localhost:8080/spring-web-test-0.0.1-SNAPSHOT, and got to the very simple index.jsp page:
However, when clicking the link, which sends me to http://localhost:8080/spring-web-test-0.0.1-SNAPSHOT/showMessage.html, I get a 404 error from Tomcat:
I suspected it was because of the .html ending - based off what I understand of the dispatcher and view resolver, it would be looking for /WEB-INF/view/showMessage.html.jsp. However, trying to access http://localhost:8080/spring-web-test-0.0.1-SNAPSHOT/showMessage returns the same error. Looking at the Tomcat logs, I see
Nov 11, 2015 9:46:53 AM org.springframework.web.servlet.DispatcherServlet noHandlerFound
WARNING: No mapping found for HTTP request with URI [/spring-web-test-0.0.1-SNAPSHOT/showMessage.html] in DispatcherServlet with name 'dispatcherServlet'
Nov 11, 2015 9:46:55 AM org.springframework.web.servlet.DispatcherServlet noHandlerFound
WARNING: No mapping found for HTTP request with URI [/spring-web-test-0.0.1-SNAPSHOT/showMessage] in DispatcherServlet with name 'dispatcherServlet'
What am I doing wrong? The whole thing seems pretty simple, and I haven't even modified anything from the template Spring Tool Suite provides, so I'd have assumed it would work right out of the box. Unfortunately there doesn't seem to be a whole lot of resources online on developing Spring web applications for use in servlet containers, and of the ones I've found, nothing seemed to suggest I'm doing anything wrong.
Thanks.
Change your index.jsp to something like this
<c:url value="/showMessage" var="messageUrl" />
You don't need file extensions, because you've set them up in your mvc-config.xml.
Then you need a basic controller to handle the mapping. Something like this:
#Controller
public class WebController{
#RequestMapping(value = "/")
public String showMessage(){
return "index";
}
#RequestMapping(value = "/showMessage")
public String showMessage(){
return "showMessage";
}
}
Does the web deploy mechanism affect Spring MVC work?
I create a web project(SpringMVCTest) contains web.xml and a pjsp pages then I create a Java project(SpringMVCTestSrc) and use the link source function to link test_src and SpringMVCTestSrc.
My Eclipse workspace
My problem is if I deploy the project in war file then it works fine
, EX: if I open
localhost:8080/SpringMVCTest/message/showMessage.pages
it will forward to
main/showMessage.jsp
but if I deploy the project with separate web and jar file it will no request mapping found like below.
[DEBUG]-[2015/07/30 15:03:39,o.s.w.s.DispatcherServlet(init):139]: Servlet 'dispatcher' configured successfully
[DEBUG]-[2015/07/30 15:03:40,o.s.w.s.DispatcherServlet(doService):861]: DispatcherServlet with name 'dispatcher' processing GET request for [/SpringMVCTest/message/showMessage.pages]
[DEBUG]-[2015/07/30 15:03:40,o.s.w.s.m.m.a.RequestMappingHandlerMapping(getHandlerInternal):294]: Looking up handler method for path /message/showMessage.pages
[DEBUG]-[2015/07/30 15:03:40,o.s.w.s.m.m.a.RequestMappingHandlerMapping(getHandlerInternal):302]: Did not find handler method for [/message/showMessage.pages]
[WARN]-[2015/07/30 15:03:40,o.s.w.s.PageNotFound(noHandlerFound):1136]: No mapping found for HTTP request with URI [/SpringMVCTest/message/showMessage.pages] in DispatcherServlet with name 'dispatcher'
The log shows the different.
If I deploy in war file. The log shows found 18 bean definitions and request mapping works fine.
Export war file from Eclipse and put it to apache-tomcat-8.0.21\webapps
Startup Tomcat and open localhost:8080/SpringMVCTest/message/showMessage.pages
The page will show Message : Hello world
o.s.c.a.ClassPathBeanDefinitionScanner(registerDefaultFilters):244]: JSR-250 'javax.annotation.ManagedBean' found and supported for component scanning
o.s.c.i.s.PathMatchingResourcePatternResolver(doFindMatchingFileSystemResources):631]: Looking for matching resources in directory tree [D:\Temp\apache-tomcat-8.0.21\webapps\SpringMVCTest\WEB-INF\classes\in\hotkey\mvc]
o.s.c.i.s.PathMatchingResourcePatternResolver(doRetrieveMatchingFiles):693]: Searching directory [D:\Temp\apache-tomcat-8.0.21\webapps\SpringMVCTest\WEB-INF\classes\in\hotkey\mvc] for files matching pattern [D:/Temp/apache-tomcat-8.0.21/webapps/SpringMVCTest/WEB-INF/classes/in/hotkey/mvc/**/*.class]
o.s.c.i.s.PathMatchingResourcePatternResolver(findPathMatchingResources):424]: Resolved location pattern [classpath*:in/hotkey/mvc/**/*.class] to resources [file [D:\Temp\apache-tomcat-8.0.21\webapps\SpringMVCTest\WEB-INF\classes\in\hotkey\mvc\MainForm.class]]
o.s.c.a.ClassPathBeanDefinitionScanner(findCandidateComponents):286]: Identified candidate component class: file [D:\Temp\apache-tomcat-8.0.21\webapps\SpringMVCTest\WEB-INF\classes\in\hotkey\mvc\MainForm.class]
o.s.b.f.x.XmlBeanDefinitionReader(loadBeanDefinitions):224]: Loaded 18 bean definitions from location pattern [classpath:test-dispatcher-context.xml]
If I deploy with separate web and jar file. The log shows found 17 bean definitions and request mapping does not work.
Build a directory in apache-tomcat-8.0.21\webapps, EX: apache-tomcat-8.0.21\webapps\SpringMVCTest
Copy WEB-INF, META-INF from Eclipse workspace to apache-tomcat-8.0.21\webapps\SpringMVCTest
Export jar file from SpringMVCTestSrc and put it to apache-tomcat-8.0.21\webapps\SpringMVCTest\WEB-INF\lib
Startup Tomcat and open localhost:8080/SpringMVCTest/message/showMessage.pages
The page shows HTTP 404
o.s.c.a.ClassPathBeanDefinitionScanner(registerDefaultFilters):244]: JSR-250 'javax.annotation.ManagedBean' found and supported for component scanning
o.s.c.i.s.PathMatchingResourcePatternResolver(findPathMatchingResources):424]: Resolved location pattern [classpath*:in/hotkey/mvc/**/*.class] to resources []
o.s.b.f.x.XmlBeanDefinitionReader(loadBeanDefinitions):224]: Loaded 17 bean definitions from location pattern [classpath:test-dispatcher-context.xml]
Does someone know why the same code but different deploy mechanism has different result?
My code as blow
web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
id="WebApp_ID" version="3.1">
<display-name>SpringMVCTest</display-name>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:test-service-context.xml</param-value>
</context-param>
<filter>
<filter-name>SetCharacterEncodingFilter</filter-name>
<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>SetCharacterEncodingFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<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>classpath:test-dispatcher-context.xml</param-value>
</init-param>
<load-on-startup>3</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>dispatcher</servlet-name>
<url-pattern>*.pages</url-pattern>
</servlet-mapping>
</web-app>
Spring Configuration(test-service-context.xml)
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd">
<bean id="testMessageService" class="in.hotkey.service.TestMessageService" >
</bean>
</beans>
Spring MVC Config(test-dispatcher-context.xml)
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns: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.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd">
<mvc:annotation-driven />
<context:component-scan base-package="in.hotkey.mvc"/>
<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/views/" />
<property name="suffix" value=".jsp" />
</bean>
<bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver" />
</beans>
Main Controller
package in.hotkey.mvc;
import in.hotkey.service.TestMessageService;
import javax.annotation.Resource;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
#Controller
public class MainForm {
#RequestMapping(value="/message/showMessage.pages")
public ModelAndView handleShowMessage() throws Exception {
ModelAndView mv = new ModelAndView("main/showMessage");
mv.addObject("message", "Hello world!");
return mv;
}
}
JSP Content
<%# page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Test</title>
</head>
<body>
<h4>Message : ${message}</h4>
</body>
</html>
I found what the problem is....
Root cause founded from Spring MVC document.
It means annotation scan need directory entries!!
The problem is if I export whole project into war file. It contains the complete directory entries in WEB-INF/classes directory but jar file has no directory entry information.
Resolve this problem just check the "Add directory entries" option in Eclipse export function.
im new to using apache and spring framework and i've been using this tutorial for learning: http://docs.spring.io/docs/Spring-MVC-step-by-step/part1.html
i made an .jsp file however my browser tells me "The requested resource is not available."
the .jsp file is pretty simple
<html>
<head><title>Hello :: Spring Application</title></head>
<body>
<h1>Hello - Spring Application</h1>
<p>Greetings.</p>
</body>
</html>
entering http://localhost:8080/project/hello.htm gives me a 404.
my web.xml file:
<?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>project</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>project</servlet-name>
<url-pattern>*.htm</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>
index.jsp
</welcome-file>
</welcome-file-list>
</web-app>
any idea how to fix this?
404 error means the requested resource is not in the server.
Your problem can be either
1. Not properly matching hello.htm to any controller
bean id="/hello.htm" class="foo.controller" or
2. You have to put your hello.jsp in webcontent folder, along with index.jsp. Not in WEB-INF folder. Refer tutorial.
i've problem when implement spring security and jsf 2.0, exactly when add springsecurity.taglib.xml in web.xml
server : glassfish server 3
springframework 3.0.2
jsf 2.0
library :
org.springframework.faces.sources 3
web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<display-name>HelloWorldExampleWithSpring3MVCInEclipse</display-name>
<context-param>
<param-name>javax.faces.FACELETS_LIBRARIES</param-name>
<param-value>/WEB-INF/springsecurity.taglib.xml</param-value>
</context-param>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/app-config.xml</param-value>
</context-param>
<context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>Production</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<servlet>
<servlet-name>Spring MVC Dispatcher Servlet</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/app-config.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<filter>
<filter-name>springSecurityFilterChain</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.jsf</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>Spring MVC Dispatcher Servlet</servlet-name>
<url-pattern>*.htm</url-pattern>
</servlet-mapping>
<filter-mapping>
<filter-name>springSecurityFilterChain</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<welcome-file-list>
<welcome-file>faces/index.jsp</welcome-file>
</welcome-file-list>
springsecurity.taglib.xml
<?xml version="1.0"?>
<!DOCTYPE facelet-taglib PUBLIC
"-//Sun Microsystems, Inc.//DTD Facelet Taglib 1.0//EN"
"http://java.sun.com/dtd/facelet-taglib_1_0.dtd">
<facelet-taglib>
<namespace>http://www.springframework.org/security/tags</namespace>
<tag>
<tag-name>authorize</tag-name>
<handler-class>org.springframework.faces.security.FaceletsAuthorizeTagHandler</handler-class>
</tag>
<function>
<function-name>areAllGranted</function-name>
<function-class>org.springframework.faces.security.FaceletsAuthorizeTagUtils</function-class>
<function-signature>boolean areAllGranted(java.lang.String)</function-signature>
</function>
<function>
<function-name>areAnyGranted</function-name>
<function-class>org.springframework.faces.security.FaceletsAuthorizeTagUtils</function-class>
<function-signature>boolean areAnyGranted(java.lang.String)</function-signature>
</function>
<function>
<function-name>areNotGranted</function-name>
<function-class>org.springframework.faces.security.FaceletsAuthorizeTagUtils</function-class>
<function-signature>boolean areNotGranted(java.lang.String)</function-signature>
</function>
<function>
<function-name>isAllowed</function-name>
<function-class>org.springframework.faces.security.FaceletsAuthorizeTagUtils</function-class>
<function-signature>boolean isAllowed(java.lang.String, java.lang.String) </function-signature>
</function>
</facelet-taglib>
this is error message
In-place deployment at D:\Project\Secret Project\Hobic Project EE\Yeah\build\web
deploy?path=D:\Project\Secret Project\Hobic Project EE\Yeah\build\web&name=Yeah&force=true failed on GlassFish Server 3
D:\Project\Secret Project\Hobic Project EE\Yeah\nbproject\build-impl.xml:760: The module has not been deployed.
BUILD FAILED (total time: 1 minute 29 seconds)
server error message
SEVERE: Exception while loading the app
SEVERE: Exception while loading the app : java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: java.lang.RuntimeException: com.sun.faces.config.ConfigurationException:
Source Document: jar:file:/D:/Project/Secret%20Project/Hobic%20Project%20EE/Zest/build/web/WEB- INF/lib/org.springframework.faces-2.0.4.RELEASE.jar!/META-INF/faces-config.xml
Cause: Class 'org.springframework.faces.webflow.FlowActionListener' is missing a runtime dependency: java.lang.NoClassDefFoundError: org/springframework/webflow/execution/RequestContext
your suggest right [java.lang.NoClassDefFoundError: org/springframework/webflow/execution/RequestContext], and i got new error now :(
SEVERE: Exception while loading the app
SEVERE: Exception while loading the app : java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Failed to import bean definitions from relative location [security.xml]
Offending resource: ServletContext resource [/WEB-INF/app-config.xml]; nested exception is org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Unable to locate Spring NamespaceHandler for XML schema namespace [http://www.springframework.org/schema/security]
Offending resource: ServletContext resource [/WEB-INF/security.xml]
*solution [Offending resource: ServletContext resource [/WEB-INF/security.xml]] *
![.jar needed][1]
can you give suggest for my problem ?
thx agung
I don't use Netbeans, so I don't know its ins and outs, but this error message seems to indicate that some error/exception has been occurred beforehand. Is there really not anything more into the build log?
Anyway, not sure if that solves the problem and is related to the concrete problem, but one thing which caught my eye is that your <facelet-taglib> is declared conform Facelets 1.x while you're using JSF 2.x which has Facelets 2.x bundled. Netbeans might have fallen over that.
Fix the root declaration of .taglib.xml file as follows:
<?xml version="1.0" encoding="UTF-8"?>
<facelet-taglib
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-facelettaglibrary_2_0.xsd"
version="2.0"
>
<!-- Config here. -->
</facelet-taglib>
Further, Glassfish is a Servlet 3.0 compatible container, but your web.xml root declaration complies Servlet 2.5. This should technically also not immediately cause a problem, but you'll miss Servlet 3.0 / EL 2.2 advantages this way.
I'd fix the root declaration of the web.xml as well:
<?xml version="1.0" encoding="UTF-8"?>
<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"
>
<!-- Config here. -->
</web-app>
Update as per your update the root cause of your concrete problem seems to be the following:
java.lang.NoClassDefFoundError: org/springframework/webflow/execution/RequestContext
The NoClassDefFoundError means that the in the message mentioned class is missing in the classpath, while it is (indirectly) required by other classes in your application. The solution would be to add the class (or in this particular case, the JAR file with the class) to the classpath. The mentioned class is part of Spring WebFlow. You need to download it and include it in the classpath (the buildpath as the IDE calls it) the same way as you did for the core Spring framework and Spring Security.
Update 2 as per your second update, a new problem appeared after fixing the first:
Unable to locate Spring NamespaceHandler for XML schema namespace [http://www.springframework.org/schema/security] Offending resource: ServletContext resource [/WEB-INF/security.xml]
I'm no Spring guy so I can't answer that from top of head, but Google suggests that this problem is caused by a missing Spring Security Config JAR file.
I try to write a simple Ajax client to send and receive messages. It's successfully deployed but I have never received msg from the client. I am beating myself to think out what I am missing, but still can't make it work.
Here is my code:
I creat a dynamic web application named: ActiveMQAjaxService and put activemq-web.jar and all neccessary dependencies in the WEB-INF/lib folder. In this way, AjaxServlet and MessageServlet will be deployed
I start activemq server in command line: ./activemq => activemq successfully created and display:
Listening for connections at: tcp://lilyubuntu:61616
INFO | Connector openwire Started
INFO | ActiveMQ JMS Message Broker (localhost, ID:lilyubuntu-56855-1272317001405-0:0) started
INFO | Logging to org.slf4j.impl.JCLLoggerAdapter(org.mortbay.log) via org.mortbay.log.Slf4jLog
INFO | jetty-6.1.9
INFO | ActiveMQ WebConsole initialized.
INFO | Initializing Spring FrameworkServlet 'dispatcher'
INFO | ActiveMQ Console at http://0.0.0.0:8161/admin
INFO | Initializing Spring root WebApplicationContext
INFO | Connector vm://localhost Started
INFO | Camel Console at http://0.0.0.0:8161/camel
INFO | ActiveMQ Web Demos at http://0.0.0.0:8161/demo
INFO | RESTful file access application at http://0.0.0.0:8161/fileserver
INFO | Started SelectChannelConnector#0.0.0.0:8161
3) index.xml, which is the html to test the client:
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<script type="text/javascript" src="amq/amq.js"></script>
<script type="text/javascript">amq.uri='amq';</script>
<title>Hello Ajax ActiveMQ</title>
</head>
<body>
<p>Hello World!</p>
<script type="text/javascript">
amq.sendMessage("topic://myDetector", "message");
var myHandler =
{
rcvMessage: function(message)
{
alert("received "+message);
}
};
function myPoll(first)
{
if (first)
{
amq.addListener('myDetector', 'topic://myDetector', myHandler.rcvMessage);
}
}
amq.addPollHandler(myPoll);
4) Web.xml:
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<display-name>ActiveMQ Web Demos</display-name>
<description>
Apache ActiveMQ Web Demos
</description>
<!-- context config -->
<context-param>
<param-name>org.apache.activemq.brokerURL</param-name>
<param-value>vm://localhost</param-value> (I also tried tcp://localhost:61616)
<description>The URL of the Message Broker to connect to</description>
</context-param>
<context-param>
<param-name>org.apache.activemq.embeddedBroker</param-name>
<param-value>true</param-value>
<description>Whether we should include an embedded broker or not</description>
</context-param>
<!-- servlet mappings -->
<!-- the subscription REST servlet -->
<servlet>
<servlet-name>AjaxServlet</servlet-name>
<servlet-class>org.apache.activemq.web.AjaxServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet>
<servlet-name>MessageServlet</servlet-name>
<servlet-class>org.apache.activemq.web.MessageServlet</servlet-class>
<load-on-startup>1</load-on-startup>
<!--
Uncomment this parameter if you plan to use multiple consumers over REST
<init-param>
<param-name>destinationOptions</param-name>
<param-value>consumer.prefetchSize=1</param-value>
</init-param>
-->
</servlet>
<!-- the queue browse servlet -->
<filter>
<filter-name>session</filter-name>
<filter-class>org.apache.activemq.web.SessionFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>session</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
After all of these, I deploy the web-app, and it's successfully deployed, but when I try it out in http://localhost:8080/ActiveMQAjaxService/index.html , nothing happens.
I can run the demo portfolioPublisher demo successfully at http://localhost:8161/demo/portfolio/portfolio.html, and see the numbers updated all the time. But for my simple web-app, nothing really works.
Any suggestion/hint is welcomed. Thanks so much
Lily
Try going to the management web console; web-page, and seeing if you can send a message to your broker from that context, that might go along way towards directing you towards the problem.
I set up the web.xml in web application as following and it works.
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<display-name>msg_tomcat_activemq</display-name>
<context-param>
<param-name>org.apache.activemq.brokerURL</param-name>
<param-value>tcp://192.168.1.105:61616</param-value>
</context-param>
<context-param>
<param-name>org.apache.activemq.embeddedBroker</param-name>
<param-value>true</param-value>
</context-param>
<servlet>
<servlet-name>AjaxServlet</servlet-name>
<servlet-class>org.apache.activemq.web.AjaxServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet>
<servlet-name>MessageServlet</servlet-name>
<servlet-class>org.apache.activemq.web.MessageServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>AjaxServlet</servlet-name>
<url-pattern>/amq/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>MessageServlet</servlet-name>
<url-pattern>/message/*</url-pattern>
</servlet-mapping>
<filter>
<filter-name>session</filter-name>
<filter-class>org.eclipse.jetty.continuation.ContinuationFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>session</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<listener>
<listener-class>org.apache.activemq.web.SessionListener</listener-class>
</listener>
</web-app>