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

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
Arthur WangAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

CEHJCommented:
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
0
Arthur WangAuthor 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.
0
Arthur WangAuthor 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
0
CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

CEHJCommented:
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
0
Arthur WangAuthor 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.
0
CEHJCommented:
Well, i mean in Websphere's own library path. Sometimes that's necessary (at least with Tomcat)
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Arthur WangAuthor Commented:
i see, I will try to place the common-validator.jar file into the tomcat library and give it a try.
0
Arthur WangAuthor 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
0
Arthur WangAuthor 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.
0
CEHJCommented:
:)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.