Hi John,

totally right, as you point out, the 'ClassLoader' goes nuts when
SAXParserFactory comes from a different jar and from the JRE (rt.jar).

The rebuilt cdk.jar (without xml-apis:xml-apis) works fine for me.

thanks again for your time.

Oscar

2014-09-04 12:03 GMT+02:00 John May <john...@ebi.ac.uk>:

> Hi Oscar,
>
> Thanks for the example of configuring shade to exclude it.
>
> I guess the issue you were having was it was clashing with the JDK class
> (see below). XML APIs is not really my domain but I'll see if we can remove
> dependence on xmlapis from the CDK so you don’t have to add the hack. I
> believe it's mainly used for XOM which is used for CML and might be an
> artifact of an old xom version.
>
> J
>
>
>
> On Sep 4, 2014, at 10:56 AM, Oscar Mora <oscarmorape...@gmail.com> wrote:
>
> John,
>
> I have tried your hunch but it does works for me, after looking and adding
> <scope>provided</scope> to all 'xom:xom' dependencies the final jar still
> contains the classes of the dependency. Sorry
>
> I found one way to solve this. If anybody runs in the same problem, the
> following has worked for me:
>
> The packaging process is performed using 'shade-plugin' (
> http://maven.apache.org/plugins/maven-shade-plugin/) in bundle/pom.xml:
>
> ...
> <plugin>
> <groupId>org.apache.maven.plugins</groupId>
> <artifactId>maven-shade-plugin</artifactId>
>  <version>2.2</version>
> <configuration>
> <finalName>cdk-${project.parent.version}</finalName>
>  <filters>
> <filter>
> <artifact>*:*</artifact>
>  <excludes>
> <exclude>META-INF/*.SF</exclude>
> <exclude>META-INF/*.DSA</exclude>
>  <exclude>META-INF/*.RSA</exclude>
> </excludes>
> </filter>
>  </filters>
> </configuration>
> <executions>
>  <execution>
> <phase>package</phase>
> <goals>
>  <goal>shade</goal>
> </goals>
> </execution>
>  </executions>
> </plugin>
> ...
>
> The configuration tag of this plug-in allows to exclude specific
> dependencies by using the <artifactSet> tag. I have added the following (in
> bold):
>
> ...
> <plugin>
> <groupId>org.apache.maven.plugins</groupId>
> <artifactId>maven-shade-plugin</artifactId>
>  <version>2.2</version>
> <configuration>
> <finalName>cdk-${project.parent.version}</finalName>
>  <filters>
> <filter>
> <artifact>*:*</artifact>
>  <excludes>
> <exclude>META-INF/*.SF</exclude>
> <exclude>META-INF/*.DSA</exclude>
>  <exclude>META-INF/*.RSA</exclude>
> </excludes>
> </filter>
>  </filters>
> *<artifactSet> *
> * <excludes>*
> * <exclude>xml-apis:xml-apis:*:*</exclude>*
> * </excludes>*
> * </artifactSet>*
>  </configuration>
> <executions>
> <execution>
>  <phase>package</phase>
> <goals>
> <goal>shade</goal>
>  </goals>
> </execution>
> </executions>
> </plugin>
> ...
>
> In my case I wanted to remove dependency xml-apis:xml-apis. The final
> package cdk-1.5.7.jar does not contain the classes of this dependency.
>
> thanks for your time.
>
> Oscar
>
>
>
> 2014-09-03 20:32 GMT+02:00 John May <john...@ebi.ac.uk>:
>
>> Hi Oscar,
>>
>> Just a hunch but might also need to exclude xom also - xom depends on
>> xml-apis (see here http://mvnrepository.com/artifact/xom/xom/1.2.5).
>>
>> [WARNING] xml-apis-1.3.03.jar, xpp3-1.1.4c.jar define 1 overlappping
>> classes:
>> [WARNING]   - javax.xml.namespace.QName
>> [WARNING] xom-1.2.5.jar, xml-apis-1.3.03.jar define 1 overlappping
>> classes:
>> [WARNING]   - org.w3c.dom.UserDataHandler
>>
>>
>> J
>>
>> On Sep 3, 2014, at 7:06 PM, Oscar Mora <oscarmorape...@gmail.com> wrote:
>>
>> Hi,
>>
>> I use CDK as external library in a java-based project. I am experiencing
>> problems with the 'Classloader' and for this I would like to rebuild CDK
>> avoiding the inclusion of an specific dependency. The class which I think
>> is problematic (I must admit I am not 100% sure) is:
>>
>> javax.xml.parsers.SAXParserFactory
>>
>> This class is contained in the dependency:
>>
>> xml-apis.xml-apis
>>
>> I have detected this dependency in cdk/base/dict sub-project
>>
>>         <dependency>
>>             <groupId>xml-apis</groupId>
>>             <artifactId>xml-apis</artifactId>
>>             <version>1.3.03</version>
>>         </dependency>
>>
>> and I have added the following line to the pom.xml contained in
>> cdk/base/dict/pom.xml :
>>
>>         <dependency>
>>             <groupId>xml-apis</groupId>
>>             <artifactId>xml-apis</artifactId>
>>             <version>1.3.03</version>
>> *            <scope>provided</scope>*
>>         </dependency>
>>
>> Then, I have rebuilt the CDK project using the command:
>>
>> $mvn clean compile package -Dmaven.test.skip=true
>>
>> But the final .jar (contained in bundle/target) still contains the class:
>>
>> javax.xml.parsers.SAXParserFactory
>>
>> What am I doing wrong ? Could anybody give me a piece of advice to solve
>> this situation ?
>>
>> thanks in advance
>>
>> Oscar
>>
>>
>>
>>
>> ------------------------------------------------------------------------------
>> Slashdot TV.
>> Video for Nerds.  Stuff that matters.
>> http://tv.slashdot.org/_______________________________________________
>> Cdk-user mailing list
>> Cdk-user@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/cdk-user
>>
>>
>>
>>
>> ------------------------------------------------------------------------------
>> Slashdot TV.
>> Video for Nerds.  Stuff that matters.
>> http://tv.slashdot.org/
>> _______________________________________________
>> Cdk-user mailing list
>> Cdk-user@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/cdk-user
>>
>>
>
> ------------------------------------------------------------------------------
> Slashdot TV.
> Video for Nerds.  Stuff that matters.
> http://tv.slashdot.org/_______________________________________________
> Cdk-user mailing list
> Cdk-user@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/cdk-user
>
>
>
------------------------------------------------------------------------------
Slashdot TV.  
Video for Nerds.  Stuff that matters.
http://tv.slashdot.org/
_______________________________________________
Cdk-user mailing list
Cdk-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/cdk-user

Reply via email to