4.3.6. Debug and Resolve Seam 2.2 Booking Archive Deployment Errors and Exceptions
Important
Procedure 4.10. 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/system/layers/base/
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 theEAP6_HOME/standalone/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/system/layers/base/
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 theEAP6_HOME/standalone/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/system/layers/base/
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"/>
Thejboss-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 theEAP6_HOME/standalone/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 EAP 5.1 deployment. Look for the JAR that contains the missing class in theEAP5_HOME/seam/lib/
directory. To do this, open a console and type the following:$ cd EAP5_HOME/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/seam/lib/hibernate-validator.jar jboss-seam-booking.ear/lib
Redeploy the application by deleting theEAP6_HOME/standalone/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 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 theEAP6_HOME/standalone/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/system/layers/base/
directory by looking for theorg/apache/commons/collections
path. The module name is “org.apache.commons.collections”. Modify thejboss-deployment-structure.xml
to add the module dependency to the deployment section of the file.<module name="org.apache.commons.collections" export="true"/>
Thejboss-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 theEAP6_HOME/standalone/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 EAP 6, datasource configuration has changed and needs to be defined in the
EAP6_HOME/standalone/configuration/standalone.xml
file. Because JBoss EAP 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 theEAP6_HOME/standalone/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 EAP 6: Step-By-Step Instructions”