how to solve the java.lang.NoClassDefFoundError: org/apache/commons/validator/ValidatorException

Arthur Wang
Arthur Wang used Ask the Experts™
on
I have a java project(using struts) running under weblogic app server in production without any problem. however, after i migrate it to the Tomcat app server, it always report the following error message for a specific action.

Error creating form bean of class org.apache.commons.beanutils.LazyDynaBean
java.lang.NoClassDefFoundError: org/apache/commons/validator/ValidatorException
      at org.apache.struts.config.FormBeanConfig.createActionForm(FormBeanConfig.java:219)
      at org.apache.struts.util.RequestUtils.createActionForm(RequestUtils.java:292)
      at org.apache.struts.util.RequestUtils.createActionForm(RequestUtils.java:191)

the tomcat server enviroment is below:

[root@server85 logs]# cat catalina.out 
01-Sep-2018 19:25:25.637 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server version:        Apache Tomcat/9.0.5
01-Sep-2018 19:25:25.639 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server built:          Feb 6 2018 21:42:23 UTC
01-Sep-2018 19:25:25.639 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server number:         9.0.5.0
01-Sep-2018 19:25:25.639 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Name:               Linux
01-Sep-2018 19:25:25.639 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Version:            4.1.12-94.3.9.el7uek.x86_64
01-Sep-2018 19:25:25.639 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Architecture:          amd64
01-Sep-2018 19:25:25.639 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Java Home:             /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.131-11.b12.el7.x86_64/jre
01-Sep-2018 19:25:25.639 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Version:           1.8.0_131-b12
01-Sep-2018 19:25:25.640 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Vendor:            Oracle Corporation
01-Sep-2018 19:25:25.640 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_BASE:         /data/purl/apache-tomcat-9.0.5
01-Sep-2018 19:25:25.640 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_HOME:         /data/purl/apache-tomcat-9.0.5
01-Sep-2018 19:25:25.640 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.config.file=/data/purl/apache-tomcat-9.0.5/conf/logging.properties
01-Sep-2018 19:25:25.640 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
01-Sep-2018 19:25:25.640 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djdk.tls.ephemeralDHKeySize=2048
01-Sep-2018 19:25:25.640 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.protocol.handler.pkgs=org.apache.catalina.webresources
01-Sep-2018 19:25:25.640 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dignore.endorsed.dirs=
01-Sep-2018 19:25:25.640 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.base=/data/purl/apache-tomcat-9.0.5
01-Sep-2018 19:25:25.641 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.home=/data/purl/apache-tomcat-9.0.5
01-Sep-2018 19:25:25.641 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.io.tmpdir=/data/purl/apache-tomcat-9.0.5/temp
01-Sep-2018 19:25:25.641 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: [/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib]
01-Sep-2018 19:25:25.692 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["http-nio-8080"]
01-Sep-2018 19:25:25.702 INFO [main] org.apache.tomcat.util.net.NioSelectorPool.getSharedSelector Using a shared selector for servlet write/read
01-Sep-2018 19:25:25.707 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["ajp-nio-8009"]
01-Sep-2018 19:25:25.707 INFO [main] org.apache.tomcat.util.net.NioSelectorPool.getSharedSelector Using a shared selector for servlet write/read
01-Sep-2018 19:25:25.708 INFO [main] org.apache.catalina.startup.Catalina.load Initialization processed in 354 ms
01-Sep-2018 19:25:25.724 INFO [main] org.apache.catalina.core.StandardService.startInternal Starting service [Catalina]
01-Sep-2018 19:25:25.724 INFO [main] org.apache.catalina.core.StandardEngine.startInternal Starting Servlet Engine: Apache Tomcat/9.0.5
01-Sep-2018 19:25:25.741 INFO [main] org.apache.catalina.startup.HostConfig.deployWAR Deploying web application archive [/data/purl/apache-tomcat-9.0.5/webapps/wts.war]
01-Sep-2018 19:25:27.518 INFO [main] org.apache.jasper.servlet.TldScanner.scanJars At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
2018-09-01 19:25:27 INFO  (org.apache.struts.tiles.TilesPlugin:238) - Tiles definition factory loaded for module ''.
2018-09-01 19:25:27 INFO  (org.apache.struts.validator.ValidatorPlugIn:213) - Loading validation rules file from '/WEB-INF/validator-rules.xml'
2018-09-01 19:25:27 INFO  (org.apache.struts.validator.ValidatorPlugIn:213) - Loading validation rules file from '/WEB-INF/validation.xml'
01-Sep-2018 19:25:28.022 INFO [main] org.apache.catalina.startup.HostConfig.deployWAR Deployment of web application archive [/data/purl/apache-tomcat-9.0.5/webapps/wts.war] has finished in [2,280] ms
01-Sep-2018 19:25:28.022 INFO [main] org.apache.catalina.startup.HostConfig.deployWAR Deploying web application archive [/data/purl/apache-tomcat-9.0.5/webapps/chinaurl.war]
01-Sep-2018 19:25:28.321 INFO [main] org.apache.jasper.servlet.TldScanner.scanJars At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
01-Sep-2018 19:25:28.431 INFO [main] org.apache.catalina.startup.HostConfig.deployWAR Deployment of web application archive [/data/purl/apache-tomcat-9.0.5/webapps/chinaurl.war] has finished in [409] ms
01-Sep-2018 19:25:28.432 INFO [main] org.apache.catalina.startup.HostConfig.deployWAR Deploying web application archive [/data/purl/apache-tomcat-9.0.5/webapps/kiosk.war]
01-Sep-2018 19:25:29.968 INFO [main] org.apache.jasper.servlet.TldScanner.scanJars At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
2018-09-01 19:25:30 INFO  (com.mailamerica.kiosk.KioskAutoTask:65) - >>>Timer will be scheduled in 16470 seconds...
01-Sep-2018 19:25:30.172 INFO [main] org.apache.catalina.startup.HostConfig.deployWAR Deployment of web application archive [/data/purl/apache-tomcat-9.0.5/webapps/kiosk.war] has finished in [1,741] ms
01-Sep-2018 19:25:30.175 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["http-nio-8080"]
01-Sep-2018 19:25:30.180 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["ajp-nio-8009"]
01-Sep-2018 19:25:30.181 INFO [main] org.apache.catalina.startup.Catalina.start Server startup in 4472 ms

Open in new window


After searching around and find the following solution:

https://stackoverflow.com/questions/3468027/java-lang-noclassdeffounderror-org-apache-commons-lang-validate

i manually add the jar file: common-lang-2.6.jar into the lib folder of the project. the problem keep showing up. I also tried to play with different version of the jar files, common-lang-2.4, common-lang-3.6.jar, commo-lang-3.7.jar, none of them can solve the problem.

When I try to search this class---org/apache/commons/validator/ValidatorException, it seems belong to the jar: common-validator.jar, then the jar file is in the list, why does it report error message?

please refer to the attached screenshot for the jar list.
jar_list.png
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Top Expert 2016

Commented:
i manually add the jar file: common-lang-2.6.jar into the lib folder of the project. the problem is not solved still.
You probably need commons-validator-2.6.jar

Make sure you patch your struts against the latest struts vulns

Author

Commented:
I tried to change the version of the validator version into common-validator-1.6.jar. it dose not help as well.

please refer to the attached screenshot jar_list2
jar_list2.png
I will give the version 2.6 a try right now to see if it works.

Author

Commented:
Just find out there is no version 2.6, the newest version is 1.6 and this version does not help solving the problem.

apache_validator_newest_version.png
CompTIA Security+

Learn the essential functions of CompTIA Security+, which establishes the core knowledge required of any cybersecurity role and leads professionals into intermediate-level cybersecurity jobs.

Top Expert 2016

Commented:
I would doubt if it's a version thing - that class is likely to have been in every version. It might be that the classloader of the container needs it. Try adding it to the container classpath

Author

Commented:
"Try adding it to the container classpath "-----can you explain how to do that? all the jar files are in the lib directory of the application war file, I assume the container will load all the jar files located in the lib folder of the application war files.
Top Expert 2016
Commented:
Well, i mean in Websphere's own library path. Sometimes that's necessary (at least with Tomcat)

Author

Commented:
i see, I will try to place the common-validator.jar file into the tomcat library and give it a try.

Author

Commented:
I tried to place the jar into the tomcat folder, the class not found error message disappear though the web page still show the same 404 not found for the action. I will look into other places for the possible cause of my problem, but at least your idea does let me move one step further to solve the problem.

tomcat_lib_jar_list.png

Author

Commented:
CEHJ, thank you for the help to make the error message disappear from the server log though i have not completely solved my problem yet.
Top Expert 2016

Commented:
:)

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial