I'm trying to extract the Omnifaces library from a .war archive to JBoss module, however, there are problems with org.jboss.weld.context.ContextNotActiveException: WELD-001303 No active contexts for scope type org.omnifaces.cdi.ViewScoped. Application deploys successfully but breaks on first page load.
I've read BalusC's report on problems with .wars packaged in .ear (http://balusc.blogspot.com/2013_10_01_archive.html) but I'm not sure if it applies to this situation as well since we have only .war.
When the Omnifaces library is included in .war's lib folder via Maven as a compile time dependency everything works flawlessly:
<dependency>
<groupId>org.omnifaces</groupId>
<artifactId>omnifaces</artifactId>
<version>1.7</version>
</dependency>
Setting the dependency to provided scope, creating a JBoss module and appending the jboss-deployment structure to:
<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure>
<deployment>
<dependencies>
<module name="org.omnifaces" export="true" meta-inf="import"/>
<!-- i tried multiple export and meta-inf combinations -->
</dependencies>
</deployment>
</jboss-deployment-structure>
module.xml:
<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.0" name="org.omnifaces">
<resources>
<resource-root path="omnifaces-1.7.jar"/>
</resources>
<dependencies>
<module name="javaee.api"/>
<module name="javax.api"/>
<module name="javax.faces.api" />
</dependencies>
</module>
Is it possible to use Omnifaces this way, as a JBoss module?
OmniFaces is as being a JSF utility library designed as WAR module, not as EAR or appserver module.
Related
We have migrated our application from JBoss 6 to Wildfly 10. After migration the server is not storing the view state as the value of javax.faces.ViewState hidden input field after the first http response.
Application logic is storing it on server end and the scenario is to validate input text field on click of submit button. After the first http response the hidden input field disappears and on submitting some text value again, the text value is deleted and bean.xml is not called.
There has been no change in the application end. However the only difference is: Jboss had web.xml deployed with servlet mapping provided in the application war and in case of wildfly user has to deploy the war of application with wildfly 10 independently installed on the machine.
Primefaces 3.4, JSF 2.2 and Mojarra 2.2.14 is used.
The modules.xml is as below:
Path: \modules\system\layers\base\com\sun\jsf-impl\main
<module xmlns="urn:jboss:module:1.3" name="com.sun.jsf-impl">
<properties>
<property name="jboss.api" value="private"/>
</properties>
<dependencies>
<module name="javax.faces.api"/>
<module name="javaee.api"/>
<module name="javax.servlet.jstl.api"/>
<module name="org.apache.xerces" services="import"/>
<module name="org.apache.xalan" services="import"/>
<module name="org.jboss.weld.core"/>
<module name="org.jboss.weld.spi"/>
<module name="javax.xml.rpc.api"/>
<module name="javax.rmi.api"/>
<module name="org.omg.api"/>
</dependencies>
<resources>
<resource-root path="jsf-impl-2.2.14.jar"/>
</resources>
Path: \modules\system\layers\base\javax\faces\api\main
<module xmlns="urn:jboss:module:1.3" name="javax.faces.api" slot="2.2.14">
<dependencies>
<module name="com.sun.jsf-impl"/>
<module name="javax.enterprise.api" export="true"/>
<module name="javax.servlet.api" export="true"/>
<module name="javax.servlet.jsp.api" export="true"/>
<module name="javax.servlet.jstl.api" export="true"/>
<module name="javax.validation.api" export="true"/>
<module name="org.glassfish.javax.el" export="true"/>
<module name="javax.api"/>
</dependencies>
<resources>
<resource-root path="jsf-api-2.2.14.jar"/>
</resources>
</module>
What is being missed here?
I have a web application which is based on JSF 1.2 . The JSF jars are packed in the WAR library. We we try to deploy the war in JBoss EAP 7.0 , the war gets deployed successfully but the application does not run.
I found that JBoss EAP 7.0 does not support JSF 1.2 . My web application is not JSF 2.0 complaint. It will be great help if some body can list down steps to do so.
Thanks
Please try these steps:
Add a deployment-structure.xml to your project (WEB-INF/jboss-deployment-structure.xml to the WAR or META-INF/jboss-deployment-structure.xml to the EAR) with the exclusions:
<exclusions>
<module name="javax.faces.api" slot="main" />
<module name="com.sun.jsf-impl" slot="main" />
<module name="org.jboss.as.jsf-injection" slot="main" />
</exclusions>
Import all dependecies in pom.xml, what jsf need. Like that:
<dependency>
<groupId>javax.faces</groupId>
<artifactId>jsf-api</artifactId>
<version>1.2-b19</version>
</dependency>
<dependency>
<groupId>javax.faces</groupId>
<artifactId>jsf-impl</artifactId>
<version>1.2-b19</version>
</dependency>
<dependency>
<groupId>com.sun.facelets</groupId>
<artifactId>jsf-facelets</artifactId>
<version>1.1.11</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.1.0</version>
</dependency>
Actually this combination worked for me on EAP 7 version of JBOSS 7.1.5 servers.
This way I was able to load jsf1.2 jars from my WEB-INF/lib folder rather than what was supplied by JBOSS 7.1.5.
I had a EAR file which had the WAR file.
Web.xml:
<context-param>
<param-name>org.jboss.jbossfaces.WAR_BUNDLES_JSF_IMPL</param-name>
<param-value>true</param-value>
</context-param>
In ear META-INF/jboss-deployment-structure.xml
<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure>
<ear-subdeployments-isolated>true</ear-subdeployments-isolated>
<deployment>
<exclusions>
<module name="javax.faces.api" slot="main" />
<module name="com.sun.jsf-impl" slot="main" />
</exclusions>
</deployment>
<sub-deployment name="yourwarfilename.war">
<exclusions>
<module name="javax.faces.api" slot="main" />
<module name="com.sun.jsf-impl" slot="main" />
</exclusions>
</sub-deployment>
</jboss-deployment-structure>
I'm trying to use the last version of libs in my project. But Jboss EAP 6.2 already have some old libs, so i created a jboss-deployment-structure.xml and move to 'WEB-INF/' folder. See the file:
<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<deployment>
<exclusions>
<module name="com.sun.jsf-impl" slot="1.2"/>
<module name="javax.faces.api" slot="1.2" />
<module name="org.jboss.weld.core"/>
</exclusions>
</deployment>
</jboss-deployment-structure>
In my pom.xml i added some libs that i need:
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-api</artifactId>
<version>2.2.13</version>
</dependency>
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-impl</artifactId>
<version>2.2.13</version>
</dependency>
<dependency>
<groupId>org.jboss.weld</groupId>
<artifactId>weld-core</artifactId>
<version>2.3.5.Final</version>
</dependency>
<dependency>
<groupId>org.omnifaces</groupId>
<artifactId>omnifaces</artifactId>
<version>2.4</version>
</dependency>
The jboss should ignore jsf 1.2 and weld provided and use my libs in pom.xml, right ? But when i start the jboss i got the following error:
Caused by: java.lang.NoSuchMethodError: com.sun.faces.util.Util.isCdiOneOneOrGreater()Z
So i changed my jboss-deployment-structure.xml to this:
<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<deployment>
<exclude-subsystems>
<subsystem name="jsf-impl"/>
<subsystem name="weld"/>
</exclude-subsystems>
</deployment>
</jboss-deployment-structure>
Now, console don't show error but when i try access my jsf page i got 404 page not found.
I have a web project with a dependency I want to compile on a different profile so it generates some additional files I want on the web project.
To be more specific, a Web project with a Netbeans Application as dependency. The Netbeans project has a deployment profile that created the update center (just a folder with files in it). I want this update center to be added to the war file for deployment.
Is there a way to make the web project build the dependency on this profile so I get the files I need?
Is there other options to make this work?
Update: Example
<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>
<!-- The Basics -->
<groupId>...</groupId>
<artifactId>...</artifactId>
<version>...</version>
<dependencies>
<dependency>
<groupId>project-of-interest</groupId>
<artifactId>project-id</artifactId>
<version>4.0</version>
<type>jar</type>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.6</version>
<configuration>
<webResources>
<resource>
<!-- this is relative to the pom.xml directory -->
<directory>resource2</directory>
</resource>
</webResources>
</configuration>
</plugin>
</plugins>
</build>
</project>
project-of-interest has a deployment profile in which the files I need are generated and somehow resource2 points to the location of those files.
My main issue is making sure the files I need are available.
you can point to specific profile with maven command
mvn clean install -P $profile
I've been Using Eclipse/Ant for some time and decided to take a look at Netbeans/Maven for my JSF development. Along the way, I thought I'd try to use a version of Mojarra that is newer than the one I have installed in glassfish/modules. I can't seem to get that to work, and since I'm new to both Maven and Netbeans, I'm not sure if it's something with those, or something else.
I've made a very simple app which uses a backing bean to print out the Mojarra version from the index page:
Info.java:
#Named
#RequestScoped
public class Info
{
public String getVersion()
{
return FacesContext.class.getPackage().getImplementationVersion();
}
}
index.xhtml:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://xmlns.jcp.org/jsf/html">
<h:body>
<h:outputText value="The Mojarra version is #{info.version}" />
</h:body>
</html>
When I run this, I see the page contents of
The Mojarra version is 2.2.5
as I'd expect (I put the 2.2.5 jar into glassfish/modules some time back). I then added the dependency for Mojarra 2.2.7 that I found from the Mojarra Web Site:
<dependency>
<groupId>org.glassfish</groupId>
<artifactId>javax.faces</artifactId>
<version>2.2.x</version>
</dependency>
with "x" replaced by "7". The resulting POM file looks like this (most of it is boilerplate from Netbeans):
POM.xml:
<?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.mycompany</groupId>
<artifactId>mavenproject1</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging>
<name>mavenproject1</name>
<properties>
<endorsed.dir>${project.build.directory}/endorsed</endorsed.dir>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-web-api</artifactId>
<version>7.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.glassfish</groupId>
<artifactId>javax.faces</artifactId>
<version>2.2.7</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<compilerArguments>
<endorseddirs>${endorsed.dir}</endorseddirs>
</compilerArguments>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.3</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.6</version>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<outputDirectory>${endorsed.dir}</outputDirectory>
<silent>true</silent>
<artifactItems>
<artifactItem>
<groupId>javax</groupId>
<artifactId>javaee-endorsed-api</artifactId>
<version>7.0</version>
<type>jar</type>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
When I run the app, there is no difference in the output, it still shows version 2.2.5. I found this article with an answer from #BalusC that mentions Glassfish must be explicitly told to override the installed version of faces to use an alternate version deployed with the app, by putting this in WEB-INF/glassfish-web.xml for early versions of GF3:
<class-loader delegate="false" />
<property name="useBundledJsf" value="true" />
Even though I'm using GF4, I thought I'd give it a try, and added a glassfish-web.xml with this:
glassfish-web.xml:
<glassfish-web-app error-url="">
<class-loader delegate="false" />
<property name="useBundledJsf" value="true" />
</glassfish-web-app>
The result is a page that has shows the message with an empty version string:
The Mojarra version is
The GF log also indicates no errors. The .war file that is created includes WEB-INF/lib/javax.faces-2.2.7.jar, so I suspect the problem has something to do with the GF configuration, rather than the Netbeans/Maven packaging.
I know I can download the 2.2.7 jar and put it in the glassfish/modules directory (which is how I began using 2.2.5). But the ultimate goal is to try alternate versions of JSF in an app-specific way (ideally, by just changing Maven coordinates for the JSF dependency), rather than change the GF install. Is there anyway to do this through configuration of the app and without altering the GF install?
Update 9/14/2015:
I built a new Netbeans project:
GlassFish 4.1 (out of the box), which has Mojarra 2.2.7, by default.
NB Maven/Web Application project, with JSF 2.2 Framework.
Modified the index.xhtml file as shown above.
Added a Info.java class, containing the contents, above (javax.enterprise.context.RequestScoped, javax.inject.Named).
Added a WEB-INF/glassfish-web.xml and added the lines shown above.
Added the dependency to the pom.xml file as shown above, but using javax.faces version 2.2.12.
Essentially, I'm getting the same result. If the useBundledJsf property setting is not in the glassfish-web.xml file, the version displays as 2.2.7 (even though the war file has 2.2.12 in it). And if the useBundledJsf property setting is there, along with the change to the class-loader to "false", the version is blank.
I also installed Mojarra 2.2.10 by changing the javax.faces file in the glassfish install to use 2.2.10. When I do that, I get the same results -- either the version is empty, or it shows 2.2.10 (2.2.12 is still configured, and in the war in both cases).
An alternative solution can be to try Payara 4.1.1.154 as it comes bundled with Mojarra 2.2.12
I think this can be a good solution for your needs.
This section details the modules that have been updated since the last release (4.1.153).
Mojarra 2.2.12
Webservices 2.3.2-b608
JAXB 2.2.12-b141219.1637
JAXB-API 2.2.13-b141020.1521
Weld 2.2.16.Final
Tyrus 1.11
JBatch 1.0.1-b09
Grizzly 2.3.23
HK2 2.4.0-b32
Jersey 2.22
Hazelcast 3.5.2