Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3933120
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T23:33:55+00:00 2026-05-19T23:33:55+00:00

I created some OSGi-bundles. One of these has a function to export data to

  • 0

I created some OSGi-bundles. One of these has a function to export data to xml using XStream. It just works fine. Also importing again when using the Bundle as library and not within an OSGi context, works.

But if I call my import within another bundle I get a “com.thoughtworks.xstream.converters.ConversionException” with the follwing Debugging Information printed out:

---- Debugging information ----
message             : Cannot find class ChildDate
cause-exception     : com.thoughtworks.xstream.converters.reflection.ObjectAccessException
cause-message       : Cannot find class ChildData
class               : ChildData
required-type       : ChildData
path                : /ParentData/ChildData
-------------------------------
message             : Could not call ParentData.readObject()
cause-exception     : com.thoughtworks.xstream.converters.ConversionException
cause-message       : Cannot find class ParentData : Cannot find class ChildData
class               : ParentData
required-type       : ChildData
path                : /ParentData/ChildData
-------------------------------

I think it’s a similar problem to this: XStream and OSGi or this: CannotResolveClassException in OSGi environment

So I tried to solve it setting the ClassLoader. But it does not work.

Parts of my ParentData class:

public class ParentData implements Serializable {
  // [...]
  private static ClassLoader classLoaderForImport = ParentData.class.getClassLoader();
  // [...]
  public static void setClassLoaderForImport(ClassLoader classLoaderForImport) {
    ParentData.classLoaderForImport = classLoaderForImport;
  }
  // [...]
  public static Lumicon importFromXMLFile(String path) {
    return importFromFile(new DomDriver(), path);
  }
  private static ParentData importFromFile(HierarchicalStreamDriver driver, String path) {
    try {
      XStream xstream = new XStream(driver);
      //set the classloader as the default one won't work in any case
      xstream.setClassLoader(ParentData.classLoaderForImport);
      xstream.alias("ParentData", classLoaderForImport.loadClass(ParentData.class.getName()));//ParentData.class);
      xstream.alias("ChildData", classLoaderForImport.loadClass(ChildData.class.getName()));//ChildData.class);
      Reader reader = new FileReader(path);
      Object object = xstream.fromXML(reader);
      return (ParentData) object;
    } catch (ClassNotFoundException ex) {
      System.out.println("This did not work.");
    } catch (FileNotFoundException e) {
      System.out.println("File " + path + " not found.");
    }
  }
// [...]
}

The function xstream.fromXML(reader) does not work, but classLoaderForImport.loadClass(ChildData.class.getName()) doesn’t fail.

This is how I call it from another Bundle:

ParentData.setClassLoaderForImport(ParentData.class.getClassLoader());
data = ParentData.importFromXMLFile(path); // this is where the Exception happens

I also tried this.getClass().getClassLoader() and ChildData.class.getClassLoader()

Could it be, that this does not work, because this function is called from a third bundle?

Some more Info:

  • Java version: 1.4 (no, I can not upgrade to 1.5 or 1.6)
  • Execution environment: J2SE-1.6
  • Maven Version: 2.2.1
  • Running with Pax Runner (1.5.0) from OPS4J – http://www.ops4j.org
  • OSGi: Equinox 3.6.0
  • XStream 1.3.1 (com.springsource.com.thoughtworks.xstream)

Any help would be very welcome!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T23:33:56+00:00Added an answer on May 19, 2026 at 11:33 pm

    Assuming your question contains all the relevant code, the problem is given away by the following:

    Could not call ParentData.readObject()
    

    You have declared that your ParentData implements Serializable. Although the Serializable interface does not include any methods, both Java serialization and XStream expect a readObject and a writeObject. I’m a little rusty on the exact situations in which these are mandatory, but I would suggest you to remove the implements Serializable from the ParentData class.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using some off-the-shelf OSGi bundles in my application and would like to repackage
I'm developing my application as a set of OSGi bundles using Maven 2. Some
I've created some fairly simple XAML, and it works perfectly (at least in KAXML).
I have created some rounded navigation tabs using CSS and am having trouble when
I'm using SQL*Plus 9.2 on Oracle 10g enterprise. I have created some scripts that
I am just getting started with OSGI and Declarative Services (DS) using Equinox and
I created some Maintenance Plans in SQL Server 2008 without using the wizard (i.e.
I've created some sample data as a StaticResource in a Sketchflow prototype (this is
I've created some classes that will be used to provide data to stored procedures
We have created a web service using JAX-WS and ProSyst OSGi. Accessing the service

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.