Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / October 2007

Tip: Looking for answers? Try searching our database.

JBoss 4.2.1-GA dynamic class loading

Thread view: 
wimxa@yahoo.com - 28 Sep 2007 17:21 GMT
I have been searching on the Internet about this, but no real success.
I am using JBoss 4.2.1-GA. I have ClassA and ClassB, with interfaces
IClassA and IClassB and a stateless session bean returning IClassA
(while actually returning ClassB instance). I get the exception when I
try to fetch it.

Here is the stack trace:
---------- stack trace start
ERROR SocketClientInvoker - Got marshalling exception, exiting
java.lang.ClassNotFoundException: test.domain.ClassB
    at
org.jboss.remoting.serialization.ClassLoaderUtility.loadClass(ClassLoaderUtility.java:
82)
    at
org.jboss.remoting.loading.RemotingClassLoader.loadClass(RemotingClassLoader.java:
76)
    at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:242)
    at
org.jboss.remoting.loading.ObjectInputStreamWithClassLoader.resolveClass(ObjectInputStreamWithClassLoader.java:
174)
    at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:
1544)
    at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:
1466)
    at
java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:
1699)
    at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1305)
    at java.io.ObjectInputStream.readObject(ObjectInputStream.java:348)
    at
org.jboss.aop.joinpoint.InvocationResponse.readExternal(InvocationResponse.java:
122)
    at java.io.ObjectInputStream.readExternalData(ObjectInputStream.java:
1755)
    at
java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:
1717)
    at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1305)
    at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:
1908)
    at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:
1832)
    at
java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:
1719)
    at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1305)
    at java.io.ObjectInputStream.readObject(ObjectInputStream.java:348)
    at
org.jboss.remoting.serialization.impl.java.JavaSerializationManager.receiveObjectVersion2_2(JavaSerializationManager.java:
239)
    at
org.jboss.remoting.serialization.impl.java.JavaSerializationManager.receiveObject(JavaSerializationManager.java:
133)
    at
org.jboss.remoting.marshal.serializable.SerializableUnMarshaller.read(SerializableUnMarshaller.java:
120)
    at
org.jboss.remoting.transport.socket.MicroSocketClientInvoker.versionedRead(MicroSocketClientInvoker.java:
943)
    at
org.jboss.remoting.transport.socket.MicroSocketClientInvoker.transport(MicroSocketClientInvoker.java:
584)
    at
org.jboss.remoting.MicroRemoteClientInvoker.invoke(MicroRemoteClientInvoker.java:
122)
    at org.jboss.remoting.Client.invoke(Client.java:1550)
    at org.jboss.remoting.Client.invoke(Client.java:530)
    at
org.jboss.aspects.remoting.InvokeRemoteInterceptor.invoke(InvokeRemoteInterceptor.java:
62)
    at
org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:
101)
    at
org.jboss.aspects.tx.ClientTxPropagationInterceptor.invoke(ClientTxPropagationInterceptor.java:
61)
    at
org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:
101)
    at
org.jboss.aspects.security.SecurityClientInterceptor.invoke(SecurityClientInterceptor.java:
53)
    at
org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:
101)
    at
org.jboss.ejb3.remoting.IsLocalInterceptor.invoke(IsLocalInterceptor.java:
72)
    at
org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:
101)
    at
org.jboss.ejb3.stateless.StatelessRemoteProxy.invoke(StatelessRemoteProxy.java:
103)
    at $Proxy0.getIClassA(Unknown Source)
    at test.client.TestClient.test1(TestClient.java:163)
    at test.client.TestClient.run(TestClient.java:237)
    at test.client.TestClient.main(TestClient.java:290)
---------- stack trace end
steph - 03 Oct 2007 22:03 GMT
> I have been searching on the Internet about this, but no real success.
> I am using JBoss 4.2.1-GA. I have ClassA and ClassB, with interfaces
[quoted text clipped - 97 lines]
>     at test.client.TestClient.main(TestClient.java:290)
> ---------- stack trace end

it's hard to answer without the code of ClassB en so one, but does it
implement Serializable ?
wimxa@yahoo.com - 04 Oct 2007 13:21 GMT
> it's hard to answer without the code of ClassB en so one, but does it
> implement Serializable ?
It does. Think of it this way - I don't have a problem changing the
code, but I don't know what to change. What is necessary to make it
work? Is there any documentation about this? If the classes need to
implement interfaces, extend other classes, be packaged specifically,
if I need to have some configuration for JBoss - basically whatever is
necessary I am willing to try. Can you tell me what that is, so I can
try and see if it works for me?

The example I made is a fictional one, so it can be changed however
you wish. Here is the code:

--- ClassA
@Entity
public class ClassA implements Serializable, IClassA {
    private static final long serialVersionUID = 1L;

    private int id;
    private int propA;

    @Id
    @GeneratedValue
    public int getId() {
        return id;
    }

    public int getPropA() {
        return propA;
    }

    public void setId(int id) {
        this.id = id;
    }

    public void setPropA(int propA) {
        this.propA = propA;
    }
}

---- ClassB
@Entity
public class ClassB extends ClassA implements Serializable, IClassB {
    private static final long serialVersionUID = 1L;

    private int propB;

    public int getPropB() {
        return propB;
    }

    public void setPropB(int propB) {
        this.propB = propB;
    }
}

---- IClassA
public interface IClassA {
    int getPropA();
    void setPropA(int propA);
}

---- IClassB
public interface IClassB extends IClassA {
    int getPropB();
    void setPropB(int propB);
}

---- StatelessSessionBeanTest
@Stateless
public class StatelessSessionBeanTest implements
IStatelessSessionBeanTest {
    public IClassA getClassA() {
        ClassA classA = new ClassA();
        classA.setPropA(881);
        return classA;
    }

    public IClassB getClassB() {
        ClassB classB = new ClassB();
        classB.setPropA(881);
        classB.setPropB(98234);
        return classB;
    }
}

---- IStatelessSessionBeanTest
@Remote
public interface IStatelessSessionBeanTest {
    IClassA getClassA();
    IClassB getClassB();
}
EricF - 05 Oct 2007 03:54 GMT
>> it's hard to answer without the code of ClassB en so one, but does it
>> implement Serializable ?
[quoted text clipped - 88 lines]
>        IClassB getClassB();
>}

So what was the question? The original post isn't here. Makes it hard to help.

Eric
wimxa@yahoo.com - 05 Oct 2007 13:19 GMT
> So what was the question? The original post isn't here. Makes it hard to help.
Eric,

I can see the original post, but here it is again.

#########------ original post start

I have been searching on the Internet about this, but no real success.
I am using JBoss 4.2.1-GA. I have ClassA and ClassB, with interfaces
IClassA and IClassB and a stateless session bean returning IClassA
(while actually returning ClassB instance). I get the exception when I
try to fetch it.

Here is the stack trace:
---------- stack trace start
ERROR SocketClientInvoker - Got marshalling exception, exiting
java.lang.ClassNotFoundException: test.domain.ClassB
       at
org.jboss.remoting.serialization.ClassLoaderUtility.loadClass(ClassLoaderUtility.java:
82)
       at
org.jboss.remoting.loading.RemotingClassLoader.loadClass(RemotingClassLoader.java:
76)
       at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:
319)
       at java.lang.Class.forName0(Native Method)
       at java.lang.Class.forName(Class.java:242)
       at
org.jboss.remoting.loading.ObjectInputStreamWithClassLoader.resolveClass(ObjectInputStreamWithClassLoader.java:
174)
       at
java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:
1544)
       at
java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:
1466)
       at
java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:
1699)
       at
java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1305)
       at java.io.ObjectInputStream.readObject(ObjectInputStream.java:
348)
       at
org.jboss.aop.joinpoint.InvocationResponse.readExternal(InvocationResponse.java:
122)
       at
java.io.ObjectInputStream.readExternalData(ObjectInputStream.java:
1755)
       at
java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:
1717)
       at
java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1305)
       at
java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:
1908)
       at
java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:
1832)
       at
java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:
1719)
       at
java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1305)
       at java.io.ObjectInputStream.readObject(ObjectInputStream.java:
348)
       at
org.jboss.remoting.serialization.impl.java.JavaSerializationManager.receiveObjectVersion2_2(JavaSerializationManager.java:
239)
       at
org.jboss.remoting.serialization.impl.java.JavaSerializationManager.receiveObject(JavaSerializationManager.java:
133)
       at
org.jboss.remoting.marshal.serializable.SerializableUnMarshaller.read(SerializableUnMarshaller.java:
120)
       at
org.jboss.remoting.transport.socket.MicroSocketClientInvoker.versionedRead(MicroSocketClientInvoker.java:
943)
       at
org.jboss.remoting.transport.socket.MicroSocketClientInvoker.transport(MicroSocketClientInvoker.java:
584)
       at
org.jboss.remoting.MicroRemoteClientInvoker.invoke(MicroRemoteClientInvoker.java:
122)
       at org.jboss.remoting.Client.invoke(Client.java:1550)
       at org.jboss.remoting.Client.invoke(Client.java:530)
       at
org.jboss.aspects.remoting.InvokeRemoteInterceptor.invoke(InvokeRemoteInterceptor.java:
62)
       at
org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:
101)
       at
org.jboss.aspects.tx.ClientTxPropagationInterceptor.invoke(ClientTxPropagationInterceptor.java:
61)
       at
org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:
101)
       at
org.jboss.aspects.security.SecurityClientInterceptor.invoke(SecurityClientInterceptor.java:
53)
       at
org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:
101)
       at
org.jboss.ejb3.remoting.IsLocalInterceptor.invoke(IsLocalInterceptor.java:
72)
       at
org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:
101)
       at
org.jboss.ejb3.stateless.StatelessRemoteProxy.invoke(StatelessRemoteProxy.java:
103)
       at $Proxy0.getIClassA(Unknown Source)
       at test.client.TestClient.test1(TestClient.java:163)
       at test.client.TestClient.run(TestClient.java:237)
       at test.client.TestClient.main(TestClient.java:290)
---------- stack trace end

#########------ original post end

Question: When I try to fetch ClassA or ClassB instance using
getClassA or getClassB methods of StatelessSessionBeanTest, the client
bombs with the exception in the original post. That is, it doesn't
know how to load the entity classes (ClassA and ClassB) from the JBoss
server. I assume this is possible because JBoss is setting up the RMI
codebase (I've seen it say that when booting up - at http://127.0.0.1:8083).
Is this possible and, if it is, what is the problem? Better, do you
have a pointer to some working example on the Web? I want to use this
so clients can be automatically "upgraded" when some change happens to
entity beans - if the interface stays the same, the client should
continue to work, but it will work with the new version (so the logic
that changed can actually work).

Thanks for the note.
asoto - 05 Oct 2007 19:23 GMT
On Oct 5, 8:19 am, wi...@yahoo.com wrote:

Wi...

Have you found the solution to this problem.
I'm  also having the same problem but so far have not been able to
figure it out.
Thanks
Alex
wimxa@yahoo.com - 08 Oct 2007 21:46 GMT
> Wi...
>
[quoted text clipped - 3 lines]
> Thanks
> Alex

Alex,

Unfortunately no. I have also posted to JBoss forums - no replies yet.
This doesn't seem to be capable in JBoss, even though it's all over
the place in the config files - it seems that it is just there for
some underlying things or as a future reference...

Best wishes!


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.