NoClassDefFoundError: org / apache / tomcat / util / codec / binary / Base64

Still trying to make chapters or tails of a hopelessly outdated official spring textbook .

This time this is a bug in the topic:

c:\Users\mkumpan\Projects\Spring testing\build.xml:152: java.lang.NoClassDefFoundError: org/apache/tomcat/util/codec/binary/Base64 <stack trace dump omitted> 

This class is really contained in tomcat-util.jar:

 bash-3.1$ pwd /c/Program Files/Tomcat/lib bash-3.1$ jar -tf ./tomcat-util.jar | grep Base64 org/apache/tomcat/util/codec/binary/Base64.class 

And I'm pretty sure I included it in build.xml:

 <fileset dir="${appserver.home}/bin"> <include name="*.jar"/> </fileset> 

I even tried to be more explicit:

 <fileset dir="C:\Program Files\Tomcat\lib\" includes="tomcat-util.jar"> 

Nothing works, I still get this message every time I try to launch any targets related to tomcat. Could someone possibly suggest a line of inquiry?

Google doesn't seem to be reporting anything.

Update: Below is a link to the full path to the master class.

 <path id="master-classpath"> <fileset dir="${web.dir}/WEB-INF/lib"> <include name="*/*.jar"/> </fileset> <fileset dir="${appserver.lib}"> <include name="*.jar"/> </fileset> <fileset dir="${appserver.home}/bin"> <include name="*.jar"/> </fileset> <pathelement path="${build.dir}"/> </path> 
+6
source share
5 answers

The wrong path was used for necessary purposes, which did not contain the path to the much-needed tomcat-util.jar .

Kudos to @akostadinov for the product in the right direction.

+4
source

If you use the following tomcat-related entries in build.xml and build.properties, ant deployment should work in tomcat 7 and later

 <!-- ============================================================== --> <!-- Tomcat tasks - remove these if you don't have Tomcat installed --> <!-- ============================================================== --> <path id="catalina-ant-classpath"> <!-- We need the Catalina jars for Tomcat --> <!-- * for other app servers - check the docs --> <fileset dir="${appserver.lib}"> <include name="catalina-ant.jar"/> <include name="tomcat-util.jar"/> </fileset> </path> <taskdef name="install" classname="org.apache.catalina.ant.DeployTask"> <classpath refid="catalina-ant-classpath"/> </taskdef> <taskdef name="reload" classname="org.apache.catalina.ant.ReloadTask"> <classpath refid="catalina-ant-classpath"/> </taskdef> <taskdef name="list" classname="org.apache.catalina.ant.ListTask"> <classpath refid="catalina-ant-classpath"/> </taskdef> <taskdef name="start" classname="org.apache.catalina.ant.StartTask"> <classpath refid="catalina-ant-classpath"/> </taskdef> <taskdef name="stop" classname="org.apache.catalina.ant.StopTask"> <classpath refid="catalina-ant-classpath"/> </taskdef> <target name="install" description="Install application in Tomcat"> <install url="${tomcat.manager.url}" username="${tomcat.manager.username}" password="${tomcat.manager.password}" path="/${name}" war="${name}"/> </target> <target name="reload" description="Reload application in Tomcat"> <reload url="${tomcat.manager.url}" username="${tomcat.manager.username}" password="${tomcat.manager.password}" path="/${name}"/> </target> <target name="start" description="Start Tomcat application"> <start url="${tomcat.manager.url}" username="${tomcat.manager.username}" password="${tomcat.manager.password}" path="/${name}"/> </target> <target name="stop" description="Stop Tomcat application"> <stop url="${tomcat.manager.url}" username="${tomcat.manager.username}" password="${tomcat.manager.password}" path="/${name}"/> </target> <target name="list" description="List Tomcat applications"> <list url="${tomcat.manager.url}/text" username="${tomcat.manager.username}" password="${tomcat.manager.password}"/> </target> <!-- End Tomcat tasks --> 

and also make sure the following entries are added to tomcat-users.xml in the tomcat / conf dir installation

  <role rolename="manager-gui"/> <role rolename="admin-gui"/> <role rolename="manager"/> <role rolename="manager-script"/> <user username="kanchan" password="kanchan" roles="manager,manager-gui,admin-gui,manager-script"/> 
+4
source

For those who might stumble upon this problem with tomcat 7. It looks like org / apache / tomcat / util / codec / binary / Base64 0.39 was added to the tomcat-coyote.jar file in version 7.0.

So, I think the options are:

  • upgrade to 7.0.39 +
  • use it somewhere else org / apache / commons / codec / binary / Base64 (commons-codec: commons-codec)
0
source

In Tomcat 8, the corresponding tomcat-util.jar library appears, not tomcat-coyote :-)

0
source

For tomcat version 7 and above, just include tomcat-util.jar in your build.xml file

 <fileset dir="${appserver.lib}"> ... <include name="tomcat-util.jar"/> ... </fileset> 
0
source

Source: https://habr.com/ru/post/953555/


All Articles