To bootstrap at the Web tier.
Add the following to the web.xml
Code:
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring-config.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
Then to get access to the WebApplicationContext use the following.
Code:
ApplicationContext ctx = WebApplicationContextUtils.getWebApplicationContext(request.getSession().getServletContext())
This will retrieve the bootstrapped application context from an Application scoped variable.
To bootstrap the EJB container you can have your EJB Bean Class extend from Springs AbstractStatelessSessionBean. Then add an EJB Environment Variable with the name of "ejb/BeanFactoryPath" and value of "location of your application context file".
Code:
<env-entry>
<env-entry-name>ejb/BeanFactoryPath</env-entry-name>
<env-entry-type>java.lang.String</env-entry-type>
<env-entry-value>classpath:applicationContext.xml</env-entry-value>
</env-entry>
Then in your EJB you can use the getBeanFactory() method to get the bootstrapped application context from the EJB container.
Note: now that I re-read your problem this might be because your classpath is not the same for both the Web container and EJB container. Need to verify that you have all the jar files added to Java jar dependecies of both the Web and EJB components.