Getting localized messages from a jar file - jsf

I am currently refactoring common resources (css, images & javascript) of two belonging frontend (web) projects into a separate jar file and it works perfectly fine.
Now I am trying to do the same with localized messages, but I must be missing something, as I only get the keys of the 'default' messages, without localization.
My jar file is structured like this:
faces-util.jar
|--META-INF
|--resources
|--css
|--images
|--js
Putting the messages files directly in the root folder (src/main/resources) it works, but only for the default locale (messages.properties). Localized message files like messages_de.properties are ignored.
Here is my faces-config.xml:
<?xml version='1.0' encoding='UTF-8'?>
<faces-config version="2.2"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_2.xsd">
<application>
<locale-config>
<default-locale>en</default-locale>
<supported-locale>de</supported-locale>
</locale-config>
<resource-bundle>
<base-name>messages</base-name>
<var>msg</var>
</resource-bundle>
</application>
</faces-config>
I tried putting faces-config.xml inside /META-INF or /META-INF/resources but without success.
In the web projects I have the standard config faces-config.xml inside WEB-INF and the messages properties files in /src/main/resources.
What am I doing wrong? Can anybody give me a hint?
Thx in advance

Related

IBM AppScan - Missing Secure Attribute in Encrypted Session (SSL) Cookie

We have got an Missing Secure Attribute in Encrypted Session (SSL) Cookie issue for primefaces.download based on IBM App Scan DSAT test.
Primefaces version is 7.0
Sample Example : https://www.primefaces.org/showcase/ui/data/dataexporter/basic.xhtml
primefaces.download -- this cookies is set when we download a file
We already have session-config in the web.xml , but when i check in chrome the primefaces.download cookie is not set as http-only and secured .
Is there anything else required to be done when running it on JBOSS 7.2?
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
..........
<session-config>
<cookie-config>
<http-only>true</http-only>
<secure>true</secure>
</cookie-config>
<tracking-mode>COOKIE</tracking-mode>
</session-config>
Updated :
Issue raised
https://github.com/primefaces/primefaces/issues/6040
A Pull Request to fix the issue in 9.0-SNAPSHOT has been submitted.
https://github.com/primefaces/primefaces/pull/6041

spring integration 4.1.4. exception : Unable to locate NamespaceHandler for XML schema

I used spring 2.2. and I have recently upgraded to spring 4.1.4.
My project uses the the following application context:
<?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:int="http://www.springframework.org/schema/integration"
xmlns:int-file="http://www.springframework.org/schema/integration/file"
xmlns:task="http://www.springframework.org/schema/task"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/task
http://www.springframework.org/schema/task/spring-task.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/integration
classpath:com/alu/motive/smdm/mediation/process/orchestration/activity/spring-integration.xsd">
Note that I am using classpath to refer to the spring integration xsd file as I did not see the spring.shemas in the spring jar file.
When I run the application, I receive the following exception:
Exception in thread "Thread-8" org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Unable to locate Spring NamespaceHandler for XML schema namespace [http://www.springframework.org/schema/integration]
Likely, the root cause comes from the absence of the spring.handlers file.
Could you tell me what is the best way to solve my issues?
Unfortunately your namespace config isn't full.
You declare int and int-file nls, bu don't declare their schemaLocation.
If you really are interested in the Spring Integration and have appropriate jars in the classpath, please, add their schemaLocation:
http://www.springframework.org/schema/integration/file http://www.springframework.org/schema/integration/file/spring-integration-file.xsd
http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd
I have just found my issue.
I had forgotten to add spring-integration-core-4.1.2.RELEASE.jar in my classpath.
FI, i have no more need to use classpath in the application context xml file.
The spring.shemas & spring.handlers files are included spring-integration-core-4.1.2.RELEASE.jar.

JBoss AS 7.1 Clustering with JSF

I am trying to cluster enable my JSF 2.1 application (mojarra 2.1, Primefaces) on Jboss AS 7.2 (EAP 6.3) And I have researched this issue wihtou being able to find an answer.
I have deployed the application to two nodes and logged into the application. The I shut down the node that was being used and when I try to use the application again, I am directed to a login page. The have printed the session id and it changes when I hit the new node.
I have deployed a sample cluster bench (https://github.com/clusterbench/clusterbench) and the examples all work, with the exception of the JSF sample. The session id is always lost when a node goes down.
My web.xml is:
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
<distributable />
...
</web-app>
My jboss.web.xml is:
<jboss-web version="6.0"
xmlns="http://www.jboss.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.jboss.com/xml/ns/javaee http://www.jboss.org/j2ee/schema/jboss-web_6_0.xsd">
<replication-config>
<!-- The default value is SET_AND_NON_PRIMITIVE_GET, therefore the byte array which is carrying the data is considered
non-primitive and would cause replication even in read only scenario. -->
<replication-trigger>SET</replication-trigger>
<!-- Replicating entire session is the default. -->
<replication-granularity>SESSION</replication-granularity>
</replication-config>
<context-root>/sample</context-root>
</jboss-web>

requested resource is not available

I am using JSF in one of my application and the scenario is as follows:
1.I have a pages folder under WEB_INF
2.Inside pages I have a.jsp
3.When I deploy this application with the local tomcat it says "The requested resource (/pages/a.jsp) is not available."
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaeehttp://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
<display-name>Sample_Proj</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>AddUser.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
</web-app>
Is there anything else i need to add into web.xml?
The below url is what I'm using to hit the page:
http://localhost:8080/Sample_Proj/WEB-INF/page/AddUser.jsp
Your jsp files / folders should exist in the root of the web project and not in the WEB-INF folder, i.e.:
/pages/a.jsp
/WEB-INF/...
Your web.xml file is very much incomplete when it comes to a JSF web project. I would recommend reading the Java EE 6 tutorial, you can read through this chapter on getting started with web applications

English error messages in JSF 2.0.3 (not validation)?

I had configured JSF 1.2 successfully to display English error messages that come from the server. Now I was making the transition to JSF 2.0, but the error messages seem to be back to German. Localized error messages are a real pain if you want to google up anything (I have no idea who decided localized error messages to be a good thing BTW!).
Here's the faces-config.xml:
<?xml version="1.0" encoding="UTF-8"?>
<faces-config version="2.0"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd">
<application>
<!-- view handler only for JSF 1.2 -->
<!--view-handler>com.sun.facelets.FaceletViewHandler</view-handler-->
<locale-config>
<default-locale>en</default-locale>
<supported-locale>en</supported-locale>
<supported-locale>en_US</supported-locale>
</locale-config>
</application>
</faces-config>
I'm using JSF 2.0.3 as shipped with JBAS 6, plus Seam and RichFaces.
Does anyone know how to get error messages in English language? Maybe config from the deployer or JBAS 6 itself?
Edit: the error messages appear at server startup as launched from inside Eclipse.
The message comes from your container, not from JSF.
You can change your regional settings or add the JVM parameter -Duser.language=en when you start the container.

Resources