I'm attempting to move an existing Richfaces 3.3.4 / JSF 1.2 application off Glassfish 3 (for a number of reasons) onto Payara 5.192. The application runs fine with a couple exceptions, the primary problem being rich:fileUpload doesn't work.
I added multipart-config to web.xml, but that didn't resolve the problem:
<context-param>
<param-name>javax.faces.DISABLE_FACELET_JSF_VIEWHANDLER</param-name>
<param-value>true</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>
<multipart-config>
<max-file-size>33554432</max-file-size>
<max-request-size>335544320</max-request-size>
</multipart-config>
</servlet>
Here is the error:
org.ajax4jsf.exception.FileUploadException: IO Error parsing multipart request
at org.ajax4jsf.request.MultipartRequest.parseRequest(MultipartRequest.java:388)
at org.richfaces.component.FileUploadPhaselistener.beforePhase(FileUploadPhaselistener.java:63)
at com.sun.faces.lifecycle.Phase.handleBeforePhase(Phase.java:201)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:74)
at com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:109)
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:177)
at javax.faces.webapp.FacesServlet.executeLifecyle(FacesServlet.java:707)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:451)
at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1628)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:339)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:209)
at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:206)
at org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:290)
at org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:367)
at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:515)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:251)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:209)
at org.apache.catalina.core.ApplicationDispatcher.doInvoke(ApplicationDispatcher.java:822)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:688)
at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:527)
at org.apache.catalina.core.ApplicationDispatcher.doDispatch(ApplicationDispatcher.java:496)
at org.apache.catalina.core.ApplicationDispatcher.dispatch(ApplicationDispatcher.java:378)
at org.apache.catalina.core.StandardHostValve.custom(StandardHostValve.java:507)
at org.apache.catalina.core.StandardHostValve.dispatchToErrorPage(StandardHostValve.java:701)
at org.apache.catalina.core.StandardHostValve.status(StandardHostValve.java:385)
at org.apache.catalina.core.StandardHostValve.throwable(StandardHostValve.java:319)
at org.apache.catalina.core.StandardHostValve.postInvoke(StandardHostValve.java:217)
at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:373)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:238)
at com.sun.enterprise.v3.services.impl.ContainerMapper$HttpHandlerCallable.call(ContainerMapper.java:520)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:217)
at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:182)
at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:156)
at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:218)
at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:95)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:260)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:177)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:109)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:88)
at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:53)
at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:524)
at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:89)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:94)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:33)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:114)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:569)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:549)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.io.IOException: Request prolog cannot be read
at org.ajax4jsf.request.MultipartRequest.readProlog(MultipartRequest.java:333)
at org.ajax4jsf.request.MultipartRequest.initialize(MultipartRequest.java:369)
at org.ajax4jsf.request.MultipartRequest.parseRequest(MultipartRequest.java:379)
... 47 more¡ëôwÍ$
Related
I am trying to run a JSF web application on Payara 5.194.
The whole application is compiled and runs successfully. But after being deployed it gives an error and doesn't load.
I am not able to identify the cause of this error.
Warning: StandardWrapperValve[FacesServlet]: Servlet.service() for servlet FacesServlet threw exception
java.lang.ArrayIndexOutOfBoundsException
at java.lang.System.arraycopy(Native Method)
at com.sun.faces.util.ByteArrayGuardAESCTR.decrypt(ByteArrayGuardAESCTR.java:133)
at com.sun.faces.context.flash.ELFlash$PreviousNextFlashInfoManager.decode(ELFlash.java:1390)
at com.sun.faces.context.flash.ELFlash.getCurrentFlashManager(ELFlash.java:1213)
at com.sun.faces.context.flash.ELFlash.doPrePhaseActions(ELFlash.java:617)
at com.sun.faces.lifecycle.Phase.handleBeforePhase(Phase.java:190)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:74)
at com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:109)
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:177)
at javax.faces.webapp.FacesServlet.executeLifecyle(FacesServlet.java:707)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:451)
at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1628)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:258)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:160)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:755)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:575)
at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:99)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:159)
at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:371)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:238)
at com.sun.enterprise.v3.services.impl.ContainerMapper$HttpHandlerCallable.call(ContainerMapper.java:520)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:217)
at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:182)
at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:156)
at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:218)
at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:95)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:260)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:177)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:109)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:88)
at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:53)
at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:524)
at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:89)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:94)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:33)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:114)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:569)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:549)
at java.lang.Thread.run(Thread.java:748)
This is related to invalid flash cookie data. Did you try clearing the cookies?
Also see this bug report which is still open: https://github.com/javaserverfaces/mojarra/issues/4386
I'm required to force HTTPS in my web application so I did the following 2 thing in my web.xml configuration:
<security-constraint>
<web-resource-collection>
<web-resource-name>*</web-resource-name>
<url-pattern>/*</url-pattern>
</web-resource-collection>
<user-data-constraint>
<transport-guarantee>CONFIDENTIAL</transport-guarantee>
</user-data-constraint>
</security-constraint>
<session-config>
<session-timeout>10</session-timeout>
<cookie-config>
<http-only>true</http-only>
<secure>true</secure>
</cookie-config>
<tracking-mode>COOKIE</tracking-mode>
</session-config>
When I deploy the webapp on glassfish 5 (which is the container where the webapp should run) I get a series of errors as if the application has entered into a loop during the servlet filters chain.
The exceptions I can identify are:
UPDATE the stack is the following
[glassfish 5.0] [SEVERE] [] [org.glassfish.grizzly.http2.Http2ServerFilter] [tid: _ThreadID=45 _ThreadName=http-listener-2(2)] [timeMillis: 1519314445367] [levelValue: 1000] [[
Unable to push resource identified by path [/demat/svz]]]
[glassfish 5.0] [SEVERE] [] [org.glassfish.grizzly.http2.Http2ServerFilter] [tid: _ThreadID=48 _ThreadName=http-listener-2(5)] [timeMillis: 1519314445367] [levelValue: 1000] [[
Unable to push resource identified by path [/demat/javax.faces.resource/core.js.jsf?ln=primefaces&v=6.1.2.NLC]]]
[glassfish 5.0] [SEVERE] [] [org.glassfish.grizzly.http2.Http2ServerFilter] [tid: _ThreadID=45 _ThreadName=http-listener-2(2)] [timeMillis: 1519314445367] [levelValue: 1000] [[
[glassfish 5.0] [SEVERE] [] [org.glassfish.grizzly.http2.Http2ServerFilter] [tid: _ThreadID=46 _ThreadName=http-listener-2(2)] [timeMillis: 1519144903315] [levelValue: 1000] [[
org.glassfish.grizzly.http2.Http2StreamException streamId=4474 errorCode=REFUSED_STREAM
at org.glassfish.grizzly.http2.Http2Session.openStream(Http2Session.java:1116)
at org.glassfish.grizzly.http2.Http2ServerFilter.doPush(Http2ServerFilter.java:994)
at org.glassfish.grizzly.http2.Http2ServerFilter.handleEvent(Http2ServerFilter.java:626)
at org.glassfish.grizzly.filterchain.ExecutorResolver$6.execute(ExecutorResolver.java:94)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:284)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:201)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:133)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:112)
at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
at org.glassfish.grizzly.filterchain.FilterChainContext.notifyDownstream(FilterChainContext.java:952)
at org.glassfish.grizzly.filterchain.FilterChainContext.notifyDownstream(FilterChainContext.java:934)
at org.apache.catalina.core.ApplicationPushBuilder.push(ApplicationPushBuilder.java:367)
at com.sun.faces.context.ExternalContextImpl.pushIfPossibleAndNecessary(ExternalContextImpl.java:704)
at com.sun.faces.context.ExternalContextImpl.encodeResourceURL(ExternalContextImpl.java:662)
at javax.faces.context.ExternalContextWrapper.encodeResourceURL(ExternalContextWrapper.java:164)
at com.sun.faces.renderkit.html_basic.ScriptStyleBaseRenderer.encodeEnd(ScriptStyleBaseRenderer.java:246)
at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:949)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1912)
at com.sun.faces.renderkit.RenderKitUtils.renderJsfJsIfNecessary(RenderKitUtils.java:1203)
at com.sun.faces.renderkit.html_basic.CommandLinkRenderer.encodeBegin(CommandLinkRenderer.java:117)
at javax.faces.component.UIComponentBase.encodeBegin(UIComponentBase.java:892)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1903)
at javax.faces.render.Renderer.encodeChildren(Renderer.java:176)
at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:918)
at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeRecursive(HtmlBasicRenderer.java:309)
at com.sun.faces.renderkit.html_basic.GroupRenderer.encodeChildren(GroupRenderer.java:114)
at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:918)
at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeRecursive(HtmlBasicRenderer.java:309)
at com.sun.faces.renderkit.html_basic.GroupRenderer.encodeChildren(GroupRenderer.java:114)
at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:918)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1905)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1908)
org.glassfish.grizzly.http.util.MimeHeaders$MaxHeaderCountExceededException: Illegal attempt to exceed the configured maximum number of headers: 100
at org.glassfish.grizzly.http.util.MimeHeaders.createHeader(MimeHeaders.java:466) ~[nucleus-grizzly-all.jar:?]
at org.glassfish.grizzly.http.util.MimeHeaders.addValue(MimeHeaders.java:507) ~[nucleus-grizzly-all.jar:?]
at org.apache.catalina.core.ApplicationPushBuilder.<init>(ApplicationPushBuilder.java:222) ~[web-core.jar:?]
at org.apache.catalina.connector.Request.newPushBuilder(Request.java:2609) ~[web-core.jar:?]
at org.apache.catalina.connector.RequestFacade.newPushBuilder(RequestFacade.java:1167) ~[web-core.jar:?]
at com.sun.faces.context.ExternalContextImpl.getPushBuilder(ExternalContextImpl.java:728) ~[javax.faces.jar:2.3.2]
at com.sun.faces.context.ExternalContextImpl.pushIfPossibleAndNecessary(ExternalContextImpl.java:701) ~[javax.faces.jar:2.3.2]
at com.sun.faces.context.ExternalContextImpl.encodeResourceURL(ExternalContextImpl.java:662) ~[javax.faces.jar:2.3.2]
at com.sun.faces.el.ResourceELResolver.getValue(ResourceELResolver.java:143) ~[javax.faces.jar:2.3.2]
at com.sun.faces.el.DemuxCompositeELResolver._getValue(DemuxCompositeELResolver.java:180) ~[javax.faces.jar:2.3.2]
at com.sun.faces.el.DemuxCompositeELResolver.getValue(DemuxCompositeELResolver.java:208) ~[javax.faces.jar:2.3.2]
at com.sun.el.parser.AstValue.getValue(AstValue.java:139) ~[javax.el.jar:3.0.1-b08]
at com.sun.el.parser.AstValue.getValue(AstValue.java:203) ~[javax.el.jar:3.0.1-b08]
at com.sun.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:226) ~[javax.el.jar:3.0.1-b08]
at org.jboss.weld.module.web.el.WeldValueExpression.getValue(WeldValueExpression.java:50) ~[weld-osgi-bundle.jar:3.0.0.Final]
at com.sun.faces.application.resource.ResourceHelper$ELEvaluatingInputStream.evaluateExpressionIntoBuffer(ResourceHelper.java:832) ~[javax.faces.jar:2.3.2]
at com.sun.faces.application.resource.ResourceHelper$ELEvaluatingInputStream.readExpressionIntoBufferAndEvaluateIntoBuffer(ResourceHelper.java:755) ~[javax.faces.jar:2.3.2]
at com.sun.faces.application.resource.ResourceHelper$ELEvaluatingInputStream.read(ResourceHelper.java:719) ~[javax.faces.jar:2.3.2]
at java.io.InputStream.read(InputStream.java:179) ~[?:1.8.0_121]
at java.io.BufferedInputStream.fill(BufferedInputStream.java:246) ~[?:1.8.0_121]
at java.io.BufferedInputStream.read1(BufferedInputStream.java:286) ~[?:1.8.0_121]
at java.io.BufferedInputStream.read(BufferedInputStream.java:345) ~[?:1.8.0_121]
at java.nio.channels.Channels$ReadableByteChannelImpl.read(Channels.java:385) ~[?:1.8.0_121]
at com.sun.faces.application.resource.ResourceHandlerImpl.handleResourceRequest(ResourceHandlerImpl.java:345) ~[javax.faces.jar:2.3.2]
at javax.faces.application.ResourceHandlerWrapper.handleResourceRequest(ResourceHandlerWrapper.java:178) ~[javax.faces.jar:2.3.2]
at org.primefaces.application.resource.PrimeResourceHandler.handleResourceRequest(PrimeResourceHandler.java:87) ~[primefaces-6.1.2.SIA.jar:?]
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:667) ~[javax.faces.jar:2.3.2]
at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1580) ~[web-core.jar:?]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:338) ~[web-core.jar:?]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) ~[web-core.jar:?]
at org.primefaces.webapp.filter.FileUploadFilter.doFilter(FileUploadFilter.java:100) ~[primefaces-6.1.2.SIA.jar:?]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:250) ~[web-core.jar:?]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) ~[web-core.jar:?]
Since JSF 2.3, CSS/JS resources will automatically be pushed to server when both server and client support HTTP/2 protocol and connection goes over SSL (HTTPS). You can clearly see this back in class and method names of this part of the stack trace:
at com.sun.faces.context.ExternalContextImpl.pushIfPossibleAndNecessary(ExternalContextImpl.java:704)
at com.sun.faces.context.ExternalContextImpl.encodeResourceURL(ExternalContextImpl.java:662)
at javax.faces.context.ExternalContextWrapper.encodeResourceURL(ExternalContextWrapper.java:164)
at com.sun.faces.renderkit.html_basic.ScriptStyleBaseRenderer.encodeEnd(ScriptStyleBaseRenderer.java:246)
However, in your specific case, the JSF page in question apparently has so many CSS/JS resources that it exceeds the server-configured limit of 100 response header entries.
org.glassfish.grizzly.http.util.MimeHeaders$MaxHeaderCountExceededException: Illegal attempt to exceed the configured maximum number of headers: 100
Given these facts, there are several solutions:
Decrease the amount of CSS/JS resources. Frankly, ~100 CSS/JS resources is insane. Consider combining them, if necessary with help of OmniFaces CombinedResourceHandler.
Configure GlassFish to allow more than 100 headers. This can be done via asadmin in commandline. Below is an example which increases it to 200 and assumes that the name of the HTTP listener being used is http-listener-1 (you can also find it in Admin console app).
set configs.config.server-config.network-config.protocols.protocol.http-listener-1.http.max-response-headers=200
Explicitly disable pushing CSS/JS resources by the below Mojarra-specific trick.
#FacesConfig
#ApplicationScoped
public class Config {
#Inject
private FacesContext context;
public void viewInitialized(#Observes #Initialized(ViewScoped.class) UIViewRoot view) {
context.getAttributes().put("com.sun.faces.ExternalContextImpl.PUSH_SUPPORTED", false);
}
}
This is indeed somewhat hacky, but that's because there's no explicit support for disabling this via e.g. a web.xml context parameter. Note that #FacesConfig is necessary in order to be able to #Inject the FacesContext, and that it suffices to have only one annotation of it application-wide. Otherwise you can still grab FacesContext#getCurrentInstance().
I solved it by disabling HTTP/2. For some reason, the number of resources pushed to the browser doesn't matter but for so long as I kept HTTP/2 enabled it was creating the above mentioned errors (those mentioned in the question).
To disable HTTP/2 execute the following command in asadmin:
> asadmin set server.network-config.protocols.protocol.http-listener-2.http.http2-enabled=false
Or in your domain.xml
<protocol name="http-listener-2" security-enabled="true">
<http http2-enabled="false" max-connections="250" compression="on" default-virtual-server="server">
<file-cache></file-cache>
</http>
<ssl classname="com.sun.enterprise.security.ssl.GlassfishSSLImpl" cert-nickname="s1as"></ssl>
</protocol>
I would like to ask you a question about the scoping of the beans with cxf.
According to the documentation all the bean will in scope singleton. However I would like to have them in scope request.
In the doc here http://cxf.apache.org/docs/jaxrs-services-configuration.html
I found:
When service classes and providers are registered this way, the default life-cycle is 'singleton'. You can override it by setting a "jaxrs.scope" parameter with the value of 'prototype' (equivalent to per-request).
I tried thousand of stuff and I was not able to make them working:
Here is my web xml
<?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>CxfRestService</display-name>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/beans.xml</param-value>
</context-param>
<context-param>
<param-name>log4jConfigLocation</param-name>
<param-value>/WEB-INF/resource/log4j.properties</param-value>
</context-param>
<servlet>
<servlet-name>CXFServlet</servlet-name>
<servlet-class>org.apache.cxf.transport.servlet.CXFServlet</servlet-class>
<init-param>
<param-name>jaxrs.scope</param-name>
<param-value>request</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>CXFServlet</servlet-name>
<url-pattern>/rest/*</url-pattern>
</servlet-mapping>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<listener>
<listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
</listener>
</web-app>
I did a simple test with this:
#Path("/")
#WebService(name = "profile", targetNamespace = "")
#Named
public class ProfileCXFService {
private String thisIsAValue;
/**
* Create a profile
*/
#POST
#Path("")
#Produces({ MediaType.APPLICATION_JSON })
#Consumes({ MediaType.APPLICATION_JSON })
public Response createProfile(Profile profile){
if(thisIsAValue == null){
thisIsAValue = "toto";
} else{
return Response.serverError().entity("NOOOOOO").build();
}
return Response.ok().entity("YESSSSS").build();
}
The first call is YESSS and the second NOOOOO.
I would like to have all my beans as request. Were can I find a common way to configure this.
In fact I do not have problem with singleton as the only fields I have are services which are as well singleton and the only moment where I need to use fields specific to the request I am doing a new MyObject. However I heard that Singleton can cause latency if the traffic grows on the server.
Do you have any idea of what can I do?
Thanks a lot in advance and best regards
Geoffrey
So basically found the solution:
In your beans.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:jaxws="http://cxf.apache.org/jaxws"
xmlns:jaxrs="http://cxf.apache.org/jaxrs"
xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://cxf.apache.org/jaxrs
http://cxf.apache.org/schemas/jaxrs.xsd
http://cxf.apache.org/jaxws
http://cxf.apache.org/schemas/jaxws.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.1.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.0.xsd">
<jaxrs:server id="profile" address="/profile">
<jaxrs:providers>
<bean class="com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider" />
</jaxrs:providers>
<jaxrs:serviceBeans>
<ref bean="ProfileCXFServiceImpl"/>
</jaxrs:serviceBeans>
<jaxrs:extensionMappings>
<entry key="xml" value="application/xml" />
<entry key="json" value="application/json" />
</jaxrs:extensionMappings>
</jaxrs:server>
<bean class="org.springframework.context.annotation.CommonAnnotationBeanPostProcessor"/>
<bean id="ProfileCXFServiceImpl" class="com.project.cxfrestservice.ProfileCXFServiceImpl" scope="prototype"><aop:scoped-proxy /></bean>
</beans>
And Voila!!!!
I am getting duplicate id error in my xhtml pages after adding the below context param in web.xml
<context-param>
<param-name>org.apache.myfaces.SERIALIZE_STATE_IN_SESSION</param-name>
<param-value>false</param-value>
</context-param>
below is the error message
org.icefaces.impl.application.ExtendedExceptionHandler handle
WARNING: queued exception
java.lang.IllegalStateException: component with duplicate id "v9g4o62-retrieve-update" found
at org.apache.myfaces.view.facelets.compiler.CheckDuplicateIdFaceletUtils.checkIds(CheckDuplicateIdFaceletU
tils.java:100)
at org.apache.myfaces.view.facelets.compiler.CheckDuplicateIdFaceletUtils.checkIds(CheckDuplicateIdFaceletU
tils.java:116)
at org.apache.myfaces.view.facelets.compiler.CheckDuplicateIdFaceletUtils.checkIds(CheckDuplicateIdFaceletU
tils.java:116)
at org.apache.myfaces.view.facelets.compiler.CheckDuplicateIdFaceletUtils.checkIds(CheckDuplicateIdFaceletU
tils.java:82)
at org.apache.myfaces.view.facelets.DefaultFaceletsStateManagementStrategy.saveView(DefaultFaceletsStateMan
agementStrategy.java:536)
at org.apache.myfaces.application.StateManagerImpl.saveView(StateManagerImpl.java:188)
at javax.faces.application.StateManager.getViewState(StateManager.java:253)
at org.icefaces.impl.context.DOMResponseWriter$WriteViewStateMarkup.write(DOMResponseWriter.java:614)
at org.icefaces.impl.util.DOMUtils.printNode(DOMUtils.java:373)
at org.icefaces.impl.util.DOMUtils.printNode(DOMUtils.java:355)
at org.icefaces.impl.util.DOMUtils.printNode(DOMUtils.java:355)
at org.icefaces.impl.util.DOMUtils.printNode(DOMUtils.java:355)
at org.icefaces.impl.util.DOMUtils.printNode(DOMUtils.java:306)
at org.icefaces.impl.util.DOMUtils.printNode(DOMUtils.java:290)
at org.icefaces.impl.context.DOMResponseWriter.endDocument(DOMResponseWriter.java:238)
at org.apache.myfaces.view.facelets.FaceletViewDeclarationLanguage.renderView(FaceletViewDeclarationLanguag
e.java:1983)
at org.apache.myfaces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:285)
at org.apache.myfaces.lifecycle.RenderResponseExecutor.execute(RenderResponseExecutor.java:116)
at org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:241)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:199)
at com.mtcom.abc.webapp.servlet.abcServlet.service(abcServlet.java:104)
at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:280)
at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:254)
at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:136)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:346)
at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:25)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:79)
at com.planetj.servlet.filter.compression.CompressingFilter.doFilter(CompressingFilter.java:270)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:79)
at weblogic.servlet.internal.RequestEventsFilter.doFilter(RequestEventsFilter.java:27)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:79)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java
:3436)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:340
2)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
at weblogic.servlet.provider.WlsSubjectHandle.run(WlsSubjectHandle.java:57)
at weblogic.servlet.internal.WebAppServletContext.doSecuredExecute(WebAppServletContext.java:2285)
at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2201)
at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2179)
at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1572)
at weblogic.servlet.provider.ContainerSupportProviderImpl$WlsRequestExecutor.run(ContainerSupportProviderIm
pl.java:255)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:311)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:263)
<11 Jul, 2016 3:49:16 PM IST> <Warning> <org.icefaces.impl.application.ExtendedExceptionHandler> <BEA-000000> <queu
ed exception
java.lang.IllegalStateException: component with duplicate id "v9g4o62-retrieve-update" found
at org.apache.myfaces.view.facelets.compiler.CheckDuplicateIdFaceletUtils.checkIds(CheckDuplicateIdFaceletU
tils.java:100)
at org.apache.myfaces.view.facelets.compiler.CheckDuplicateIdFaceletUtils.checkIds(CheckDuplicateIdFaceletU
tils.java:116)
at org.apache.myfaces.view.facelets.compiler.CheckDuplicateIdFaceletUtils.checkIds(CheckDuplicateIdFaceletU
tils.java:116)
at org.apache.myfaces.view.facelets.compiler.CheckDuplicateIdFaceletUtils.checkIds(CheckDuplicateIdFaceletU
tils.java:82)
at org.apache.myfaces.view.facelets.DefaultFaceletsStateManagementStrategy.saveView(DefaultFaceletsStateMan
agementStrategy.java:536)
Truncated. see log file for complete stacktrace
>
I have upgraded the following technologies in my project
Icefaces 1.8 to 3.3
jsf 1.X to 2.0
Not able to find what is the exact root cause . Pleae do needful
Thanks in Advance.
Our team is upgrading my very big Webapplication from Myfaces-1.1.5 to Myfaces-2.1.9
and from Tomahawk-1.1.3 to Tomahawk-1.1.14.
Problem is my current application using ajax4jsf filter..
<context-param>
<param-name>org.ajax4jsf.VIEW_HANDLERS</param-name>
<param-value>com.sun.facelets.FaceletViewHandler</param-value>
</context-param>
<filter>
<filter-name>ajax4jsf</filter-name>
<filter-class>org.ajax4jsf.Filter</filter-class>
</filter>
I have changed the value of context param as follows
<context-param>
<param-name>org.ajax4jsf.VIEW_HANDLERS</param-name>
<param-value>org.apache.myfaces.view.facelets.FaceletViewHandler</param-value>
</context-param>
Because of this I am getting exception. I have read at multiple places that with JSF 2.1, ajax4jsf filter is not required but could you please tell what should I use and how...
Feb 26, 2015 4:45:48 PM org.apache.myfaces.view.facelets.compiler.TagLibraryConf
ig loadImplicit
SEVERE: Error Loading Library: jar:file:/C:/Projects/eMessaging/EM1.4M6-LibUpgra
de_new/web/target/emessaging-webapp-1.4M6/WEB-INF/lib/ajax4jsf-1.0.6.jar!/META-I
NF/a4j.taglib.xml
java.io.IOException: Error parsing [jar:file:/C:/Projects/eMessaging/EM1.4M6-Lib
Upgrade_new/web/target/emessaging-webapp-1.4M6/WEB-INF/lib/ajax4jsf-1.0.6.jar!/M
ETA-INF/a4j.taglib.xml]:
at org.apache.myfaces.view.facelets.compiler.TagLibraryConfig.create(Tag
LibraryConfig.java:805)
at org.apache.myfaces.view.facelets.compiler.TagLibraryConfig.loadImplic
it(TagLibraryConfig.java:839)
at org.apache.myfaces.view.facelets.compiler.Compiler.initialize(Compile
r.java:101)
at org.apache.myfaces.view.facelets.compiler.Compiler.compile(Compiler.j
ava:126)
at org.apache.myfaces.view.facelets.impl.DefaultFaceletFactory._createFa
celet(DefaultFaceletFactory.java:300)
at org.apache.myfaces.view.facelets.impl.DefaultFaceletFactory.access$00
0(DefaultFaceletFactory.java:53)
at org.apache.myfaces.view.facelets.impl.DefaultFaceletFactory$1.newInst
ance(DefaultFaceletFactory.java:114)
at org.apache.myfaces.view.facelets.impl.DefaultFaceletFactory$1.newInst
ance(DefaultFaceletFactory.java:111)
at org.apache.myfaces.view.facelets.impl.FaceletCacheImpl.getFacelet(Fac
eletCacheImpl.java:83)
at org.apache.myfaces.view.facelets.impl.FaceletCacheImpl.getFacelet(Fac
eletCacheImpl.java:50)
at org.apache.myfaces.view.facelets.impl.DefaultFaceletFactory.getFacele
t(DefaultFaceletFactory.java:199)
at org.apache.myfaces.view.facelets.impl.DefaultFaceletFactory.getFacele
t(DefaultFaceletFactory.java:182)
at com.g1.emessaging.ui.EmsgFaceletViewHandler.buildView(EmsgFaceletView
Handler.java:550)
at com.g1.emessaging.ui.EmsgFaceletViewHandler.renderView(EmsgFaceletVie
wHandler.java:607)
at org.ajax4jsf.framework.ViewHandlerWrapper.renderView(ViewHandlerWrapp
er.java:101)
at org.ajax4jsf.framework.ajax.AjaxViewHandler.renderView(AjaxViewHandle
r.java:221)
at org.apache.myfaces.lifecycle.RenderResponseExecutor.execute(RenderRes
ponseExecutor.java:116)
at org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:
241)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:199)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
icationFilterChain.java:303)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
ilterChain.java:208)
at org.ajax4jsf.framework.ajax.xmlfilter.BaseXMLFilter.doXmlFilter(BaseX
MLFilter.java:75)
at org.ajax4jsf.framework.ajax.xmlfilter.BaseFilter.doFilter(BaseFilter.