Hallo,
ich bin noch ziemlich neu in der Java EE Welt und mach grad ein Tutorial aus einem Buch. Leider hab ich da einige Probleme mit dem Lookup (glaub ich)...
Ich hänge hier schon seit einer Ewigkeit
Ich hab JBoss 5 und Java 6 installiert und arbeite mit Eclispe 3.5
Ich hab 2 Projekte angelegt, eines für Server und eines für Client...
Hier mal die Server-Klassen
Remote Interface
die Implementierung
und hier noch ein POJO
In meinem Client Projekt hab ich einmal das Remote Interface ZWarenkorbRemote (siehe oben) drin,
und die folgenden Client-Klasse
Hier noch der stack trace
Ach, ja genau: das Deployen hat funktioniert, in der jndiView sehe ich meine ZWarenkorb bean.
Ich bin mit meinem (sehr beschränkten) Latein am Ende, hoffentlich kann mir einer von euch einen Tipp geben.
Danke schon mal
ich bin noch ziemlich neu in der Java EE Welt und mach grad ein Tutorial aus einem Buch. Leider hab ich da einige Probleme mit dem Lookup (glaub ich)...
Ich hänge hier schon seit einer Ewigkeit
Ich hab JBoss 5 und Java 6 installiert und arbeite mit Eclispe 3.5
Ich hab 2 Projekte angelegt, eines für Server und eines für Client...
Hier mal die Server-Klassen
Remote Interface
Java:
@Remote
public interface ZWarenkorbRemote {
public void legeInWarenkorb(int anzahl, String artikelnr, int einzelpreis);
public void entferneAusWarenkorb(String artikelnr);
public int geheZurKasse();
}
die Implementierung
Java:
@Stateful
public class ZWarenkorb implements ZWarenkorbRemote, Serializable {
private Map<String, ZWare> waren = new HashMap<String, ZWare>();
public void legeInWarenkorb(int anzahl, String artikelnr, int einzelpreis) {
waren.put(artikelnr, new ZWare(anzahl, artikelnr, einzelpreis));
}
public void entferneAusWarenkorb(String artikelnr) {
waren.remove(artikelnr);
}
@Remove
public int geheZurKasse() {
int gesamtpreis = 0;
for(ZWare ware : waren.values()){
gesamtpreis += ware.getPreis();
}
return gesamtpreis;
}
}
und hier noch ein POJO
Java:
public class ZWare {
private int anzahl;
private String artikelnr;
private double preis;
public ZWare(int anz, String anr, double p){
this.artikelnr = anr;
this.preis = p;
this.anzahl = anz;
}
public String getArtikelnr() {
return artikelnr;
}
public void setArtikelnr(String artikelnr) {
this.artikelnr = artikelnr;
}
public double getPreis() {
return preis;
}
public void setPreis(double preis) {
this.preis = preis;
}
public void setAnzahl(int anzahl) {
this.anzahl = anzahl;
}
public int getAnzahl() {
return anzahl;
}
}
In meinem Client Projekt hab ich einmal das Remote Interface ZWarenkorbRemote (siehe oben) drin,
und die folgenden Client-Klasse
Java:
public class Main {
public static void main(String[] args) {
try {
Properties props = new Properties();
props.setProperty("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");
props.setProperty("java.naming.provider.url", "jnp://localhost:1099");
InitialContext context = new InitialContext(props);
ZWarenkorbRemote warenkorb = (ZWarenkorbRemote) context.lookup("ZWarenkorb/remote");
warenkorb.legeInWarenkorb(1, "Terminator 5", 19);
warenkorb.legeInWarenkorb(2, "Avatar", 29);
} catch (NamingException e) {
e.printStackTrace();
}
}
/* (non-Java-doc)
* @see java.lang.Object#Object()
*/
public Main() {
super();
}
}
Hier noch der stack trace
Java:
javax.naming.NamingException: Could not dereference object [Root exception is java.lang.reflect.UndeclaredThrowableException]
at org.jnp.interfaces.NamingContext.getObjectInstanceWrapFailure(NamingContext.java:1504)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:822)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:686)
at javax.naming.InitialContext.lookup(InitialContext.java:392)
at Main.main(Main.java:16)
Caused by: java.lang.reflect.UndeclaredThrowableException
at $Proxy0.createProxyBusiness(Unknown Source)
at org.jboss.ejb3.proxy.impl.objectfactory.session.SessionProxyObjectFactory.createProxy(SessionProxyObjectFactory.java:129)
at org.jboss.ejb3.proxy.impl.objectfactory.session.stateful.StatefulSessionProxyObjectFactory.getProxy(StatefulSessionProxyObjectFactory.java:64)
at org.jboss.ejb3.proxy.impl.objectfactory.ProxyObjectFactory.getObjectInstance(ProxyObjectFactory.java:158)
at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:304)
at org.jnp.interfaces.NamingContext.getObjectInstance(NamingContext.java:1479)
at org.jnp.interfaces.NamingContext.getObjectInstanceWrapFailure(NamingContext.java:1496)
... 4 more
Caused by: java.lang.ClassNotFoundException: de.kulzer.warenkorb.ZWarenkorbRemote
at org.jboss.remoting.serialization.ClassLoaderUtility.loadClass(ClassLoaderUtility.java:103)
at org.jboss.remoting.loading.RemotingClassLoader.loadClass(RemotingClassLoader.java:86)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:247)
at org.jboss.remoting.loading.ObjectInputStreamWithClassLoader.resolveProxyClass(ObjectInputStreamWithClassLoader.java:253)
at java.io.ObjectInputStream.readProxyDesc(ObjectInputStream.java:1531)
at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1493)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1732)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:351)
at org.jboss.aop.joinpoint.InvocationResponse.readExternal(InvocationResponse.java:119)
at java.io.ObjectInputStream.readExternalData(ObjectInputStream.java:1792)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1751)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1947)
at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1871)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1753)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:351)
at org.jboss.remoting.serialization.impl.java.JavaSerializationManager.receiveObjectVersion2_2(JavaSerializationManager.java:238)
at org.jboss.remoting.serialization.impl.java.JavaSerializationManager.receiveObject(JavaSerializationManager.java:138)
at org.jboss.remoting.marshal.serializable.SerializableUnMarshaller.read(SerializableUnMarshaller.java:123)
at org.jboss.remoting.transport.socket.MicroSocketClientInvoker.versionedRead(MicroSocketClientInvoker.java:1220)
at org.jboss.remoting.transport.socket.MicroSocketClientInvoker.transport(MicroSocketClientInvoker.java:850)
at org.jboss.remoting.MicroRemoteClientInvoker.invoke(MicroRemoteClientInvoker.java:165)
at org.jboss.remoting.Client.invoke(Client.java:1724)
at org.jboss.remoting.Client.invoke(Client.java:629)
at org.jboss.aspects.remoting.InvokeRemoteInterceptor.invoke(InvokeRemoteInterceptor.java:60)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
at org.jboss.ejb3.proxy.impl.remoting.IsLocalProxyFactoryInterceptor.invoke(IsLocalProxyFactoryInterceptor.java:72)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
at org.jboss.aspects.remoting.PojiProxy.invoke(PojiProxy.java:62)
at $Proxy0.createProxyBusiness(Unknown Source)
at org.jboss.ejb3.proxy.impl.objectfactory.session.SessionProxyObjectFactory.createProxy(SessionProxyObjectFactory.java:129)
at org.jboss.ejb3.proxy.impl.objectfactory.session.stateful.StatefulSessionProxyObjectFactory.getProxy(StatefulSessionProxyObjectFactory.java:64)
at org.jboss.ejb3.proxy.impl.objectfactory.ProxyObjectFactory.getObjectInstance(ProxyObjectFactory.java:158)
at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:304)
at org.jnp.interfaces.NamingContext.getObjectInstance(NamingContext.java:1479)
at org.jnp.interfaces.NamingContext.getObjectInstanceWrapFailure(NamingContext.java:1496)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:822)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:686)
at javax.naming.InitialContext.lookup(InitialContext.java:392)
at Main.main(Main.java:16)
at org.jboss.aspects.remoting.InvokeRemoteInterceptor.invoke(InvokeRemoteInterceptor.java:72)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
at org.jboss.ejb3.proxy.impl.remoting.IsLocalProxyFactoryInterceptor.invoke(IsLocalProxyFactoryInterceptor.java:72)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)
at org.jboss.aspects.remoting.PojiProxy.invoke(PojiProxy.java:62)
Ach, ja genau: das Deployen hat funktioniert, in der jndiView sehe ich meine ZWarenkorb bean.
Ich bin mit meinem (sehr beschränkten) Latein am Ende, hoffentlich kann mir einer von euch einen Tipp geben.
Danke schon mal