[jboss-user] [EJB 3.0] - Default JNDI Naming

nomike do-not-reply at jboss.com
Wed Sep 27 07:50:59 EDT 2006


Hi!

I'm currently exploring EJB 3.0 using the Book "Mastering EJB 3.0 4th Edition".
I have written a small test-session-bean.

It consists of the following:
MyMath.java

  | package at.tac.ejb3.test.mymath;
  | 
  | /**
  |  * @author michael
  |  * @version 0.1.0.0 27.09.2006
  |  */
  | public interface MyMath {
  |   public Integer sum(Integer a, Integer b);
  | }
  | 
MyMathBean.java

  | /**
  |  *
  |  * @author michael
  |  * @version 0.1.0.0 27.09.2006
  |  */
  | package at.tac.ejb3.test.mymath;
  | 
  | import javax.ejb.Stateless;
  | import javax.ejb.Remote;
  | import javax.ejb.Local;
  | 
  | @Stateless
  | @Remote(MyMath.class)
  | @Local(MyMath.class)
  | public class MyMathBean implements MyMath{
  |   public Integer sum(Integer a, Integer b) {
  |     return a + b;
  |   }
  | }
  | 
It has no ejb-jar.xml and the jboss.xml, persistence.xml and jbosscmp-jdbc.xml don't contain any valuable data.

My first Question now: What is the name of my "Bean" now? "MyMath" or "MyMathBean"?

In the book I read anonymous wrote : The EJB 3.0 specification mandates that containers bind beans to the JNDI tree by their fully qualified names at deployment time. This ensures that we can look up the beans in a very simple way.

But when I invoke list() on the JNDIView Bean using jmx-console I get:

  | java: Namespace
  |   +- XAConnectionFactory (class: org.jboss.mq.SpyXAConnectionFactory)
  |   +- DefaultDS (class: org.jboss.resource.adapter.jdbc.WrapperDataSource)
  |   +- SecurityProxyFactory (class: org.jboss.security.SubjectSecurityProxyFactory)
  |   +- DefaultJMSProvider (class: org.jboss.jms.jndi.JNDIProviderAdapter)
  |   +- comp (class: javax.naming.Context)
  |   +- JmsXA (class: org.jboss.resource.adapter.jms.JmsConnectionFactoryImpl)
  |   +- ConnectionFactory (class: org.jboss.mq.SpyConnectionFactory)
  |   +- jaas (class: javax.naming.Context)
  |   |   +- other (class: org.jboss.security.plugins.SecurityDomainContext)
  |   |   +- HsqlDbRealm (class: org.jboss.security.plugins.SecurityDomainContext)
  |   |   +- jbossmq (class: org.jboss.security.plugins.SecurityDomainContext)
  |   |   +- JmsXARealm (class: org.jboss.security.plugins.SecurityDomainContext)
  |   +- timedCacheFactory (class: javax.naming.Context)
  | Failed to lookup: timedCacheFactory, errmsg=org.jboss.util.TimedCachePolicy
  |   +- TransactionPropagationContextExporter (class: org.jboss.tm.TransactionPropagationContextFactory)
  |   +- StdJMSPool (class: org.jboss.jms.asf.StdServerSessionPoolFactory)
  |   +- Mail (class: javax.mail.Session)
  |   +- comp.ejb3 (class: javax.naming.Context)
  |   |   NonContext: null
  |   +- TransactionPropagationContextImporter (class: org.jboss.tm.TransactionPropagationContextImporter)
  |   +- TransactionManager (class: org.jboss.tm.TxManager)
  | 
  | Global JNDI Namespace
  |   +- XAConnectionFactory (class: org.jboss.mq.SpyXAConnectionFactory)
  |   +- TopicConnectionFactory (class: org.jboss.naming.LinkRefPair)
  |   +- EventDispatcher (class: org.jboss.ws.eventing.mgmt.DispatcherDelegate)
  |   +- UserTransactionSessionFactory (proxy: $Proxy42 implements interface org.jboss.tm.usertx.interfaces.UserTransactionSessionFactory)
  |   +- UIL2ConnectionFactory[link -> ConnectionFactory] (class: javax.naming.LinkRef)
  |   +- UIL2XAConnectionFactory[link -> XAConnectionFactory] (class: javax.naming.LinkRef)
  |   +- QueueConnectionFactory (class: org.jboss.naming.LinkRefPair)
  |   +- topic (class: org.jnp.interfaces.NamingContext)
  |   |   +- testDurableTopic (class: org.jboss.mq.SpyTopic)
  |   |   +- testTopic (class: org.jboss.mq.SpyTopic)
  |   |   +- securedTopic (class: org.jboss.mq.SpyTopic)
  |   +- queue (class: org.jnp.interfaces.NamingContext)
  |   |   +- A (class: org.jboss.mq.SpyQueue)
  |   |   +- testQueue (class: org.jboss.mq.SpyQueue)
  |   |   +- ex (class: org.jboss.mq.SpyQueue)
  |   |   +- DLQ (class: org.jboss.mq.SpyQueue)
  |   |   +- D (class: org.jboss.mq.SpyQueue)
  |   |   +- C (class: org.jboss.mq.SpyQueue)
  |   |   +- B (class: org.jboss.mq.SpyQueue)
  |   +- MyMathBean (class: org.jnp.interfaces.NamingContext)
  |   |   +- local (proxy: $Proxy73 implements interface at.tac.ejb3.test.mymath.MyMath,interface org.jboss.ejb3.JBossProxy,interface javax.ejb.EJBLocalObject)
  |   |   +- remote (proxy: $Proxy72 implements interface at.tac.ejb3.test.mymath.MyMath,interface org.jboss.ejb3.JBossProxy,interface javax.ejb.EJBObject)
  |   +- ConnectionFactory (class: org.jboss.mq.SpyConnectionFactory)
  |   +- UserTransaction (class: org.jboss.tm.usertx.client.ClientUserTransaction)
  |   +- jmx (class: org.jnp.interfaces.NamingContext)
  |   |   +- invoker (class: org.jnp.interfaces.NamingContext)
  |   |   |   +- RMIAdaptor (proxy: $Proxy36 implements interface org.jboss.jmx.adaptor.rmi.RMIAdaptor,interface org.jboss.jmx.adaptor.rmi.RMIAdaptorExt)
  |   |   +- rmi (class: org.jnp.interfaces.NamingContext)
  |   |   |   +- RMIAdaptor[link -> jmx/invoker/RMIAdaptor] (class: javax.naming.LinkRef)
  |   +- UILXAConnectionFactory[link -> XAConnectionFactory] (class: javax.naming.LinkRef)
  |   +- UILConnectionFactory[link -> ConnectionFactory] (class: javax.naming.LinkRef)
  | 
and JBoss throws an error to the console:

  | 13:46:33,895 ERROR [JNDIView] JNDIView.getHAJndiAttributes() failed
  | java.lang.NullPointerException: name cannot be null
  | 	at javax.management.ObjectName.construct(ObjectName.java:342)
  | 	at javax.management.ObjectName.<init>(ObjectName.java:1304)
  | 	at org.jboss.naming.JNDIView.getHAJndiAttributes(JNDIView.java:836)
  | 	at org.jboss.naming.JNDIView.getHAUrl(JNDIView.java:811)
  | 	at org.jboss.naming.JNDIView.list(JNDIView.java:193)
  | 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  | 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
  | 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
  | 	at java.lang.reflect.Method.invoke(Method.java:585)
  | 	at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
  | 	at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
  | 	at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:133)
  | 	at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
  | 	at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:142)
  | 	at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
  | 	at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
  | 	at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
  | 	at org.jboss.jmx.adaptor.control.Server.invokeOpByName(Server.java:258)
  | 	at org.jboss.jmx.adaptor.control.Server.invokeOp(Server.java:223)
  | 	at org.jboss.jmx.adaptor.html.HtmlAdaptorServlet.invokeOp(HtmlAdaptorServlet.java:262)
  | 	at org.jboss.jmx.adaptor.html.HtmlAdaptorServlet.processRequest(HtmlAdaptorServlet.java:100)
  | 	at org.jboss.jmx.adaptor.html.HtmlAdaptorServlet.doPost(HtmlAdaptorServlet.java:82)
  | 	at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
  | 	at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
  | 	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
  | 	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
  | 	at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
  | 	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
  | 	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
  | 	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
  | 	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
  | 	at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:175)
  | 	at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74)
  | 	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
  | 	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
  | 	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
  | 	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
  | 	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
  | 	at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
  | 	at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
  | 	at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
  | 	at java.lang.Thread.run(Thread.java:595)
  | 

So what do I have to do to get
context.lookup(MyMath.class.getName()); or
context.lookup(MyMathBean.class.getName()); (I don't know which is right)
working as in the book?

thx in advance

nomike aka Michael Postmann

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3974509#3974509

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3974509



More information about the jboss-user mailing list