aspose file tools*
The moose likes EJB and other Java EE Technologies and the fly likes Problems with first EBJ Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Problems with first EBJ" Watch "Problems with first EBJ" New topic
Author

Problems with first EBJ

Carlos A. Perez
Greenhorn

Joined: Apr 09, 2004
Posts: 27
Hi im writing my first EJB, it compiles and JBoss deploys it without problem, but when i run my client throws an exception:

java.lang.NoClassDefFoundError: Lorg/jboss/tm/TransactionPropagationContextFactory;
at java.lang.Class.getDeclaredFields0(Native Method)
at java.lang.Class.privateGetDeclaredFields(Class.java:1514)
at java.lang.Class.getDeclaredField(Class.java:1206)
at java.io.ObjectStreamClass.getDeclaredSUID(ObjectStreamClass.java:1474)
at java.io.ObjectStreamClass.access$400(ObjectStreamClass.java:47)
at java.io.ObjectStreamClass$3.run(ObjectStreamClass.java:335)
at java.security.AccessController.doPrivileged(Native Method)
at java.io.ObjectStreamClass.<init>(ObjectStreamClass.java:333)
at java.io.ObjectStreamClass.lookup(ObjectStreamClass.java:253)
at java.io.ObjectStreamClass.initNonProxy(ObjectStreamClass.java:453)
at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1521)
at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1435)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1626)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1274)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:324)
at java.util.HashMap.readObject(HashMap.java:1006)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:838)
at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1746)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1646)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1274)
at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1845)
at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1769)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1646)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1274)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:324)
at org.jboss.proxy.ClientContainer.readExternal(ClientContainer.java:112)
at java.io.ObjectInputStream.readExternalData(ObjectInputStream.java:1686)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1644)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1274)
at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1845)
at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1769)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1646)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1274)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:324)
at java.rmi.MarshalledObject.get(MarshalledObject.java:135)
at org.jnp.interfaces.MarshalledValuePair.get(MarshalledValuePair.java:30)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:550)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:507)
at javax.naming.InitialContext.lookup(InitialContext.java:347)
at examples.HelloClient.main(HelloClient.java:30)
Exception in thread "main"

the code of the client is the following:

public class HelloClient {

public static void main(String[] args) throws NamingException, CreateException, RemoteException, RemoveException {
Hashtable environment = new Hashtable();
environment.put( Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory" );
environment.put( Context.PROVIDER_URL, "localhost:1099" );
System.out.println ("Inicio4");
Context ctx = new InitialContext (environment);
System.out.println ("Inicio5");
Object obj = ctx.lookup( "Hello" );
System.out.println ("Inicio6");
HelloHome home = (HelloHome) PortableRemoteObject.narrow( obj, HelloHome.class);
Hello hello = home.create();
System.out.println (hello.hello());
hello.remove();
}
}

the exception is throw in the following line: Object obj = ctx.lookup( "Hello" );
(it doesnt print "Inicio6");

i thought that maybe the problem was the JNDI port (1099) but the config says that its the correct port:

<!-- ==================================================================== -->
<!-- JNDI -->
<!-- ==================================================================== -->

<mbean code="org.jboss.naming.NamingService"
name="jboss:service=Naming">
<!-- The listening port for the bootstrap JNP service. Set this to -1
to run the NamingService without the JNP invoker listening port.
-->
<attribute name="Port">1099</attribute>
<!-- The bootstrap JNP server bind address. This also sets the default
RMI service bind address. Empty == all addresses
-->
<attribute name="BindAddress">${jboss.bind.address}</attribute>
<!-- The port of the RMI naming service, 0 == anonymous 1098-->
<attribute name="RmiPort">1098</attribute>
<!-- The RMI service bind address. Empty == all addresses
-->
<attribute name="RmiBindAddress">${jboss.bind.address}</attribute>
</mbean>

<mbean code="org.jboss.naming.JNDIView"
name="jboss:service=JNDIView"
xmbean-dd="resource:xmdesc/JNDIView-xmbean.xml">
</mbean>

so any idea whats wrong?
Eric Lemaitre
Ranch Hand

Joined: Jul 03, 2004
Posts: 538

Hi !

You have one property lacking :

environment.put( Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory" );
environment.put( Context.PROVIDER_URL, "localhost:1099" );

But there are 3 JNDI properties when JBoss is involved :

java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
java.naming.provider.url=jnp://localhost:1099
java.naming.factory.url.pkgs=org.jboss.naming rg.jnp.interfaces

Last property is lacking in your case.

Best regards.


Eric LEMAITRE
CNAM IT Engineer, MS/CS (RHCE, RHCX, SCJA, SCJP, SCJD, SCWCD, SCBCD, SCEA, Net+)
Free Online Tutorials: http://www.free-tutorials-online.net/
Carlos A. Perez
Greenhorn

Joined: Apr 09, 2004
Posts: 27
Thanks, but i change the code:

public class HelloClient {

public static void main(String[] args) throws NamingException, CreateException, RemoteException, RemoveException {
Hashtable environment = new Hashtable();
environment.put( "java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory" );
environment.put( "java.naming.provider.url", "jnp://localhost:1099" );
environment.put( "java.naming.factory.url.pkgs", "org.jboss.naming rg.jnp.interfaces" );
System.out.println ("Inicio4");
Context ctx = new InitialContext (environment);
System.out.println ("Inicio5");
Object obj = ctx.lookup( "Hello" );
System.out.println ("Inicio6");
HelloHome home = (HelloHome) PortableRemoteObject.narrow( obj, HelloHome.class);
Hello hello = home.create();
System.out.println (hello.hello());
hello.remove();
}
}

and it still sends the same exception :-S
Bob Peterson
Ranch Hand

Joined: Jul 30, 2004
Posts: 47
I've been having the exact same problem and am still stuck. Did you ever get it working or does anyone have any other suggestions?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problems with first EBJ