4.3.6. Debug and Resolve Seam 2.2 Booking Archive Deployment Errors and Exceptions
Important
Procedure 4.16. Debug and resolve deployment errors and exceptions
- Issue - java.lang.ClassNotFoundException: javax.faces.FacesExceptionWhen you deploy the application, the log contains the following error:
ERROR \[org.jboss.msc.service.fail\] (MSC service thread 1-1) MSC00001: Failed to start service jboss.deployment.subunit."jboss-seam-booking.ear"."jboss-seam-booking.war".POST_MODULE: org.jboss.msc.service.StartException in service jboss.deployment.subunit."jboss-seam-booking.ear"."jboss-seam-booking.war".POST_MODULE: Failed to process phase POST_MODULE of subdeployment "jboss-seam-booking.war" of deployment "jboss-seam-booking.ear" (.. additional logs removed ...) Caused by: java.lang.ClassNotFoundException: javax.faces.FacesException from \[Module "deployment.jboss-seam-booking.ear:main" from Service Module Loader\] at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:191)
What it means:The ClassNotFoundException indicates a missing dependency. In this case, it cannot find the class
javax.faces.FacesException
and you need to explicitly add the dependency.How to resolve it:Find the module name for that class in the EAP6_HOME/modules directory by looking for a path that matches the missing class. In this case, you find 2 modules that match:
javax/faces/api/main javax/faces/api/1.2
Both modules have the same module name:javax.faces.api
but one in the main directory is for JSF 2.0 and the one located in the 1.2 directory is for JSF 1.2. If there was only one module available, you could simply create aMANIFEST.MF
file and added the module dependency. But in this case, you want to use the JSF 1.2 version and not the 2.0 version in main, so you need to specify one and exclude the other. To do this, you create ajboss-deployment-structure.xml
file in the EAR'sMETA-INF/
directory that contains the following data:<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.0"> <deployment> <dependencies> <module name="javax.faces.api" slot="1.2" export="true"/> </dependencies> </deployment> <sub-deployment name="jboss-seam-booking.war"> <exclusions> <module name="javax.faces.api" slot="main"/> </exclusions> <dependencies> <module name="javax.faces.api" slot="1.2"/> </dependencies> </sub-deployment> </jboss-deployment-structure>
In thedeployment
section, you add the dependency for thejavax.faces.api
for the JSF 1.2 module. You also add the dependency for the JSF 1.2 module in the subdeployment section for the WAR and exclude the module for JSF 2.0.Redeploy the application by deleting thestandalone/deployments/jboss-seam-booking.ear.failed
file and creating a blankjboss-seam-booking.ear.dodeploy
file in the same directory. - Issue - java.lang.ClassNotFoundException: org.apache.commons.logging.LogWhen you deploy the application, the log contains the following error:
ERROR [org.jboss.msc.service.fail] (MSC service thread 1-8) MSC00001: Failed to start service jboss.deployment.unit."jboss-seam-booking.ear".INSTALL: org.jboss.msc.service.StartException in service jboss.deployment.unit."jboss-seam-booking.ear".INSTALL: Failed to process phase INSTALL of deployment "jboss-seam-booking.ear" (.. additional logs removed ...) Caused by: java.lang.ClassNotFoundException: org.apache.commons.logging.Log from [Module "deployment.jboss-seam-booking.ear.jboss-seam-booking.war:main" from Service Module Loader]
What it means:The
ClassNotFoundException
indicates a missing dependency. In this case, it cannot find the classorg.apache.commons.logging.Log
and you need to explicitly add the dependency.How to resolve it:Find the module name for that class in the
EAP6_HOME/modules/
directory by looking for a path that matches the missing class. In this case, you find one module that matches the pathorg/apache/commons/logging/
. The module name is “org.apache.commons.logging”.Modify thejboss-deployment-structure.xml
file to add the module dependency to the deployment section of the file.<module name="org.apache.commons.logging" export="true"/>
Thejboss-deployment-structure.xml
should now look like this:<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.0"> <deployment> <dependencies> <module name="javax.faces.api" slot="1.2" export="true"/> <module name="org.apache.commons.logging" export="true"/> </dependencies> </deployment> <sub-deployment name="jboss-seam-booking.war"> <exclusions> <module name="javax.faces.api" slot="main"/> </exclusions> <dependencies> <module name="javax.faces.api" slot="1.2"/> </dependencies> </sub-deployment> </jboss-deployment-structure>
Redeploy the application by deleting thestandalone/deployments/jboss-seam-booking.ear.failed
file and creating a blankjboss-seam-booking.ear.dodeploy
file in the same directory. - Issue - java.lang.ClassNotFoundException: org.dom4j.DocumentExceptionWhen you deploy the application, the log contains the following error:
ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/seam-booking]] (MSC service thread 1-3) Exception sending context initialized event to listener instance of class org.jboss.seam.servlet.SeamListener: java.lang.NoClassDefFoundError: org/dom4j/DocumentException (... additional logs removed ...) Caused by: java.lang.ClassNotFoundException: org.dom4j.DocumentException from [Module "deployment.jboss-seam-booking.ear.jboss-seam.jar:main" from Service Module Loader]
What it means:The
ClassNotFoundException
indicates a missing dependency. In this case, it cannot find the classorg.dom4j.DocumentException
.How to resolve it:Find the module name in the
EAP6_HOME/modules/
directory by looking for theorg/dom4j/DocumentException
. The module name is “org.dom4j”. Modify thejboss-deployment-structure.xml
file to add the module dependency to the deployment section of the file.<module name="org.dom4j" export="true"/>
The jboss-deployment-structure.xml file should now look like this:<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.0"> <deployment> <dependencies> <module name="javax.faces.api" slot="1.2" export="true"/> <module name="org.apache.commons.logging" export="true"/> <module name="org.dom4j" export="true"/> </dependencies> </deployment> <sub-deployment name="jboss-seam-booking.war"> <exclusions> <module name="javax.faces.api" slot="main"/> </exclusions> <dependencies> <module name="javax.faces.api" slot="1.2"/> </dependencies> </sub-deployment> </jboss-deployment-structure>
Redeploy the application by deleting thestandalone/deployments/jboss-seam-booking.ear.failed
file and creating a blankjboss-seam-booking.ear.dodeploy
file in the same directory. - Issue - java.lang.ClassNotFoundException: org.hibernate.validator.InvalidValueWhen you deploy the application, the log contains the following error:
ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/seam-booking]] (MSC service thread 1-6) Exception sending context initialized event to listener instance of class org.jboss.seam.servlet.SeamListener: java.lang.RuntimeException: Could not create Component: org.jboss.seam.international.statusMessages (... additional logs removed ...) Caused by: java.lang.ClassNotFoundException: org.hibernate.validator.InvalidValue from [Module "deployment.jboss-seam-booking.ear.jboss-seam.jar:main" from Service Module Loader]
What it means:The
ClassNotFoundException
indicates a missing dependency. In this case, it cannot find the classorg.hibernate.validator.InvalidValue
.How to resolve it:There is a module “org.hibernate.validator”, but the JAR does not contain the
org.hibernate.validator.InvalidValue
class, so adding the module dependency does not resolve this issue. In this case, the JAR containing the class was part of the JBoss Enterprise Application Platform 5.1 deployment. Look for the JAR that contains the missing class in theEAP5_HOME/jboss-eap-5.1/seam/lib/
directory. To do this, open a console and type the following:$ cd EAP5_HOME/jboss-eap-5.1/seam/lib $ grep 'org.hibernate.validator.InvalidValue' `find . -name '*.jar'
The result shows:$ Binary file ./hibernate-validator.jar matches $ Binary file ./test/hibernate-all.jar matches
In this case, copy thehibernate-validator.jar
to thejboss-seam-booking.ear/lib/
directory:$ cp EAP5_HOME/jboss-eap-5.1/seam/lib/hibernate-validator.jar jboss-seam-booking.ear/lib
Redeploy the application by deleting thestandalone/deployments/jboss-seam-booking.ear.failed
file and creating a blankjboss-seam-booking.ear.dodeploy
file in the same directory. - Issue - java.lang.InstantiationException: org.jboss.seam.jsf.SeamApplicationFactoryWhen you deploy the application, the log contains the following error:
INFO [javax.enterprise.resource.webcontainer.jsf.config] (MSC service thread 1-7) Unsanitized stacktrace from failed start...: com.sun.faces.config.ConfigurationException: Factory 'javax.faces.application.ApplicationFactory' was not configured properly. at com.sun.faces.config.processor.FactoryConfigProcessor.verifyFactoriesExist(FactoryConfigProcessor.java:296) [jsf-impl-2.0.4-b09-jbossorg-4.jar:2.0.4-b09-jbossorg-4] (... additional logs removed ...) Caused by: javax.faces.FacesException: org.jboss.seam.jsf.SeamApplicationFactory at javax.faces.FactoryFinder.getImplGivenPreviousImpl(FactoryFinder.java:606) [jsf-api-1.2_13.jar:1.2_13-b01-FCS] (... additional logs removed ...) at com.sun.faces.config.processor.FactoryConfigProcessor.verifyFactoriesExist(FactoryConfigProcessor.java:294) [jsf-impl-2.0.4-b09-jbossorg-4.jar:2.0.4-b09-jbossorg-4] ... 11 more Caused by: java.lang.InstantiationException: org.jboss.seam.jsf.SeamApplicationFactory at java.lang.Class.newInstance0(Class.java:340) [:1.6.0_25] at java.lang.Class.newInstance(Class.java:308) [:1.6.0_25] at javax.faces.FactoryFinder.getImplGivenPreviousImpl(FactoryFinder.java:604) [jsf-api-1.2_13.jar:1.2_13-b01-FCS] ... 16 more
What it means:The
com.sun.faces.config.ConfigurationException
andjava.lang.InstantiationException
indicate a dependency issue. In this case, the cause is not as obvious.How to resolve it:You need to find the module that contains the
com.sun.faces
classes. While there is nocom.sun.faces
module, there are are twocom.sun.jsf-impl
modules. A quick check of thejsf-impl-1.2_13.jar
in the 1.2 directory shows it contains thecom.sun.faces
classes. As you did with thejavax.faces.FacesException
ClassNotFoundException
, you want to use the JSF 1.2 version and not the JSF 2.0 version in main, so you need to specify one and exclude the other. You need to modify thejboss-deployment-structure.xml
to add the module dependency to the deployment section of the file. You also need to add it to the WAR subdeployment and exclude the JSF 2.0 module. The file should now look like this:<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.0"> <deployment> <dependencies> <module name="javax.faces.api" slot="1.2" export="true"/> <module name="com.sun.jsf-impl" slot="1.2" export="true"/> <module name="org.apache.commons.logging" export="true"/> <module name="org.dom4j" export="true"/> </dependencies> </deployment> <sub-deployment name="jboss-seam-booking.war"> <exclusions> <module name="javax.faces.api" slot="main"/> <module name="com.sun.jsf-impl" slot="main"/> </exclusions> <dependencies> <module name="javax.faces.api" slot="1.2"/> <module name="com.sun.jsf-impl" slot="1.2"/> </dependencies> </sub-deployment> </jboss-deployment-structure>
Redeploy the application by deleting thestandalone/deployments/jboss-seam-booking.ear.failed
file and creating a blankjboss-seam-booking.ear.dodeploy
file in the same directory. - Issue - java.lang.ClassNotFoundException: org.apache.commons.collections.ArrayStackWhen you deploy the application, the log contains the following error:
ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/seam-booking]] (MSC service thread 1-1) Exception sending context initialized event to listener instance of class com.sun.faces.config.ConfigureListener: java.lang.RuntimeException: com.sun.faces.config.ConfigurationException: CONFIGURATION FAILED! org.apache.commons.collections.ArrayStack from [Module "deployment.jboss-seam-booking.ear:main" from Service Module Loader] (... additional logs removed ...) Caused by: java.lang.ClassNotFoundException: org.apache.commons.collections.ArrayStack from [Module "deployment.jboss-seam-booking.ear:main" from Service Module Loader]
What it means:The
ClassNotFoundException
indicates a missing dependency. In this case, it cannot find the classorg.apache.commons.collections.ArrayStack
.How to resolve it:Find the module name in the
EAP6_HOME/modules/
directory by looking for theorg/apache/commons/collections
path. The module name is “org.apache.commons.collections”. Modify the jboss-deployment-structure.xml to add the module dependency to the deployment section of the file.<module name="org.apache.commons.collections" export="true"/>
The jboss-deployment-structure.xml file should now look like this:<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.0"> <deployment> <dependencies> <module name="javax.faces.api" slot="1.2" export="true"/> <module name="com.sun.jsf-impl" slot="1.2" export="true"/> <module name="org.apache.commons.logging" export="true"/> <module name="org.dom4j" export="true"/> <module name="org.apache.commons.collections" export="true"/> </dependencies> </deployment> <sub-deployment name="jboss-seam-booking.war"> <exclusions> <module name="javax.faces.api" slot="main"/> <module name="com.sun.jsf-impl" slot="main"/> </exclusions> <dependencies> <module name="javax.faces.api" slot="1.2"/> <module name="com.sun.jsf-impl" slot="1.2"/> </dependencies> </sub-deployment> </jboss-deployment-structure>
Redeploy the application by deleting thestandalone/deployments/jboss-seam-booking.ear.failed
file and creating a blankjboss-seam-booking.ear.dodeploy
file in the same directory. - Issue - Services with missing/unavailable dependenciesWhen you deploy the application, the log contains the following error:
ERROR [org.jboss.as.deployment] (DeploymentScanner-threads - 2) {"Composite operation failed and was rolled back. Steps that failed:" => {"Operation step-2" => {"Services with missing/unavailable dependencies" => ["jboss.deployment.subunit.\"jboss-seam-booking.ear\".\"jboss-seam-booking.jar\".component.AuthenticatorAction.START missing [ jboss.naming.context.java.comp.jboss-seam-booking.\"jboss-seam-booking.jar\".AuthenticatorAction.\"env/org.jboss.seam.example.booking.AuthenticatorAction/em\" ]","jboss.deployment.subunit.\"jboss-seam-booking.ear\".\"jboss-seam-booking.jar\".component.HotelSearchingAction.START missing [ jboss.naming.context.java.comp.jboss-seam-booking.\"jboss-seam-booking.jar\".HotelSearchingAction.\"env/org.jboss.seam.example.booking.HotelSearchingAction/em\" ]"," (... additional logs removed ...) "jboss.deployment.subunit.\"jboss-seam-booking.ear\".\"jboss-seam-booking.jar\".component.BookingListAction.START missing [ jboss.naming.context.java.comp.jboss-seam-booking.\"jboss-seam-booking.jar\".BookingListAction.\"env/org.jboss.seam.example.booking.BookingListAction/em\" ]","jboss.persistenceunit.\"jboss-seam-booking.ear/jboss-seam-booking.jar#bookingDatabase\" missing [ jboss.naming.context.java.bookingDatasource ]"]}}}
What it means:When you get a “Services with missing/unavailable dependencies” error, look at the text within the brackets after “missing”. In this case you see:
missing [ jboss.naming.context.java.comp.jboss-seam-booking.\"jboss-seam-booking.jar\".AuthenticatorAction.\"env/org.jboss.seam.example.booking.AuthenticatorAction/em\" ]
The “/em” indicates an Entity Manager and datasource issue.How to resolve it:In JBoss Enterprise Application Platform 6, datasource configuration has changed and needs to be defined in the
standalone/configuration/standalone.xml
file. Since JBoss Enterprise Application Platform 6 ships with an example database that is already defined in thestandalone.xml
file, modify thepersistence.xml
file to use that example database in this application. Looking in thestandalone.xml
file, you can see that thejndi-name
for the example database isjava:jboss/datasources/ExampleDS
. Modify thejboss-seam-booking.jar/META-INF/persistence.xml
file to comment the existingjta-data-source
element and replace it as follows:<!-- <jta-data-source>java:/bookingDatasource</jta-data-source> --> <jta-data-source>java:jboss/datasources/ExampleDS</jta-data-source>
Redeploy the application by deleting thestandalone/deployments/jboss-seam-booking.ear.failed
file and creating a blankjboss-seam-booking.ear.dodeploy
file in the same directory. - Issue - java.lang.ClassNotFoundException: org.hibernate.cache.HashtableCacheProviderWhen you deploy the application, the log contains the following error:
ERROR [org.jboss.msc.service.fail] (MSC service thread 1-4) MSC00001: Failed to start service jboss.persistenceunit."jboss-seam-booking.ear/jboss-seam-booking.jar#bookingDatabase": org.jboss.msc.service.StartException in service jboss.persistenceunit."jboss-seam-booking.ear/jboss-seam-booking.jar#bookingDatabase": Failed to start service at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1786) (... log messages removed ...) Caused by: java.lang.ClassNotFoundException: org.hibernate.cache.HashtableCacheProvider from [Module "org.hibernate:main" from local module loader @12a3793 (roots: /home/sgilda/tools/jboss7/modules)] at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:191) (... log messages removed ...)
What it means:The
ClassNotFoundException
indicates a missing dependency. In this case, it cannot find the classorg.hibernate.cache.HashtableCacheProvider
.How to resolve it:There is no module for “org.hibernate.cache”. In this case, the JAR containing the class was part of the JBoss Enterprise Application Platform 5.1 deployment. Look for the JAR that contains the missing class in the
EAP5_HOME/jboss-eap-5.1/seam/lib/
directory. To do this, open a console and type the following:$ cd EAP5_HOME/jboss-eap-5.1/seam/lib $ grep 'org.hibernate.validator.InvalidValue' `find . -name '*.jar'`
The result shows:Binary file ./hibernate-core.jar matches Binary file ./test/hibernate-all.jar matches
In this case, copy thehibernate-core.jar
to thejboss-seam-booking.ear/lib/
directory:cp EAP5_HOME/jboss-eap-5.1/seam/lib/hibernate-core.jar jboss-seam-booking.ear/lib
Redeploy the application by deleting thestandalone/deployments/jboss-seam-booking.ear.failed
file and creating a blankjboss-seam-booking.ear.dodeploy
file in the same directory. - Issue - java.lang.ClassCastException: org.hibernate.cache.HashtableCacheProviderWhen you deploy the application, the log contains the following error:
ERROR [org.jboss.msc.service.fail] (MSC service thread 1-2) MSC00001: Failed to start service jboss.persistenceunit."jboss-seam-booking.ear/jboss-seam-booking.jar#bookingDatabase": org.jboss.msc.service.StartException in service jboss.persistenceunit."jboss-seam-booking.ear/jboss-seam-booking.jar#bookingDatabase": Failed to start service at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1786) (... log messages removed ...) Caused by: java.lang.ClassCastException: org.hibernate.cache.HashtableCacheProvider cannot be cast to org.hibernate.cache.spi.CacheProvider at org.hibernate.cache.internal.bridge.RegionFactoryCacheProviderBridge.init(RegionFactoryCacheProviderBridge.java:65) ... 20 more
What it means:A
ClassCastException
can be a result of many problems. If you look at this exception in the log, it appears the classorg.hibernate.cache.HashtableCacheProvider
extendsorg.hibernate.cache.spi.CacheProvider
and is being loaded by a different class loader than the class it extends. Theorg.hibernate.cache.HashtableCacheProvider
class is in in thehibernate-core.jar
and is being loaded by the application class loader. The class it extends,org.hibernate.cache.spi.CacheProvider
, is in theorg/hibernate/main/hibernate-core-4.0.0.Beta1.jar
and is implicitly loaded by that module. This is not obvious, but due to changes in Hibernate 4, this problem is caused by a backward compatibility issue due moving theHashtableCacheProvider
class into another package. This class was moved from theorg.hibernate.cache
package to theorg.hibernate.cache.internal
package. If you don't remove thehibernate.cache.provider_class
property from thepersistence.xml
file, it forces the Seam application to bundle the old Hibernate libraries, resulting inClassCastExceptions
. In JBoss Enterprise Application Platform6, you should move away from using HashtableCacheProvider and use Infinispan instead.How to resolve it:In JBoss Enterprise Application Platform 6, comment out the
hibernate.cache.provider_class property
in thejboss-seam-booking.jar/META-INF/persistence.xml
file as follows:<!-- <property name="hibernate.cache.provider_class" value="org.hibernate.cache.HashtableCacheProvider"/> -->
Redeploy the application by deleting thestandalone/deployments/jboss-seam-booking.ear.failed
file and creating a blankjboss-seam-booking.ear.dodeploy
file in the same directory. - At this point, the application deploys without errors, but when you access the URL http://localhost:8080/seam-booking/ in a browser and attempt "Account Login", you get a runtime error “The page isn't redirecting properly”. In the next step, you learn how to debug and resolve runtime errors.To learn how to debug and resolve runtime issues, click here: Section 4.3.7, “Debug and Resolve Seam 2.2 Booking Archive Runtime Errors and Exceptions”To return to the previous topic, click here: Section 4.3.4, “Migrate the Seam 2.2 Booking Archive to JBoss Enterprise Application 6: Step-By-Step Instructions”