404 /index.xhtml Not Found in ExternalContext as a Resource - maven

I am aware that there are similar questions related to this topic. However, none of the answers did help me and I simply can't get my Intellij/Tomcat running correctly.
Tomcat is not able to find any *.xhtml or plain html file. Every single time I try to run the project out of IntellIj I just get the error mentioned in the title. I also tried deploying the project with maven. Didn't work out well (same problem).
I installed Tomcat with Xampp in the default location C:\xampp on a Win10 64 bit machine. Here is how my project is structured:
I defined all my dependencies in the pom.xml plus the plugin to deploy the web app on tomcat:
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>${servlet.version}</version>
<scope>provided</scope>
</dependency>
<!-- Mojarra JSF -->
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-api</artifactId>
<version>${mojarra.version}</version>
</dependency>
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-impl</artifactId>
<version>${mojarra.version}</version>
</dependency>
<!-- PrimeFaces -->
<dependency>
<groupId>org.primefaces</groupId>
<artifactId>primefaces</artifactId>
<version>${primefaces.version}</version>
</dependency>
<dependency>
<groupId>org.primefaces.extensions</groupId>
<artifactId>all-themes</artifactId>
<version>1.0.8</version>
</dependency>
What i configured for Tomcat in Intellij: Run/Debug settings in Intellij
I no longer have any idea whatsoever what this could be. Checked URLs multiple times, threw away that declaration for the virtual /faces/* folder in the web.xml. Here's my full web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<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">
<welcome-file-list>
<welcome-file>index.xhtml</welcome-file>
</welcome-file-list>
<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>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.jsf</url-pattern>
</servlet-mapping>
<listener>
<listener-class>com.sun.faces.config.ConfigureListener</listener-class>
</listener>
<listener id="ServiceLocator">
<display-name>InitializeContextListener</display-name>
<listener-class>wuhu.webclient.InitializeContextListener</listener-class>
</listener>
<context-param>
<description>State saving method: 'client' or 'server' (=default). See JSF Specification 2.5.2</description>
<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>client</param-value>
</context-param>
<context-param>
<param-name>javax.servlet.jsp.jstl.fmt.localizationContext</param-name>
<param-value>resources.application</param-value>
</context-param>
<context-param>
<param-name>javax.faces.DATETIMECONVERTER_DEFAULT_TIMEZONE_IS_SYSTEM_TIMEZONE</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<param-name>WUHU_SERVICE_URL</param-name>
<param-value>http://localhost:%s/wuhuservice</param-value>
</context-param>
<context-param>
<param-name>WUHU_SERVICE_PORT</param-name>
<param-value>8123</param-value>
</context-param>
</web-app>

Faulty Maven project structure, answered by JimHawkins in the comments

Related

How do I configure two instances of log4j2 to work in a Spring 5.3.18 project via web.xml file, hosted on Tomcat 9

I need to use two separate log4j loggers in my Spring project running on tomcat 9. I started by getting the dependencies and placing in my pom.xml:
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>2.17.1</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.17.1</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-web</artifactId>
<version>2.17.1</version>
</dependency>
Then I created the xml log configuration file, and afterwards in my web.xml I placed the following:
<listener>
<listener-class>org.apache.logging.log4j.web.Log4jServletContextListener</listener-class>
</listener>
<filter>
<filter-name>log4jServletFilter</filter-name>
<filter-class>org.apache.logging.log4j.web.Log4jServletFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>log4jServletFilter</filter-name>
<url-pattern>/*</url-pattern>
<dispatcher>REQUEST</dispatcher>
<dispatcher>FORWARD</dispatcher>
<dispatcher>INCLUDE</dispatcher>
<dispatcher>ERROR</dispatcher>
</filter-mapping>
<context-param>
<param-name>log4jContextName</param-name>
<param-value>PersonLogger</param-value>
</context-param>
<context-param>
<param-name>log4jConfiguration</param-name>
<param-value>file:../conf/properties/PersonLogConfig.xml</param-value>
</context-param>
Then, in my application I used it like so:
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
static final Logger LOG = LogManager.getLogger("PersonLogger." + PersonAgentImpl.class);
LOG.info("working");
This all worked without issue, the folder and log file were created and logged to as expected. However when I tried to add a second logger- it would not work. Neither folder/log file would be created. (they both work separately if I comment out one though)
This is how I attempted to set up two instances in my web.xml:
<listener>
<listener-class>org.apache.logging.log4j.web.Log4jServletContextListener</listener-class>
</listener>
<filter>
<filter-name>log4jServletFilter</filter-name>
<filter-class>org.apache.logging.log4j.web.Log4jServletFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>log4jServletFilter</filter-name>
<url-pattern>/*</url-pattern>
<dispatcher>REQUEST</dispatcher>
<dispatcher>FORWARD</dispatcher>
<dispatcher>INCLUDE</dispatcher>
<dispatcher>ERROR</dispatcher>
</filter-mapping>
<!-- PersonLogger -->
<context-param>
<param-name>log4jContextName1</param-name>
<param-value>PersonLogger</param-value>
</context-param>
<context-param>
<param-name>log4jConfiguration1</param-name>
<param-value>file:../conf/properties/PersonLogConfig.xml</param-value>
</context-param>
<!-- AnimalLogger -->
<context-param>
<param-name>log4jContextName2</param-name>
<param-value>AnimalLogger</param-value>
</context-param>
<context-param>
<param-name>log4jConfiguration2</param-name>
<param-value>file:../conf/properties/AnimalLogConfig.xml</param-value>
</context-param>
Any ideas on what might be wrong? From what I understand as long as the param names are different than 2 instances of log4j should be able to work at the same time- using the context name to specify which one is used.

CommandButton does not fire action when <h:form> includes enctype="multipart/form-data"

I have already posted a question regarding p:fileuploada few days ago. After digging deeper into this problem I realized that my main issue seems to be of a different origin and I therefore opened up a new question.
I am developing a web app (JSF2.2) for mobile devices where a user can upload a file at several occasions. I want to use Primefaces' p:fileuploadcomponent for this job which does not seem to work. I discovered that the problem seems to be connected with the enctype="multipart/form-data" attribute of <h:form>. Whenever I have this attribute in my form, commandButton does not call the bean method specified in its action=""attribute (neither when using actionListener=""). When I delete the enctype="multipart/form-data" attribute everything works as it should except for the file upload obiously.
For testing and debugging purposes I created an uploadTest.xhtmlpage
that looks currently as follows:
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:p="http://primefaces.org/ui"
xmlns:f="http://xmlns.jcp.org/jsf/core"
xmlns:h="http://xmlns.jcp.org/jsf/html">
<f:view renderKitId="PRIMEFACES_MOBILE" />
<h:head>
</h:head>
<h:body>
<h:form id="dasistmeineform" enctype="multipart/form-data">
<p:fileUpload value="#{uploadBean.uploadedFile}" mode="simple"/>
<p:commandButton action="#{uploadBean.upload}" ajax="false" value="upload" />
</h:form>
</h:body>
</html>
To exclude Primefaces from the list of possible error causes I created another test page as well where I only used <h:inputFile> and <h:commandButton> and no primefaces components. This gives me the same result.
Here is my UploadBean.java:
import javax.faces.bean.RequestScoped;
import javax.faces.bean.ManagedBean;
import org.primefaces.model.UploadedFile;
#ManagedBean
#RequestSoped
public class UploadBean {
private UploadedFile uploadedFile;
public UploadedFile getUploadedFile() {
return uploadedFile;
}
public void setUploadedFile(UploadedFile uploadedFile) {
this.uploadedFile = uploadedFile;
}
public void upload() {
if (this.getUploadedFile() != null) {
System.out.println("Hurray!");
}
}
}
My personal guess is that this issue has something to do with the way the application is set up or how JSF is implemented in the app. To troubleshoot this I followed the JSF set up guide by #BalusC. Moreover I followed some of his other troubleshooting guides, including how to troubleshoot p:fileupload and a list of possible causes why a bean method is not invoked when pressing h:commandButton. Nothing has helped so far unfortunately.
I get no error in the Netbeans console and neither in Chrome's developer console. After I press the upload button I can see the HTTP request with the developer tools. The Response has the code 200 so everything should have worked correctly on the HTTP side, right?
The web application uses the following components:
JSF 2.2.13 (Mojarra)
Spring Webflow
Spring MVC
Primefaces 5.3
Omnifaces 1.3
Bootsfaces 0.9.1
The application is deployed and tested on a Jetty 8.1.5 Server directly via Netbeans.
To check if I have all the necessary dependencies downloaded, I'll include the relevant party of my pom.xml (I use maven):
<dependencies>
<dependency>
<groupId>org.glassfish</groupId>
<artifactId>javax.faces</artifactId>
<version>2.2.13</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.0.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.2</version>
</dependency>
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>1.3</version>
</dependency>
</dependencies>
I included commons-io and commons-fileupload to test if p:fileupload would work with the old (prior to Servlet 3.0) way, which it didn't.
Here is my web.xml: (please note that I also tested without the context-param and filter entries for p:fileupload without success):
-->
<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">
<description>Webflow Archetype</description>
<context-param>
<param-name>primefaces.UPLOADER</param-name>
<param-value>auto</param-value>
</context-param>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath*:/spring/applicationContext.xml,/WEB-INF/config/web-application-config.xml
</param-value>
</context-param>
<!-- Causes Facelets to refresh templates during development -->
<context-param>
<param-name>javax.faces.FACELETS_REFRESH_PERIOD</param-name>
<param-value>1</param-value>
</context-param>
<context-param>
<param-name>com.sun.faces.expressionFactory</param-name>
<param-value>org.jboss.el.ExpressionFactoryImpl</param-value>
</context-param>
<context-param>
<param-name>com.sun.faces.sendPoweredByHeader</param-name>
<param-value>false</param-value>
</context-param>
<!-- Disable/Enable PF/M default theme: -->
<!-- <context-param>
<param-name>primefaces.mobile.THEME</param-name>
<param-value>none</param-value>
</context-param>-->
<context-param>
<param-name>primefaces.THEME</param-name>
<param-value>cupertino</param-value>
</context-param>
<context-param>
<param-name>primefaces.FONT_AWESOME</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<description>Define partial state saving as true/false.</description>
<param-name>javax.faces.PARTIAL_STATE_SAVING_METHOD</param-name>
<param-value>false</param-value>
</context-param>
<context-param>
<param-name>javax.faces.DATETIMECONVERTER_DEFAULT_TIMEZONE_IS_SYSTEM_TIMEZONE</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>Development</param-value>
</context-param>
<!-- Custom MarqueeComponent -->
<context-param>
<param-name>javax.faces.FACELETS_LIBRARIES</param-name>
<param-value>/WEB-INF/marquee-taglib.xml</param-value>
</context-param>
<context-param>
<param-name>BootsFaces_USETHEME</param-name>
<param-value>true</param-value>
</context-param>
<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/>
</init-param>
<load-on-startup>2</load-on-startup>
<!-- <multipart-config>
<max-file-size>10485760</max-file-size>
<max-request-size>20971520</max-request-size>
<file-size-threshold>5242880</file-size-threshold>
</multipart-config>-->
</servlet>
<!-- Map all /spring requests to the Dispatcher Servlet for handling -->
<servlet>
<servlet-name>Jersey Spring Servlet</servlet-name>
<servlet-class>com.sun.jersey.spi.spring.container.servlet.SpringServlet</servlet-class>
<init-param>
<param-name>com.sun.jersey.config.property.packages</param-name>
<param-value>at.managementpartners.icosysmobile.rest</param-value>
</init-param>
</servlet>
<servlet>
<servlet-name>FileServlet</servlet-name>
<servlet-class>at.managementpartners.icosysmobile.web.util.FileServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Spring MVC Dispatcher Servlet</servlet-name>
<url-pattern>/spring/ *</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>ImageServlet</servlet-name>
<servlet-class>at.managementpartners.icosysmobile.web.util.ImageServlet</servlet-class>
</servlet>
<!-- Serves static resource content from .jar files such as spring-faces.jar -->
<!-- Map all /resources requests to the Resource Servlet for handling -->
<!-- Faces Servlet -->
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
<!-- <multipart-config>
<max-file-size>10485760</max-file-size>
<max-request-size>20971520</max-request-size>
<file-size-threshold>5242880</file-size-threshold>
</multipart-config>-->
</servlet>
<!-- Faces Servlet Mapping -->
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>/faces/ *</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>/javax.faces.resource/ *</url-pattern>
</servlet-mapping>
<!--
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.xhtml</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>/do/ *</url-pattern>
</servlet-mapping>
-->
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.jsf</url-pattern>
</servlet-mapping>
<!-- servlet>
<servlet-name>Primefaces Resource Servlet</servlet-name>
<servlet-class>
org.primefaces.resource.ResourceServlet
</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Primefaces Resource Servlet</servlet-name>
<url-pattern>/primefaces_resource/*</url-pattern>
</servlet-mapping -->
<!-- Welcome files -->
<servlet-mapping>
<servlet-name>Jersey Spring Servlet</servlet-name>
<url-pattern>/rest</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>Jersey Spring Servlet</servlet-name>
<url-pattern>/rest/*</url-pattern>
</servlet-mapping>
<!--<servlet-mapping>
<servlet-name>GetClientHostnameServlet</servlet-name>
<url-pattern>/GetClientHostnameServlet</url-pattern>
</servlet-mapping> -->
<servlet-mapping>
<servlet-name>FileServlet</servlet-name>
<url-pattern>/files/*</url-pattern>
</servlet-mapping>
<filter>
<filter-name>PrimeFaces FileUpload Filter</filter-name>
<filter-class>org.primefaces.webapp.filter.FileUploadFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>PrimeFaces FileUpload Filter</filter-name>
<servlet-name>Faces Servlet</servlet-name>
<dispatcher>FORWARD</dispatcher>
</filter-mapping>
<filter>
<filter-name>ClickjackFilterSameOrigin</filter-name>
<filter-class>at.managementpartners.icosysmobile.web.util.ClickjackFilter</filter-class>
<init-param>
<param-name>mode</param-name>
<param-value>SAMEORIGIN</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>ClickjackFilterSameOrigin</filter-name>
<url-pattern>/ *</url-pattern>
</filter-mapping>
<filter>
<filter-name>charEncodingFilter</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>
<init-param>
<param-name>forceEncoding</param-name>
<param-value>true</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>charEncodingFilter</filter-name>
<url-pattern>/ *</url-pattern>
</filter-mapping>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<!-- Allows Jetty to serve Faces applications -->
<listener>
<listener-class>com.sun.faces.config.ConfigureListener</listener-class>
</listener>
<!-- <filter>
<filter-name>PrimeFaces FileUpload Filter</filter-name>
<filter-class>
org.primefaces.webapp.filter.FileUploadFilter
</filter-class>
</filter>
<filter-mapping>
<filter-name>PrimeFaces FileUpload Filter</filter-name>
<servlet-name>Spring MVC Dispatcher Servlet</servlet-name>
</filter-mapping>-->
<filter>
<filter-name>springSecurityFilterChain</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>
<filter-mapping>
<filter-name>springSecurityFilterChain</filter-name>
<url-pattern>/ *</url-pattern>
</filter-mapping>
<!-- Lebenszeit der Session in Minuten (480 min = 8 Stunden; 180 min = 3 Stunden) -->
<session-config>
<session-timeout>180</session-timeout>
<cookie-config>
<secure>true</secure>
</cookie-config>
</session-config>
<mime-mapping>
<extension>ttf</extension>
<mime-type>application/x-font-ttf</mime-type>
</mime-mapping>
<mime-mapping>
<extension>woff</extension>
<mime-type>application/x-font-woff</mime-type>
</mime-mapping>
<mime-mapping>
<extension>woff2</extension>
<mime-type>application/font-woff2</mime-type>
</mime-mapping>
<mime-mapping>
<extension>eot</extension>
<mime-type>application/vnd.ms-fontobject</mime-type>
</mime-mapping>
<!-- The front controller of this Spring Web application, responsible for handling all application requests -->
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
<jsp-config>
<jsp-property-group>
<url-pattern>*.jsp</url-pattern>
<trim-directive-whitespaces>false</trim-directive-whitespaces>
</jsp-property-group>
</jsp-config>
<error-page>
<error-code>500</error-code>
<location>/WEB-INF/errors/error.xhtml</location>
</error-page>
<error-page>
<error-code>404</error-code>
<location>/WEB-INF/errors/error.xhtml</location>
</error-page>
<error-page>
<error-code>403</error-code>
<location>/WEB-INF/errors/error.xhtml</location>
</error-page>
<error-page>
<error-code>402</error-code>
<location>/WEB-INF/errors/error.xhtml</location>
</error-page>
<error-page>
<error-code>401</error-code>
<location>/WEB-INF/errors/error.xhtml</location>
</error-page>
<error-page>
<error-code>400</error-code>
<location>/WEB-INF/errors/error.xhtml</location>
</error-page>
</web-app>
Please note that I had to seperate ´/*´ with a space (´/ *´) so that the rest of my code wouldn't get formatted as a comment. (If there is a smarter way to do this please don't hesitate to tell me)
Could Spring's MVC Dispatcher Servlet somehow interfere with the upload functionality of Servlet 3.0?
Am I using other components that break the standard behaviour of Servlet 3.0 file upload?
Is my project even set up correctly?
Thank you very much. Even a little hint would be greatly appreciated.

Using vaadin add-on "EasyUpload" - compile widgetset with maven

I'm new of vaadin and this is the first time that I try to use an add-on EasyUpload add-on
I'm using maven to build my project, and i modified my pom.xml in ths way:
<project>
<modelVersion>4.0.0</modelVersion>
<artifactId>My-vaadin-webapp</artifactId>
<packaging>war</packaging>
<!-- Add-On Repository -->
<repositories>
<repository>
<id>vaadin-addons</id>
<url>http://maven.vaadin.com/vaadin-addons</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.vaadin.addon</groupId>
<artifactId>easyuploads</artifactId>
<version>7.0.1</version>
</dependency>
</dependencies>
</project>
But when to try
MultiFileUpload
i get the following result:
I read the I should compile my widget-set, but I don't use a custom widget-set, I'm using a default widget-Set.
This is my web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app>
<display-name>MyApp</display-name>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<listener>
<listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
</listener>
<listener>
<listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
</listener>
<session-config>
<session-timeout>30</session-timeout>
</session-config>
<servlet>
<servlet-name>MyServlet</servlet-name>
<servlet-class>com.myApplication.AutowiringApplicationServlet</servlet-class>
<init-param>
<description>Vaadin UI class to use</description>
<param-name>UI</param-name>
<param-value>com.myApplication.Application</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>VaadinApplication</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
</web-app>
Where am I doing wrong?
How to can I do to solve my problem?
Create a widgetset in the src/main/resources folder under an arbitrary package (x.y for example). Name it AppWidgetSet.gwt.xml for example.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit 2.5.1//EN" "http://google-web-toolkit.googlecode.com/svn/tags/2.5.1/distro-source/core/src/gwt-module.dtd">
<module>
<inherits name="com.vaadin.DefaultWidgetSet" />
<set-property name="user.agent" value="safari"/>
<inherits name="org.vaadin.easyuploads.Widgetset" />
</module>
Annotate your custom UI with the following:
#Widgetset("x.y.AppWidgetSet")
The "inherits" part is autogenerated by the mvn vaadin:update-widgetset goal based on the dependencies of your pom. Since I included the multifileupload here you don't need to call it this time.
Do a mvn vaadin:compile.
Refresh your project and your server.
When you use addon widgets, you will have to recompile the whole widget set.
Depending on your maven targets there should exist one such...

Application was not properly initialized at startup, could not find Factory: javax.faces.context.FacesContextFactory

Hi I have a spring richfaces project run with myfaces 2.1.10, but I want to change to Mojarra 2.1.19 , but the application give me the error:
SEVERE [javax.faces] (MSC service thread 1-4) Application was not properly initialized at startup, could not find Factory: javax.faces.context.FacesContextFactory. Attempting to find backup.
ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/projvehimerc]] (MSC service thread 1-4) StandardWrapper.Throwable: java.lang.IllegalStateException: Could not find backup for factory javax.faces.context.FacesContextFactory.
I want to use jboss-jsf-api_2.1_spec, my pom.xml:
<properties>
<!-- [WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent! -->
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<spring.version>3.1.3.RELEASE</spring.version>
<hibernate.version>4.1.8.Final</hibernate.version>
<org.richfaces.bom.version>4.3.0.Final</org.richfaces.bom.version>
<spring.security.version>3.1.3.RELEASE</spring.security.version>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.richfaces</groupId>
<artifactId>richfaces-bom</artifactId>
<version>${org.richfaces.bom.version}</version>
<scope>import</scope>
<type>pom</type>
</dependency>
<dependency>
<groupId>org.jboss.spec.javax.faces</groupId>
<artifactId>jboss-jsf-api_2.1_spec</artifactId>
<version>2.1.19.Final</version>
</dependency>
<dependency>
<groupId>org.jboss.spec.javax.servlet</groupId>
<artifactId>jboss-servlet-api_3.0_spec</artifactId>
<version>1.0.2.Final</version>
</dependency>
</dependencies>
my web.xml, version 3.0 :
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
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>richfaces-application</display-name>
<!-- Listener para crear el Spring Container compartido por todos los
Servlets y Filters (WebApplication Context)-->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
classpath*:META-INF/spring/spring-master.xml
WEB-INF/spring/spring-security.xml
</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<!-- For JSF -->
<listener>
<listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
</listener>
<!-- Jboss not use it bundle integrated JSF -->
<context-param>
<param-name>org.jboss.jbossfaces.WAR_BUNDLES_JSF_IMPL</param-name>
<param-value>true</param-value>
</context-param>
<!-- Spring JavaServiceFaces framework ApacheMyfaces
<listener>
<listener-class>org.apache.myfaces.webapp.StartupServletContextListener</listener-class>
</listener>
-->
<!-- Spring Security, for all -->
<filter>
<filter-name>springSecurityFilterChain</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>
<filter-mapping>
<filter-name>springSecurityFilterChain</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<!-- RichFaces Framework -->
<!-- For control of skins -->
<context-param>
<param-name>org.richfaces.enableControlSkinning</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<param-name>org.richfaces.skin</param-name>
<param-value>blueSky</param-value>
</context-param>
<!-- Servlet for Dispatcher of flows -->
<servlet>
<servlet-name>transportes</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>WEB-INF/spring/transportes-servlet.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>transportes</servlet-name>
<url-pattern>/flows/*</url-pattern>
</servlet-mapping>
<!-- Servlets for JSF-->
<servlet>
<servlet-name>faces</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>faces</servlet-name>
<!-- <url-pattern>*.xhtml</url-pattern> -->
<url-pattern>/faces/*</url-pattern>
</servlet-mapping>
<!-- Use JSF view templates saved as *.xhtml, for use with Facelets -->
<context-param>
<param-name>javax.faces.DEFAULT_SUFFIX</param-name>
<param-value>.xhtml</param-value>
</context-param>
<!-- Set the PROJECT_STAGE to 'Development' to receive constructive error messages during development.
Change the PROJECT_STAGE to 'Production' when putting the application into production -->
<context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>Development</param-value>
</context-param>
<!-- Page That control SpringWeb -->
<welcome-file-list>
<welcome-file>index.jsf</welcome-file>
</welcome-file-list>
</web-app>
What is missing?, thnks.

java.lang.ClassFormatError: Absent Code attribute in method that is not native or abstract in class file javax/faces/webapp/FacesServlet

I want to use Mojarra 2.1 with Tomcat 7,
so I added following dependencies in my pom file:
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-api</artifactId>
<version>2.1.2</version>
</dependency>
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-impl</artifactId>
<version>2.1.2</version>
</dependency>
However, when I tried to start Tomcat, I got following exception:
org.apache.catalina.LifecycleException: Failed to start component [StandardServer[8007]]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:152)
at org.apache.catalina.startup.Catalina.start(Catalina.java:621)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:322)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:450)
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardService[Catalina]]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:152)
at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:727)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:148)
... 7 more
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina]]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:152)
at org.apache.catalina.core.StandardService.startInternal(StandardService.java:443)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:148)
... 9 more
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost]]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:152)
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1033)
at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:291)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:148)
... 11 more
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/myapp]]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:152)
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1033)
at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:774)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:148)
... 14 more
Caused by: java.lang.ClassFormatError: Absent Code attribute in method that is not native or abstract in class file javax/faces/webapp/FacesServlet
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:632)
at java.lang.ClassLoader.defineClass(ClassLoader.java:616)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
at org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:2820)
at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:1150)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1645)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1523)
at com.sun.faces.config.FacesInitializer.<clinit>(FacesInitializer.java:107)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:247)
at org.apache.catalina.startup.ContextConfig.getServletContainerInitializer(ContextConfig.java:1543)
at org.apache.catalina.startup.ContextConfig.processServletContainerInitializers(ContextConfig.java:1466)
at org.apache.catalina.startup.ContextConfig.webConfig(ContextConfig.java:1285)
at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:896)
at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:322)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5103)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:148)
... 17 more
How is this caused and how can I solve it?
Here's my web.xml file which may contain the cause of the problem:
<?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">
<display-name>appName</display-name>
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
<listener>
<listener-class>
org.springframework.web.context.request.RequestContextListener
</listener-class>
</listener>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
classpath:META-INF/spring/context.xml
classpath:META-INF/spring/security.xml
</param-value>
</context-param>
<context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>Development</param-value>
</context-param>
<welcome-file-list>
<welcome-file>customers</welcome-file>
</welcome-file-list>
<context-param>
<description>State saving method: 'client' or 'server' (=default). See JSF Specification 2.5.2</description>
<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>server</param-value>
</context-param>
<context-param>
<param-name>javax.servlet.jsp.jstl.fmt.localizationContext</param-name>
<param-value>resources.application</param-value>
</context-param>
<listener>
<listener-class>com.sun.faces.config.ConfigureListener</listener-class>
</listener>
<context-param>
<param-name>javax.faces.FACELETS_SKIP_COMMENTS</param-name>
<param-value>true</param-value>
</context-param>
<!-- Spring Security -->
<filter>
<filter-name>springSecurityFilterChain</filter-name>
<filter-class>
org.springframework.web.filter.DelegatingFilterProxy
</filter-class>
</filter>
<filter-mapping>
<filter-name>springSecurityFilterChain</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter>
<filter-name>Pretty Filter</filter-name>
<filter-class>com.ocpsoft.pretty.PrettyFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>Pretty Filter</filter-name>
<url-pattern>/*</url-pattern>
<dispatcher>FORWARD</dispatcher>
<dispatcher>REQUEST</dispatcher>
<dispatcher>ERROR</dispatcher>
</filter-mapping>
<servlet>
<servlet-name>Resource Servlet</servlet-name>
<servlet-class>com.icesoft.faces.webapp.CompatResourceServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Resource Servlet</servlet-name>
<url-pattern>/xmlhttp/*</url-pattern>
</servlet-mapping>
<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>/faces/*</url-pattern>
</servlet-mapping>
</web-app>
I have the same problem as you and found out that change from servlet-api to javax.servlet.api will fix the problem. Hope this help. Please note that, I am using Juno Eclipse, Tomcat 7, Dynamic Web Module 3.0, and JDK 1.7.
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-api</artifactId>
<version>2.1.13</version>
</dependency>
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-impl</artifactId>
<version>2.1.13</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.0.1</version>
</dependency>
I have the same problem, and it seams somehow to
<groupId>javax</groupId>
<artifactId>javaee-web-api</artifactId>
or
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
after setting them to scope provides (or delete them at all when you start an server in maven test) it starts working for me.
#See this Blog: java.lang.ClassFormatError : Absent Code attribute in method that is not native or abstract in class file … - It discuss the problem for javax.persistence.GenerationType but I think you and I hit the same problem.
Change:
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-impl</artifactId>
<version>2.1.2</version>
</dependency>
To:
<dependency>
<groupId>org.glassfish</groupId>
<artifactId>javax.faces</artifactId>
<version>2.1.6</version>
</dependency>
This workaround fixed it for me:
https://rogerkeays.com/java-lang-classformaterror-exception-with-eclipselink-static-weaving-solved
I traded to glassfish-embedded-all and resolved this.
<dependency>
<groupId>org.glassfish.main.extras</groupId>
<artifactId>glassfish-embedded-all</artifactId>
<version>3.1.2.2</version>
<scope>provided</scope>
</dependency>

Resources