Wildfly Swarm部署问题 - 无法解决工件'xalan:serializer:2.7.1.jbossorg-2'

时间:2017-01-24 11:06:26

标签: gradle wildfly swarm

使用gradle脚本:

buildscript {
    version = System.getProperty('swarmVersion') ?: '2017.1.1'

    repositories {
        mavenLocal()
        mavenCentral()
    }

    dependencies {
        classpath "io.spring.gradle:dependency-management-plugin:1.0.0.RC2"
        classpath "org.wildfly.swarm:wildfly-swarm-plugin:$version"
    }
}

apply plugin: "io.spring.dependency-management"
apply plugin: 'wildfly-swarm'
apply plugin: 'java'
apply plugin: 'application'

mainClassName = 'test.Main'

swarm {
    properties {
        swarm.http.port = 8080
    }
}

repositories {
    mavenLocal()
    mavenCentral()
    maven {
        url 'https://maven.repository.redhat.com/nexus/content/repositories/releases/'
    }
    maven {
        url 'https://maven.repository.redhat.com/nexus/content/repositories/thirdparty-releases/'
    }
}

dependencyManagement {
    imports {
        mavenBom "org.wildfly.swarm:bom-all:$version"
    }
}

dependencies {
    compile "org.wildfly.swarm:jaxrs"
}

test.Main

  package test;

import test.resources.TestResource;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.wildfly.swarm.Swarm;
import org.wildfly.swarm.jaxrs.JAXRSArchive;

public class Main {

  public static void main(String... args) throws Exception {

    Swarm swarm = new Swarm();
    JAXRSArchive deployment = ShrinkWrap.create(JAXRSArchive.class);
    deployment.addClass(TestResource.class);
    deployment.addAllDependencies();
    swarm.start();
    swarm.deploy(deployment);
  }
}

启动jar时出现此错误:

2017-01-24 12:00:35,363 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-8) MSC000001: Failed to start service jboss.deployment.unit."8cf83a03-d940-4e8b-b223-f9a9e00976ce.war".INSTALL: org.jboss.msc.service.StartException in service jboss.deployment.unit."8cf83a03-d940-4e8b-b223-f9a9e00976ce.war".INSTALL: WFLYSRV0153: Failed to process phase INSTALL of deployment "8cf83a03-d940-4e8b-b223-f9a9e00976ce.war"
        at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:154)
        at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1948)
        at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1881)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at java.lang.Thread.run(Thread.java:745)
Caused by: org.jboss.as.server.deployment.DeploymentUnitProcessingException: WFLYUT0049: Error loading SCI from module: javax.servlet.jstl.api:main
        at org.wildfly.extension.undertow.deployment.ServletContainerInitializerDeploymentProcessor.deploy(ServletContainerInitializerDeploymentProcessor.java:118)
        at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:147)
        ... 5 more
Caused by: org.jboss.modules.ModuleLoadException: Error loading module from modules/org/apache/xalan/main/module.xml
        at org.jboss.modules.xml.ModuleXmlParser.parseModuleXml(ModuleXmlParser.java:228)
        at org.wildfly.swarm.bootstrap.modules.ClasspathModuleFinder.findModule(ClasspathModuleFinder.java:80)
        at org.jboss.modules.ModuleLoader.findModule(ModuleLoader.java:439)
        at org.jboss.modules.ModuleLoader.loadModuleLocal(ModuleLoader.java:342)
        at org.jboss.modules.ModuleLoader.preloadModule(ModuleLoader.java:289)
        at org.jboss.modules.Module.addPaths(Module.java:1079)
        at org.jboss.modules.Module.link(Module.java:1449)
        at org.jboss.modules.Module.relinkIfNecessary(Module.java:1477)
        at org.jboss.modules.ModuleLoader.loadModule(ModuleLoader.java:225)
        at org.wildfly.extension.undertow.deployment.ServletContainerInitializerDeploymentProcessor.deploy(ServletContainerInitializerDeploymentProcessor.java:109)
        ... 6 more
Caused by: org.jboss.modules.xml.XmlPullParserException: Failed to resolve artifact 'xalan:serializer:2.7.1.jbossorg-2' (position: END_TAG seen ...esources>\n    <artifact name="xalan:serializer:2.7.1.jbossorg-2"/>... @5:57) 
        at org.jboss.modules.xml.ModuleXmlParser.parseArtifact(ModuleXmlParser.java:838)
        at org.jboss.modules.xml.ModuleXmlParser.parseResources(ModuleXmlParser.java:739)
        at org.jboss.modules.xml.ModuleXmlParser.parseModuleContents(ModuleXmlParser.java:535)
        at org.jboss.modules.xml.ModuleXmlParser.parseDocument(ModuleXmlParser.java:340)
        at org.jboss.modules.xml.ModuleXmlParser.parseModuleXml(ModuleXmlParser.java:226)
        ... 15 more

2017-01-24 12:00:35,371 ERROR [org.jboss.as.controller.management-operation] (main) WFLYCTL0013: Operation ("add") failed - address: (("deployment" => "8cf83a03-d940-4e8b-b223-f9a9e00976ce.war")) - failure description: {
    "WFLYCTL0080: Failed services" => {"jboss.deployment.unit.\"8cf83a03-d940-4e8b-b223-f9a9e00976ce.war\".INSTALL" => "org.jboss.msc.service.StartException in service jboss.deployment.unit.\"8cf83a03-d940-4e8b-b223-f9a9e00976ce.war\".INSTALL: WFLYSRV0153: Failed to process phase INSTALL of deployment \"8cf83a03-d940-4e8b-b223-f9a9e00976ce.war\"
    Caused by: org.jboss.as.server.deployment.DeploymentUnitProcessingException: WFLYUT0049: Error loading SCI from module: javax.servlet.jstl.api:main
    Caused by: org.jboss.modules.ModuleLoadException: Error loading module from modules/org/apache/xalan/main/module.xml
    Caused by: org.jboss.modules.xml.XmlPullParserException: Failed to resolve artifact 'xalan:serializer:2.7.1.jbossorg-2' (position: END_TAG seen ...esources>\\n    <artifact name=\"xalan:serializer:2.7.1.jbossorg-2\"/>... @5:57) "},
    "WFLYCTL0412: Required services that are not installed:" => ["jboss.deployment.unit.\"8cf83a03-d940-4e8b-b223-f9a9e00976ce.war\".INSTALL"],
    "WFLYCTL0180: Services with missing/unavailable dependencies" => undefined
}
2017-01-24 12:00:35,374 ERROR [org.jboss.as.server] (main) WFLYSRV0021: Deploy of deployment "8cf83a03-d940-4e8b-b223-f9a9e00976ce.war" was rolled back with the following failure message: 
{
    "WFLYCTL0080: Failed services" => {"jboss.deployment.unit.\"8cf83a03-d940-4e8b-b223-f9a9e00976ce.war\".INSTALL" => "org.jboss.msc.service.StartException in service jboss.deployment.unit.\"8cf83a03-d940-4e8b-b223-f9a9e00976ce.war\".INSTALL: WFLYSRV0153: Failed to process phase INSTALL of deployment \"8cf83a03-d940-4e8b-b223-f9a9e00976ce.war\"
    Caused by: org.jboss.as.server.deployment.DeploymentUnitProcessingException: WFLYUT0049: Error loading SCI from module: javax.servlet.jstl.api:main
    Caused by: org.jboss.modules.ModuleLoadException: Error loading module from modules/org/apache/xalan/main/module.xml
    Caused by: org.jboss.modules.xml.XmlPullParserException: Failed to resolve artifact 'xalan:serializer:2.7.1.jbossorg-2' (position: END_TAG seen ...esources>\\n    <artifact name=\"xalan:serializer:2.7.1.jbossorg-2\"/>... @5:57) "},
    "WFLYCTL0412: Required services that are not installed:" => ["jboss.deployment.unit.\"8cf83a03-d940-4e8b-b223-f9a9e00976ce.war\".INSTALL"],
    "WFLYCTL0180: Services with missing/unavailable dependencies" => undefined
}

3 个答案:

答案 0 :(得分:1)

Wildfly Swarm的gradle插件存在许多问题,例如

https://issues.jboss.org/browse/SWARM-542

https://issues.jboss.org/browse/SWARM-826

并且this comment并不能让我确信它们会很快被修复。

为此,暂时我的方法只是假设使用Gradle可靠地构建Swarm应用程序的唯一方法是首先使用Maven构建一个空心的Swarm uberjar,然后使用Gradle集成生成的Wildfly jar或者(就像我一样),在Docker中。

你错过了自动分数检测(无论如何这对我来说似乎没有用)但另一方面,如果你没有为每个构建构建整个uberjar,你的构建时间会更快。当然,由于Maven显然是Red Hat的一等公民,因此您可以将自己与依赖供应商支持的构建工具脱钩。

有关空心uberjars的更多信息:

https://wildfly-swarm.gitbooks.io/wildfly-swarm-users-guide/content/getting-started/tooling/maven-plugin.html

要使用uberjar部署应用程序,只需将WAR添加到命令行:

java -jar my-hollow-swarm.jar my-application.war

另外,您还可以传递配置和其他详细信息:

java -jar my-hollow-swarm.jar my-application.war -c /etc/config.xml
java -jar my-hollow-swarm.jar my-application.war --help

答案 1 :(得分:0)

如果我将软件包添加到部署中,那么我会找出解决方法,然后swarm能够正常部署它。以下是对我有用的解决方案。

Swarm swarm = new Swarm();
JAXRSArchive deployment = ShrinkWrap.create(JAXRSArchive.class);
deployment.addPackage("test");
deployment.addAllDependencies();
swarm.start();
swarm.deploy(deployment);

答案 2 :(得分:0)

您需要在Maven设置中激活JBoss Nexus存储库。

另见:

一个例子:

原因是,当WildFly Swarm和WildFly配置工具正确下载工件时,其中一些仅在JBoss Nexus上可用,Maven将在本地缓存的元数据中跟踪它。

当您运行不同的进程(如您自己的应用程序)而不启用此存储库时,正在使用的Eclipse Aether库将(按预期)尊重此元数据并忽略任何当前未启用的任何工件库中。