Caused by: java.lang.ClassNotFoundException: net.sf.json.xml.XMLSerializer not found by com.myproject.core [35154]

StackOverflow https://stackoverflow.com/questions/21710402

  •  10-10-2022
  •  | 
  •  

Question

I use json-lib to convert xml structure to json format. My dependencies looks like this:

 <dependencies>

        <dependency>
            <groupId>net.sf.json-lib</groupId>
            <artifactId>json-lib</artifactId>
            <version>2.4</version>
        </dependency>

        <dependency>
            <groupId>commons-lang</groupId>
            <artifactId>commons-lang</artifactId>
            <version>2.5</version>
        </dependency>

        <dependency>
            <groupId>commons-lang</groupId>
            <artifactId>commons-lang</artifactId>
            <version>2.3</version>
        </dependency>

        <dependency>
            <groupId>net.sf.ezmorph</groupId>
            <artifactId>ezmorph</artifactId>
            <version>1.0.6</version>
        </dependency>

        <dependency>
            <groupId>commons-logging</groupId>
            <artifactId>commons-logging</artifactId>
            <version>1.1.1</version>
        </dependency>

        <dependency>
            <groupId>commons-collections</groupId>
            <artifactId>commons-collections</artifactId>
            <version>3.2.1</version>
        </dependency>

        <dependency>
            <groupId>commons-beanutils</groupId>
            <artifactId>commons-beanutils</artifactId>
            <version>1.8.0</version>
        </dependency>

        <!-- XML -->
        <dependency>
            <groupId>xom</groupId>
            <artifactId>xom</artifactId>
            <version>1.0</version>
        </dependency>

    </dependencies>

On the following line:

 XMLSerializer xmlSerializer = new XMLSerializer();

The compiler throws the foolwoing error:

Caused by: java.lang.ClassNotFoundException: net.sf.json.xml.XMLSerializer not found by com.myproject.core

Any Idea why I get this error?

Was it helpful?

Solution

I solve the problem by adding the missing jars to maven-bundle-plugin embeded dependencies

           <plugin>
                <groupId>org.apache.felix</groupId>
                <artifactId>maven-bundle-plugin</artifactId>
                <extensions>true</extensions>
                <configuration>
                    <instructions>
                        <Embed-Dependency>
                            ..
                            .....
                            json-lib,
                            xom,
                            ezmorph,
                            commons-collections,
                            commons-beanutils,
                            .....
                        </Embed-Dependency>
                  .............
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top