maven - Spring Boot with JSF2.2 : Error getting customize embedded tomcat -
my spring boot configuration jsf is:
import java.util.collections; import javax.faces.webapp.facesservlet; import javax.servlet.dispatchertype; import javax.servlet.servletcontext; import org.primefaces.webapp.filter.fileuploadfilter; import org.springframework.beans.factory.config.customscopeconfigurer; import org.springframework.boot.springapplication; import org.springframework.boot.autoconfigure.springbootapplication; import org.springframework.boot.builder.springapplicationbuilder; import org.springframework.boot.context.embedded.configurableembeddedservletcontainer; import org.springframework.boot.context.embedded.embeddedservletcontainercustomizer; import org.springframework.boot.context.embedded.filterregistrationbean; import org.springframework.boot.context.embedded.mimemappings; import org.springframework.boot.context.embedded.servletregistrationbean; import org.springframework.boot.context.web.springbootservletinitializer; import org.springframework.context.annotation.bean; import org.springframework.context.annotation.import; import org.springframework.web.context.servletcontextaware; @springbootapplication public class application extends springbootservletinitializer implements servletcontextaware, embeddedservletcontainercustomizer { public static void main(string[] args) { springapplication.run(application.class, args); } @override protected springapplicationbuilder configure(springapplicationbuilder application) { return application.sources(application.class); } @bean public servletregistrationbean facesservletregistraiton() { servletregistrationbean registration = new servletregistrationbean(new facesservlet(), new string[] {"*.jsf", "*.xhtml"}); registration.setloadonstartup(1); return registration; } @override public void setservletcontext(servletcontext servletcontext) { servletcontext.setinitparameter("com.sun.faces.forceloadconfiguration", boolean.true.tostring()); } @override public void customize(configurableembeddedservletcontainer container) { mimemappings mappings = new mimemappings(mimemappings.default); mappings.add("xsd", "text/xml; charset=utf-8"); mappings.add("eof", "fa/fontawesome-webfont.eot"); mappings.add("woff", "fa/fontawesome-webfont.woff"); mappings.add("ttf", "fa/fontawesome-webfont.ttf"); container.setmimemappings(mappings); } }
and pom.xml is:
<?xml version="1.0" encoding="utf-8"?> <project xmlns="http://maven.apache.org/pom/4.0.0" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation="http://maven.apache.org/pom/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelversion>4.0.0</modelversion> <groupid>com.sjf</groupid> <artifactid>springjsf</artifactid> <version>1.0-snapshot</version> <parent> <groupid>org.springframework.boot</groupid> <artifactid>spring-boot-starter-parent</artifactid> <version>1.2.5.release</version> </parent> <properties> <project.build.sourceencoding>utf-8</project.build.sourceencoding> <java.version>1.8</java.version> </properties> <dependencies> <!-- spring boot --> <dependency> <groupid>org.springframework.boot</groupid> <artifactid>spring-boot-starter-web</artifactid> </dependency> <dependency> <groupid>org.springframework.boot</groupid> <artifactid>spring-boot-starter-data-jpa</artifactid> </dependency> <dependency> <groupid>org.springframework.boot</groupid> <artifactid>spring-boot-starter-mail</artifactid> </dependency> <dependency> <groupid>org.springframework.boot</groupid> <artifactid>spring-boot-starter-security</artifactid> </dependency> <dependency> <groupid>org.springframework.boot</groupid> <artifactid>spring-boot-starter-test</artifactid> <scope>test</scope> </dependency> <!-- tomcat embedded --> <dependency> <groupid>org.apache.tomcat.embed</groupid> <artifactid>tomcat-embed-core</artifactid> </dependency> <dependency> <groupid>org.apache.tomcat.embed</groupid> <artifactid>tomcat-embed-logging-juli</artifactid> </dependency> <dependency> <groupid>org.apache.tomcat.embed</groupid> <artifactid>tomcat-embed-jasper</artifactid> </dependency> <dependency> <groupid>org.eclipse.jdt.core.compiler</groupid> <artifactid>ecj</artifactid> <version>4.4</version> <scope>provided</scope> </dependency> <!-- jsf --> <dependency> <groupid>org.glassfish</groupid> <artifactid>javax.faces</artifactid> <version>2.2.10</version> </dependency> </dependencies> <build> <plugins> <plugin> <groupid>org.springframework.boot</groupid> <artifactid>spring-boot-maven-plugin</artifactid> </plugin> </plugins> </build> </project>
when use embeddedservletcontainercustomizer interface set mime mapping got error:
2015-07-17 02:38:25.091 error 8984 --- [ main] javax.faces : unable obtain injectionprovider init time facescontext. container implement mojarra injection spi? 2015-07-17 02:38:25.106 error 8984 --- [ main] javax.faces : application not initialized @ startup, not find factory: javax.faces.context.facescontextfactory. attempting find backup. 2015-07-17 02:38:25.106 error 8984 --- [ main] o.a.c.c.c.[tomcat].[localhost].[/app] : standardwrapper.throwable java.lang.illegalstateexception: not find backup factory javax.faces.context.facescontextfactory. @ javax.faces.factoryfinderinstance.getfactory(factoryfinderinstance.java:541) @ javax.faces.factoryfinder.getfactory(factoryfinder.java:275) @ javax.faces.webapp.facesservlet.init(facesservlet.java:350) @ org.apache.catalina.core.standardwrapper.initservlet(standardwrapper.java:1231) @ org.apache.catalina.core.standardwrapper.load(standardwrapper.java:1034) @ org.apache.catalina.core.standardcontext.loadonstartup(standardcontext.java:4914) @ org.springframework.boot.context.embedded.tomcat.tomcatembeddedcontext.deferredloadonstartup(tomcatembeddedcontext.java:66) @ org.springframework.boot.context.embedded.tomcat.tomcatembeddedservletcontainer.startconnector(tomcatembeddedservletcontainer.java:209) @ org.springframework.boot.context.embedded.tomcat.tomcatembeddedservletcontainer.start(tomcatembeddedservletcontainer.java:152) @ org.springframework.boot.context.embedded.embeddedwebapplicationcontext.startembeddedservletcontainer(embeddedwebapplicationcontext.java:288) @ org.springframework.boot.context.embedded.embeddedwebapplicationcontext.finishrefresh(embeddedwebapplicationcontext.java:141) @ org.springframework.context.support.abstractapplicationcontext.refresh(abstractapplicationcontext.java:525) @ org.springframework.boot.context.embedded.embeddedwebapplicationcontext.refresh(embeddedwebapplicationcontext.java:118) @ org.springframework.boot.springapplication.refresh(springapplication.java:667) @ org.springframework.boot.springapplication.dorun(springapplication.java:342) @ org.springframework.boot.springapplication.run(springapplication.java:273) @ org.springframework.boot.springapplication.run(springapplication.java:971) @ org.springframework.boot.springapplication.run(springapplication.java:960) @ com.genu.springsecuredjsf.application.main(application.java:29)
is missing on facescontext setting? please help.
use class:
@configuration public class containercustomizer implements embeddedservletcontainercustomizer, ordered { @override public int getorder() { return 0; } @override public void customize(configurableembeddedservletcontainer container) { ... } }
Comments
Post a Comment