Bill,
sorry i needed to be more precise
I have an EJB3 in which i want to inject a spring bean..
i have followed this link
http://twasink.net/blog/archives/200...spring_wi.html
and down the article it mentioned
SpringBeanAutowiringInterceptor
here's my code
Code:
@Stateless (name="Facade")
@Interceptors(SpringBeanAutowiringInterceptor.class)
public class StatelessFacade implements Facade {
@Autowired
private MySpringBean mySpringBean;
public String getFoobar() {
return "Foobar";
}
}
here'sm by beanRefContext.xml
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
<bean id="factoryKey"
class="org.springframework.context.support.ClassPathXmlAp plicationContext">
<constructor-arg value="myBeansContext.xml"/>
</bean>
</beans>
and here' smy myBeansContext.xml
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<!--
- Application context for EJB3
-->
<beans>
<bean id="simpleBean"
class="com.mm.j2me.spring.MySpringBean"/>
</bean>
</beans>
and here' sexception
Code:
java.lang.RuntimeException: org.springframework.beans.factory.access.BootstrapEx
ception: Unable to initialize group definition. Group resource name [classpath*:
beanRefContext.xml], factory key [null]; nested exception is org.springframework
.beans.factory.CannotLoadBeanClassException: Cannot find class [org.springframew
ork.context.support.ClassPathXmlAp plicationContext] for bean with name 'factory
Key' defined in URL [file:/C:/Sw/J2MEJobApp/ejbJ2ME/target/classes/beanRefContex
t.xml]; nested exception is java.lang.ClassNotFoundException: org.springframewor
k.context.support.ClassPathXmlAp plicationContext
at org.jboss.ejb3.interceptor.LifecycleInterceptorHandler.postConstruct(
LifecycleInterceptorHandler.java:113)
at org.jboss.ejb3.EJBContainer.invokePostConstruct(EJBContainer.java:505
)
at org.jboss.ejb3.AbstractPool.create(AbstractPool.java:112)
at org.jboss.ejb3.ThreadlocalPool.get(ThreadlocalPool.java:48)
at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(Stateles
sInstanceInterceptor.java:54)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.
java:101)
at org.jboss.aspects.security.AuthenticationInterceptor.invoke(Authentic
ationInterceptor.java:77)
at org.jboss.ejb3.security.Ejb3AuthenticationInterceptor.invoke(Ejb3Auth
enticationInterceptor.java:102)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.
java:101)
at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterce
ptor.java:47)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.
java:101)
at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(Asynchrono
usInterceptor.java:106)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.
java:101)
at org.jboss.ejb3.stateless.StatelessContainer.localInvoke(StatelessCont
ainer.java:211)
at org.jboss.ejb3.stateless.StatelessLocalProxy.invoke(StatelessLocalPro
xy.java:79)
at $Proxy28.getFoobar(Unknown Source)
at example1.StatelessFacadeTest.testFoobar(StatelessFacadeTest.java:38)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.testng.internal.MethodHelper.invokeMethod(MethodHelper.java:552)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:411)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:785)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:114)
at org.testng.TestRunner.privateRun(TestRunner.java:693)
at org.testng.TestRunner.run(TestRunner.java:574)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:241)
at org.testng.SuiteRunner.run(SuiteRunner.java:145)
at org.testng.TestNG.createAndRunSuiteRunners(TestNG.java:901)
at org.testng.TestNG.runSuitesLocally(TestNG.java:863)
at org.testng.TestNG.run(TestNG.java:613)
at org.apache.maven.surefire.testng.TestNGExecutor.run(TestNGExecutor.ja
va:74)
at org.apache.maven.surefire.testng.TestNGXmlTestSuite.execute(TestNGXml
TestSuite.java:92)
at org.apache.maven.surefire.Surefire.run(Surefire.java:177)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(Su
refireBooter.java:339)
at org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.j
ava:997)
Caused by: org.springframework.beans.factory.access.BootstrapException: Unable t
o initialize group definition. Group resource name [classpath*:beanRefContext.xm
l], factory key [null]; nested exception is org.springframework.beans.factory.Ca
nnotLoadBeanClassException: Cannot find class [org.springframework.context.suppo
rt.ClassPathXmlAp plicationContext] for bean with name 'factoryKey' defined in U
RL [file:/C:/Sw/J2MEJobApp/ejbJ2ME/target/classes/beanRefContext.xml]; nested ex
ception is java.lang.ClassNotFoundException: org.springframework.context.support
.ClassPathXmlAp plicationContext
at org.springframework.beans.factory.access.SingletonBeanFactoryLocator.
useBeanFactory(SingletonBeanFactoryLocator.java:389)
at org.springframework.ejb.interceptor.SpringBeanAutowiringInterceptor.g
etBeanFactoryReference(SpringBeanAutowiringInterceptor.java:132)
at org.springframework.ejb.interceptor.SpringBeanAutowiringInterceptor.g
etBeanFactory(SpringBeanAutowiringInterceptor.java:113)
at org.springframework.ejb.interceptor.SpringBeanAutowiringInterceptor.a
utowireBean(SpringBeanAutowiringInterceptor.java:93)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.jboss.ejb3.interceptor.LifecycleInvocationContextImpl.proceed(Lif
ecycleInvocationContextImpl.java:131)
at org.jboss.ejb3.interceptor.LifecycleInterceptorHandler.postConstruct(
LifecycleInterceptorHandler.java:109)
... 40 more
Caused by: org.springframework.beans.factory.CannotLoadBeanClassException: Canno
t find class [org.springframework.context.support.ClassPathXmlAp plicationContex
t] for bean with name 'factoryKey' defined in URL [file:/C:/Sw/J2MEJobApp/ejbJ2M
E/target/classes/beanRefContext.xml]; nested exception is java.lang.ClassNotFoun
dException: org.springframework.context.support.ClassPathXmlAp plicationContext
at org.springframework.beans.factory.support.AbstractBeanFactory.resolve
BeanClass(AbstractBeanFactory.java:1173)
at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.predictBeanType(AbstractAutowireCapableBeanFactory.java:479)
at org.springframework.beans.factory.support.AbstractBeanFactory.isFacto
ryBean(AbstractBeanFactory.java:787)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.
preInstantiateSingletons(DefaultListableBeanFactory.java:393)
at org.springframework.context.support.AbstractApplicationContext.finish
BeanFactoryInitialization(AbstractApplicationContext.java:736)
at org.springframework.context.support.AbstractApplicationContext.refres
h(AbstractApplicationContext.java:369)
at org.springframework.context.access.ContextSingletonBeanFactoryLocator
.initializeDefinition(ContextSingletonBeanFactoryLocator.java:141)
at org.springframework.beans.factory.access.SingletonBeanFactoryLocator.
useBeanFactory(SingletonBeanFactoryLocator.java:384)
... 49 more
Caused by: java.lang.ClassNotFoundException: org.springframework.context.support
.ClassPathXmlAp plicationContext
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at org.springframework.util.ClassUtils.forName(ClassUtils.java:230)
at org.springframework.beans.factory.support.AbstractBeanDefinition.reso
lveBeanClass(AbstractBeanDefinition.java:381)
at org.springframework.beans.factory.support.AbstractBeanFactory.resolve
BeanClass(AbstractBeanFactory.java:1170)
... 56 more
i m running my tests using jboss embedded container and testNG, and when i ran tehm using mvn -X to see what's in classpath i can clearly see spring-2.5.1.jar
Code:
C:\Documents and Settings\Marco Mistroni\.m2\repository\org\springframework\spring\2.5.1\spring-2.5.1.jar, C:\Sw\J2MEJobApp\ejbJ2ME\lib\jbossws-client-1.3.jar]
could you please help me out?
thanks and regards
marco
thanks and regards
marco