How to use omnifaces CDN resource handler with versioned resources? - jsf

How to use omnifaces CDNResourceHandler with versioned resources?
Original url:
javax.faces.resource/jquery/jquery.js.xhtml?ln=primefaces&v=5.0
Desired url:
//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js
How to map this to a specific url, omitting the version query parameter?
Mapping:
Using following mapping appends the version query parameter to the final url resulting in 404 HTTP error.
primefaces:jquery/jquery.js=//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js
Results in:
//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js&v=5.0
System:
Glassfish 4
Mojarra 2.24
Primefaces 5.0
Rewrite 2.11

I reproduced it. This will happen when the PrimeFaces PrimeResourceHandler is initialized after OmniFaces CDNResourceHandler.
If you've declared the CDNResourceHandler inside /WEB-INF/faces-config.xml, then this is quite unexpected and likely a bug in GlassFish4.
But if you've declared the CDNResourceHandler inside /META-INF/faces-config.xml of a JAR which you in turn placed inside /WEB-INF/lib, then this can indeed happen if GlassFish initializes that JAR before the PrimeFaces JAR. In order to solve the problem, you need to explicitly declare your JAR's /META-INF/faces-config.xml to be initialized after the PrimeFaces one by adding the following entry to your JAR's /META-INF/faces-config.xml:
<ordering>
<after>
<name>primefaces</name>
</after>
</ordering>
Alternatively, move the CDNResourceHandler declaration to webapp's /WEB-INF/faces-config.xml.

Related

WebSphere 9.0.5.3 and MyFaces 2.2 with CACHE_EL_EXPRESSIONS

When org.apache.myfaces.CACHE_EL_EXPRESSIONS with value alwaysRecompile is in web.xml, WAR starts but when trying to go to any JSF view, this exception is thrown:
java.lang.NoSuchMethodException: org.apache.myfaces.view.facelets.AbstractFaceletCache.setMemberFactories(javax.faces.view.facelets.FaceletCache$MemberFactory, javax.faces.view.facelets.FaceletCache$MemberFactory)
Any ideas? WebSphere 9 is using MyFaces 2.2. Are there some limitations as compared to "usual" MyFaces 2.2 implementation?
I tested on 9.0.5.6 and also encountered the same error.
java.lang.NoSuchMethodException: org.apache.myfaces.view.facelets.AbstractFaceletCache.setMemberFactories(javax.faces.view.facelets.FaceletCache$MemberFactory, javax.faces.view.facelets.FaceletCache$MemberFactory)
at java.lang.Class.newNoSuchMethodException(Class.java:567)
at java.lang.Class.throwExceptionOrReturnNull(Class.java:1222)
at java.lang.Class.getMethodHelper(Class.java:1308)
at java.lang.Class.getDeclaredMethod(Class.java:936)
at org.apache.myfaces.view.facelets.impl.DefaultFaceletFactory.<init>(DefaultFaceletFactory.java:166)
at org.apache.myfaces.view.facelets.FaceletViewDeclarationLanguage.createFaceletFactory(FaceletViewDeclarationLanguage.java:2233)
I see the code is trying to retrieve the setMemberFactories method with 2 args rather than 3 (as the exception indicates, too).
I'll create an issue and have this issue resolve in the next WAS 9 release cycle. Thanks for discovering this!

Implementation of Jakarta XML Binding-API not found?

My context :
BND (bndtools with Eclipse IDE) ;
OSGI (-runfw: org.eclipse.osgi;version='[3.16.100.v20201030-1916,3.16.200.v20210226-1447]') ;
runee: JavaSE-1.8
in bnd.launch file :
-runbundles: \
org.apache.felix.gogo.command;version='[1.1.2,1.1.3)',\
org.apache.felix.gogo.runtime;version='[1.1.4,1.1.5)',\
org.apache.felix.gogo.shell;version='[1.1.4,1.1.5)',\
org.apache.commons.commons-fileupload;version='[1.4.0,1.4.1)',\
org.apache.commons.commons-io;version='[2.8.0,2.8.1)',\
org.apache.felix.webconsole;version='[4.6.0,4.6.1)',\
org.apache.felix.http.jetty;version='[4.1.6,4.1.7)',\
org.apache.felix.http.servlet-api;version='[1.1.2,1.1.3)',\
org.apache.felix.scr;version='[2.1.24,2.1.25)',\
org.eclipse.equinox.cm;version='[1.5.0,1.5.1)',\
org.eclipse.equinox.console;version='[1.4.300,1.4.301)',\
org.eclipse.equinox.device;version='[1.1.100,1.1.101)',\
org.eclipse.osgi.services;version='[3.10.0,3.10.1)',\
org.eclipse.osgi.util;version='[3.6.0,3.6.1)',\
ch.qos.logback.classic;version='[1.2.3,1.2.4)',\
ch.qos.logback.core;version='[1.2.3,1.2.4)',\
org.apache.felix.logback;version='[1.0.2,1.0.3)',\
slf4j.api;version='[1.7.30,1.7.31)',\
com.sun.activation.jakarta.activation;version='[2.0.1,2.0.2)',\
jakarta.xml.bind-api;version='[3.0.1,3.0.2)',\
com.sun.xml.bind.jaxb-osgi;version='[3.0.1,3.0.2)'
No use of any POM.xml file at all
When I launch the application, I get a
jakarta.xml.bind.JAXBException: Implementation of Jakarta XML Binding-API has not been found on module path or classpath.
- with linked exception:
[java.lang.ClassNotFoundException: org.glassfish.jaxb.runtime.v2.ContextFactory]
at jakarta.xml.bind.ContextFinder.newInstance(ContextFinder.java:255)
at jakarta.xml.bind.ContextFinder.newInstance(ContextFinder.java:243)
at jakarta.xml.bind.ContextFinder.find(ContextFinder.java:407)
at jakarta.xml.bind.JAXBContext.newInstance(JAXBContext.java:691)
at jakarta.xml.bind.JAXBContext.newInstance(JAXBContext.java:632)
If I add org.glassfish.jaxb.runtime;version='[3.0.1,3.0.2)'
to the runbundles list, it doesn't change anything (same exception).
Then if I add -runpath: org.glassfish.jaxb.runtime;version='[3.0.1,3.0.2)' to the bnd.launch file : it doesn't change anything either (same exception).
What did I did wrong ??
Thanks
Are you running on Java 1.9 or later? (The error message talks about module path.) The problem might be that JAXB is no longer exported from the JVM in later versions. This will the class loading of glassfish to fail without telling the underlying reason sometimes.
You can add -runvm -v:class to get more information about the class loading.

WebLogic 12.2.1.4 JSF 1.2 ELContext provokes null pointer on literal expressions

Jsf page with myFaces trinidad 1.2.15 ver JSF 1.2-20 could not be parsed due to expression evaluation error over ELContext. here is the stack
Caused by: java.lang.NullPointerException
at com.sun.el.ValueExpressionLiteral.getValue(ValueExpressionLiteral.java:79)
at org.apache.myfaces.trinidad.webapp.UIXComponentELTag.setProperty(UIXComponentELTag.java:135)
at org.apache.myfaces.trinidadinternal.taglib.html.HtmlHeadTag.setProperties(HtmlHeadTag.java:70)
at org.apache.myfaces.trinidad.webapp.UIXComponentELTag.setProperties(UIXComponentELTag.java:122)
at javax.faces.webapp.UIComponentELTag.createComponent(UIComponentELTag.java:230)
at javax.faces.webapp.UIComponentClassicTagBase.createChild(UIComponentClassicTagBase.java:513)
at javax.faces.webapp.UIComponentClassicTagBase.findComponent(UIComponentClassicTagBase.java:782)
at javax.faces.webapp.UIComponentClassicTagBase.doStartTag(UIComponentClassicTagBase.java:1354)
at org.apache.myfaces.trinidad.webapp.UIXComponentELTag.doStartTag(UIXComponentELTag.java:71)
at jsp_servlet._jsp._btwizard.__btwizardmain._jsp__tag2(__btwizardmain.java:648) ....
The problem was that the setProperty method of UIXComponentELTag by default passes a null argument for ElContext as this:
bean.setProperty(key, expression.getValue(null));
This is not supported on the version of elcontext that weblogic12 uses. We were not allowed to change the version of trinidad being used so we had to patch the library changing all the calls of getValue with
bean.setProperty(key, expression.getValue(FacesContext.getCurrentInstance().getELContext()));
We also found this problem on some clases that were generated from XML files like Color.xml, DateTime.xml and Number.xml, so we had to prevent them from being generated and provide our own implementation.

Parsing Hazelcast 4.1 XmlClientConfig fails in Apache TomEE

Trying to construct a Hazelcast 4.1 client configuration from XML throws IllegalArgumentException if the application is running in Apache TomEE-Plus 8.0.0.
If executed in a standalone Java VM (AdoptOpenJDK 11.0.5), the problem does not occur.
Standalone test and TomEE use identical JDK.
Part of the stack trace:
java.lang.IllegalArgumentException: Nicht unterstützt: http://javax.xml.XMLConstants/property/accessExternalDTD
at org.apache.xalan.processor.TransformerFactoryImpl.setAttribute(TransformerFactoryImpl.java:571)
at com.hazelcast.config.AbstractXmlConfigHelper.schemaValidation(AbstractXmlConfigHelper.java:109)
at com.hazelcast.client.config.XmlClientConfigBuilder.parseAndBuildConfig(XmlClientConfigBuilder.java:175)
at com.hazelcast.client.config.XmlClientConfigBuilder.build(XmlClientConfigBuilder.java:157)
at com.hazelcast.client.config.XmlClientConfigBuilder.build(XmlClientConfigBuilder.java:150)
at com.hazelcast.client.config.XmlClientConfigBuilder.build(XmlClientConfigBuilder.java:145)
...
I found a post on StackOverflow that seems to be related to my problem:
Set feature accessExternalDTD in TransformerFactory
Unfortunately, I have no idea if the suggested solution in answer no. 1 really matches my problem.
And even if so, I do not know how to apply the suggested solution in application code or configurations only, without changes inside Hazelcast code.
Any ideas how to fix this?
Hazelcast Client-Config XML:
<?xml version="1.0" encoding="UTF-8"?>
<hazelcast-client xsi:schemaLocation="http://www.hazelcast.com/schema/client-config hazelcast-client-config-4.1.xsd"
xmlns="http://www.hazelcast.com/schema/client-config"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
...
</hazelcast-client>
TomEE version:
apache-tomee-plus-8.0.0 (Apache Tomcat Version 9.0.22)
Java version:
AdoptOpenJDK 11.0.5
IMPLEMENTOR="AdoptOpenJDK"
IMPLEMENTOR_VERSION="AdoptOpenJDK"
JAVA_VERSION="11.0.5"
JAVA_VERSION_DATE="2019-10-15"
MODULES="java.base java.compiler java.datatransfer java.xml java.prefs java.desktop java.instrument java.logging java.management java.security.sasl java.naming java.rmi java.management.rmi java.net.http java.scripting java.security.jgss java.transaction.xa java.sql java.sql.rowset java.xml.crypto java.se java.smartcardio jdk.accessibility jdk.internal.vm.ci jdk.management jdk.unsupported jdk.internal.vm.compiler jdk.aot jdk.charsets jdk.crypto.ec jdk.crypto.cryptoki jdk.dynalink jdk.httpserver jdk.internal.ed jdk.internal.le jdk.internal.vm.compiler.management jdk.jdwp.agent jdk.jfr jdk.jsobject jdk.localedata jdk.management.agent jdk.management.jfr jdk.naming.dns jdk.naming.rmi jdk.net jdk.pack jdk.scripting.nashorn jdk.scripting.nashorn.shell jdk.sctp jdk.security.auth jdk.security.jgss jdk.xml.dom jdk.zipfs"
OS_ARCH="x86_64"
OS_NAME="Linux"
SOURCE=".:git:7d14fe4b6f30"
This looks like this issue which is due to the presence of an old JAXP implementation in the classpath. This is fixed in Hazelcast 4.1.1 (fix pull request) by supplying a system property switch to avoid failing when XXE protection cannot be turned on.
You should be able to start your Hazelcast client in Apache TomEE by upgrading to Hazelcast 4.1.1 and setting system property hazelcast.ignoreXxeProtectionFailures=true (for example by supplying -Dhazelcast.ignoreXxeProtectionFailures=true to Apache TomEE's java startup command line).
This seems to be an issue with XML / DTD . Please check with the following config file
https://github.com/hazelcast/hazelcast/blob/master/hazelcast/src/main/resources/hazelcast-client-default.xml
and code
public ClientConfig clientConfig() throws Exception {
return new XmlClientConfigBuilder("hazelcast-client.xml").build();
}

Failed to parse the expression [#{contatosController.adicionar(actionEvent)}]

I'm trying to learn JSF and EL and I am facing the following error:
/index.xhtml #20,120 actionListener="#{contatosController.adicionar(actionEvent)}" Q
What does that mean and how can I solve it?
It means that your environment does not support the EL 2.2 feature of invoking methods with arguments. The EL syntax #{bean.method(argument)} is unsupported in EL 2.1 and older and therefore unparsable. Just get rid of that argument. JSF fills it in by itself anyway.
actionListener="#{contatosController.adicionar}"
Please note that even if you upgraded to EL 2.2, it would still end up in trouble as you're essentially passing null to it (you don't have a managed bean #{actionEvent}, right?). You should actually never need to specify the default argument of a JSF (action)listener method yourself.
See also:
How to call a method with a parameter in JSF
Differences between action and actionListener

Resources