打开 SAML xml-apis Maven 依赖问题
Open SAML xml-apis Maven Dependency Issue
我正在尝试通过 Maven 将 Open SAML 库添加到我的 Grails 项目中。所以对于 pom.xml
我添加了开放的 SAML 依赖项:
<dependency>
<groupId>org.opensaml</groupId>
<artifactId>opensaml</artifactId>
<version>2.5.1-1</version>
</dependency>
<dependency>
<groupId>org.opensaml</groupId>
<artifactId>openws</artifactId>
<version>1.4.2-1</version>
</dependency>
<dependency>
<groupId>org.opensaml</groupId>
<artifactId>xmltooling</artifactId>
<version>1.3.2-1</version>
</dependency>
grails run-app
和 mvn install
工作正常,但是当我将构建的 war 文件放入 tomcat 8 时,我在启动时遇到以下错误:
2015-07-22 11:17:53,091 [localhost-startStop-1] ERROR context.ContextLoader - Context initialization failed
org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from ServletContext resource [/WEB-INF/applicationContext.xml]; nested exception is java.lang.NoClassDefFoundError: org/w3c/dom/ElementTraversal
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.NoClassDefFoundError: org/w3c/dom/ElementTraversal
at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
... 5 more
Caused by: java.lang.ClassNotFoundException: org.w3c.dom.ElementTraversal
... 7 more
通过一些研究,我发现 xml-apis:xml-apis:1.4.01 应该添加到我的 pom 文件中,以便它出现在 WEB-INF/lib解压后的文件夹 war。因此,我将以下依赖项添加到我的 pom 文件中:
<dependency>
<groupId>xml-apis</groupId>
<artifactId>xml-apis</artifactId>
<version>1.4.01</version>
<scope>compile</scope>
</dependency>
我还查看了mvn dependency:tree -Dverbose
生成的依赖树,发现:
+- xml-apis:xml-apis:jar:1.4.01:compile
+- org.opensaml:opensaml:jar:2.5.1-1:compile
| +- (org.opensaml:openws:jar:1.4.2-1:compile - omitted for duplicate)
| +- commons-collections:commons-collections:jar:3.1:compile
| +- commons-lang:commons-lang:jar:2.1:compile
| +- velocity:velocity:jar:1.5:compile
| | +- (commons-collections:commons-collections:jar:3.1:compile - omitted for duplicate)
| | \- (commons-lang:commons-lang:jar:2.1:compile - omitted for duplicate)
| +- org.owasp.esapi:esapi:jar:2.0GA:compile
| +- (xml-apis:xml-apis:jar:1.4.01:runtime - omitted for duplicate)
| +- xerces:xercesImpl:jar:2.10.0:runtime
| | \- (xml-apis:xml-apis:jar:1.4.01:runtime - omitted for duplicate)
| +- xml-resolver:xml-resolver:jar:1.2:runtime
| \- xalan:xalan:jar:2.7.1:runtime
| \- xalan:serializer:jar:2.7.1:runtime
| \- (xml-apis:xml-apis:jar:1.3.04:runtime - omitted for conflict with 1.4.01)
+- org.opensaml:openws:jar:1.4.2-1:compile
| +- (org.opensaml:xmltooling:jar:1.3.2-1:compile - omitted for duplicate)
| +- commons-codec:commons-codec:jar:1.3:compile
| +- commons-httpclient:commons-httpclient:jar:3.1:compile
| | \- (commons-codec:commons-codec:jar:1.2:compile - omitted for conflict with 1.3)
| +- (xml-apis:xml-apis:jar:1.4.01:runtime - omitted for duplicate)
| +- (xerces:xercesImpl:jar:2.10.0:runtime - omitted for duplicate)
| +- (xml-resolver:xml-resolver:jar:1.2:runtime - omitted for duplicate)
| \- (xalan:xalan:jar:2.7.1:runtime - omitted for duplicate)
+- org.opensaml:xmltooling:jar:1.3.2-1:compile
| +- org.slf4j:slf4j-api:jar:1.6.1:compile
| +- org.slf4j:jcl-over-slf4j:jar:1.6.1:compile
| | \- (org.slf4j:slf4j-api:jar:1.6.1:compile - omitted for duplicate)
| +- org.slf4j:log4j-over-slf4j:jar:1.6.1:compile
| | \- (org.slf4j:slf4j-api:jar:1.6.1:compile - omitted for duplicate)
| +- org.slf4j:jul-to-slf4j:jar:1.6.1:compile
| | \- (org.slf4j:slf4j-api:jar:1.6.1:compile - omitted for duplicate)
| +- joda-time:joda-time:jar:2.8.1:compile
| +- org.bouncycastle:bcprov-jdk15:jar:1.45:compile
| +- org.apache.santuario:xmlsec:jar:1.4.4:compile
| +- ca.juliusdavies:not-yet-commons-ssl:jar:0.3.9:compile
| | \- (commons-httpclient:commons-httpclient:jar:3.0:compile - omitted for conflict with 3.1)
| +- net.jcip:jcip-annotations:jar:1.0:compile
| +- (xml-apis:xml-apis:jar:1.4.01:runtime - omitted for duplicate)
| +- (xerces:xercesImpl:jar:2.10.0:runtime - omitted for duplicate)
| +- (xml-resolver:xml-resolver:jar:1.2:runtime - omitted for duplicate)
| \- (xalan:xalan:jar:2.7.1:runtime - omitted for duplicate)
似乎所需的 xml-apis jar 将被打包到 war 文件中,因此位于 WEB-INF/lib 中,但是在使用 war 构建之后=17=] 在 pom 文件中使用这个我仍然得到上面的 No Class Found Errors 并且 xml-apis jar 仍然没有出现在 WEB-INF/lib 文件夹中。我想我已经按照通常的方法解决了这个问题,但我仍然无法解决这个问题。有谁知道为什么 xml-apis 依赖没有被打包到 war 文件中,或者为什么 Tomcat 启动时出现这个错误?谢谢。
我能够通过从 POM 中的所有 Open SAML 依赖项中排除 xerces:xercesImpl jar 来解决这个问题。
POM 中的 Open SAML 依赖项如下所示:
<dependency>
<groupId>org.opensaml</groupId>
<artifactId>opensaml</artifactId>
<version>2.5.1-1</version>
<exclusions>
<exclusion>
<groupId>xerces</groupId>
<artifactId>xercesImpl</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.opensaml</groupId>
<artifactId>openws</artifactId>
<version>1.4.2-1</version>
<exclusions>
<exclusion>
<groupId>xerces</groupId>
<artifactId>xercesImpl</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.opensaml</groupId>
<artifactId>xmltooling</artifactId>
<version>1.3.2-1</version>
<exclusions>
<exclusion>
<groupId>xerces</groupId>
<artifactId>xercesImpl</artifactId>
</exclusion>
</exclusions>
</dependency>
我正在尝试通过 Maven 将 Open SAML 库添加到我的 Grails 项目中。所以对于 pom.xml
我添加了开放的 SAML 依赖项:
<dependency>
<groupId>org.opensaml</groupId>
<artifactId>opensaml</artifactId>
<version>2.5.1-1</version>
</dependency>
<dependency>
<groupId>org.opensaml</groupId>
<artifactId>openws</artifactId>
<version>1.4.2-1</version>
</dependency>
<dependency>
<groupId>org.opensaml</groupId>
<artifactId>xmltooling</artifactId>
<version>1.3.2-1</version>
</dependency>
grails run-app
和 mvn install
工作正常,但是当我将构建的 war 文件放入 tomcat 8 时,我在启动时遇到以下错误:
2015-07-22 11:17:53,091 [localhost-startStop-1] ERROR context.ContextLoader - Context initialization failed
org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from ServletContext resource [/WEB-INF/applicationContext.xml]; nested exception is java.lang.NoClassDefFoundError: org/w3c/dom/ElementTraversal
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.NoClassDefFoundError: org/w3c/dom/ElementTraversal
at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
... 5 more
Caused by: java.lang.ClassNotFoundException: org.w3c.dom.ElementTraversal
... 7 more
通过一些研究,我发现 xml-apis:xml-apis:1.4.01 应该添加到我的 pom 文件中,以便它出现在 WEB-INF/lib解压后的文件夹 war。因此,我将以下依赖项添加到我的 pom 文件中:
<dependency>
<groupId>xml-apis</groupId>
<artifactId>xml-apis</artifactId>
<version>1.4.01</version>
<scope>compile</scope>
</dependency>
我还查看了mvn dependency:tree -Dverbose
生成的依赖树,发现:
+- xml-apis:xml-apis:jar:1.4.01:compile
+- org.opensaml:opensaml:jar:2.5.1-1:compile
| +- (org.opensaml:openws:jar:1.4.2-1:compile - omitted for duplicate)
| +- commons-collections:commons-collections:jar:3.1:compile
| +- commons-lang:commons-lang:jar:2.1:compile
| +- velocity:velocity:jar:1.5:compile
| | +- (commons-collections:commons-collections:jar:3.1:compile - omitted for duplicate)
| | \- (commons-lang:commons-lang:jar:2.1:compile - omitted for duplicate)
| +- org.owasp.esapi:esapi:jar:2.0GA:compile
| +- (xml-apis:xml-apis:jar:1.4.01:runtime - omitted for duplicate)
| +- xerces:xercesImpl:jar:2.10.0:runtime
| | \- (xml-apis:xml-apis:jar:1.4.01:runtime - omitted for duplicate)
| +- xml-resolver:xml-resolver:jar:1.2:runtime
| \- xalan:xalan:jar:2.7.1:runtime
| \- xalan:serializer:jar:2.7.1:runtime
| \- (xml-apis:xml-apis:jar:1.3.04:runtime - omitted for conflict with 1.4.01)
+- org.opensaml:openws:jar:1.4.2-1:compile
| +- (org.opensaml:xmltooling:jar:1.3.2-1:compile - omitted for duplicate)
| +- commons-codec:commons-codec:jar:1.3:compile
| +- commons-httpclient:commons-httpclient:jar:3.1:compile
| | \- (commons-codec:commons-codec:jar:1.2:compile - omitted for conflict with 1.3)
| +- (xml-apis:xml-apis:jar:1.4.01:runtime - omitted for duplicate)
| +- (xerces:xercesImpl:jar:2.10.0:runtime - omitted for duplicate)
| +- (xml-resolver:xml-resolver:jar:1.2:runtime - omitted for duplicate)
| \- (xalan:xalan:jar:2.7.1:runtime - omitted for duplicate)
+- org.opensaml:xmltooling:jar:1.3.2-1:compile
| +- org.slf4j:slf4j-api:jar:1.6.1:compile
| +- org.slf4j:jcl-over-slf4j:jar:1.6.1:compile
| | \- (org.slf4j:slf4j-api:jar:1.6.1:compile - omitted for duplicate)
| +- org.slf4j:log4j-over-slf4j:jar:1.6.1:compile
| | \- (org.slf4j:slf4j-api:jar:1.6.1:compile - omitted for duplicate)
| +- org.slf4j:jul-to-slf4j:jar:1.6.1:compile
| | \- (org.slf4j:slf4j-api:jar:1.6.1:compile - omitted for duplicate)
| +- joda-time:joda-time:jar:2.8.1:compile
| +- org.bouncycastle:bcprov-jdk15:jar:1.45:compile
| +- org.apache.santuario:xmlsec:jar:1.4.4:compile
| +- ca.juliusdavies:not-yet-commons-ssl:jar:0.3.9:compile
| | \- (commons-httpclient:commons-httpclient:jar:3.0:compile - omitted for conflict with 3.1)
| +- net.jcip:jcip-annotations:jar:1.0:compile
| +- (xml-apis:xml-apis:jar:1.4.01:runtime - omitted for duplicate)
| +- (xerces:xercesImpl:jar:2.10.0:runtime - omitted for duplicate)
| +- (xml-resolver:xml-resolver:jar:1.2:runtime - omitted for duplicate)
| \- (xalan:xalan:jar:2.7.1:runtime - omitted for duplicate)
似乎所需的 xml-apis jar 将被打包到 war 文件中,因此位于 WEB-INF/lib 中,但是在使用 war 构建之后=17=] 在 pom 文件中使用这个我仍然得到上面的 No Class Found Errors 并且 xml-apis jar 仍然没有出现在 WEB-INF/lib 文件夹中。我想我已经按照通常的方法解决了这个问题,但我仍然无法解决这个问题。有谁知道为什么 xml-apis 依赖没有被打包到 war 文件中,或者为什么 Tomcat 启动时出现这个错误?谢谢。
我能够通过从 POM 中的所有 Open SAML 依赖项中排除 xerces:xercesImpl jar 来解决这个问题。
POM 中的 Open SAML 依赖项如下所示:
<dependency>
<groupId>org.opensaml</groupId>
<artifactId>opensaml</artifactId>
<version>2.5.1-1</version>
<exclusions>
<exclusion>
<groupId>xerces</groupId>
<artifactId>xercesImpl</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.opensaml</groupId>
<artifactId>openws</artifactId>
<version>1.4.2-1</version>
<exclusions>
<exclusion>
<groupId>xerces</groupId>
<artifactId>xercesImpl</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.opensaml</groupId>
<artifactId>xmltooling</artifactId>
<version>1.3.2-1</version>
<exclusions>
<exclusion>
<groupId>xerces</groupId>
<artifactId>xercesImpl</artifactId>
</exclusion>
</exclusions>
</dependency>