Tomcat 无法启动使用 Eclipse、JRebel 和 Spring Boot

Posted

技术标签:

【中文标题】Tomcat 无法启动使用 Eclipse、JRebel 和 Spring Boot【英文标题】:Tomcat fails to start using Eclipse, JRebel, and Spring Boot 【发布时间】:2017-02-21 09:17:00 【问题描述】:

我正在运行 JRebel 和 Tomcat 9 的 Eclipse 中构建 Spring Boot 应用程序。我已将 JRebel 性质添加到我的项目中,并确认生成的 rebel.xml 是正确的。当我将我的应用程序部署到 Tomcat 并启动它时,我会看到这个错误堆栈。

2016-10-12 09:55:10.689 ERROR [8] [SDK-CBP] Class 'org.springframework.jmx.export.MBeanExporter' could not be processed by org.zeroturnaround.javarebel.integration.spring.beans.cbp.MBeanExporterCBP@org.apache.catalina.loader.WebappClassLoader@35310f27: org.zeroturnaround.bundled.javassist.CannotCompileException: [source error] setRegistrationBehavior(int) not found in org.springframework.jmx.export.MBeanExporter
    at org.zeroturnaround.bundled.javassist.CtNewMethod.make(SourceFile:79)
    at org.zeroturnaround.bundled.javassist.CtNewMethod.make(SourceFile:45)
    at org.zeroturnaround.javarebel.integration.spring.beans.cbp.MBeanExporterCBP.process(MBeanExporterCBP.java:40)
    at org.zeroturnaround.javarebel.integration.support.JavassistClassBytecodeProcessor.process(SourceFile:117)
    at com.zeroturnaround.javarebel.rx.a(SourceFile:365)
    at com.zeroturnaround.javarebel.rx.a(SourceFile:354)
    at com.zeroturnaround.javarebel.rx.a(SourceFile:322)
    at com.zeroturnaround.javarebel.SDKIntegrationImpl.runBytecodeProcessors(SourceFile:33)
    at com.zeroturnaround.javarebel.px.transform(SourceFile:94)
    at java.lang.ClassLoader.defineClass(ClassLoader.java)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
    at org.apache.catalina.loader.WebappClassLoaderBase.findClassInternal(WebappClassLoaderBase.java:2452)
    at org.apache.catalina.loader.WebappClassLoaderBase.findClass(WebappClassLoaderBase.java:854)
    at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1264)
    at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1147)
    at org.springframework.util.ClassUtils.forName(ClassUtils.java:250)
    at org.springframework.util.ClassUtils.isPresent(ClassUtils.java:327)
    at org.springframework.boot.autoconfigure.condition.OnClassCondition$MatchType$2.matches(OnClassCondition.java:123)
    at org.springframework.boot.autoconfigure.condition.OnClassCondition.getMatchingClasses(OnClassCondition.java:93)
    at org.springframework.boot.autoconfigure.condition.OnClassCondition.getMatchOutcome(OnClassCondition.java:50)
    at org.springframework.boot.autoconfigure.condition.SpringBootCondition.matches(SpringBootCondition.java:47)
    at org.springframework.context.annotation.ConditionEvaluator.shouldSkip(ConditionEvaluator.java:102)
    at org.springframework.context.annotation.ConfigurationClassParser.processConfigurationClass(ConfigurationClassParser.java:209)
    at org.springframework.context.annotation.ConfigurationClassParser.processImports(ConfigurationClassParser.java:539)
    at org.springframework.context.annotation.ConfigurationClassParser.processDeferredImportSelectors(ConfigurationClassParser.java:482)
    at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:191)
    at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:324)
    at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:246)
    at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:273)
    at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:98)
    at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:681)
    at org.springframework.context.support.AbstractApplicationContext.__refresh(AbstractApplicationContext.java:523)
    at org.springframework.context.support.AbstractApplicationContext.jrLockAndRefresh(AbstractApplicationContext.java)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java)
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122)
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:736)
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:369)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:313)
    at org.springframework.boot.web.support.SpringBootServletInitializer.run(SpringBootServletInitializer.java:151)
    at org.springframework.boot.web.support.SpringBootServletInitializer.createRootApplicationContext(SpringBootServletInitializer.java:131)
    at org.springframework.boot.web.support.SpringBootServletInitializer.onStartup(SpringBootServletInitializer.java:86)
    at org.springframework.web.SpringServletContainerInitializer.onStartup(SpringServletContainerInitializer.java:171)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5185)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1409)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1399)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
Caused by: compile error: setRegistrationBehavior(int) not found in org.springframework.jmx.export.MBeanExporter
    at org.zeroturnaround.bundled.javassist.compiler.TypeChecker.atMethodCallCore(SourceFile:749)
    at org.zeroturnaround.bundled.javassist.compiler.TypeChecker.atCallExpr(SourceFile:695)
    at org.zeroturnaround.bundled.javassist.compiler.JvstTypeChecker.atCallExpr(SourceFile:157)
    at org.zeroturnaround.bundled.javassist.compiler.ast.CallExpr.accept(SourceFile:46)
    at org.zeroturnaround.bundled.javassist.compiler.CodeGen.doTypeCheck(SourceFile:242)
    at org.zeroturnaround.bundled.javassist.compiler.CodeGen.atStmnt(SourceFile:330)
    at org.zeroturnaround.bundled.javassist.compiler.ast.Stmnt.accept(SourceFile:50)
    at org.zeroturnaround.bundled.javassist.compiler.CodeGen.atStmnt(SourceFile:351)
    at org.zeroturnaround.bundled.javassist.compiler.ast.Stmnt.accept(SourceFile:50)
    at org.zeroturnaround.bundled.javassist.compiler.MemberCodeGen.atTryStmnt(SourceFile:204)
    at org.zeroturnaround.bundled.javassist.compiler.CodeGen.atStmnt(SourceFile:367)
    at org.zeroturnaround.bundled.javassist.compiler.ast.Stmnt.accept(SourceFile:50)
    at org.zeroturnaround.bundled.javassist.compiler.CodeGen.atStmnt(SourceFile:351)
    at org.zeroturnaround.bundled.javassist.compiler.ast.Stmnt.accept(SourceFile:50)
    at org.zeroturnaround.bundled.javassist.compiler.CodeGen.atIfStmnt(SourceFile:398)
    at org.zeroturnaround.bundled.javassist.compiler.CodeGen.atStmnt(SourceFile:355)
    at org.zeroturnaround.bundled.javassist.compiler.ast.Stmnt.accept(SourceFile:50)
    at org.zeroturnaround.bundled.javassist.compiler.CodeGen.atStmnt(SourceFile:351)
    at org.zeroturnaround.bundled.javassist.compiler.ast.Stmnt.accept(SourceFile:50)
    at org.zeroturnaround.bundled.javassist.compiler.MemberCodeGen.atTryStmnt(SourceFile:204)
    at org.zeroturnaround.bundled.javassist.compiler.CodeGen.atStmnt(SourceFile:367)
    at org.zeroturnaround.bundled.javassist.compiler.ast.Stmnt.accept(SourceFile:50)
    at org.zeroturnaround.bundled.javassist.compiler.CodeGen.atStmnt(SourceFile:351)
    at org.zeroturnaround.bundled.javassist.compiler.ast.Stmnt.accept(SourceFile:50)
    at org.zeroturnaround.bundled.javassist.compiler.CodeGen.atMethodBody(SourceFile:292)
    at org.zeroturnaround.bundled.javassist.compiler.CodeGen.atMethodDecl(SourceFile:274)
    at org.zeroturnaround.bundled.javassist.compiler.ast.MethodDecl.accept(SourceFile:44)
    at org.zeroturnaround.bundled.javassist.compiler.Javac.compileMethod(SourceFile:169)
    at org.zeroturnaround.bundled.javassist.compiler.Javac.compile(SourceFile:95)
    at org.zeroturnaround.bundled.javassist.CtNewMethod.make(SourceFile:74)
    ... 49 more

编辑:我正在为 Eclipse 插件 6.5.1 和 Spring Boot 2.0.0.BUILD-SNAPSHOT 使用 JRebel

【问题讨论】:

你使用的是什么版本的 JRebel 和 Spring Boot/Beans? JRebel for Eclipse 插件 6.5.1,Spring Boot 2.0.0.BUILD-SNAPSHOT 【参考方案1】:

JRebel 无法检测类,因为 MBeanRegistrationSupport#setRegistrationBehavior 方法已被 spring-framework 开发分支上的b5db5d commit 删除。

我们更新了 Spring 集成,JRebel Nighly build(选择独立 jar)应该可以正常工作。

修复将包含在我们计划下周发布的 JRebel 6.5.2 中。

感谢您的错误报告,如果您有任何问题/问题,请写信至 support@zeroturnaround.com。

【讨论】:

谢谢。你是真正的 JRebel 开发者吗? 是的,我是。看来我需要更新我的 *** 个人资料 :) 太棒了。感谢您的时间和精力。

以上是关于Tomcat 无法启动使用 Eclipse、JRebel 和 Spring Boot的主要内容,如果未能解决你的问题,请参考以下文章

eclipse中tomcat无法正常启动求助

为啥我的tomcat启动要这么久?

命令行启动tomcat,怎么配置

无法使用 Eclipse 启动 Tomcat:“地址已在使用中”

Tomcat 无法启动使用 Eclipse、JRebel 和 Spring Boot

Tomcat 7 中的 Eclipse 4.2(Juno)“无法使用所选类型创建服务器”