尝试构建一个dubbo消费端时,启动报错:
javax.validation.ValidationException: HV000183: Unable to initialize 'javax.el.ExpressionFactory'. Check that you have the EL dependencies on the classpath, or use ParameterMessageInterpolator instead
at org.hibernate.validator.messageinterpolation.ResourceBundleMessageInterpolator.buildExpressionFactory(ResourceBundleMessageInterpolator.java:102)
at org.hibernate.validator.messageinterpolation.ResourceBundleMessageInterpolator.
at org.hibernate.validator.internal.engine.ConfigurationImpl.getDefaultMessageInterpolator(ConfigurationImpl.java:423)
at org.hibernate.validator.internal.engine.ConfigurationImpl.getDefaultMessageInterpolatorConfiguredWithClassLoader(ConfigurationImpl.java:575)
at org.hibernate.validator.internal.engine.ConfigurationImpl.getMessageInterpolator(ConfigurationImpl.java:364)
at org.hibernate.validator.internal.engine.ValidatorFactoryImpl.
at org.hibernate.validator.HibernateValidator.buildValidatorFactory(HibernateValidator.java:38)
at org.hibernate.validator.internal.engine.ConfigurationImpl.buildValidatorFactory(ConfigurationImpl.java:331)
at javax.validation.Validation.buildDefaultValidatorFactory(Validation.java:103)
at org.apache.dubbo.validation.support.jvalidation.JValidator.
at org.apache.dubbo.validation.support.jvalidation.JValidation.createValidator(JValidation.java:37)
at org.apache.dubbo.validation.support.AbstractValidation.getValidator(AbstractValidation.java:43)
at org.apache.dubbo.validation.Validation$Adaptive.getValidator(Validation$Adaptive.java)
at org.apache.dubbo.validation.filter.ValidationFilter.invoke(ValidationFilter.java:83)
at org.apache.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:73)
at org.apache.dubbo.rpc.filter.ExceptionFilter.invoke(ExceptionFilter.java:63)
at org.apache.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:73)
at org.apache.dubbo.monitor.support.MonitorFilter.invoke(MonitorFilter.java:88)
at org.apache.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:73)
at org.apache.dubbo.rpc.filter.TimeoutFilter.invoke(TimeoutFilter.java:54)
at org.apache.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:73)
at org.apache.dubbo.rpc.protocol.dubbo.filter.TraceFilter.invoke(TraceFilter.java:80)
at org.apache.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:73)
at org.apache.dubbo.rpc.filter.ContextFilter.invoke(ContextFilter.java:79)
at org.apache.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:73)
at org.apache.dubbo.rpc.filter.GenericFilter.invoke(GenericFilter.java:137)
at org.apache.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:73)
at org.apache.dubbo.rpc.filter.ClassLoaderFilter.invoke(ClassLoaderFilter.java:38)
at org.apache.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:73)
at org.apache.dubbo.rpc.filter.EchoFilter.invoke(EchoFilter.java:39)
at org.apache.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:73)
at org.apache.dubbo.rpc.protocol.dubbo.DubboProtocol$1.reply(DubboProtocol.java:128)
at org.apache.dubbo.remoting.exchange.support.header.HeaderExchangeHandler.handleRequest(HeaderExchangeHandler.java:103)
at org.apache.dubbo.remoting.exchange.support.header.HeaderExchangeHandler.received(HeaderExchangeHandler.java:200)
at org.apache.dubbo.remoting.transport.DecodeHandler.received(DecodeHandler.java:51)
at org.apache.dubbo.remoting.transport.dispatcher.ChannelEventRunnable.run(ChannelEventRunnable.java:57)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.NoClassDefFoundError: javax/el/ExpressionFactory
at org.hibernate.validator.messageinterpolation.ResourceBundleMessageInterpolator.buildExpressionFactory(ResourceBundleMessageInterpolator.java:98)
... 38 more
原pom文件:
4.0.0
org.springframework.boot
spring-boot-starter-parent
2.1.6.RELEASE
com.example
dubbo-consume
0.0.1-SNAPSHOT
dubbo-consume
Demo project for Spring Boot
1.8
2.1.6.RELEASE
2.7.1
org.springframework.boot
spring-boot-dependencies
${spring-boot.version}
pom
import
org.apache.dubbo
dubbo-dependencies-bom
${dubbo.version}
pom
import
org.apache.dubbo
dubbo
${dubbo.version}
org.springframework
spring
javax.servlet
servlet-api
log4j
log4j
org.apache.dubbo
dubbo-spring-boot-starter
2.7.1
org.apache.dubbo
dubbo
org.springframework.boot
spring-boot-autoconfigure
2.1.6.RELEASE
org.springframework.boot
spring-boot-starter-test
org.springframework.boot
spring-boot-starter-tomcat
com.example
dubbo-interface
1.0-SNAPSHOT
org.apache.dubbo
dubbo-dependencies-zookeeper
${dubbo.version}
pom
org.springframework.boot
spring-boot-maven-plugin
apache.snapshots.https
Apache Development Snapshot Repository
https://repository.apache.org/content/repositories/snapshots
false
true
原因分析:
可以通过mvn依赖树来分析 这个类所在包的引用
命令:mvn dependency:tree
找到这个类并定位到包 得知 是由org.apache.tomcat.embed 引进来的
而embed这个包是由 spring-boot-starter-tomcat引进来的
查看之前没有问题的工程 starter-tomcat是由starter-web包引进来的 版本号(2.0.3-RELEASE)与新工程版本(2.1.6)不一致
于是将pom文件修改 引进2.0.3的包,结果还是报异常。。
最终解决方案:
pom文件新增
org.springframework.boot
spring-boot-starter-tomcat
com.example
dubbo-interface
1.2-SNAPSHOT
org.hibernate
hibernate-validator
org.hibernate
hibernate-validator
5.1.1.Final