[jboss-user] [Beginners Corner] - Wrong class when getting started.

aleccawley do-not-reply at jboss.com
Thu Oct 12 06:54:35 EDT 2006


I am trying to get started with EJB3 in JBoss. I have installed JBoss4.0.4GA and patched in jboss-EJB-3.0_RC9-FD. Then I have written my first Stateless Session Bean, derived from the training course, and (after some trouble) deployed it.

I then try to access it with my Client, using the code below.
  public static void main (String[] args) throws Exception
    {

    Properties props = new Properties () ;
    props.setProperty ("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory") ;
    props.setProperty ("java.naming.provider.url", "localhost:1099") ;

    InitialContext ctx = new InitialContext (props) ;

    Object o = ctx.lookup (CalcImpl.class.getSimpleName ()) ;
    Calc calculator = (Calc) o ;
    System.out.println ("1 + 1 = " + calculator.add (1, 1)) ;
    System.out.println ("1 - 1 = " + calculator.subtract (1, 1)) ;

    }

But the Object o returned from ctx.lookup is not, as I expect, a CalcImpl Object, but a NamingContext Object, which then causes a Class Cast error. 

What am I doing wrong?

Incidentally, after patching, the JBoss startup throws this exception:
        ... 83 more
11:42:02,648 ERROR [MainDeployer] Could not create deployment: file:/C:/JBoss/jboss-4.0.4.GA/server/default/deploy/ejb3-entity-cache-service.xml
org.jboss.deployment.DeploymentException: No ClassLoaders found for: org.jboss.cache.TreeCache; - nested throwable: (java.lang.ClassNotFoundException: No ClassLoaders found for: org.jboss.cache.TreeCache)
        at org.jboss.system.ServiceConfigurator.install(ServiceConfigurator.java:196)
        at org.jboss.system.ServiceController.install(ServiceController.java:226)

Should I worry? Should I report?

Thanks for any help

Alec




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

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



More information about the jboss-user mailing list