Spring 启动应用程序 WAR 部署到 Resin 4:有没有办法先使用应用程序 (WEB-INF/lib) 类加载器?

Spring Boot application WAR deployment to Resin 4: is there a way to use app (WEB-INF/lib) classloader first?

我正在尝试将 Spring 引导应用程序作为 WAR 部署到 Caucho Resin 4。我在点击该应用程序时遇到错误:

org.springframework.context.ApplicationContextException: Unable to
start embedded container; nested exception is
org.springframework.beans.factory.BeanCreationException: Error creating
bean with name
'org.springframework.boot.autoconfigure.jersey.JerseyAutoConfiguration'
: Bean instantiation via constructor failed; nested exception is
org.springframework.beans.BeanInstantiationException: Failed to
instantiate
[org.springframework.boot.autoconfigure.jersey.JerseyAutoConfiguration$
$EnhancerBySpringCGLIB$b91c9d]: Constructor threw exception; nested
exception is
org.springframework.beans.factory.UnsatisfiedDependencyException: Error
creating bean with name 'dashboardResource' defined in file
[/var/resin/webapps/itasng-0.8.5/WEB-INF/classes/gov/nih/cit/itasng/
rest/DashboardResource.class]: Unsatisfied dependency expressed through
constructor parameter 0; nested exception is
org.springframework.beans.factory.UnsatisfiedDependencyException: Error
creating bean with name 'payPeriodRepository' defined in file
[/var/resin/webapps/itasng-0.8.5/WEB-INF/classes/gov/nih/cit/itasng/
persistence/PayPeriodRepository.class]: Unsatisfied dependency
expressed through constructor parameter 0; nested exception is
org.springframework.beans.factory.BeanCreationException: Error creating
bean with name
'org.springframework.orm.jpa.SharedEntityManagerCreator#0': Cannot
resolve reference to bean 'entityManagerFactory' while setting
constructor argument; nested exception is
org.springframework.beans.factory.BeanCreationException: Error creating
bean with name 'entityManagerFactory' defined in class path resource
[org/springframework/boot/autoconfigure/orm/jpa/
HibernateJpaAutoConfiguration.class]: Invocation of init method failed;
nested exception is java.lang.NoSuchMethodError:
javax.persistence.Table.indexes()[Ljavax/persistence/Index; at
org.springframework.boot.context.embedded.EmbeddedWebApplicationContext
.onRefresh(EmbeddedWebApplicationContext.java:137)
~[spring-boot-1.5.7.RELEASE.jar:1.5.7.RELEASE]
...

很明显,这是一个典型的 class-loading 问题:classes 由父 class-loader 从 Resin lib 加载(例如 lib/javaee-16.jar ) 导致使用较新版本构建的应用出现问题(例如 WEB-INF/lib/hibernate-jpa-2.1-api-1.0.0.Final.jar).

我之前使用的大多数应用程序服务器在特定于供应商的 –web.xml 描述符中的某处都有一个设置来切换 class 加载程序顺序,以便 WEB-INF/lib classes 加载第一的。但是,如果存在这样的选项,Resin 文档并没有一个简单的答案。

有没有办法在 Resin 4 中切换 class 加载顺序或者有什么替代解决方案?

Resin 4.0无法先使用app classloader

相关类加载问题的潜在解决方法可能涉及使用 <jvm-classpath> 优先于 Resin 的类路径。

一个示例用例是使用更高版本的 JPA 而不是已部署的 JPA 2.0 out-of-the-box。

文档参考:

http://www.caucho.com/resin-4.0/admin/cluster-config.xtp#jvm-classpath