$show=/label

[Fixed] org.apache.tomcat.util.bcel.classfile.classformatexception: invalid byte tag in constant pool: 19

SHARE:

How to fix org.apache.tomcat.util.bcel.classfile.classformatexception invalid byte tag in constant issue in Java.

1. ClassFormatException: Invalid byte tag in constant pool: 15 Overview


In this tutorial, We'll learn how to fix org.apache.tomcat.util.bcel.classfile.ClassFormatException: Invalid byte tag in constant pool: 15. This is a common issue while working with Tomcat 7 or Tomcat 8 version. We'll provide you the various solutions to fix this error permanently.

Addition to this issue, you can find the other set of trouble shooting problems.

[Fixed] Java 8: Invalid byte tag in constant pool: 15 or 19 - Tomcat

Common issues on the same error. The solution is common in all cases.

Invalid byte tag in constant pool: 15
Invalid byte tag in constant pool: 16
Invalid byte tag in constant pool: 18
Invalid byte tag in constant pool: 19


[Fixed] Tomcat 7+ Java 8 : Invalid byte tag in constant pool: 15


Let me tell my store with this problem and how did the troubleshoot this issue.

org.apache.tomcat.util.bcel.classfile.classformatexception: invalid byte tag in constant pool: 19



I have started working with java version 1.7 and Apache Tomcat/7.0.12. After some time my mind was completely changed. Felt very curious really waiting to work with java 8 features.

Read the article on Java 8 Lambda Expressions Feature

But, Later did the analysis and have just updated java version to 1.8 (C:\Program Files\Java\jdk1.8.0_51).

Finally, restarted my tomcat server then appeared exception with the following full error stack trace.

Exception occurred after Tomcat 7 or Tomcat 8 restart:



Aug 22, 2015 10:57:05 AM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.12
org.apache.tomcat.util.bcel.classfile.ClassFormatException: Invalid byte tag in constant pool: 15
    at org.apache.tomcat.util.bcel.classfile.Constant.readConstant(Constant.java:131)
    at org.apache.tomcat.util.bcel.classfile.ConstantPool.(ConstantPool.java:60)
    at org.apache.tomcat.util.bcel.classfile.ClassParser.readConstantPool(ClassParser.java:209)
    at org.apache.tomcat.util.bcel.classfile.ClassParser.parse(ClassParser.java:119)
    at org.apache.catalina.startup.ContextConfig.processAnnotationsStream(ContextConfig.java:1917)
    at org.apache.catalina.startup.ContextConfig.processAnnotationsJar(ContextConfig.java:1806)
    at org.apache.catalina.startup.ContextConfig.processAnnotationsUrl(ContextConfig.java:1765)
    at org.apache.catalina.startup.ContextConfig.processAnnotations(ContextConfig.java:1751)
    at org.apache.catalina.startup.ContextConfig.webConfig(ContextConfig.java:1255)
    at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:882)
    at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:317)
    at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
    at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:89)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5081)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1033)
    at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:774)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1033)
    at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:291)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
    at org.apache.catalina.core.StandardService.startInternal(StandardService.java:443)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
    at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:727)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
    at org.apache.catalina.startup.Catalina.start(Catalina.java:620)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:303)
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:431)


d tomcat official website. Stated that "The "offical answer" is that Tomcat 7 runs on Java 8, see http://tomcat.apache.org/whichversion.html ("Java version 6 and later")."

2. Solution 1 - web.xml


However, if annotation scanning is enabled (metadata-complete="true" in web.xml) there are some issues due to BCEL (not able to process the new Java 8 byte codes). You will get exceptions like (at least with Tomcat 7):


SEVERE: Unable to process Jar entry [jdk/nashorn/internal/objects/NativeString.class] from Jar [jar:file:/usr/lib/jvm/jdk1.8.0_5/jre/lib/ext/nashorn.jar!/] for annotations
org.apache.tomcat.util.bcel.classfile.ClassFormatException: Invalid byte tag in constant pool: 15
    at org.apache.tomcat.util.bcel.classfile.Constant.readConstant(Constant.java:131)

If not using annotation scanning, everything works fine, starting release 7.0.53 (updated compiler with better Java 8 support).

(UPDATE 2014-10-17) If your are using annotation scanning and your own code is not Java 8 based, another solution is to add the following line in /etc/tomcat7/catalina.properties (text added after "ant-launcher.jar" so part of property tomcat.util.scan.DefaultJarScanner.jarsToSkip):


junit.jar,junit-*.jar,ant-launcher.jar,\
jfxrt.jar,nashorn.jar

Tested with Tomcat 7.0.28 and Oracle JDK 8_25 on Debian 7.6.


3. Solution 2 - Tomcat upgrade to latest


Upgrade the tomcat version to Tomcat 7.0.65. Works well.

Solution 2 is simple, definitely works.

There are some more scenarios which causes the same problem which is below case and another case as well. We have provided other alternative solutions based many user experiences. Hope helps.
Problem: Tomcat 7 - Servlet 3.0: Invalid byte tag in constant pool:

I just switched the web.xml to servlet 3.0 (from a app running 2.4 previously) and now I'm seeing the following error (turned on fine logging for org.apache.tomcat.util):

Following is the problem requirements.

tomcat 7.0.16
Java 1.6.0_22
CentOS 5.6

Error occured for ClassFormatException:


mtyson  FINE: Scanning JAR [file:/usr/java/jdk1.6.0_22/jre/lib/ext/jcharset.jar] from classpath
mtyson  Jul 19, 2011 10:04:40 AM org.apache.catalina.startup.HostConfig deployDirectory
mtyson  SEVERE: Error deploying web application directory ROOT
mtyson  org.apache.tomcat.util.bcel.classfile.ClassFormatException: Invalid byte tag in constant pool: 60

4. Solution 3 - Problem with IBM library


It may not be your issue, but mine was the same as this one -- an old version of com.ibm.icu:icu4j. I solved the problem by changing by build configuration to exclude the older transitive dependencies and explicitly depending upon the latest version (4.8).


I was facing the same issue from a week and resolved by simply replacing the icu4j.2.1.jar file with latest version of jar.

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>com.ibm.icu</groupId>
            <artifactId>icu4j</artifactId>
            <version>3.4.4</version>
        </dependency>
    </dependencies>
</dependencyManagement>

5. Solution 4 - COOKIE


Notice the use of the version="2.5" with the web-app_3_0.xsd schema and the presence of the session-config tracking-mode which is only part of the 3.0 spec not the 2.5 (AFAIK)

Add the below code in web.xml file.

<session-config>
        <tracking-mode>COOKIE</tracking-mode>
</session-config>


6. Conclusion

In this article, We've learn how to fix "Invalid byte tag in constant pool: 15" error. And more provided 4 ways to solve this error with examples.

References:

StackOverFlow 1
StackOverFlow 2
MkYong

COMMENTS

BLOGGER: 3
  1. Unfortunately there are more exception if you try to use Lambda expressions or stream api and you also use Mojarra 2.1. The following exception occures at all startup (with TomEE 1.7.4 which includes Tomcat 7.0.68):

    listItems.stream().forEach((item) -> {
    doAnything(item);
    });


    INFO: Initializing Mojarra 2.1.29 ( 20140702-1445 https://svn.java.net/svn/mojarra~svn/tags/2.1.29@13392) for context '/reflex'
    márc. 23, 2016 7:10:35 DU org.apache.openejb.server.cxf.rs.CxfRsHttpListener configureFactory
    ERROR j.e.resource.webcontainer.jsf.config - Unknow type constant pool 18 at position 41
    ERROR j.e.resource.webcontainer.jsf.config - Unknow type constant pool 0 at position 42
    ERROR j.e.resource.webcontainer.jsf.config - Unknow type constant pool 0 at position 43
    ERROR j.e.resource.webcontainer.jsf.config - Unknow type constant pool 0 at position 44
    ERROR j.e.resource.webcontainer.jsf.config - Unknow type constant pool -33 at position 45
    ERROR j.e.resource.webcontainer.jsf.config - Unknow type constant pool 15 at position 223
    ERROR j.e.resource.webcontainer.jsf.config - Unknow type constant pool 61 at position 226
    ERROR j.e.resource.webcontainer.jsf.config - Unknow type constant pool 16 at position 227
    ERROR j.e.resource.webcontainer.jsf.config - Unknow type constant pool 0 at position 228
    ERROR j.e.resource.webcontainer.jsf.config - Unknow type constant pool -87 at position 229

    If you change into:

    With
    for (ItemType item : listItems) {
    doAnything(item);
    }

    everything works perfect.

    When i have changed the Mojarra library to 2.2.13 the problem disappeared even using TomEE 1.7.0.

    ReplyDelete
  2. Unfortunately there are more exception if you try to use Lambda expressions or stream api and you also use Mojarra 2.1. The following exception occures at all startup (with TomEE 1.7.4 which includes Tomcat 7.0.68):

    listItems.stream().forEach((item) -> {
    doAnything(item);
    });


    INFO: Initializing Mojarra 2.1.29 ( 20140702-1445 https://svn.java.net/svn/mojarra~svn/tags/2.1.29@13392) for context '/reflex'
    márc. 23, 2016 7:10:35 DU org.apache.openejb.server.cxf.rs.CxfRsHttpListener configureFactory
    ERROR j.e.resource.webcontainer.jsf.config - Unknow type constant pool 18 at position 41
    ERROR j.e.resource.webcontainer.jsf.config - Unknow type constant pool 0 at position 42
    ERROR j.e.resource.webcontainer.jsf.config - Unknow type constant pool 0 at position 43
    ERROR j.e.resource.webcontainer.jsf.config - Unknow type constant pool 0 at position 44
    ERROR j.e.resource.webcontainer.jsf.config - Unknow type constant pool -33 at position 45
    ERROR j.e.resource.webcontainer.jsf.config - Unknow type constant pool 15 at position 223
    ERROR j.e.resource.webcontainer.jsf.config - Unknow type constant pool 61 at position 226
    ERROR j.e.resource.webcontainer.jsf.config - Unknow type constant pool 16 at position 227
    ERROR j.e.resource.webcontainer.jsf.config - Unknow type constant pool 0 at position 228
    ERROR j.e.resource.webcontainer.jsf.config - Unknow type constant pool -87 at position 229

    If you change into:

    With
    for (ItemType item : listItems) {
    doAnything(item);
    }

    everything works perfect.

    When i have changed the Mojarra library to 2.2.13 the problem disappeared even using TomEE 1.7.0.

    ReplyDelete
Please do not add any spam links in the comments section.

About Us

Author: Venkatesh - I love to learn and share the technical stuff.
Name

accumulo,1,ActiveMQ,2,Adsense,1,API,31,ArrayList,16,Arrays,2,Bean Creation,3,Bean Scopes,1,BiConsumer,1,Blogger Tips,1,Books,1,C Programming,1,Collection,4,Collections,20,Collector,1,Command Line,1,Compile Errors,1,Configurations,7,Constants,1,Control Statements,8,Conversions,5,Core Java,72,Corona India,1,Create,2,CSS,1,Date,2,Date Time API,3,Dictionary,1,Difference,1,Download,1,Eclipse,2,Efficiently,1,Error,1,Errors,1,Exception,1,Exceptions,2,Fast,1,Files,9,Float,1,Font,1,For examples,1,For loop examples,1,For Loop in Java,1,Form,1,Freshers,1,Function,3,Functional Interface,2,Garbage Collector,1,Generics,4,Git,4,Grant,1,Grep,1,HashMap,1,HTML,2,HttpClient,2,Immutable,1,Inner for loops,1,Installation,1,Interview Questions,5,Iterate,2,Jackson API,3,Java,28,Java 10,1,Java 11,5,Java 12,5,Java 13,2,Java 14,2,java 5 For loop,1,Java 8,48,Java 9,1,Java Design Patterns,1,Java Files,1,Java for loop,1,Java Program,2,Java Programs,65,java.lang,5,java.util. function,1,jQuery,1,Kotlin,10,Kotlin Programs,6,Lambda,1,lang,29,Leap Year,1,live updates,1,Math,1,Maven,1,Method References,1,Mockito,1,MongoDB,3,Nested for loop,1,Nested for loop examples,1,New Features,1,Operations,1,Optional,4,Oracle,5,Oracle 18C,1,Partition,1,Patterns,1,Programs,1,Property,1,Python,2,Quarkus,1,Read,1,Real Time,1,Recursion,2,Remove,2,Rest API,1,Schedules,1,Serialization,1,Servlet,1,Softwares,1,Sorting Techniques,8,Spring,2,Spring Boot,23,Spring Email,1,Spring MVC,1,Stream,3,Streams,11,String,48,String Programs,8,String Revese,1,Swing,1,System,1,Tags,1,Threads,8,Tomcat,1,Tomcat 8,1,Troubleshoot,16,Unix,2,Updates,3,util,5,While Loop,1,
ltr
item
JavaProgramTo.com: [Fixed] org.apache.tomcat.util.bcel.classfile.classformatexception: invalid byte tag in constant pool: 19
[Fixed] org.apache.tomcat.util.bcel.classfile.classformatexception: invalid byte tag in constant pool: 19
How to fix org.apache.tomcat.util.bcel.classfile.classformatexception invalid byte tag in constant issue in Java.
https://1.bp.blogspot.com/-i9Ad5ckQlfA/XO2TUzvrl6I/AAAAAAAABmo/qYbnhHoR3V4wPFBoC7y0EljkrGmcxu5aQCLcBGAs/s320/%255BFixed%255D%2BTomcat%2B7%252B%2BJava%2B8%2BInvalid%2Bbyte%2Btag%2Bin%2Bconstant%2Bpool%2B15.PNG
https://1.bp.blogspot.com/-i9Ad5ckQlfA/XO2TUzvrl6I/AAAAAAAABmo/qYbnhHoR3V4wPFBoC7y0EljkrGmcxu5aQCLcBGAs/s72-c/%255BFixed%255D%2BTomcat%2B7%252B%2BJava%2B8%2BInvalid%2Bbyte%2Btag%2Bin%2Bconstant%2Bpool%2B15.PNG
JavaProgramTo.com
https://www.javaprogramto.com/2015/08/java-8-classformatexception-invalid_21.html
https://www.javaprogramto.com/
https://www.javaprogramto.com/
https://www.javaprogramto.com/2015/08/java-8-classformatexception-invalid_21.html
true
3124782013468838591
UTF-8
Loaded All Posts Not found any posts VIEW ALL Readmore Reply Cancel reply Delete By Home PAGES POSTS View All RECOMMENDED FOR YOU LABEL ARCHIVE SEARCH ALL POSTS Not found any post match with your request Back Home Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sun Mon Tue Wed Thu Fri Sat January February March April May June July August September October November December Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec just now 1 minute ago $$1$$ minutes ago 1 hour ago $$1$$ hours ago Yesterday $$1$$ days ago $$1$$ weeks ago more than 5 weeks ago Followers Follow THIS PREMIUM CONTENT IS LOCKED STEP 1: Share to a social network STEP 2: Click the link on your social network Copy All Code Select All Code All codes were copied to your clipboard Can not copy the codes / texts, please press [CTRL]+[C] (or CMD+C with Mac) to copy Table of Content