I've created portlet project in RSA, and set target runtime as WebSphere Portal 7 which I use. But now I want to create managed bean, to use JSF. But I cant import annotation. What I've missed?
If you are using maven you need to include this dependency to get the code to compile:
<dependency>
<groupId>javax.faces</groupId>
<artifactId javax.faces-api</artifactId>
</dependency>
Otherwise download the jar from maven central at http://search.maven.org/#search|ga|1|javax.faces.api and it to your project's build classpath in RSA.
Related
I'm using avro-tools 1.9.2 in my project and due to some reason can't even update it. I see that avro-tools 1.9.2 using the old log4 1.x API natively (its not a transitive dependency instead its included natively in the jar itself), Is there any way to exclude package when using the jar file at runtime? I know its very unfair/weird questions. But I really need get going.
<dependency>
<groupId>org.apache.avro</groupId>
<artifactId>avro-tools</artifactId>
<version>1.9.2</version>
</dependency>
I'm trying to upgrade a legacy Java EE application to Jakarta EE 8 on a Wildfly server. Most of the upgrade has gone smoothly since 8 doesn't swap the package names to jakarta yet. However, some of our code is using classes from Oracle's com.sun.faces package. These classes appear to be included in the Jakarta EE Faces API specification, but they are not included in our project when I use the following Maven dependency:
<dependency>
<groupId>jakarta.faces</groupId>
<artifactId>jakarta.faces-api</artifactId>
<version>2.3.2</version>
<scope>provided</scope>
</dependency>
To get these in the classpath, I have to use the Oracle dependency:
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-impl</artifactId>
<version>2.2.20</version>
<scope>provided</scope>
</dependency>
Obviously, we want to ditch using this package altogether at some point, but I was hoping there was a way to include this in our Jakarta migration.
The com.sun.faces.* is not part of Jakarta EE API. It's part of the Jakarta EE implementation. More precisely, it's the actual JSF implementation. Its name is "Mojarra".
You should indeed not need to have a dependency on it in your pom.xml in order to be JEE-implementation-independent (i.e. in order to be able to deploy your webapp to any JEE-compatible server without any code changes). If the code however doesn't compile when you remove it, then you apparently have somewhere a hard dependency on it, e.g. a hardcoded import or superclass referring to com.sun.faces.* package. This is indeed usually not correct.
The solution should be straight forward:
Remove that Mojarra dependency
Find all compilation errors
Fix them one by one by using the standard JSF API approach
If no one could be found, research or ask on Stack Overflow
I need to bundle JSF implementation in my WAR file due to known bug in the original mojarra implementation.
I am not allowed to replace the JSF implementation in the modules, so i am using the useBundledJsf property.
Running Payara Version: Payara Server 4.1.1.164 #badassfish (build 28)
This versions should support useBundledJsf properly.
I have added this to my glassfish-web.xml:
<class-loader delegate="false" />
<property name="useBundledJsf" value="true" />
and added the javax.faces dependecy to my pom:
<dependency>
<groupId>org.glassfish</groupId>
<artifactId>javax.faces</artifactId>
<version>2.2.13</version>
</dependency>
I am getting the following error and all injections are failing.
SEVERE: JSF1051: Service entry 'org.glassfish.faces.integration.GlassFishInjectionProvider' does not extend DiscoverableInjectionProvider. Entry will be ignored.
I have tried to add the weld-integration.jar to my project but it still produces the JSF1051 error following by:
Unable to create a new instance of 'org.jboss.weld.jsf.ConversationAwareViewHandler'
The dependency for the weld-integration i have used:
<dependency>
<groupId>org.glassfish.main.web</groupId>
<artifactId>weld-integration</artifactId>
<version>4.1.2</version>
<exclusions>
<exclusion>
<artifactId>*</artifactId>
<groupId>*</groupId>
</exclusion>
</exclusions>
There is an extra feature to make this easier in Payara Server 171 which was added specifically to make these scenarios work properly.
From the documentation:
It’s possible to configure an extreme isolation level on the class loading delegation for deployed applications. With this extreme isolation behavior, a deployed application can force the server to load only classes from libraries included on Payara Server that belong to whitelisted packages defined on its deployment descriptors.
To configure whitelist packaging you can use the <whitelist-package> element on the glassfish-web.xml (WAR artifacts) or the glassfish-application.xml (EAR artifacts). This element can be included multiple times to whitelist multiple packages. Here is an example of whitelisting both the Google Guava and Jackson packages for a WAR application:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE glassfish-web-app PUBLIC "-//GlassFish.org//DTD GlassFish Application Server 3.1 Servlet 3.0//EN" "http://glassfish.org/dtds/glassfish-web-app_3_0-1.dtd">
<glassfish-web-app error-url="">
...
<whitelist-package>com.google.guava</whitelist-package>
<whitelist-package>com.fasterxml.jackson</whitelist-package>
</glassfish-web-app>
The whitelist syntax is simple: Define the name of the package which contains the classes in question. For example writing com.google would whitelist all Google libraries included on the server, while writing com.google.guava would only whitelist the Google Guava library instead.
Extreme Classloading Isolation
I'd like to use PrimeFaces in my Java EE 6 (Jboss AS 7.1.1Final) application with this structure:
EAR
|- lib/
| |- primefaces-4.0.jar
|
|- ejb-module.jar
|- webbapp1.war
|- webapp2.war
However, when deploying to JBoss AS 7, I'm getting several exceptions such as:
java.lang.LinkageError: Failed to link org/primefaces/context/PrimeFacesContextFactory
(Please see the full stack trace here on PasteBin)
For EAR's pom.xml, I'm using this Maven dependency for PrimeFaces:
<dependency>
<groupId>org.primefaces</groupId>
<artifactId>primefaces</artifactId>
<version>4.0</version>
<type>jar</type>
</dependency>
However, when I put the dependency into pom.xml of one WAR, it works, but I want to share the primefaces library between multiple WARs.
I've googled a lot but have not found any solution. Thank you for any advice.
You cannot. Webapp libraries do not belong in EAR/lib, but in WAR/WEB-INF/lib. The EAR/lib is never intented as a "shared library" for all WAR projects of the EAR. It's that only for all EJB projects (the business services) of the EAR.
The LinkageError on a PrimeFaces-specific class which you're facing is caused because the (default) webapp-specific libraries like JSF API/impl are not available to the classloader as used by EAR/lib. This causes all libraries in the EAR/lib which have a (virtual) dependency in WAR/WEB-INF/lib to fail with class loading errors like LinkageError.
If you really really need a "shared library" for all WAR projects, then your best bet is putting the library in Java EE container itself (like as by default already done for JSF API/impl libraries). In case of JBoss, that's called a "module". I however wouldn't recommend that as that makes the webapp unportable across containers without specifically configuring the container by the serveradmin. Just give each webapp its own set of webapp libraries.
I am trying to configure JSF with the help of this blog http://balusc.blogspot.com/2008/01/jsf-tutorial-with-eclipse-and-tomcat.html
I cant see preferences-> web -> JSF Tools -> libraries
I need to include mojjaira but i didnt see library option here
help me where can i see this option
You seem to be using Eclipse 3.6. That tutorial was targeted on Eclipse 3.5 and the location of that preference has been changed in Eclipse 3.6. It's now available by a generic preference: Java > Build Path > User Libraries. But you can also just skip the step altogether and specify it during the Dynamic Web Project wizard. Or even better, head to the JSF 2.0 tutorial, it's targeted on Eclipse 3.6.
Just include JK-Faces maven dependency:
<dependencies>
<dependency>
<groupId>com.jalalkiswani</groupId>
<artifactId>jk-faces</artifactId>
<version>0.0.9-1</version>
</dependency>
</dependencies>
, and it will configure everything for you. Give it a try