ClassFormatException产生原因及解决方案

Tomcat 8.5启动报错‘Invalid byte tag in constant pool: 19’?别慌,一个配置项就能搞定 本文详细介绍了Tomcat 8.5启动时遇到‘Invalid byte tag in constant pool: 19’错误的快速修复方法。通过修改catalina.properties文件中的jarsToSkip配置,跳过包含module-info.class的JAR文件扫描,有效解决兼容性问题,适用于生产环境的紧急修复。 阅读详情

ClassFormatException 是在 Java 中与字节码文件(即 .class 文件)相关的一种异常。它通常在类加载期间发生,当 Java 虚拟机(JVM)或类加载器发现类文件的格式不符合 Java 类文件规范时,便会抛出这个异常。

一、常见原因:

  1. 损坏的 .class 文件:

    • 原因: .class 文件可能在编译后被损坏,导致其格式不再符合 JVM 的要求。这可能是由于磁盘错误、传输问题或其他外部原因引起的。
    • 示例: 如果一个 .class 文件在传输过程中变得不完整或被意外修改,那么 JVM 在加载该文件时可能会抛出 ClassFormatException。
  2. 使用不兼容的编译器生成的类文件:

    • 原因: 使用不兼容的编译器或工具生成的类文件,可能会导致类文件格式与 JVM 所期待的不一致。
    • 示例: 如果使用自定义或过时的 Java 编译器生成类文件,JVM 可能无法识别或正确解析这些文件。
  3. 手动修改 .class 文件:

    • 原因: 开发者可能尝试手动修改 .class 文件中的字节码。如果这些修改导致字节码结构不再符合规范,则会引发此异常。
    • 示例: 手动编辑 .class 文件的字节码,例如使用十六进制编辑器直接更改字节码指令,可能会导致格式错误。
  4. 版本不匹配:

    • 原因: 由较新版本的 Java 编译器生成的 .class 文件尝试在较旧版本的 JVM 上加载时,可能会导致 ClassFormatException。
    • 示例: 使用 Java 17 编译的类文件可能在 Java 8 的 JVM 上运行时导致格式问题,因为较旧的 JVM 不支持较新版本的字节码格式。
  5. 类加载器问题:

    • 原因: 自定义类加载器如果没有正确实现加载机制,可能会在加载类时产生格式错误。
    • 示例: 如果自定义类加载器在读取或处理字节码时发生错误,可能会生成一个不正确的类对象,从而导致异常。

二、解决方案:

  1. 重新编译类文件:

    • 确保使用正确且兼容的编译器重新编译源代码,生成新的 .class 文件。
  2. 检查 .class 文件的完整性:

    • 如果怀疑类文件被损坏,尝试重新获取或重新生成文件,避免在不完整或损坏的文件上进行操作。
  3. 避免手动修改字节码:

    • 尽量避免手动编辑 .class 文件。如果必须修改字节码,建议使用专业工具如 ASM 或 BCEL 来确保生成的字节码是合法的。
  4. 验证 Java 版本兼容性:

    • 确保编译和运行时的 JVM 版本兼容。如果在较新版本的 JVM 上编译类文件,请确保在相同或更高版本的 JVM 上运行它们。
  5. 检查类加载器实现:

    • 如果使用了自定义类加载器,仔细检查加载器的实现是否正确处理了字节码的加载和解析。
java.util.zip.ZipException: zip file is empty Tomcat启动报错 java.util.zip.ZipException: zip file is empty 完成报错信息: Aug 27, 2019 7:19:38 PM org.apache.catalina.startup.ContextConfig processAnnotationsJar SEVERE: Unable to process Jar [jar:file:.../WEB-INF/lib/... 阅读详情

相关推荐

JD-GUI 1.4官方MAC版入门:安装、反编译操作与常见故障排查

Java字节码反编译是理解无源码JAR包的核心技术,静态分析字节码并还原为可读源码,常用于旧系统维护、三方库排查与线上补丁核对。JVM环境差异常导致图形化反编译工具在macOS上闪退或无法解析,尤其JavaFX与JDK版本兼容性是最常见门槛。通过调整JVM参数、指定Java 11运行环境、使用命令行辅助验证,可有效解决JD-GUI 1.4在Mac上的安装与启动问题。本文围绕官方MAC版本的安装路径、Java版本选择、反编译操作、参数调优及常见故障展开,提供从打开class到导出源码的完整实践方案,并给出ja

weixin_33940469的博客 292

Invalid byte tag in constant pool: 19

一、问题 Invalid byte tag in constant pool: 19 具体错误: org.apache.catalina.startup.ContextConfig.processAnnotationsJar Unable to process Jar entry [META-INF/versions/9/module-info.class] from Jar [file:/...

JackiAndroid的专栏 1万+

CANFD升级踩坑实录:DBC转换时DLC大于8的信号怎么处理?

本文详细探讨了CANFD升级过程中DLC大于8的信号处理问题,提供了工程化解决方案和AutoSar BSW层配置要点。通过分析CAN与CANFD的DLC本质差异,提出信号拆分重组、DLC重映射和协议层适配三种策略,并给出验证与测试方案,帮助开发者避免数据截断和通信故障。

weixin_42521843的博客 229

完美解决tomcat启动异常:Invalid byte tag in constant pool: 19;Unable to process Jar entry [module-info.class]

tomcat启动异常:Invalid byte tag in constant pool: 19;Unable to process Jar entry [module-info.class]

weixin_43860634的博客 5991

告别手动维护!教你用SAP BAPI批量更新生产订单BOM组件(CO02工单)

本文详细介绍了如何利用SAP BAPI实现生产订单BOM组件的批量更新,解决传统手工操作(如CO02工单)效率低下的问题。通过核心函数解析和批量处理框架设计,帮助用户大幅提升工作效率,降低错误率,适用于物料主数据变更、季节性配方调整等场景。

weixin_30844577的博客 561

超全!!snowboy语音唤醒(树莓派4b)

通过snowboy进行树莓派的语音唤醒

crimaster1024的博客 8735

出现 org.apache.tomcat.util.bcel.classfile.ClassFormatException 异常的原因及解决方法

1 异常描述在从 SVN 正常检出项目后,部署完 Maven 及配置完 Tomcat 之后,按常规方法启动服务器,报出如下错误:2 异常原因通过观察上图标记出来的异常描述,咱们可以知道: org.apache.tomcat.util.bcel.classfile.ClassFormatException: Invalid byte tag in constant pool: 15 此异常,为:C

安正勋的博客 10万+

手把手教你用TUSB2E22中继器实现eUSB2与USB 2.0互转(附实测数据对比)

本文详细介绍了如何利用TUSB2E22中继器实现eUSB2与USB 2.0的高效互转,包括技术背景、硬件设计要点、信号完整性测试方法及故障排查策略。通过实测数据对比,展示了TUSB2E22在信号延迟、功耗和眼图性能上的显著优势,为工程师提供了实用的工程方案。

weixin_29199873的博客 283

org.apache.tomcat.util.bcel.classfile.ClassFormatException: Invalid byte tag in constant pool: 19

tomcat问题排查记录:org.apache.tomcat.util.bcel.classfile.ClassFormatException: Invalid byte tag in constant pool: 19 最近项目引入一个jar包之后启动报错。 等我把项目部署到 测试环境 tomcat 下后,项目是可以跑起来的且能正常运行,但是在项目启动过程中,报了一堆错: SEVERE: Unable to process Jar entry [module-info.class] from Ja

EnjoySelfLife的博客 774

Unity3d移动端性能优化

以下条目主要针对移动端,大部分也适合PC端 一、Profiler的使用 1.性能优化应贯穿项目开发的全过程,如需求(性能能不能达到要求)、设计、开发、测试等。不能开发结束才优化性能。 2.官方推荐的优化工具是【Window】->【Profiler】 3.确认瓶颈是CPU-bound(Gfx.WaitForCommands)还是CPU-bound(Gfx.WaitForPresent) 4.内存分析使用Memory Profiler 二、内存优作 5.减少内存收集的影...

zouxin_88的专栏 3056

汽车电子RTOS--AUTOSAR OS

AUTOSAR OS(AUTomotive Open System ARchitecture Operating System)是AUTOSAR(汽车开放系统架构)标准中的一个重要组件,它是一个专门为汽车电子控制单元(ECU)设计的实时操作系统(RTOS)。AUTOSAR OS旨在提供一个标准化的软件平台,以促进不同供应商和汽车制造商之间的组件复用和协同开发,提高软件质量和降低成本。

MHD0815的博客 1798

出现 org.apache.tomcat.xxx.ClassFormatException: Invalid byte tag in constant pool: 15 异常的原因及解决方法

1 错误描述最近,当我从 SVN 检出项目并正常配置完 Tomcat 之后,启动项目,总是报出如下异常:2 错误原因通过观察上述标记出来的异常描述,我们可以知道: org.apache.tomcat.util.bcel.classfile.ClassFormatException: Invalid byte tag in constant pool: 15 此异常,为:类格式异常:常量池中无效的

安正勋的博客 1万+

java技术专家【面试】Java程序员英语面试整个流程

java技术专家【面试】Java程序员英语面试整个流程

大壮 753

org.eclipse.jdt.internal.compiler.classfmt.ClassFormatException

使用maven的时候,抛出这个异常,我使用的jdk9,和tomcat8。使用tomcat:run运行maven自带服务器时,会产生这个异常。 我的解决方法:在pom.xml配置文件的build的plugins下插入 然后使用Tomcat7:run运行服务器,问题得以解决。 ...

qq_44665927的博客 213

OpenHarmony Stage模型深度解剖:从Ability Kit到沙箱隔离的全链路底层原理

基于微内核架构,提供进程管理、内存管理、IPC通信等基础能力:包含V8引擎、ArkTS运行时、渲染引擎等核心组件:Ability Kit框架,提供应用生命周期管理、组件调度等能力:基于Stage模型的应用程序。

m0_67505153的博客 191

Probability and Statistics - 4th edition

Probability and Statistics - 4th edition

java 中的 module-info_无法处理Java9项目中的文件module-info.class导致ClassFormatException...

尝试在IntelliJ 2017.2.2中的Java9预发行版下运行Vaadin8.1应用程序,我能够vaadinjavanine.war使用一个新项目构建一个,并使用JettyServer托管该项目。我最终试图将产生的战争部署到tomcat服务器。但是,在tomcat服务器启动期间,出现以下异常:21-Aug-2017 22:53:38.830 SEVERE [localhost-startSt...

weixin_42442653的博客 977

win10 跳过U8环境检测的IE WebControls.rar

win10 安装u8的时候 提示IE WebControls 不通过,这个工具可以欺骗u8的检查。 跳过U8环境检测的IE WebControls。提示导入失败后,重新检测通过。

Tomcat启动报错:ClassFormatException: Invalid byte tag in constant pool: 19

一. 遇到问题❓ ❗️先放一张tomcat启动时报错的日志❗️ 我所用的JDK版本为:jdk8 tomcat版本为:tomcat 7.xx 从字面以后可以看到 Unable to process Jar entry xxx for annotations (无法处理注释的xx Jar包的条目) 对应的报错是**ClassFormatException **( 类格式异常) 这个异常继承了RuntimeException(运行时异常) 官方解释如下: Thrown when the BCEL att

houdou2092的博客 8184

OV9734 DATASHEET,完整规格书

OV9734完整规格书,包括电气参数,尺寸规格,寄存器配置表等

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

Tomcat报错之Invalid byte tag in constant pool 19

org.apache.tomcat.util.bcel.classfile.ClassFormatException: Invalid byte tag in constant pool: 19 单纯看报错意思无法得知为什么会报这样的错误以及如何去解决这个问题。我查阅了相关资料,并请教各路大神最终将问题定位到了 Lombok 身上。

小异常的博客 5万+

报错ClassFormatException

tomcat启动红色警告,虽然没影响项目启动运行,但是看着很不爽啊,得搞一波。 严重: Unable to process Jar entry [module-info.class] from Jar [jar:file:/D:/maven/repository/com/fasterxml/jackson/core/jackson-annotations/2.12.3/jackson-annotations-2.12.3.jar!/] for annotations org.apache.tomcat.

糯米爱吃西瓜 1829

tomcat启动报错:Invalid byte tag in constant pool: 19

提供给其他系统使用的jar包造成tomcat启动报错: Unable to process Jar entry [module-info.class] from Jar [jar:file:/xxxxxxxx/lombok-1.18.4.jar!/] for annotations org.apache.tomcat.util.bcel.classfile.ClassFormatException...

虫一 8万+

springboot中移除tomcat插件的方法

<dependency>    <groupId>org.springframework.boot</groupId>    <artifactId>spring-boot-starter-web</artifactId>    <!-- 从依赖信息里移除 Tomca...

Mr_lambor的博客 1970

Idea如何导入项目并且运行失败后解决方案,解决Invalid byte tag in constant pool: 19(常量池中的字节标记无效)报错

点击左上角File>New>Project from Existing Sources。里数据库依赖的版本过高,与原本案例框架中的版本不符合,后进行版本的修改,成功运行。下午在学习一个案例时,发现需要导入一个项目框架。在各大贴吧寻找解决方案时,尝试了很多类似降低。执行tomcat7:run时发生报错,显示。最后在检查代码时发现,我使用的。找到你想导入项目的文件所在地。版本,均不可以解决问题。

2301_76895560的博客 1291

jacorg.apache.tomcat.util.bcel.classfile.ClassFormatException: Invalid byte tag in constant pool: 19

这个问题是tomcat版本过低报的错误,由于开发的tomcat版本高于部署的tomcat版本,所以你部署的时候会遇见这个错误。 解决办法: 方法一:将当前的tomcat7升级至高版本tomcat8。 方法二:将当前的tomcat7的tomcat\conf\catalina.properties文件,节点增加log4j-api-2.10.0.jar,然后重新启动tomcat,问题解决。(其实目的就是设置tomcat扫描时忽略这个jar包) tomcat.util.scan.DefaultJarSca

雾里华的博客 1330

关于IDEAClassFormatException: Invalid byte tag in constant pool: 19错误。

比如上面报错apache-tomcat-8.0.18/webapps/ROOT/WEB-INF/lib/lombok-1.18.26.jar!-info.class问题得以解决。只不过并不是去maven仓库里找jar包,而是去WEB-INF下的lib中找到对应的jar包,删除module-info.class即可。有时可能还会遇到apache-tomcat-8.0.18/webapps/ROOT/WEB-INF/lib/log4j-api-2.10.0.jar的报错。这时就要去删除jar包中。

qq_68890680的博客 819
上一篇: ClassCastException产生原因及解决方案
下一篇: 详解Mybatis中ResultType和ResultMap区别
境里婆娑
境里婆娑 新星创作者: Java技术领域 新星创作者: Java技术领域 领域专家: 后端开发技术领域 领域专家: 后端开发技术领域
博客等级 码龄10年 1万+粉丝 300原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

境里婆娑

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值