standalone jar calling ejb error on instantiating bean
goedo Jan 16, 2004 10:26 AMHelp!
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):
(I've changed all < and > by [ and ] for better posting....)
[?xml version="1.0" encoding="UTF-8"?]
[jardesc]
[jar path="C:/eclipse/GpsClient.jar"/]
[options overwrite="true" compress="true" exportErrors="true" exportWarnings="true" saveDescription="true" descriptionLocation="/GpsClient/Export.jardesc" useSourceFolders="false" buildIfNeeded="true"/]
[manifest manifestVersion="1.0" usesManifest="true" reuseManifest="true" saveManifest="true" generateManifest="false" manifestLocation="/GpsClient/GpsClient.manifest" mainClassHandleIdentifier="=GpsClient/src<gpsj2ee.GUI{Gui_1.java[Gui_1"]
[sealing sealJar="true"]
[packagesToSeal/]
[packagesToUnSeal/]
[/sealing]
[/manifest]
[selectedElements exportClassFiles="true" exportJavaFiles="true"]
[file path="/GpsClient/.project"/]
[javaElement handleIdentifier="=gpsj2ee/src"/]
[javaElement handleIdentifier="=GpsTools/src"/]
[folder path="/gpsj2ee/lib"/]
[file path="/GpsClient/GpsClient.manifest"/]
[folder path="/gpsj2ee/docroot"/]
[file path="/gpsj2ee/GpsEJB-client.jar"/]
[javaElement handleIdentifier="=GpsClient/src"/]
[folder path="/gpsj2ee/temp"/]
[file path="/GpsClient/xdoclet-build.xml"/]
[file path="/GpsClient/.classpath"/]
[file path="/GpsClient/.xdoclet"/]
[folder path="/GpsClient/lib"/]
[file path="/GpsClient/Export.jardesc"/]
[file path="/GpsClient/.packaging"/]
[folder path="/GpsClient/temp"/]
[file path="/GpsClient/packaging-build.xml"/]
[folder path="/gpsj2ee/doc"/]
[/selectedElements]
[/jardesc]