Deploying JSF 1.2 based web application to JBoss EAP 7.0 - jsf

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>

Related

Using jsf 2.2, Weld 2.3.5 with JBOSS 6 EAP

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.

Spring-Data-Cassandra causes XSD validation error using XML configuration

Heyy hello, I have some kind of error that won't affect on my project's compilation,deployment and running But it shows red mark at my configuration file for Spring-data-Cassandra also shows problem in problems menu.
Can any one please tell what's the issue?
I have seen same question related to spring-data-JPA and Spring-data-* but they are not helping so I am posting this one.
here is error message:-
The errors below were detected when validating the file "spring-tool.xsd" via the file "application-config.xml". In most cases these errors can be detected by validating "spring-tool.xsd" directly. However it is possible that errors will only occur when spring-tool.xsd is validated in the context of application-config.xml.
The errors below were detected when validating the file "spring-beans.xsd" via the file "application-config.xml". In most cases these errors can be detected by validating "spring-beans.xsd" directly. However it is possible that errors will only occur when spring-beans.xsd is validated in the context of application-config.xml.
Here is my config.xml file and pom file
<?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:mvc="http://www.springframework.org/schema/mvc"
xmlns:cassandra="http://www.springframework.org/schema/data/cassandra"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc.xsd
http://www.springframework.org/schema/cql
http://www.springframework.org/schema/cql/spring-cql.xsd
http://www.springframework.org/schema/data/cassandra
http://www.springframework.org/schema/data/cassandra/spring-cassandra.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx.xsd
">
<!-- Uncomment and add your base-package here:
<context:component-scan
base-package="org.springframework.samples.service"/> -->
<!-- Loads the properties into the Spring Context and uses them to fill
in placeholders in the bean definitions -->
<context:property-placeholder location="classpath:/properties/database.properties" />
<!-- REQUIRED: The Cassandra Cluster -->
<cassandra:cluster contact-points="${cassandra.contactpoints}"
port="${cassandra.port}" />
<!-- REQUIRED: The Cassandra Session, built from the Cluster, and attaching
to a keyspace -->
<cassandra:session keyspace-name="${cassandra.keyspace}" />
<!-- REQUIRED: The Default Cassandra Mapping Context used by CassandraConverter -->
<cassandra:mapping />
<!-- REQUIRED: The Default Cassandra Converter used by CassandraTemplate -->
<cassandra:converter />
<!-- REQUIRED: The Cassandra Template is the building block of all Spring
Data Cassandra -->
<cassandra:template id="cassandraTemplate" />
</beans>
POM file
<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>org.springframework.samples.service.service</groupId>
<artifactId>XYZ</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<properties>
<!-- Generic properties -->
<java.version>1.6</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<!-- Web -->
<jsp.version>2.2</jsp.version>
<jstl.version>1.2</jstl.version>
<servlet.version>2.5</servlet.version>
<!-- Spring -->
<spring-framework.version>4.0.0.RELEASE</spring-framework.version>
**<!-- I also try this one -->**
<!-- <spring-framework.version>3.2.8.RELEASE</spring-framework.version> -->
<!-- Logging -->
<logback.version>1.0.13</logback.version>
<slf4j.version>1.7.5</slf4j.version>
<!-- Test -->
<junit.version>4.11</junit.version>
</properties>
<dependencies>
<!-- Spring MVC -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${spring-framework.version}</version>
</dependency>
<!-- Other Web dependencies -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>${jstl.version}</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>${servlet.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>jsp-api</artifactId>
<version>${jsp.version}</version>
<scope>provided</scope>
</dependency>
<!-- Spring and Transactions -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
<version>${spring-framework.version}</version>
</dependency>
<!-- Logging with SLF4J & LogBack -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${slf4j.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>${logback.version}</version>
<scope>runtime</scope>
</dependency>
<!-- Test Artifacts -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>${spring-framework.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<!-- Cassandra Connectivity -->
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-cassandra</artifactId>
<version>1.2.2.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
<version>${spring-framework.version}</version>
</dependency>
</dependencies>
<repositories>
<!-- Spring Milestone -->
<repository>
<id>spring-milestone</id>
<name>Spring Maven MILESTONE Repository</name>
<url>http://repo.springsource.org/libs-milestone</url>
</repository>
</repositories>
</project>

How to use alternate version of Mojarra with Glassfish 4 (Netbeans/Maven)

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

Omnifaces as JBoss AS7 module

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.

JSF 2.0 and Richfaces configuration

I'm new in Richfaces framework. In this time I'm trying to add this to my engineering project. Unfortunately have a lot of problem with making this framework running with JSF 2.0 . I've tried to download a lot of maven archetypes but most of them aren't working. Could you point me the place where I can find something like JSF 2.0 + Richfaces 4 blank and configured project? It can be maven as well. I've spend all day today to make it running but things are so complex for me in this time.
You do not need much. You probably need the reposity for the dependencies, the plugin to build the war file, a JSF version (I assume that your container supplies a JSF api+implementation, thus provided), and RichFaces API + implementation.
<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.your.package</groupId>
<artifactId>your.project</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<properties>
<project.build.version>0.0.1-SNAPSHOT</project.build.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<repositories>
<repository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>jboss</id>
<name>JBoss repository</name>
<!-- <url>https://repository.jboss.org/nexus/content/groups/public-jboss/</url> -->
<url>http://repo1.maven.org/maven2/</url>
</repository>
</repositories>
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-api</artifactId>
<version>2.1.22</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-impl</artifactId>
<version>2.1.22</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.richfaces.core</groupId>
<artifactId>richfaces-core-api</artifactId>
<version>4.3.3.Final</version>
</dependency>
<dependency>
<groupId>org.richfaces.core</groupId>
<artifactId>richfaces-core-impl</artifactId>
<version>4.3.3.Final</version>
</dependency>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.4</version>
<configuration>
<webXml>src\main\webapp\WEB-INF\web.xml</webXml>
</configuration>
</plugin>
</plugins>
</build>
</project>

Resources