讨论区 » AAS-V10企业版 »
javax.validation的ClassCastException类转换异常
报错提示:
[2023-03-16T21:48:00] [] [SEVERE] [] [javax.enterprise.web.core] [tid: _ThreadID=92 _ThreadName=ApusicLogManager] [timeMillis: 1678974480468] [levelValue: 1000] [[
Error invoking ServletContainerInitializer org.springframework.web.SpringServletContainerInitializer
javax.validation.ValidationException: RESTEASY008520: Unable to load Validation support
at org.jboss.resteasy.plugins.validation.AbstractValidatorContextResolver.getContext(AbstractValidatorContextResolver.java:94)
at org.jboss.resteasy.plugins.validation.ValidatorContextResolver.getContext(ValidatorContextResolver.java:16)
at org.jboss.resteasy.core.ResourceMethodInvoker.<init>(ResourceMethodInvoker.java:153)
at org.jboss.resteasy.core.ResourceMethodRegistry.processMethod(ResourceMethodRegistry.java:381)
at org.jboss.resteasy.core.ResourceMethodRegistry.register(ResourceMethodRegistry.java:308)
at org.jboss.resteasy.core.ResourceMethodRegistry.addResourceFactory(ResourceMethodRegistry.java:259)
at org.jboss.resteasy.core.ResourceMethodRegistry.addResourceFactory(ResourceMethodRegistry.java:227)
at org.jboss.resteasy.core.ResourceMethodRegistry.addResourceFactory(ResourceMethodRegistry.java:208)
at org.jboss.resteasy.core.ResourceMethodRegistry.addResourceFactory(ResourceMethodRegistry.java:192)
at org.jboss.resteasy.plugins.spring.SpringBeanProcessor.onApplicationEvent(SpringBeanProcessor.java:531)
at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:176)
at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:169)
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:143)
at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:421)
at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:378)
at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:938)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:586)
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:145)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:745)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:423)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:307)
at org.springframework.boot.web.servlet.support.SpringBootServletInitializer.run(SpringBootServletInitializer.java:175)
at org.springframework.boot.web.servlet.support.SpringBootServletInitializer.createRootApplicationContext(SpringBootServletInitializer.java:155)
at org.springframework.boot.web.servlet.support.SpringBootServletInitializer.onStartup(SpringBootServletInitializer.java:97)
at org.springframework.web.SpringServletContainerInitializer.onStartup(SpringServletContainerInitializer.java:174)
at org.apache.catalina.core.StandardContext.callServletContainerInitializers(StandardContext.java:5764)
at com.sun.enterprise.web.WebModule.callServletContainerInitializers(WebModule.java:609)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:5660)
at com.sun.enterprise.web.WebModule.start(WebModule.java:526)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:885)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:868)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:644)
at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:2069)
at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:1690)
at com.sun.enterprise.web.WebApplication.start(WebApplication.java:83)
at com.apusic.aas.internal.data.EngineRef.start(EngineRef.java:98)
at com.apusic.aas.internal.data.ModuleInfo.start(ModuleInfo.java:267)
at com.apusic.aas.internal.data.ApplicationInfo.start(ApplicationInfo.java:358)
at com.apusic.enterprise.v10.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:479)
at com.apusic.enterprise.v10.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:197)
at com.apusic.aas.deployment.admin.DeployCommand.execute(DeployCommand.java:489)
at com.apusic.enterprise.v10.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.java:523)
at com.apusic.enterprise.v10.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.java:519)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at java.base/javax.security.auth.Subject.doAs(Subject.java:361)
at com.apusic.enterprise.v10.admin.CommandRunnerImpl$2.execute(CommandRunnerImpl.java:518)
at com.apusic.enterprise.v10.admin.CommandRunnerImpl$3.run(CommandRunnerImpl.java:549)
at com.apusic.enterprise.v10.admin.CommandRunnerImpl$3.run(CommandRunnerImpl.java:541)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at java.base/javax.security.auth.Subject.doAs(Subject.java:361)
at com.apusic.enterprise.v10.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:540)
at com.apusic.enterprise.v10.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1448)
at com.apusic.enterprise.v10.admin.CommandRunnerImpl.access$1500(CommandRunnerImpl.java:88)
at com.apusic.enterprise.v10.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1842)
at com.apusic.aas.deployment.autodeploy.AutoOperation.run(AutoOperation.java:143)
at com.apusic.aas.deployment.autodeploy.AutoDeployer.deploy(AutoDeployer.java:580)
at com.apusic.aas.deployment.autodeploy.AutoDeployer.deployAll(AutoDeployer.java:467)
at com.apusic.aas.deployment.autodeploy.AutoDeployer.run(AutoDeployer.java:389)
at com.apusic.aas.deployment.autodeploy.AutoDeployer.run(AutoDeployer.java:380)
at com.apusic.aas.deployment.autodeploy.AutoDeployService$1.run(AutoDeployService.java:209)
at java.base/java.util.TimerThread.mainLoop(Timer.java:556)
at java.base/java.util.TimerThread.run(Timer.java:506)
Caused by: java.lang.ClassCastException: Cannot cast org.hibernate.validator.internal.engine.ValidatorFactoryImpl to javax.validation.ValidatorFactory
at java.base/java.lang.Class.cast(Class.java:3605)
at org.jboss.resteasy.plugins.validation.AbstractValidatorContextResolver.getValidatorFactory(AbstractValidatorContextResolver.java:51)
at org.jboss.resteasy.plugins.validation.AbstractValidatorContextResolver.getContext(AbstractValidatorContextResolver.java:90)
... 61 more
处理方案:
1. 修改jvm参数,-Dcom.apusic.enterprise.overrideablejavaxpackages的原javax.validation改为javax.ws
-Dcom.apusic.enterprise.overrideablejavaxpackages=javax.ws
2.设置apusic-web.xml,放到应用的WEB-INF目录下
<?xml version="1.0" encoding="UTF-8"?>
<aas-web-app error-url="">
<class-loader delegate="false">
<property name="ignoreParentsFiles" value="true"></property>
<property name="ignoreResources" value="META-INF/services/javax.servlet.ServletContainerInitializer;META-INF/services/org.jboss.resteasy.spi.ResteasyUriBuilder;META-INF/services/org.glassfish.jersey.server.spi.ComponentProvider;META-INF/services/org.glassfish.jersey.servlet.internal.spi.ServletContainerProvider;META-INF/services/javax.validation.spi.ValidationProvider"></property>
<property name="ignoreClassPrefix" value="org.glassfish.jersey;org.hibernate.validator"></property>
</class-loader>
</aas-web-app>
apusic-web.xml (680 Bytes) apusic-web.xml |