Reputation: 493
I'm using: Wildfly 8.2, JSF 2.2 (Mojarra 2.2.8) , Omnifaces 2.1 and java 7.
The problem is that I've created some objects and every request they are recreated (null). I also tried using conversationScope but the same thing happens.
Using sessionScope it works.
Controller:
@Named
@ViewScoped
public class Teste implements Serializable {
private static final long serialVersionUID = 1L;
private Map<String, String> passwordReminderUsers;
private String key;
@PostConstruct
public void init() {
if (!FacesContext.getCurrentInstance().isPostback())
passwordReminderUsers = new HashMap<String, String>();
}
public void add() {
passwordReminderUsers.put(key, "b");
}
public String getKey() {
return key;
}
public void setKey(String key) {
this.key = key;
}
}
The passwordReminderUsers
is null
on every postback, causing NPE.
View:
<h:form id="form-login" prependId="false">
<h:inputText value="#{teste.key}" />
<h:commandButton value="add" action="#{teste.add()}" />
</h:form>
I've made some tests doing the request without primefaces, with f:ajax, and several others, nothing works.
this code: JSF view scoped bean: #{authenticator}
shows that every request the bean is recreated.
Maybe related: We were using the JSF 2.0 and updated some months ago to JSF 2.2. I have to use these namespaces:
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.org/ui"
xmlns:c="http://java.sun.com/jsp/jstl/core"
xmlns:pe="http://primefaces.org/ui/extensions"
template="/WEB-INF/templates/default.xhtml">
Because the new xmlns.jcp.org
ones didn't work and started to break the pages and not render jsf components.
MAVEN pom:
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<!-- maven-compiler-plugin -->
<maven.compiler.target>1.7</maven.compiler.target>
<maven.compiler.source>1.7</maven.compiler.source>
</properties>
<repositories>
<repository>
<id>jvnet-nexus-releases</id>
<name>jvnet-nexus-releases</name>
<url>http://maven.java.net/content/repositories/releases/</url>
</repository>
<repository>
<id>jboss-public-repository-group</id>
<name>JBoss Public Repository Group</name>
<url>http://repository.jboss.org/nexus/content/groups/public/</url>
<layout>default</layout>
<releases>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
</snapshots>
</repository>
<repository>
<id>prime-repo</id>
<name>Prime Repo</name>
<url>http://repository.primefaces.org</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>jboss-public-repository-group</id>
<name>JBoss Public Repository Group</name>
<url>http://repository.jboss.org/nexus/content/groups/public/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.wildfly.bom</groupId>
<artifactId>jboss-javaee-7.0-with-hibernate</artifactId>
<version>8.2.0.Final</version>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-web-api</artifactId>
<version>7.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.primefaces</groupId>
<artifactId>primefaces</artifactId>
<version>5.2</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>1.3.2</version>
</dependency>
<dependency>
<groupId>org.omnifaces</groupId>
<artifactId>omnifaces</artifactId>
<version>2.1</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.1.3</version>
</dependency>
Wildfly log on start up
java.class.path = C:\wildfly-8.2.0.Final\jboss-modules.jar
java.class.version = 51.0
java.endorsed.dirs = C:\Program Files\Java\jre7\lib\endorsed
java.ext.dirs = C:\Program Files\Java\jre7\lib\ext;C:\windows\Sun\Java\lib\ext
java.home = C:\Program Files\Java\jre7
java.io.tmpdir = C:\Users\VICTOR~1.BEL\AppData\Local\Temp\
java.library.path = C:\Program Files\Java\jre7\bin;C:\windows\Sun\Java\bin;C:\windows\system32;C:\windows;native;C:\Program Files (x86)\Java\jre7\bin;C:\Program Files\Common Files\Microsoft Shared\Windows Live;C:\Program Files (x86)\Common Files\Microsoft Shared\Windows Live;C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client\;C:\windows\system32;C:\windows;C:\windows\System32\Wbem;C:\windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\maven\apache-maven-3.2.1\bin;C:\Program Files (x86)\Microsoft SQL Server\110\Tools\Binn\;C:\Program Files\Microsoft SQL Server\110\Tools\Binn\;C:\Program Files\Microsoft SQL Server\110\DTS\Binn\;C:\Program Files (x86)\Microsoft SQL Server\110\Tools\Binn\ManagementStudio\;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\PrivateAssemblies\;C:\Program Files (x86)\Microsoft SQL Server\110\DTS\Binn\;c:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\;C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\110\Tools\Binn\;C:\Program Files (x86)\Microsoft SQL Server\120\Tools\Binn\;C:\Program Files\Microsoft SQL Server\120\Tools\Binn\;C:\Program Files\Microsoft SQL Server\120\DTS\Binn\;C:\Program Files (x86)\Microsoft SQL Server\120\Tools\Binn\ManagementStudio\;C:\Program Files (x86)\Microsoft SQL Server\120\DTS\Binn\;C:\Program Files (x86)\Java\jre7\bin;C:\Program Files\Common Files\Microsoft Shared\Windows Live;C:\Program Files (x86)\Common Files\Microsoft Shared\Windows Live;C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client\;C:\windows\system32;C:\windows;C:\windows\System32\Wbem;C:\windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\maven\apache-maven-3.2.1\bin;C:\Program Files (x86)\Microsoft SQL Server\110\Tools\Binn\;C:\Program Files\Microsoft SQL Server\110\Tools\Binn\;C:\Program Files\Microsoft SQL Server\110\DTS\Binn\;C:\Program Files (x86)\Microsoft SQL Server\110\Tools\Binn\ManagementStudio\;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\PrivateAssemblies\;C:\Program Files (x86)\Microsoft SQL Server\110\DTS\Binn\;c:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\;c:\Program Files (x86)\Microsoft SQL Se;c:\cvs.exe;C:\Program Files (x86)\IDM Computer Solutions\UltraEdit\;.;;.;;.;;.
java.net.preferIPv4Stack = true
java.runtime.name = Java(TM) SE Runtime Environment
java.runtime.version = 1.7.0_51-b13
java.specification.name = Java Platform API Specification
java.specification.vendor = Oracle Corporation
java.specification.version = 1.7
java.util.logging.manager = org.jboss.logmanager.LogManager
java.vendor = Oracle Corporation
java.vendor.url = http://java.oracle.com/
java.vendor.url.bug = http://bugreport.sun.com/bugreport/
java.version = 1.7.0_51
java.vm.info = mixed mode
java.vm.name = Java HotSpot(TM) 64-Bit Server VM
java.vm.specification.name = Java Virtual Machine Specification
java.vm.specification.vendor = Oracle Corporation
java.vm.specification.version = 1.7
java.vm.vendor = Oracle Corporation
java.vm.version = 24.51-b03
javax.management.builder.initial = org.jboss.as.jmx.PluggableMBeanServerBuilder
javax.xml.datatype.DatatypeFactory = __redirected.__DatatypeFactory
javax.xml.parsers.DocumentBuilderFactory = __redirected.__DocumentBuilderFactory
javax.xml.parsers.SAXParserFactory = __redirected.__SAXParserFactory
javax.xml.stream.XMLEventFactory = __redirected.__XMLEventFactory
javax.xml.stream.XMLInputFactory = __redirected.__XMLInputFactory
javax.xml.stream.XMLOutputFactory = __redirected.__XMLOutputFactory
javax.xml.transform.TransformerFactory = __redirected.__TransformerFactory
javax.xml.validation.SchemaFactory:http://www.w3.org/2001/XMLSchema = __redirected.__SchemaFactory
javax.xml.xpath.XPathFactory:http://java.sun.com/jaxp/xpath/dom = __redirected.__XPathFactory
jboss.bind.address = localhost
jboss.bind.address.management = localhost
jboss.home.dir = C:\wildfly-8.2.0.Final
jboss.host.name = wvox-000805
jboss.modules.dir = C:\wildfly-8.2.0.Final\modules
jboss.modules.system.pkgs = org.jboss.byteman
jboss.node.name = wvox-000805
jboss.qualified.host.name = wvox-000805
jboss.server.base.dir = C:\wildfly-8.2.0.Final\standalone
jboss.server.config.dir = C:\wildfly-8.2.0.Final\standalone\configuration
jboss.server.data.dir = C:\wildfly-8.2.0.Final\standalone\data
jboss.server.deploy.dir = C:\wildfly-8.2.0.Final\standalone\data\content
jboss.server.log.dir = C:\wildfly-8.2.0.Final\standalone\log
jboss.server.name = wvox-000805
jboss.server.persist.config = true
jboss.server.temp.dir = C:\wildfly-8.2.0.Final\standalone\tmp
line.separator =
logging.configuration = file:/C:/wildfly-8.2.0.Final/standalone/configuration/logging.properties
module.path = C:/wildfly-8.2.0.Final/modules
org.jboss.boot.log.file = C:/wildfly-8.2.0.Final/standalone/log/boot.log
org.jboss.logmanager.nocolor = true
org.jboss.resolver.warning = true
org.xml.sax.driver = __redirected.__XMLReaderFactory
os.arch = amd64
os.name = Windows 7
os.version = 6.1
path.separator = ;
program.name = JBossTools: WildFly 8.x
sun.arch.data.model = 64
sun.boot.class.path = C:\Program Files\Java\jre7\lib\resources.jar;C:\Program Files\Java\jre7\lib\rt.jar;C:\Program Files\Java\jre7\lib\sunrsasign.jar;C:\Program Files\Java\jre7\lib\jsse.jar;C:\Program Files\Java\jre7\lib\jce.jar;C:\Program Files\Java\jre7\lib\charsets.jar;C:\Program Files\Java\jre7\lib\jfr.jar;C:\Program Files\Java\jre7\classes
sun.boot.library.path = C:\Program Files\Java\jre7\bin
sun.cpu.endian = little
sun.cpu.isalist = amd64
sun.desktop = windows
sun.io.unicode.encoding = UnicodeLittle
sun.java.command = org.jboss.modules.Main -mp C:/wildfly-8.2.0.Final/modules -jaxpmodule javax.xml.jaxp-provider org.jboss.as.standalone -b localhost --server-config=standalone.xml -Djboss.server.base.dir=C:\wildfly-8.2.0.Final\standalone
sun.java.launcher = SUN_STANDARD
sun.jnu.encoding = Cp1252
sun.management.compiler = HotSpot 64-Bit Tiered Compilers
sun.os.patch.level = Service Pack 1
sun.rmi.dgc.client.gcInterval = 3600000
sun.rmi.dgc.server.gcInterval = 3600000
user.country = US
user.country.format = BR
user.dir = C:\wildfly-8.2.0.Final\bin
Upvotes: 2
Views: 622
Reputation: 1108732
Maybe related: We were using the JSF 2.0 and updated some months ago to JSF 2.2. I have to use these namespaces [snip] Because the new xmlns.jcp.org ones didn't work and started to break the pages and not render jsf components
This is definitely a strong clue that you are actually not using JSF 2.2, but still an older version. If that happened while running on WildFly, which is supposed to already provide JSF 2.2 out the box, then this means that your runtime classpath is polluted with multiple different JSF versions, or that the WildFly instance is modified.
It should work fine on a stock and unmodified WildFly instance.
Upvotes: 1