0 Replies Latest reply on Jan 14, 2004 7:53 AM by goedo

    run from eclipse ide works: run from commandline not with ja

    goedo Newbie

       

      "goedo" wrote:
      Help!
      I programmed my first EJB (works fine, done with lomboz) and I can access it from a servlet and from a GUI client (I created with v4all...)

      The servlet, called from a browser, runs fine on any jboss server i use for my tests (http://anyserver:8080/gps)

      The GUI work fine from the eclipse IDE with "run application"; I tried to export the client to a jar (GpsClient.jar). This starts the GUI but fails when it starts the bean (ClientCall test = new ClientCall();) where ClientCall is the "bean" (i attach the source hereafter...)

      In the cmd-window the classpath env is empty; I've got NO j2ee.jar from sun anywhere :-(

      My env is:
      jboss 3.2.3
      jdk 1.4.2_03b2
      eclipse 3.0M6
      win xp professional always up to date

      please HELP!!!!!
      TIA
      Roger


      log:

      C:\eclipse>java -jar GpsClient.jar
      java.lang.NoClassDefFoundError: javax/ejb/EJBObject
      at java.lang.ClassLoader.defineClass0(Native Method)
      at java.lang.ClassLoader.defineClass(Unknown Source)
      at java.security.SecureClassLoader.defineClass(Unknown Source)
      at java.net.URLClassLoader.defineClass(Unknown Source)
      at java.net.URLClassLoader.access$100(Unknown Source)
      at java.net.URLClassLoader$1.run(Unknown Source)
      at java.security.AccessController.doPrivileged(Native Method)
      at java.net.URLClassLoader.findClass(Unknown Source)
      at java.lang.ClassLoader.loadClass(Unknown Source)
      at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
      at java.lang.ClassLoader.loadClass(Unknown Source)
      at java.lang.ClassLoader.loadClassInternal(Unknown Source)
      at gpsj2ee.GUI.Gui_1.test(Gui_1.java:95)
      at gpsj2ee.GUI.Gui_1.actionPerformed(Gui_1.java:68)
      at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
      at javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(Unknow
      n Source)
      at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
      at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
      at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Sour
      ce)
      at java.awt.Component.processMouseEvent(Unknown Source)
      at java.awt.Component.processEvent(Unknown Source)
      at java.awt.Container.processEvent(Unknown Source)
      at java.awt.Component.dispatchEventImpl(Unknown Source)
      at java.awt.Container.dispatchEventImpl(Unknown Source)
      at java.awt.Component.dispatchEvent(Unknown Source)
      at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
      at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
      at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
      at java.awt.Container.dispatchEventImpl(Unknown Source)
      at java.awt.Window.dispatchEventImpl(Unknown Source)
      at java.awt.Component.dispatchEvent(Unknown Source)
      at java.awt.EventQueue.dispatchEvent(Unknown Source)
      at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)

      at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
      at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
      at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
      at java.awt.EventDispatchThread.run(Unknown Source)

      C:\eclipse>

      ClientCall source code:

      /*
      * Created on Jan 9, 2004
      *
      */
      package gpsj2ee.GUI;

      import DOMUtil.*;
      import gpsj2ee.interfaces.Gps;
      import gpsj2ee.interfaces.GpsHome;

      import java.util.Hashtable;

      import JSortTable.*;

      import javax.naming.InitialContext;
      import javax.naming.NamingException;
      import javax.swing.JTable;
      import javax.xml.parsers.DocumentBuilder;
      import javax.xml.parsers.DocumentBuilderFactory;

      import org.w3c.dom.Document;
      import org.w3c.dom.Element;
      import org.w3c.dom.NodeList;


      /**
      * @author admgps
      *
      * calls the gps ejb to get and format the data
      */

      public class ClientCall {
      /**
      *
      */
      private GpsHome getHome() throws NamingException{
      return (GpsHome) getContext().lookup(
      GpsHome.JNDI_NAME);
      }

      private InitialContext getContext() throws NamingException {
      Hashtable props = new Hashtable();
      props.put(
      InitialContext.INITIAL_CONTEXT_FACTORY,
      "org.jnp.interfaces.NamingContextFactory"); //$NON-NLS-1$
      props.put(InitialContext.PROVIDER_URL, Messages.getString("ClientCall.1")); //$NON-NLS-1$

      // This establishes the security for authorization/authentication
      // props.put(InitialContext.SECURITY_PRINCIPAL,"username");
      // props.put(InitialContext.SECURITY_CREDENTIALS,"password");

      InitialContext initialContext = new InitialContext(props);
      return initialContext;
      }

      public void testBean(JTable TextField) {
      String stream = ""; //$NON-NLS-1$
      int c =1,r = 1, l =0;
      Object[][] data = null ;
      Document doc = null;

      try {
      Gps bean = getHome().create();
      doc = bean.test();
      bean.remove();
      } catch (Exception e) {
      System.err.println("Could not create bean GPS");
      System.out.println(e.getMessage());
      e.printStackTrace(System.out);
      }
      try {
      [....... some code ommitted, doesnt change the error.........]
      } catch (Exception e) {
      System.err.println("Error on doc parsing and outputting");
      System.out.println(e.getMessage());
      e.printStackTrace(System.out);
      } finally {
      DefaultSortTableModel model = (DefaultSortTableModel)TextField.getModel();
      model.sortColumn(0, true);
      for (int i =0; i < l; ++i) {
      model.addRow(data);
      }

      System.out.close();
      }
      }
      }

      Export descriptor(jardesc):