Reputation: 736
I am using Primefaces 6 on a Java application (Java 8) which runs without any issues on JBoss EAP 7.0 (Java 8).
When i deploy the exact same war on a JBoss EAP 7.3.7 (Running on Java 11) the fileUpload does not seem to work anymore and the fileUploadListener is not triggered at all. Instead the methods defined in <f:event type="preRenderView" listener="..." /> seems to be the ones only triggered
Javascript/HTTP, Jboss and application logs do not show any kind of errors. The rest of the application seems to work fine.
<p:fileUpload id="templateUpload"
fileUploadListener="#{myHandler.uploadFile}" mode="advanced" dragDropSupport="true"
update=":myForm:fileTable @this"
skinSimple="true" label="Label1" cancelLabel="Label2"
uploadLabel="Label3" sizeLimit="500000" allowTypes="/(\.|\/)(pdf)$/" fileLimit="1"
invalidSizeMessage="Label4"
invalidFileMessage="Label5"
fileLimitMessage="Label6"
/>
The handler is defined with @ManagedBean and @ViewScoped while me method looks as follows:
public void uploadFile(final FileUploadEvent event)
Also my HTTP Post request, seems to have the file enclosed and is sent as
Content-Type: multipart/form-data;
Accept-Encoding: gzip, deflate
Accept: application/xml, text/xml, */*; q=0.01
The major change i see is the JSF Version (2.2 to 2.3 on JBoss 7.3.7). Pretty likely that my issue lays there.
Upvotes: 1
Views: 718
Reputation: 169
I have had the same issue with Primefaces 6.1 and JBoss EAP 6.3. Debugging the application, I found that Primefaces (PrimeConfiguration.java) checks if the application server supports JSF 2.3 as follows (same for JSF 2.2, JSF 2.1):
private boolean detectJSF23() {
String version = FacesContext.class.getPackage().getImplementationVersion();
if(version != null) {
return version.startsWith("2.3");
}
else {
//fallback
try {
Class.forName("javax.faces.component.UIImportConstants");
return true;
}
catch (ClassNotFoundException ex) {
return false;
}
}
}
The method getImplementationVersion => Return the version of this implementation. It consists of any string assigned by the vendor of this implementation and does not have any particular syntax specified or expected by the Java runtime.
In JBoss EAP 6.3, the getImplementationVersion returns the string "3.0.0.SP01-redhat-00001" and therefore, it does not match.
In the case that application server does not have at least JSF 2.2, FileUploadRenderer (FileUploadRenderer.java) uses the Commons File Uploader implementation instead of the Native File Uploader implementation.
public void decode(FacesContext context, UIComponent component) {...
PrimeConfiguration cc = RequestContext.getCurrentInstance().getApplicationContext().getConfig();
String uploader = cc.getUploader();
boolean isAtLeastJSF22 = cc.isAtLeastJSF22();
String inputToDecodeId = getSimpleInputDecodeId(fileUpload, context);
if (uploader.equals("auto")) {
if (isAtLeastJSF22)
NativeFileUploadDecoder.decode(context, fileUpload, inputToDecodeId);
else
CommonsFileUploadDecoder.decode(context, fileUpload, inputToDecodeId);
}
I did my own implementation of FileUploadRenderer to use always the Native implementation in JBoss EAP 7.3 because according to the RedHat documentation, JBoss EAP 7.3 uses JSF 2.3. It solved my issue.
Upvotes: 1