Search code examples
springwebspherecdijava-ee-6

How to use Spring's Dependency Injection in Java EE 6 (WebSphere 8.5)?


We have a Spring-based application that is composed of several Java EE 5 Web Modules and runs fine in WebSphere Application Server 8.5. We use standard annotations from javax.inject, such as @Inject. Spring resolves that based on beans definietions in Spring xml files.

Now, if we upgrade our application to Java EE 6, the Application Server's CDI will attempt to resolve @Inject an must fail, because all of our beans are defined in Spring contexts, not in CDI contexts (we have no beans.xml).

Is it possible to force Spring to continue to handle @Inject in the Java EE 6 container (WebShpere 8.5)? I.e. disable CDI? Or does the upgrade to Java EE 6 force us to use CDI?


Solution

  • If you do not have a beans.xml in your deployment archive then CDI will not kick in and let Spring core runs the show.