atom feed3 messages in net.java.dev.glassfish.ejbRe: Problem with @Resource
FromSent OnAttachments
Zhao JianyongJan 14, 2009 9:08 pm 
Baptiste MATHUSJan 15, 2009 6:35 am 
Tang YongJan 15, 2009 4:58 pm 
Subject:Re: Problem with @Resource
From:Baptiste MATHUS (ml@batmat.net)
Date:Jan 15, 2009 6:35:47 am
List:net.java.dev.glassfish.ejb

Err, if your HelloWorldRemote attribute is a SLSB, why don't you use @EJB?

Cheers

2009/1/15 Zhao Jianyong <zha@cn.fujitsu.com>

Hi everybody.

I have a very intersting problem. I used @Resource to inject a SLSB in ACC,like this: =============================================================== public class Main {

@Resource(mappedName="hello") static HelloWorldRemote helloWorld;//SLSB

@Resource(name="hello") static String hello;

public static void main(String[] args) { System.out.println(helloWorld.hello()); System.out.println(hello); }

} ============================================================= When I run the ACC, I get the right result but with some Exception,like this: ============================================================= 2009/01/14 14:25:45 com.sun.enterprise.naming.NamingManagerImpl bindObjects 致命的: NAM0006: JMS Destination object not found: hello 2009/01/14 14:25:45 com.sun.enterprise.naming.NamingManagerImpl bindObjects 致命的: javax.naming.NamingException javax.naming.NamingException: ejb ref resolution error for remote business interfaceejb.HelloWorldRemote [Root exception is java.lang.ClassNotFoundException: ejb.HelloWorldRemote] at com.sun.ejb.EJBUtils.lookupRemote30BusinessObject(EJBUtils.java:425) at

com.sun.ejb.containers.RemoteBusinessObjectFactory.getObjectInstance(RemoteBusinessObjectFactory.java:74) at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:304) at com.sun.enterprise.naming.SerialContext.lookup(SerialContext.java:403) at javax.naming.InitialContext.lookup(InitialContext.java:392) at

com.sun.enterprise.naming.NamingManagerImpl.bindObjects(NamingManagerImpl.java:391) at com.sun.enterprise.appclient.AppContainer.preInvoke(AppContainer.java:146) at

com.sun.enterprise.appclient.MainWithModuleSupport.<init>(MainWithModuleSupport.java:383) at

com.sun.enterprise.appclient.MainWithModuleSupport.<init>(MainWithModuleSupport.java:259) at com.sun.enterprise.appclient.Main.main(Main.java:200) Caused by: java.lang.ClassNotFoundException: ejb.HelloWorldRemote 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:307) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301) at java.lang.ClassLoader.loadClass(ClassLoader.java:252) at com.sun.ejb.EJBUtils.getBusinessIntfClassLoader(EJBUtils.java:679) at com.sun.ejb.EJBUtils.lookupRemote30BusinessObject(EJBUtils.java:348) ... 9 more helloworld hello =========================================================== As I know ,@Resource can't be used to inject SLSB. The behavior of GlassFish V2 is correct?

Any idea ?

Thank you...