ejb@glassfish.java.net

Re: Problem with _at_Resource

From: Tang Yong <tangyong_at_cn.fujitsu.com>
Date: Fri, 16 Jan 2009 08:59:25 +0800

Hi MATHUS,

I do not agree with you a litter.

The EJB Specification only sayes that if you plan to use EJB DI,
you must use @EJB Annotation.

However, Zhao'output displayes that using @Resource can find a SLSB,
At the same time, a ClassNotFoundException is throwed. So, I think that
the output including exception is not accepted by Zhao(including me).

Other ideas?

Best Regard!

----- Original Message -----
From: Baptiste MATHUS
To: ejb_at_glassfish.dev.java.net
Sent: Thursday, January 15, 2009 10:36 PM
Subject: Re: Problem with @Resource


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

Cheers


2009/1/15 Zhao Jianyong <zhaojy_at_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 ,_at_Resource can't be used to inject SLSB.
The behavior of GlassFish V2 is correct?

Any idea ?

Thank you...

---------------------------------------------------------------------
To unsubscribe, e-mail: ejb-unsubscribe_at_glassfish.dev.java.net
For additional commands, e-mail: ejb-help_at_glassfish.dev.java.net





--
Baptiste <Batmat> MATHUS - http://batmat.net
Sauvez un arbre,
Mangez un castor !