Skip to main content

12. Migrating a JSF to Maven. Possible problems

Some problems may occur:

1. If you are copying a project folder from a source into an elder project, be carefull that some different classes may share the same @Named (value = "shared name"). If you run the project, the server may not been able to start up! The error is

SEVERE: A child container failed during start
java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/OpenWebMaven]]

You should go over and see some clue of the error:

Caused by: org.jboss.weld.exceptions.DeploymentException: WELD-001414: Bean name is ambiguous. Name lang resolves to beans: [Managed Bean [class openadmin.util.lang.LangType] with qualifiers [@Default @Any @Named], Managed Bean [class openadmin.util.lang.LangTypeEdu] with qualifiers [@Default @Any @Named]]

-----------------------------------------------------------------------------------


2. If you cannot change in project facets from Dynamic Web Module 4.0 to 3.1, you should create a new maven project and copy classes and resources. Note that DynamicWeb Module 4.0 and Java 9 may reject to deploy on Tomcat 9.0 !!! And you can get this error when running: 

The selection cannot be run on a server !

-----------------------------------------------------------------------------------


3. If beans are not reachable in a xhtml file. Maybe you have not included the files beans.xml and faces-config.xml file inside /src/main/webapp/WEB-INF folder. The error is

javax.el.PropertyNotFoundException: /index.xhtml @17,44 value="#{user.Name}": Target Unreachable, identifier 'user' resolved to null

-----------------------------------------------------------------------------------


5. Some of the dependencies may get unreachable. Try to google "maven missing_dependency" where missing_dependency is, for instance, JAXBException and locate the jar and download it (from the maven repository) and include it in your BuildPath

-----------------------------------------------------------------------------------


6. Postgres reports some strange errors while trying to connect such as :

[PersistenceUnit: control_post] Unable to build Hibernate SessionFactory
......
Caused by: org.postgresql.util.PSQLException: ERROR: column am.amcanorder does not exist

Cause: You are using a new version of PostgreSQL >= 9.6
Solution: You have to change old jar postgresql-9.4-1201.jdbc41.jar 

                with the newest one:          postgresql-42.2.1.jar

-----------------------------------------------------------------------------------


7. Hibernate cannot find JNDI resources to JDBC

Cause: Maybe the file context.xml is not located in WebContent/META-INF folder.

-----------------------------------------------------------------------------------


8. Maybe you can load data tables from ASCII text file. And you get a resource bundle error:

java.util.MissingResourceException: Can't find resource for 
        bundle java.util.PropertyResourceBundle, 
        key openadmin_model_control_atributo_default
java.base/java.util.ResourceBundle.getObject(ResourceBundle.java:544)
java.base/java.util.ResourceBundle.getString(ResourceBundle.java:501)
openadmin.util.lang.LangType.msgGenerals(LangType.java:34)

make sure you have NOT this entrance in ViewRoleData.txt:

openadmin.model.control.Atributo

and reload the data from ASCII files (and verify all entrances are in the resource bundle)

-----------------------------------------------------------------------------------


9. When you execute Run as --> Run on Server, an error may occur that cannot load session from persistent storage

SEVERE: Exception loading sessions from persistent storage
java.io.InvalidObjectException: Could not find a SessionFactory [uuid=15bf1712-5aa2-4a8e-99a0-ca505077750c,name=null]

Will Keeling proposes:

This is to do with Tomcat not being able to load previously serialized web sessions that had been saved on an earlier shutdown. This may be because Tomcat didn't shutdown cleanly and so session objects got corrupted during serialization.
One way to make this error go away would be to disable session persistence across restarts. You can do this by editing the file CATALINA_HOME/conf/context.xml and setting the pathnameattribute of the <Manager> to an empty string. This is well documented in the file for Tomcat 7:
<!-- Uncomment this to disable session persistence across Tomcat restarts -->

<Manager pathname="" />
You should also delete any old session.ser files from the CATALINA_HOME/work/Catalina/localhost/<appName> folder whilst Tomcat is shutdown.
This may not be acceptable in your case if session persistence across restarts is needed. In which case further debugging of the issue would be necessary.

Comments

Popular posts from this blog

10. JSF How to access my resources files?

Sometimes it is really difficult to access any resources form different Java applications. So let's see some scenarios: 1. Executable jar application in a NO WEB environment. Take into account that this is not a JSF application !!! It is desired to have a property file outside the "jar file" so that we can change properties when needed. For instance, we will place the properties file in the same folder that the "jar file" lies. To access the folder where the jar is, the trick is to access the folder where the compiled classed are placed and scale 3 folders . (Oh! rather strange, if anybody knows a better idea.., he will be welcome). Here is a simple code. The name of the class containing the code is ThisClass, and we have created a Property class that feeds with a file in the same folder that the" jar file" 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 /** * Gets the folder where resides the executable

2. Create a Maven JSF project and a simple login page

Updated on Oct-25-2107 0. Introduction Remember to install previously: Java JDK 8 Eclipse Oxygen Lombok  Apache Tomcat 9 1. Create a Maven Project In the top menu select : File - New - Maven Project Press Next Now fill the next form as follows It is important to select: Group id: org.ximodante.jsf  (or another packet you like) Packaging: war Artifact Id and Name: JSFv02 or any name for the project Press Finish 2. The pom.xml file Eclipse complains about the simple generated file. It seems that a web.xml is required if the packaging is selected to war. The simple generated file is  1 2 3 4 5 6 7 8 9 <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.ximodante

9. JSF: Solving common problems

1. Target Unreachable, identifier [bean] resolved to null When you reference a bean in a xhtml file with "#{bean.method}" and get this error, you should verify that: The bean implements Serializable . The references (javax.servlet-api.4.0.0, javax.faces.2.3.3,  javax.el.api.3.0.1, org.primefaces.6.1) have been selected in your pom.xml You have created the files bean.xml and faces-config.xml in the webapp/WEB-INF folder You have used the correct annotations from CDI  (javax.inject.Named and javax.enterprise.context.SessionScoped, ...) and not ManagedBean or jsf2.2 scopes. 2. Bean declaring a passivating scope must be passivation capable This error causes server not starting and fills up the console with long chained exceptions. It is very annoying. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 SEVERE: A child container failed during start java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start co