You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-user@db.apache.org by Stas Ostapenko <st...@gmail.com> on 2005/04/27 16:31:24 UTC

MetadataManager.copyOfGlobalRepository problem

Hi! I have problem with this very simple code. 
When I try to run it I have an strange exception.

import org.apache.ojb.broker.metadata.DescriptorRepository;
import org.apache.ojb.broker.metadata.MetadataManager;

public class test_copyOfGlobalRepository
{
	public static void main(String args[])
	{
	  try
	  {
		MetadataManager mm = MetadataManager.getInstance();
		mm.setEnablePerThreadChanges(true);

		DescriptorRepository dr = mm.copyOfGlobalRepository();
	  }
	  catch(Exception ex)
	  {
	  ex.printStackTrace();
	  }
        }
}

org.apache.commons.lang.SerializationException: java.lang.ClassNotFoundException
: Domain
        at org.apache.commons.lang.SerializationUtils.deserialize(SerializationU
tils.java:202)
        at org.apache.commons.lang.SerializationUtils.deserialize(SerializationU
tils.java:229)
        at org.apache.commons.lang.SerializationUtils.clone(SerializationUtils.j
ava:117)
        at org.apache.ojb.broker.metadata.MetadataManager.copyOfGlobalRepository
(MetadataManager.java:434)
        at test_copyOfGlobalRepository.main(test_copyOfGlobalRepository.java:13)

Caused by: java.lang.ClassNotFoundException: Domain
        at java.net.URLClassLoader$1.run(URLClassLoader.java:199)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:187)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:289)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:235)
        at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:302)
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Class.java:219)
        at java.io.ObjectInputStream.resolveClass(ObjectInputStream.java:558)
        at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:151
3)
        at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1435)
        at java.io.ObjectInputStream.readClass(ObjectInputStream.java:1402)
        at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1260)
        at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:18
45)
        at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1769)

        at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1
646)
        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(DelegatingMethodAcces
sorImpl.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:1
646)
        at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1274)
        at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:18
45)
        at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1769)

        at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1
646)
        at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1274)
        at java.io.ObjectInputStream.readObject(ObjectInputStream.java:324)
        at org.apache.commons.lang.SerializationUtils.deserialize(SerializationU
tils.java:199)
        ... 4 more

So, java.lang.ClassNotFoundException occurs. But Domain.class is in
the same directory with test_copyOfGlobalRepository. class ! At
http://db.apache.org/ojb/api/org/apache/ojb/broker/metadata/MetadataManager.html
info wery poor... How can I use MetadataManager.copyOfGlobalRepository
?

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org


Re: MetadataManager.copyOfGlobalRepository problem

Posted by Martin Kalén <mk...@apache.org>.
Stas Ostapenko wrote:
> Hi Martin !
> I`m using the following JVM
>  java version "1.4.2_04"
> Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_04-b05)
> Java HotSpot(TM) Client VM (build 1.4.2_04-b05, mixed mode)
>  and no app servers or other software for this simple (work or not) test.
>  Info about serialization may be added to javadoc and tutorial for the 
> MetadataManager.

It's now in MM's JavaDoc and in the guide page with a NOTE about
Serializable (and a link to SerializationUtil with the exact JavaDoc
and demands the Commons Lang guys have).

I hope that should make it clearer.

(The full website contents will probably not be pushed until closer
to a 1.0.4 maintenance release, but individual pages might "sneak"
into the site before that...)

However; back to reality - you say you get ClassNotFound with your
simple program in a "vanilla" JDK? Hm, then it should be easy enough
for me to test under the same conditions. I will try to reproduce the
exception and get back to you.

Regards,
  Martin


---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org


Re: MetadataManager.copyOfGlobalRepository problem

Posted by Martin Kalén <mk...@apache.org>.
Stas Ostapenko wrote:
> Hi Martin !
> I`m using the following JVM
>  java version "1.4.2_04"
> Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_04-b05)
> Java HotSpot(TM) Client VM (build 1.4.2_04-b05, mixed mode)
>  and no app servers or other software for this simple (work or not) test.

I just can't reproduce this. Here is what I do (on a Windows box, and
just for sake of completeness I backed to the exackt JDK-version you have):

  set JAVA_HOME=C:\JAVA\j2sdk1.4.2_04
  set PATH=%JAVA_HOME%\bin;%PATH%
  java -version

    |java version "1.4.2_04"
    |Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_04-b05)

Now I point to OJB's lib-directory for getting Commons Lang as the _only_
thing on my classpath:

  set LIB_DIR=(my path to)\db-ojb\lib
  set CLASSPATH=.;%LIB_DIR%\commons-lang-2.0.jar

I have the Domain.java from your post after making it Serializable [1]
and a simple version of your main testclass [2].

  javac Domain.java test_copyOfGlobalRepository_3.java
  java test_copyOfGlobalRepository_3

    |Hold on, about to clone!
    |All is well


I am a bit perplexed I must say. Just to work away the silly things that
can go wrong first:

*) UPPER/lower case in class names? Filename must match class name exactly.

*) package definition in Domain och test_copyOfGlobalRepository_3 but
    not in the other (I have seen proof of this not beeing the case if
    what you posted is what you run, which I assume)

*) global CLASSPATH setting including eg a JAR with old incompatible
    class versions (you have "java.net.URLClassLoader$1.run" in your
    stacktrace which seems like resources loading from JAR or HTTP?)

*) [insert here: the obivous choice we are all overlooking at the
     moment, and that will make us bang our heads against the wall
     when you tell us] :)

Regards,
  Martin


[1] http://www.mail-archive.com/ojb-user@db.apache.org/msg13541.html

[2] Full source, filename "test_copyOfGlobalRepository_3.java":
import org.apache.commons.lang.SerializationUtils;

public class test_copyOfGlobalRepository_3
{
     public static void main(String args[])
     {
         System.out.println("Hold on, about to clone!");
         SerializationUtils.clone(new Domain());
         System.out.println("All is well");
     }
}


---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org


Re: MetadataManager.copyOfGlobalRepository problem

Posted by Stas Ostapenko <st...@gmail.com>.
Hi Martin !
I`m using the following JVM
 java version "1.4.2_04"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_04-b05)
Java HotSpot(TM) Client VM (build 1.4.2_04-b05, mixed mode)
 and no app servers or other software for this simple (work or not) test.
 Info about serialization may be added to javadoc and tutorial for the 
MetadataManager.
 On 4/29/05, Martin Kalén <mk...@apache.org> wrote:
 
> Stas Ostapenko wrote:
> > So, here is new code
> >
> > public class Domain implements java.io.Serializable
> 
> SerializationUtils needs Serializable classes by contract,
> this should probably be better documented. Any suggestions
> as to where in the docs/config files you would first look
> for this? (So we could update the docs.)
> 
> > Domain d = new Domain();
> > Object result = SerializationUtils.clone(d);
> ...
> > org.apache.commons.lang.SerializationException:
> > java.lang.ClassNotFoundException: Domain
> ...
> > at org.apache.commons.lang.SerializationUtils.deserialize(
> > SerializationUtils.java:202)
> ...
> > Caused by: java.lang.ClassNotFoundException: Domain
> > at java.net.URLClassLoader$1.run(URLClassLoader.java:199)
> > at java.security.AccessController.doPrivileged(Native Method)
> 
> This is weird.
> 
> Under which JVM environment is this happening? Are you running
> inside an application server (like Tomcat or a J2EE container,
> with it's own ClassLoader)? Are you using Java security policy?
> 
> Regards,
> Martin
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
> 
>

Re: MetadataManager.copyOfGlobalRepository problem

Posted by Martin Kalén <mk...@apache.org>.
Stas Ostapenko wrote:
> So, here is new code
> 
> public class Domain implements java.io.Serializable

SerializationUtils needs Serializable classes by contract,
this should probably be better documented. Any suggestions
as to where in the docs/config files you would first look
for this? (So we could update the docs.)

> Domain d = new Domain();
> Object result = SerializationUtils.clone(d);
...
> org.apache.commons.lang.SerializationException: 
> java.lang.ClassNotFoundException: Domain
...
> at org.apache.commons.lang.SerializationUtils.deserialize(
> SerializationUtils.java:202)
...
> Caused by: java.lang.ClassNotFoundException: Domain
> at java.net.URLClassLoader$1.run(URLClassLoader.java:199)
> at java.security.AccessController.doPrivileged(Native Method)

This is weird.

Under which JVM environment is this happening? Are you running
inside an application server (like Tomcat or a J2EE container,
with it's own ClassLoader)? Are you using Java security policy?

Regards,
  Martin

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org


Re: MetadataManager.copyOfGlobalRepository problem

Posted by Stas Ostapenko <st...@gmail.com>.
So, here is new code

public class Domain implements java.io.Serializable
{

public Integer Id;
public Integer Status;
public String Domain;
public String Comment;

public Domain(){};

public Domain(Integer Id,Integer Status,String Domain,String Comment)
{
this.Id = Id;
this.Status = Status;
this.Domain = Domain;
this.Comment = Comment;
};

public void setId(Integer Id)
{
this.Id = Id;
}

public Integer getId()
{
return this.Id;
}

public void setStatus(Integer Status)
{
this.Status = Status;
}
public Integer getStatus()
{
return this.Status;
}

public void setDomain(String Domain)
{
this.Domain = Domain;
}

public String getDomain()
{
return this.Domain;
}

public void setComment(String Comment)
{
this.Comment = Comment;
}

public String getComment()
{
return this.Comment;
}
}

I need to Domain implements java.io.Serializable because 
 static Object <http://java.sun.com/j2se/1.3/docs/api/java/lang/Object.html> 
*clone<http://jakarta.apache.org/commons/lang/apidocs/org/apache/commons/lang/SerializationUtils.html#clone%28java.io.Serializable%29>
*(Serializable<http://java.sun.com/j2se/1.3/docs/api/java/io/Serializable.html>object)and
when I try

Domain d = new Domain();
Object result = SerializationUtils.clone((Serializable)d);
I get java.lang.ClassCastException. Running this code I get 

import org.apache.commons.lang.SerializationUtils;
import java.io.*;

public class test_copyOfGlobalRepository_3
{
public static void main(String args[])
{
try
{
Domain d = new Domain();
Object result = SerializationUtils.clone(d);
}
catch(Exception e)
{
e.printStackTrace();
}
}
}
org.apache.commons.lang.SerializationException: 
java.lang.ClassNotFoundException: Domain
at org.apache.commons.lang.SerializationUtils.deserialize(
SerializationUtils.java:202)
at org.apache.commons.lang.SerializationUtils.deserialize(
SerializationUtils.java:229)
at org.apache.commons.lang.SerializationUtils.clone(SerializationUtils.java
:117)
at test_copyOfGlobalRepository_3.main(test_copyOfGlobalRepository_3.java:11)
Caused by: java.lang.ClassNotFoundException: Domain
at java.net.URLClassLoader$1.run(URLClassLoader.java:199)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:187)
at java.lang.ClassLoader.loadClass(ClassLoader.java:289)
at java.lang.ClassLoader.loadClass(ClassLoader.java:235)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:302)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:219)
at java.io.ObjectInputStream.resolveClass(ObjectInputStream.java:558)
at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1513)
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 org.apache.commons.lang.SerializationUtils.deserialize(
SerializationUtils.java:199)
... 3 more

Re: MetadataManager.copyOfGlobalRepository problem

Posted by Armin Waibel <ar...@apache.org>.
Hi,

strange!
Could you do another test to check common-lang serialization util:

Domain d = new Domain();
Object result = SerializationUtils.clone(d)

This call was used by MetadataManager.

regards,
Arnin

Stas Ostapenko wrote:
> Hi !
> 
> 
>>Are you sure that Domain.class contains no "package" declaration in Java?
>>(As Armin already pointed out.)
> 
> 
> Yes. here is Domain.java
> 
> public class Domain
> {
> public Integer Id;
> public Integer Status;
> public String Domain;
> public String Comment;
> public Domain(Integer Id,Integer Status,String Domain,String Comment)
> {
> this.Id = Id;
> this.Status = Status;
> this.Domain = Domain;
> this.Comment = Comment;
> };
> public void setId(Integer Id)
> {
> this.Id = Id;
> }
> public Integer getId()
> {
> return this.Id;
> }
> public void setStatus(Integer Status)
> {
> this.Status = Status;
> }
> public Integer getStatus()
> {
> return this.Status;
> }
> public void setDomain(String Domain)
> {
> this.Domain = Domain;
> }
> public String getDomain()
> {
> return this.Domain;
> }
> public void setComment(String Comment)
> {
> this.Comment = Comment;
> }
> public String getComment()
> {
> return this.Comment;
> }
> }
> 
>>Since you have a static main method with your test, it is easy to check
>>that Domain.class can be loaded by the JVM (without involving OJB at all)
>>by doing:
>>
>>String className = "Domain";
>>ClassLoader cl = Thread.currentThread().getContextClassLoader();
>>Class domain = Class.forName(className, true, cl);
> 
> Ok. Here is code and a result : 
> 
> import org.apache.ojb.broker.metadata.DescriptorRepository;
> import org.apache.ojb.broker.metadata.MetadataManager;
> 
> public class test_copyOfGlobalRepository_two
> {
> public static void main(String args[])
> {
> try
> {
> System.out.print("loading...");
> 
> String className = "Domain";
> ClassLoader cl = Thread.currentThread().getContextClassLoader();
> Class domain = Class.forName(className, true, cl);
> 
> System.out.println("OK");
> }
> catch(Exception e)
> {
> System.out.println("Something wrong with loading class");
> e.printStackTrace();
> };
> try
> {
> System.out.println("Manipulating with MetadataManager");
> MetadataManager mm = MetadataManager.getInstance();
> mm.setEnablePerThreadChanges(true);
> DescriptorRepository dr = mm.copyOfGlobalRepository();
> }
> catch(Exception ex)
> {
> System.out.println("Something goes wrong...");
> ex.printStackTrace();
> }
> }
> }
> Output: 
> 
> loading...OK
> Manipulating with MetadataManager
> Something goes wrong...
> org.apache.commons.lang.SerializationException: 
> java.lang.ClassNotFoundException
> : Domain
> at org.apache.commons.lang.SerializationUtils.deserialize(
> SerializationUtils.java:202)
> at org.apache.commons.lang.SerializationUtils.deserialize(
> SerializationUtils.java:229)
> at org.apache.commons.lang.SerializationUtils.clone(SerializationUtils.java
> :117)
> at org.apache.ojb.broker.metadata.MetadataManager.copyOfGlobalRepository(
> MetadataManager.java:434)
> at 
> test_copyOfGlobalRepository_two.main(test_copyOfGlobalRepository_two.java:30)
> Caused by: java.lang.ClassNotFoundException: Domain
> at java.net.URLClassLoader$1.run(URLClassLoader.java:199)
> at java.security.AccessController.doPrivileged(Native Method)
> at java.net.URLClassLoader.findClass(URLClassLoader.java:187)
> at java.lang.ClassLoader.loadClass(ClassLoader.java:289)
> at java.lang.ClassLoader.loadClass(ClassLoader.java:235)
> at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:302)
> at java.lang.Class.forName0(Native Method)
> at java.lang.Class.forName(Class.java:219)
> at java.io.ObjectInputStream.resolveClass(ObjectInputStream.java:558)
> at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1513)
> at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1435)
> at java.io.ObjectInputStream.readClass(ObjectInputStream.java:1402)
> at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1260)
> 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.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.apache.commons.lang.SerializationUtils.deserialize(
> SerializationUtils.java:199)
> ... 4 more
> 
> As you see class is not in package and loading without problems. Can you 
> provide some simple working example with all configuration files so I could 
> run and compare results ? Maybe I have a config mistake? Any suggestions are 
> welcome.
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org


Re: MetadataManager.copyOfGlobalRepository problem

Posted by Stas Ostapenko <st...@gmail.com>.
Hi !

> Are you sure that Domain.class contains no "package" declaration in Java?
> (As Armin already pointed out.)

Yes. here is Domain.java

public class Domain
{
public Integer Id;
public Integer Status;
public String Domain;
public String Comment;
public Domain(Integer Id,Integer Status,String Domain,String Comment)
{
this.Id = Id;
this.Status = Status;
this.Domain = Domain;
this.Comment = Comment;
};
public void setId(Integer Id)
{
this.Id = Id;
}
public Integer getId()
{
return this.Id;
}
public void setStatus(Integer Status)
{
this.Status = Status;
}
public Integer getStatus()
{
return this.Status;
}
public void setDomain(String Domain)
{
this.Domain = Domain;
}
public String getDomain()
{
return this.Domain;
}
public void setComment(String Comment)
{
this.Comment = Comment;
}
public String getComment()
{
return this.Comment;
}
}
> Since you have a static main method with your test, it is easy to check
> that Domain.class can be loaded by the JVM (without involving OJB at all)
> by doing:
> 
> String className = "Domain";
> ClassLoader cl = Thread.currentThread().getContextClassLoader();
> Class domain = Class.forName(className, true, cl);
Ok. Here is code and a result : 

import org.apache.ojb.broker.metadata.DescriptorRepository;
import org.apache.ojb.broker.metadata.MetadataManager;

public class test_copyOfGlobalRepository_two
{
public static void main(String args[])
{
try
{
System.out.print("loading...");

String className = "Domain";
ClassLoader cl = Thread.currentThread().getContextClassLoader();
Class domain = Class.forName(className, true, cl);

System.out.println("OK");
}
catch(Exception e)
{
System.out.println("Something wrong with loading class");
e.printStackTrace();
};
try
{
System.out.println("Manipulating with MetadataManager");
MetadataManager mm = MetadataManager.getInstance();
mm.setEnablePerThreadChanges(true);
DescriptorRepository dr = mm.copyOfGlobalRepository();
}
catch(Exception ex)
{
System.out.println("Something goes wrong...");
ex.printStackTrace();
}
}
}
Output: 

loading...OK
Manipulating with MetadataManager
Something goes wrong...
org.apache.commons.lang.SerializationException: 
java.lang.ClassNotFoundException
: Domain
at org.apache.commons.lang.SerializationUtils.deserialize(
SerializationUtils.java:202)
at org.apache.commons.lang.SerializationUtils.deserialize(
SerializationUtils.java:229)
at org.apache.commons.lang.SerializationUtils.clone(SerializationUtils.java
:117)
at org.apache.ojb.broker.metadata.MetadataManager.copyOfGlobalRepository(
MetadataManager.java:434)
at 
test_copyOfGlobalRepository_two.main(test_copyOfGlobalRepository_two.java:30)
Caused by: java.lang.ClassNotFoundException: Domain
at java.net.URLClassLoader$1.run(URLClassLoader.java:199)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:187)
at java.lang.ClassLoader.loadClass(ClassLoader.java:289)
at java.lang.ClassLoader.loadClass(ClassLoader.java:235)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:302)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:219)
at java.io.ObjectInputStream.resolveClass(ObjectInputStream.java:558)
at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1513)
at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1435)
at java.io.ObjectInputStream.readClass(ObjectInputStream.java:1402)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1260)
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.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.apache.commons.lang.SerializationUtils.deserialize(
SerializationUtils.java:199)
... 4 more

As you see class is not in package and loading without problems. Can you 
provide some simple working example with all configuration files so I could 
run and compare results ? Maybe I have a config mistake? Any suggestions are 
welcome.

Re: MetadataManager.copyOfGlobalRepository problem

Posted by Martin Kalén <mk...@apache.org>.
Stas Ostapenko wrote:
> org.apache.commons.lang.SerializationException: java.lang.ClassNotFoundException
> : Domain

> So, java.lang.ClassNotFoundException occurs. But Domain.class is in
> the same directory with test_copyOfGlobalRepository. class ! At
> http://db.apache.org/ojb/api/org/apache/ojb/broker/metadata/MetadataManager.html
> info wery poor... How can I use MetadataManager.copyOfGlobalRepository

Are you sure that Domain.class contains no "package" declaration in Java?
(As Armin already pointed out.)

Since you have a static main method with your test, it is easy to check
that Domain.class can be loaded by the JVM (without involving OJB at all)
by doing:

  String className = "Domain";
  ClassLoader cl = Thread.currentThread().getContextClassLoader();
  Class domain = Class.forName(className, true, cl);

The true-flag as parameter #2 tells to run any static initializers in Domain.class

You can also test constructors by creating a new instance:
  Domain myNewDomainInstance = (Domain) domain.newInstance();

Do this before you involve OJB in the equation and get back with more details
how you go!

Regards,
  Martin

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org