I have a maven (m2e eclipse) project with these dependencies:
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.opensaml</groupId>
<artifactId>opensaml-core</artifactId>
<version>3.3.0</version>
</dependency>
<dependency>
<groupId>org.opensaml</groupId>
<artifactId>opensaml-messaging-api</artifactId>
<version>3.3.0</version>
</dependency>
<dependency>
<groupId>org.opensaml</groupId>
<artifactId>opensaml-profile-api</artifactId>
<version>3.3.0</version>
</dependency>
<dependency>
<groupId>org.opensaml</groupId>
<artifactId>opensaml-saml-api</artifactId>
<version>3.3.0</version>
</dependency>
<dependency>
<groupId>org.opensaml</groupId>
<artifactId>opensaml-security-api</artifactId>
<version>3.3.0</version>
</dependency>
<dependency>
<groupId>org.opensaml</groupId>
<artifactId>opensaml-soap-api</artifactId>
<version>3.3.0</version>
</dependency>
<dependency>
<groupId>org.opensaml</groupId>
<artifactId>opensaml-storage-api</artifactId>
<version>3.3.0</version>
</dependency>
<dependency>
<groupId>org.opensaml</groupId>
<artifactId>opensaml-xmlsec-api</artifactId>
<version>3.3.0</version>
</dependency>
<dependency>
<groupId>org.opensaml</groupId>
<artifactId>opensaml-saml-impl</artifactId>
<version>3.3.0</version>
</dependency>
<dependency>
<groupId>org.opensaml</groupId>
<artifactId>xmltooling</artifactId>
<version>1.4.6</version>
</dependency>
</dependencies>
Inside Eclipse i run mvn install -U
and everything works fine.
OLD
.............................
So i used Maven Dependency Plugin to extract all the jars from the dependencies and used them in another project.
In this Project, when i enter:
InitializationService.initialize();
I became this error:
Exception in thread "main" java.lang.ClassCastException: org.opensaml.xml.signature.impl.CryptoBinaryBuilder cannot be cast to org.opensaml.core.xml.XMLObjectBuilder
at org.opensaml.core.xml.config.XMLConfigurator.initializeObjectProviders(XMLConfigurator.java:238)
at org.opensaml.core.xml.config.XMLConfigurator.load(XMLConfigurator.java:203)
at org.opensaml.core.xml.config.XMLConfigurator.load(XMLConfigurator.java:188)
at org.opensaml.core.xml.config.XMLConfigurator.load(XMLConfigurator.java:162)
at org.opensaml.core.xml.config.AbstractXMLObjectProviderInitializer.init(AbstractXMLObjectProviderInitializer.java:52)
at org.opensaml.core.config.InitializationService.initialize(InitializationService.java:56)
Update: I could fix this problem by deleting the complete maven repository
Updated
................................
So then i used Maven Assembly Plugin to generate a jar with all dependencies included. I can pass the InitializationService.initialize()
fine, but i am getting a NullPointerException at:
marshaller = XMLObjectProviderRegistrySupport.getMarshallerFactory().getMarshaller(authnRequest.getElementQName());
Null is returned from the factory.
Related: OpenSAML 3 unmarshaller is null
Why does my program work when run inside a maven test but not when i use the jar or the code with the dependend libraries?