当前位置: 首页 > 知识库问答 >
问题:

使用Gradle生成EAR(JBoss的Spring应用程序)

冯嘉珍
2023-03-14

我遵循了这个教程(使用基于XML的Spring配置):

http://codetutr.com/2013/03/24/simple-spring-mvc-web-application-using-gradle/

当我运行Jetty时,它可以工作,我可以看到“你好,CodeTuter!”在http://localhost:8080/home

然后我修改构建。gradle生成ear文件:

apply plugin: 'ear'
apply plugin: 'war'
apply plugin: 'jetty'
apply plugin: 'eclipse-wtp'

repositories {
   mavenCentral()
}

dependencies {
   compile 'org.springframework:spring-webmvc:3.2.2.RELEASE'
   compile 'javax.servlet:javax.servlet-api:3.0.1'
   runtime 'javax.servlet:jstl:1.1.2'
   deploy files(war)
}

/* Change context path (base url). otherwise defaults to name of project */
jettyRunWar.contextPath = ''

ear文件的生成没有问题,但是当我使用本地JBoss-4.0.4部署ear文件时。我看到“你好,${name}”在http://localhost:8080/spring-mvc/home。通过查看日志,我可以看到控制器在每次重新加载URL时都在运行,但它从未替换${name}。

你知道怎么解决吗?

更糟糕的是,当我试图在服务器JBoss-5.1.0上部署相同的听筒文件时。GA,应用程序永远不会部署。Server.log:

2014-12-03 09:05:03,668 WARN  [org.jboss.util.xml.JBossEntityResolver] (HDScanner) Trying to resolve systemId as a non-file URL: http://java.sun.com/xml/ns/javaee/application_6.xsd
2014-12-03 09:05:04,932 WARN  [org.jboss.util.xml.JBossEntityResolver] (HDScanner) Trying to resolve systemId as a non-file URL: http://java.sun.com/xml/ns/javaee
2014-12-03 09:05:13,001 WARN  [org.jboss.system.server.profileservice.hotdeploy.HDScanner] (HDScanner) Scan failed
org.jboss.deployers.spi.DeploymentException: Exception determining structure: AbstractVFSDeployment(spring-mvc.ear)
    at org.jboss.deployers.spi.DeploymentException.rethrowAsDeploymentException(DeploymentException.java:49)
    at org.jboss.deployers.structure.spi.helpers.AbstractStructuralDeployers.determineStructure(AbstractStructuralDeployers.java:85)
    at org.jboss.deployers.plugins.main.MainDeployerImpl.determineStructure(MainDeployerImpl.java:1004)
    at org.jboss.deployers.plugins.main.MainDeployerImpl.determineDeploymentContext(MainDeployerImpl.java:440)
    at org.jboss.deployers.plugins.main.MainDeployerImpl.addDeployment(MainDeployerImpl.java:390)
    at org.jboss.deployers.plugins.main.MainDeployerImpl.addDeployment(MainDeployerImpl.java:300)
    at org.jboss.system.server.profileservice.repository.MainDeployerAdapter.addDeployment(MainDeployerAdapter.java:86)
    at org.jboss.system.server.profileservice.hotdeploy.HDScanner.scan(HDScanner.java:344)
    at org.jboss.system.server.profileservice.hotdeploy.HDScanner.run(HDScanner.java:255)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
    at java.util.concurrent.FutureTask$Sync.innerRunAndReset(FutureTask.java:317)
    at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:150)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$101(ScheduledThreadPoolExecutor.java:98)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.runPeriodic(ScheduledThreadPoolExecutor.java:181)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:205)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    at java.lang.Thread.run(Thread.java:619)
Caused by: java.lang.RuntimeException: Error determining structure: spring-mvc.ear
    at org.jboss.deployment.EARStructure.determineStructure(EARStructure.java:293)
    at org.jboss.deployers.vfs.plugins.structure.StructureDeployerWrapper.determineStructure(StructureDeployerWrapper.java:73)
    at org.jboss.deployers.vfs.plugins.structure.VFSStructuralDeployersImpl.doDetermineStructure(VFSStructuralDeployersImpl.java:196)
    at org.jboss.deployers.vfs.plugins.structure.VFSStructuralDeployersImpl.determineStructure(VFSStructuralDeployersImpl.java:221)
    at org.jboss.deployers.structure.spi.helpers.AbstractStructuralDeployers.determineStructure(AbstractStructuralDeployers.java:77)
    ... 16 more
Caused by: org.jboss.xb.binding.JBossXBException: Failed to parse source: Failed to parse schema for nsURI=http://java.sun.com/xml/ns/javaee, baseURI=null, schemaLocation=http://java.sun.com/xml/ns/javaee/application_6.xsd
    at org.jboss.xb.binding.parser.sax.SaxJBossXBParser.parse(SaxJBossXBParser.java:203)
    at org.jboss.xb.binding.parser.sax.SaxJBossXBParser.parse(SaxJBossXBParser.java:183)
    at org.jboss.xb.binding.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:161)
    at org.jboss.deployment.EARStructure.determineStructure(EARStructure.java:160)
    ... 20 more
Caused by: org.jboss.xb.binding.JBossXBRuntimeException: Failed to parse schema for nsURI=http://java.sun.com/xml/ns/javaee, baseURI=null, schemaLocation=http://java.sun.com/xml/ns/javaee/application_6.xsd
    at org.jboss.xb.binding.resolver.AbstractMutableSchemaResolver.resolve(AbstractMutableSchemaResolver.java:293)
    at org.jboss.xb.binding.sunday.unmarshalling.SundayContentHandler.startElement(SundayContentHandler.java:274)
    at org.jboss.xb.binding.parser.sax.SaxJBossXBParser$DelegatingContentHandler.startElement(SaxJBossXBParser.java:401)
    at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown Source)
    at org.apache.xerces.xinclude.XIncludeHandler.startElement(Unknown Source)
    at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)
    at org.apache.xerces.impl.XMLNSDocumentScannerImpl$NSContentDispatcher.scanRootElementHook(Unknown Source)
    at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
    at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
    at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
    at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
    at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
    at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
    at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
    at org.jboss.xb.binding.parser.sax.SaxJBossXBParser.parse(SaxJBossXBParser.java:199)
    ... 23 more
Caused by: org.jboss.xb.binding.JBossXBRuntimeException: -1:-1 31:3 The declaration for the entity "HTML.Version" must end with '>'.
    at org.jboss.xb.binding.sunday.unmarshalling.XsdBinderTerminatingErrorHandler.handleError(XsdBinderTerminatingErrorHandler.java:40)
    at org.apache.xerces.impl.xs.XMLSchemaLoader.reportDOMFatalError(Unknown Source)
    at org.apache.xerces.impl.xs.XSLoaderImpl.load(Unknown Source)
    at org.jboss.xb.binding.Util.loadSchema(Util.java:395)
    at org.jboss.xb.binding.sunday.unmarshalling.XsdBinder.bind(XsdBinder.java:176)
    at org.jboss.xb.binding.sunday.unmarshalling.XsdBinder.bind(XsdBinder.java:147)
    at org.jboss.xb.binding.resolver.AbstractMutableSchemaResolver.resolve(AbstractMutableSchemaResolver.java:285)
    ... 37 more

你知道怎么解决吗?

谢谢

更新:

war文件(在ear文件旁边生成)部署在Tomcat-6.0.39上,运行良好。

读着这本《http://www.gradle.org/docs/current/userguide/ear_plugin.html》,我修改了build.gradle:

apply plugin: 'ear'
apply plugin: 'war'
apply plugin: 'jetty'
apply plugin: 'eclipse-wtp'

repositories {
   mavenCentral()
}

dependencies {
   compile 'org.springframework:spring-webmvc:3.2.2.RELEASE'
   compile 'javax.servlet:javax.servlet-api:3.0.1'
   runtime 'javax.servlet:jstl:1.1.2'
   deploy files(war)   

    // The following dependencies will become ear libs and will
    // be placed in a dir configured via the libDirName property
    earlib group: 'log4j', name: 'log4j', version: '1.2.15', ext: 'jar'
}

/* Change context path (base url). otherwise defaults to name of project */
jettyRunWar.contextPath = ''


ear {
    appDirName 'src/main/webapp'  // use application metadata found in this folder
    // put dependent libraries into APP-INF/lib inside the generated EAR
    libDirName 'WEB-INF/lib'
    deploymentDescriptor {  // custom entries for application.xml:
//      fileName = "application.xml"  // same as the default value
//      version = "6"  // same as the default value
        applicationName = "spring-mvc"
        initializeInOrder = true
        displayName = "spring-mvc"  // defaults to project.name
        // defaults to project.description if not set
        description = "spring-mvc"
//      libraryDirectory = "WEB-INF/lib"  // not needed, above libDirName setting does this
//      module("spring-mvc.jar", "java")  // won't deploy as my.jar isn't deploy dependency
      webModule("spring-mvc.war", "/")  // won't deploy as my.war isn't deploy dependency
//        securityRole "admin"
//        securityRole "superadmin"
//        withXml { provider -> // add a custom node to the XML
//            provider.asNode().appendNode("data-source", "my/data/source")
//        }
    }
}

但是新的耳朵锉有和旧的一样的问题。

代码(使用原始build.gradle):

  • ZIP
  • GitHub

共有1个答案

农鸿德
2023-03-14

这不是“用Gradle生成耳朵......”的解决方案,但它是我的情况的解决方案:

  • 忘记耳朵,发动战争
 类似资料:
  • 我正在使用gradle创建一个spring boot应用程序。我需要创建一个jar,其中包含在(aws)ec2实例上部署所需的所有库。 我正试图创建一个罐子由。。。 1)点击项目结构 2)然后点击工件 3)点击- 4) 用默认设置点击ok 5) 点击build标签 6)我有一个jar文件,但它不包含类。

  • 在运行mvn spring-boot:run命令时,我无法找出什么是错误的。mvn clean install使构建成功,但对于mvn spring-boot:run,我得到一个构建失败。这是运行mvn spring-boot时控制台中的错误日志:run-x。 这是我的pom.xml。我还从eclipse ide中的活动maven配置文件中删除了pom.xml,原因是它作为本链接中的解决方案之一给

  • 问题内容: 我正在开发spring app,需要逐步执行控制器方法以了解其工作方式。我正在日食中工作,并使用命令构建我的应用程序。 如何在调试模式下运行它? 我试过了,但这只是调试日志,不是调试模式 我试过了-这给了我关于任务的信息,我看到了选项,但是当我运行 应用程序无法启动 问题答案: 运行应用程序后,应用程序将被挂起,直到将调试器连接到正在侦听的端口(端口5005)。

  • 我以为应用程序插件会有这样的选择?

  • OSGI-INF/serviceComponent.xml可以使用maven scr felix插件通过添加依赖项生成,如 但对于格雷德尔来说,我无法生成。。我已尝试添加 这是一个错误。捷豹路虎主页。找不到gradle。 我做错了什么??? 基本上,我需要依赖项来添加gradle以生成servicecomponent。xml

  • 错误: 类ModeloApp: 接口EventOfacade.java(第一行,它真的很大): 感谢任何帮助