jboss error on deploy struts 2 application - deployment

I have deployed my struts 2 application on jboss as 7 with eclipse. The console shows no error, but when I try to open "localhost:8080/site" I get a 404 page error. I tried to reach some resources from my browser e.g. localhost:8080/site/img/logo.png and it worked good, so the server is working fine, the application is actually deployed, but it seems I can't reach any jsp file. Any ideas?
The same application works fine on Tomcat 7.
This is the web.xml
<?xml version="1.0" encoding="UTF-8"?><web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
<display-name>versus</display-name>
<session-config>
<session-timeout>240</session-timeout>
<tracking-mode>COOKIE</tracking-mode>
</session-config>
<security-role>
<role-name>Denied</role-name>
</security-role>
<security-constraint>
<web-resource-collection>
<web-resource-name>Deny Direct Access</web-resource-name>
<url-pattern>*.pdf</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>Denied</role-name>
</auth-constraint>
</security-constraint>
<filter>
<filter-name>UrlRewriteFilter</filter-name>
<filter-class>org.tuckey.web.filters.urlrewrite.UrlRewriteFilter</filter-class>
<init-param>
<param-name>logLevel</param-name>
<param-value>WARN</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>UrlRewriteFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
<dispatcher>FORWARD</dispatcher>
<dispatcher>REQUEST</dispatcher>
</filter-mapping>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
This is index.jsp
<%# page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%><%# taglib prefix="s" uri="/struts-tags"%>
<!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=ISO-8859-1">
<title>Versus</title>
<meta http-equiv="refresh" content="0;url=home?request_locale=en">
</head>
<body>
</body>
</html>
this is a snippet of struts.xml
<struts>
<constant name="struts.enable.DynamicMethodInvocation" value="false" />
<constant name="struts.devMode" value="false" />
<constant name="struts.custom.i18n.resources" value="resources.ApplicationResources" />
<constant name="struts.locale" value="en" />
<constant name="struts.multipart.maxSize" value="10000000" />
<constant name="struts.i18n.encoding" value="ISO-8859-1" />
<package name="default" extends="struts-default">
<!-- INTERCEPTOR -->
<interceptors>
<interceptor name="mobile" class="utils.MobileInterceptor" />
<interceptor-stack name="myStack">
<interceptor-ref name="mobile" />
<interceptor-ref name="defaultStack" />
</interceptor-stack>
</interceptors>
<default-interceptor-ref name="myStack" />
<global-results>
<result name="success">/jsp/template.jsp</result>
<result name="input">/jsp/template.jsp</result>
<result name="error">/jsp/error.jsp</result>
<result name="none">/jsp/error.jsp</result>
</global-results>
<!-- GENERAL -->
<action name="index" class="controller.ActionIndex" method="execute" />
<action name="redirect" class="controller.ActionRedirect"
method="execute" />
<action name="login" class="controller.ActionLogin" method="login">
<result name="logged" type="redirectAction">redirect?request_locale=it&page=${page}&l4vUserLat=${l4vUserLat}&l4vUserLon=${l4vUserLon}
</result>
</action>
<action name="logout" class="controller.ActionLogin" method="logout" />

Related

Getting 404 error when executing spring MVC

I am getting 404 error every time executing Spring application. I have created the dynamic web project using eclipse. I am new to spring and use eclipse first time. Please help to solve this issue.
My web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
<display-name>SpringBasic</display-name>
<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>*.do</url-pattern>
</servlet-mapping>
</web-app>
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"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:jpa="http://www.springframework.org/schema/data/jpa"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc.xsd
http://www.springframework.org/schema/data/jpa
http://www.springframework.org/schema/data/jpa/spring-jpa.xsd">
<context:component-scan base-package="com.bt.controller" />
<mvc:annotation-driven />
<bean class = "org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name = "prefix" value = "/WEB-INF/jsp/" />
<property name = "suffix" value = ".jsp" />
</bean>
</beans>
MyController
package com.bt.controller;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
#Controller
public class MyController {
#RequestMapping("/")
#ResponseBody
public ModelAndView loadhellopage() {
System.out.println("controller");
String msg="Finally";
ModelAndView mav=new ModelAndView("hellopage");
mav.addObject("msg", "Finally");
return mav;
}
}
hellopage.jsp:
<%# page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!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=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
${message}
</body>
</html>
this is my folder structure:
Also included all the jar files in lib folder under WEB-INF.
When running the project on apache tomcat it is giving 404 error

Eclipse EE Kepler Spring MVC unable to locate views in .html/.jsp

I'm new to Spring MVC. I'm trying out simple projects like Hello World.
I originally created a Hello World using IntelliJ IDEA IDE which worked just fine. However, when I tried Eclipse EE IDE, it returned a 404 message
HTTP Status 404 -
type Status report
message
description The requested resource is not available.
web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
<display-name>FirstSpringMVCProject</display-name>
<servlet>
<servlet-name>spring-dispatcher</servlet-name> <!-- spring-dispatcher is the file named spring-dispatcher-servlet.xml -->
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>spring-dispatcher</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
</web-app>
spring-dispatcher.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation=
"http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc.xsd">
<context:component-scan base-package="com.springmvcproject" />
<!-- HandlerMapping class -->
<!-- There are plenty of handler mapping classes, this is just an example of one of the classes available -->
<bean id="HandlerMapping" class="org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping" />
<!-- defines the location or path where to look for views and what file extension to look for -->
<bean id="viewResolver"
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/views/" />
<property name="suffix" value=".jsp" />
</bean>
HelloController.java
package com.springmvcproject;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
#Controller
public class HelloController {
#RequestMapping("/hello")
public String helloWorld(){
return "hellopage";
}
}
hellopage.jsp
<%# page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!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=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<h4> This is the hello page (HelloPage.jsp)</h4>
</body>
</html>
I don't see any reasons why it will not display the contents of the hellopage.jsp when I try to access http://localhost:8080/FirstSpringMVCProject/hello
Here's the screenshot of the folder structure. There are no warnings or error.
I don't know if I just missed something here or if Eclipse is requiring something else.
I hope you can help.
Thank you.

JSF and Primefaces components doesn't render [duplicate]

This question already has an answer here:
JSF returns blank/unparsed page with plain/raw XHTML/XML/EL source instead of rendered HTML output
(1 answer)
Closed 3 years ago.
I am using primefaces4.0 with glassfish4 and java ee7 on Eclipse kepler.
I configure it (put the jar of the theme and primefaces on the lib and the java builpath and the class variables and add it on the <htm> and the web.xml) but the components doesn't appear at all. This is my code
<!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:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.org/ui">
<h:head>
<meta charset="windows-1256"></meta>
<title>Connexion</title>
</h:head>
<h:body>
<h:form>
<fieldset>
<p:outputLabel for="email">Adresse email <span class="requis"></span> </p:outputLabel>
<p:inputText id="email" value="" required="true" size="20" maxlength="60" />
<p:message id="emailMessage" for="email" errorClass="erreur" />
<br/>
<p:outputLabel for="motdepasse">Mot de passe <span class="requis"></span></p:outputLabel>
<p:inputSecret id="motdepasse" value="" required="true" size="20" maxlength="20" />
<p:message id="motDePasseMessage" for="motdepasse"
errorClass="erreur" />
<br />
<p:commandButton value="Connexion" action="" ajax="false" />
</fieldset>
</h:form>
</h:body>
</html>
and this is my web.xml file
<?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>Portail</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
<context-param>
<param-name>primefaces.THEME</param-name>
<param-value>bootstrap</param-value>
</context-param>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.xhtml</url-pattern>
</servlet-mapping>
</web-app>
Your filename is index.html but in your web.xml you specified that you just wanted to render files that end with .xhtml. Rename your file to index.xhtml
I figured out why the components wasn't rendring after reading this post No TagLibrary associated to PrimeFaces's namespace.
I did put the jar in the lib but i didn't deploy them correctly that's why the tags weren't doing their work . I repeated the configuration this time with more attention and it finally worked.

Build folder stays empty

Hi Im trying to follow the tutorial here regarding Struts. I have followed the tutorial exactly but am getting an HTTP 404 error. I know this error basically means that the resource can't be found be the the IDE.
I noticed that the 'Build' folder is actually completely empty - so I'm guessing that it should have automatically created a runnable project based on my project specifics and this is actually where the server looks in order to run an application.
So how do I go about manually generating this file? Should I drag all the resources in? Java classes, JSP files and so? If not how do I configure it to automatically build?
Cheers
EDIT
Have added what I think will be necessary to help solve this:
Web.xml Located in the WEB-INF folder, next to lib
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_9" 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>Struts2 Application</display-name>
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<welcome-file-list>
<welcome-file>Login.jsp</welcome-file>
</welcome-file-list>
Struts.xml Located in a src folder called resources in the Java Resources folder
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<constant name="struts.enable.DynamicMethodInvocation" value="false" />
<constant name="struts.devMode" value="false" />
<constant name="struts.custom.i18n.resources" value="ApplicationResources" />
<package name="default" extends="struts-default" namespace="/">
<!--
If we changed from the default execute() method, which struts looks for
to say authenticate(), then we would have to specify this in the action
method below like this:
<action
name="login"
method="authenticate"
class="net.viralpatel.struts2.LoginAction">
</action>
-->
<action name="login" class="net.viralpatel.struts2.LoginAction">
<result name="success">Welcome.jsp</result>
<result name="error">Login.jsp</result>
</action>
</package>

Spring MVC 3.1 Serving Static Resources

I'm trying to solve what seems to be a common problem of trying to serve static resources such as images, style sheets and scripts from my Java Web App. I've tried a lot of the solutions offered in other threads but have gotten nowhere, all I get is 404 errors on the resource calls.
The only other thing I can think of is that I'm running on Tomcat 7, but if I try putting 6 on I get a "The server does not support version 3.0 of the J2EE Web module specification." error, so that looks like a no go. Does anyone have any ideas where I might be going wrong?
My project is structured as so:
WebContent
META-INF
Resources
CSS
Images
close.jpg
Scripts
WEB-INF
Lib
Views
index.jsp
Web.xml
<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>
spring-servlet
<?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: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
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd">
<context:component-scan base-package="uk.ac.ncl.controllers" />
<mvc:resources mapping="/resources/**" location="/resources" />
<bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter" />
<bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping" />
<bean class="org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping" />
<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/views/" />
<property name="suffix" value=".jsp" />
</bean>
My Controller
#RequestMapping(value="/", method = RequestMethod.GET)
public String index()
{
return "index";
}
My View
<%# taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
<title>Spring 3.0 MVC Series: Index - ViralPatel.net</title>
</head>
<body>
<h1>Page with image</h1>
<!-- use c:url to get the correct absolute path -->
<img src="<c:url value="/resources/images/close.png" />" />
<img src="http://localhost:8080${pageContext.request.contextPath}/resources/images/close.png" />
View Map
</body>
Can it be a case-sensitivity issue? Your html says /resources/images but your tree looks like /Resources/Images