13 Replies Latest reply on Feb 9, 2004 11:41 PM by juha

    Can't get my client app to work

    adrianc

      I'm new to JBoss and I've poured over all the documentation I was able to download - yet I can't seem to get a simple client app to work.

      I compiled a simple session bean into a jar file and dropped it in the deploy directory. JBoss loaded it. I dropped the following xml file in the deploy directory to bind the session bean to jndi:

      <hal-core>
      <jndi-name>hal-core</jndi-name>
      <ejb-ref>
      <ejb-ref-name>core/CAppManagerBean</ejb-ref-name>
      <jndi-name>AppManager</jndi-name>
      </ejb-ref>
      </hal-core>

      With that done, I attempted to get a GUI remote client to use the single method in the session bean, using this code:

      public static void TryTheBean()
      {
      // Identify service provider to use
      // taken from JBoss user manual
      Hashtable env = new Hashtable(11);
      env.put("java.naming.factory.initial",
      "org.jnp.interfaces.NamingContextFactory");
      env.put("java.naming.factory.url.pkgs",
      "org.jboss.naming.client");
      env.put("java.naming.provider.url",
      "jnp://java.hlmksw.com:1099");

      try
      {
      Context initial = new InitialContext(env);
      Object objref = initial.lookup("AppManager");
      CAppManagerHome home = (CAppManagerHome)PortableRemoteObject.narrow(objref,CAppManagerHome.class);
      CAppManager AppBean = home.create();
      String msg = "Version " + AppBean.Version();
      frame.setTitle(msg);
      }
      catch (Exception e)
      {
      System.err.println("EJB error");
      e.printStackTrace();
      }

      }

      The initial.lookup method throws the exception:
      "javax.naming.NameNotFoundException: AppManager not bound"

      Now what do I do?

      Thanks in advance for your help!


        • 1. Re: Can't get my client app to work
          marc.fleury

          hey you seem to be reinventing the wheel on XML files here and obviously your EJB isn't deployed correctly. Please read the intro documentation for examples of well formatted XML.

          I would like to recommend you use the Eclipse IDE if you can (I use it) and it formats all the XML correctly with simple generation through XDoclet tags and such. You can find all the documentation on line.

          Pay attention to your XML and we should be fine,

          • 2. Re: Can't get my client app to work
            adrianc

            *sigh* Eclipse - another poorly documented open source project.

            I truly appreciate the reply, and I downloaded Eclipse and the JBoss plug-in. Now I can't get anything to compile. The project compiled great with JBuilder.

            I'm determined to get our apps running on JBoss - I just wish it wasn't so complicated.

            • 3. Re: Can't get my client app to work

              What is that XML with < hal-core> tags? What does your ejb-jar.xml and jboss.xml files look like?

              • 4. Re: Can't get my client app to work
                adrianc

                That's the core of my problem - JBuilder isn't generating any XML files, and I've searched reams of documentation trying to find out which XML files are needed and what they should contain.

                • 5. Re: Can't get my client app to work
                  adrianc

                  Okay, I re-read all the JBoss documentation and I now understand I need to run ant on the jboss-build.xml file - but the one mentioned in the docs is for the Dukes Bank example. Is there a generic jboss-build.xml file that I can modify to build my app?

                  • 6. Re: Can't get my client app to work
                    adrianc

                    Here is the bean code:

                    public class CAppManagerBean implements SessionBean
                    {
                    public String Version()
                    {
                    return "1.0";
                    }
                    public CAppManagerBean(){}
                    public void ejbCreate(){}
                    public void ejbRemove(){}
                    public void ejbActivate(){}
                    public void ejbPassivate(){}
                    public void setSessionContext(SessionContext sc){}
                    }

                    The bean is compiled into a core.jar file.

                    Here is the jboss.xml file:


                    <enterprise-beans>

                    <ejb-name>CAppManagerBean</ejb-name>
                    <jndi-name>AppManager</jndi-name>

                    </enterprise-beans>


                    Here is the ejb-jar.xml file:

                    <?xml version="1.0" encoding="UTF-8"?>

                    <!DOCTYPE application PUBLIC '-//Sun Microsystems, Inc.//DTD J2EE Application 1.3//EN' 'http://java.sun.com/dtd/application_1_3.dtd'>


                    <display-name>HAL-Core</display-name>
                    Application description

                    core.jar



                    I was able to get AntRunner to work in JBuilder, so progress is being made. I believe there's some information I'm missing here.

                    • 7. Re: Can't get my client app to work
                      adrianc

                      #$%^&@!!!

                      My code was mangled by the forum. *sigh* Let me try again. (my apologies for the excessive posting)

                      Bean code was posted fine previously.

                      Here is the jboss.xml file:


                      <enterprise-beans>

                      <ejb-name>CAppManagerBean</ejb-name>
                      <jndi-name>AppManager</jndi-name>

                      </enterprise-beans>


                      Here is the ejb-jar.xml file:

                      <?xml version="1.0" encoding="UTF-8"?>

                      <!DOCTYPE application PUBLIC '-//Sun Microsystems, Inc.//DTD J2EE Application 1.3//EN' 'http://java.sun.com/dtd/application_1_3.dtd'>


                      <display-name>HAL-Core</display-name>
                      Application description

                      core.jar



                      • 8. Re: Can't get my client app to work

                        the forums are messed up, sorry about that :(

                        You can use the preview button if you can find a way to post your files without the forums destroying the content.

                        • 9. Re: Can't get my client app to work
                          adrianc

                          I spent the last three days downloading more information, I installed XDoclet and Chocolate, I started my project over from scratch, I followed every instruction exactly, and I still can't get this simple bean to deploy.

                          Here is the source code for the bean:

                          package com.hlmksw.hal.framework.server;

                          import javax.ejb.SessionBean;
                          import javax.ejb.SessionContext;

                          public class VersionBean implements SessionBean
                          {

                          private SessionContext context;

                          public void setSessionContext( SessionContext context)
                          {
                          this.context = context;
                          }

                          public void ejbActivate() { }
                          public void ejbPassivate() { }
                          public void ejbRemove() { }
                          public void ejbCreate() { }

                          public java.lang.String Value()
                          {
                          return "1.0";
                          }

                          }

                          Here is the ejb-jar.xml file (double slashes prepended to each line for posting purposes):

                          //<?xml version="1.0" encoding="UTF-8"?>
                          //<!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN" "http://java.sun.com/dtd/ejb-jar_2_0.dtd">

                          //<ejb-jar >

                          // HAL-J Version Bean
                          // <display-name>HAL-J Version Bean</display-name>

                          // <enterprise-beans>

                          //
                          // <display-name>VersionBean</display-name>
                          // <ejb-name>VersionBean</ejb-name>
                          // <jndi-name>Version</jndi-name>
                          // com.hlmksw.hal.framework.server.VersionHome
                          // com.hlmksw.hal.framework.server.Version
                          //<ejb-class>com.hlmksw.hal.framework.server.VersionBean</ejb-class>
                          // <session-type>Stateless</session-type>
                          // <transaction-type>Bean</transaction-type>
                          //


                          // </enterprise-beans>

                          //</ejb-jar>


                          Here is the jboss.xml file (generated by XDoclet):

                          //<?xml version="1.0" encoding="UTF-8"?>
                          //<!DOCTYPE jboss PUBLIC "-//JBoss//DTD JBOSS 3.0//EN" "http://www.jboss.org/j2ee/dtd/jboss_3_0.dtd">

                          //

                          // <security-domain>java:/jaas/samples</security-domain>

                          // <enterprise-beans>

                          // </enterprise-beans>

                          // <resource-managers>
                          // </resource-managers>

                          //

                          Here is the application descriptor:

                          //<?xml version="1.0" encoding="UTF-8"?>

                          //<!DOCTYPE application PUBLIC '-//Sun Microsystems, Inc.//DTD J2EE Application 1.3//EN' 'http://java.sun.com/dtd/application_1_3.dtd'>

                          //
                          // <display-name>HAL-J Core</display-name>
                          // Application description
                          //
                          // core.jar
                          //
                          //

                          • 10. Re: Can't get my client app to work
                            adrianc

                            I've given up trying to post the requested XML files - the forum keeps destroying them. If anyone is interested in helping me with this problem, I can email the xml files to them.

                            • 11. Re: Can't get my client app to work
                              marc.fleury

                              let's put this as a todo on JULIEN :)

                              we should be able to post XML

                              • 12. Re: Can't get my client app to work
                                adrianc

                                Okay, I finally got my bean to deploy. It was a combination of Deployment Descriptor problems and my Ant script.

                                End of this thread.

                                Many thanks to Marc and Juha!

                                • 13. Re: Can't get my client app to work

                                  It is already a reported bug.