IllegalArgumentException: interface example.MyInterface is not visible from class loader when deploying multiple Spring applications

Solution Verified - Updated -

Issue

We are encountering a "Class is not visible from class loader" Exception when we try to deploy two WAR artifacts that use spring (deployed on jboss as module) and share a common component, that is deployed in WARs lib/ directory. The problem only occurs, when the artifacts are deployed at the same time (i.e. at jboss start). When we deploy the artifacts one by one it works.

The exception occurs at the class org.springframework.aop.framework.JdkDynamicAopProxy due to the fact, that this class gets the same class loader for both deployments (i.e. both get either the ModuleClassLoader of deployment 1 or deployment 2). The classloader is supplied by the class org.springframework.aop.framework.AbstractAdvisingBeanPostProcessor.postProcessAfterInitialization through org.springframework.util.ClassUtils.

Caused by: java.lang.IllegalArgumentException: interface example.MyInterface is not visible from class loader
    at java.lang.reflect.Proxy.getProxyClass(Proxy.java:353) [rt.jar:1.6.0_38]
    at java.lang.reflect.Proxy.newProxyInstance(Proxy.java:581) [rt.jar:1.6.0_38] 
    at org.springframework.aop.framework.JdkDynamicAopProxy.getProxy(JdkDynamicAopProxy.java:119) [spring-aop-3.2.1.RELEASE.jar:3.2.1.RELEASE]
    at org.springframework.aop.framework.ProxyFactory.getProxy(ProxyFactory.java:111) [spring-aop-3.2.1.RELEASE.jar:3.2.1.RELEASE]
    at org.springframework.aop.framework.AbstractAdvisingBeanPostProcessor.postProcessAfterInitialization(AbstractAdvisingBeanPostProcessor.java:85) [spring-aop-3.2.1.RELEASE.jar:3.2.1.RELEASE]

Environment

  • Red Hat JBoss Enterprise Application Platform (EAP)
    • 6.x

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase of over 48,000 articles and solutions.

Current Customers and Partners

Log in for full access

Log In
Close

Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.