EAR application和application.xml:library-directory元素值

时间:2017-08-22 05:58:18

标签: java-ee gradle glassfish ear application.xml

basic EAR文档文档开始并继续official Oracle文档,在application.xml上找不到多少内容。 application.xml文件的应该library-directory元素有什么意义?

部署失败:

thufir@doge:~$ 
thufir@doge:~$ GlassFish_Server/bin/asadmin deploy /home/thufir/NetBeansProjects/gradleEAR/build/libs/gradleEAR.ear 
remote failure: Error occurred during deployment: org.xml.sax.SAXParseException; lineNumber: 4; columnNumber: 22; Deployment descriptor file META-INF/application.xml in archive [gradleEAR].  cvc-complex-type.2.4.a: Invalid content was found starting with element 'library-directory'. One of '{"http://java.sun.com/xml/ns/javaee":display-name, "http://java.sun.com/xml/ns/javaee":icon, "http://java.sun.com/xml/ns/javaee":initialize-in-order, "http://java.sun.com/xml/ns/javaee":module}' is expected.. Please see server.log for more details.
Command deploy failed.
thufir@doge:~$ 

的build.gradle:

plugins {
    id 'com.gradle.build-scan' version '1.8' 
    id 'java'
    id 'application'
    id 'ear'
}

mainClassName = 'net.bounceme.doge.json.Main'

buildScan {
    licenseAgreementUrl = 'https://gradle.com/terms-of-service'
    licenseAgree = 'yes'
}

repositories {
    jcenter()
}

jar {
    manifest {
        attributes 'Main-Class': 'net.bounceme.doge.json.Main'
    }
}

task fatJar(type: Jar) {
    baseName = project.name + '-all'
    from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } }
    with jar
    manifest {
        attributes 'Implementation-Title': 'Gradle Quickstart', 'Implementation-Version': '3.4.0'
        attributes 'Main-Class': 'net.bounceme.doge.json.Main'
    }
}

dependencies {
    compile group: 'javax.json', name: 'javax.json-api', version: '1.1'
    compile group: 'org.glassfish', name: 'javax.json', version: '1.1'
    compileOnly 'javax:javaee-api:7.0'
}

项目:

gradleEAR/
├── build.gradle
├── gradle
│   └── wrapper
│       ├── gradle-wrapper.jar
│       └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── settings.gradle
└── src
    ├── main
    │   ├── java
    │   │   └── net
    │   │       └── bounceme
    │   │           └── doge
    │   │               ├── ejb
    │   │               │   ├── NewSessionBean.java
    │   │               │   └── NewSessionBeanRemote.java
    │   │               └── json
    │   │                   ├── JsonReaderClient.java
    │   │                   ├── JsonReader.java
    │   │                   ├── Main.java
    │   │                   ├── Marshaller.java
    │   │                   ├── MarshallJSON.java
    │   │                   ├── ObjectA.java
    │   │                   └── PropertiesReader.java
    │   └── resources
    └── test
        └── java

13 directories, 15 files

耳文:

thufir@doge:~/NetBeansProjects/gradleEAR/build/libs$ 
thufir@doge:~/NetBeansProjects/gradleEAR/build/libs$ ll
total 20
drwxr-xr-x 2 thufir thufir 4096 Aug 21 22:47 ./
drwxr-xr-x 6 thufir thufir 4096 Aug 21 22:47 ../
-rw-r--r-- 1 thufir thufir 8569 Aug 21 22:47 gradleEAR.ear
thufir@doge:~/NetBeansProjects/gradleEAR/build/libs$ 
thufir@doge:~/NetBeansProjects/gradleEAR/build/libs$ jar xf gradleEAR.ear 
thufir@doge:~/NetBeansProjects/gradleEAR/build/libs$ 
thufir@doge:~/NetBeansProjects/gradleEAR/build/libs$ tree
.
├── gradleEAR.ear
├── META-INF
│   ├── application.xml
│   └── MANIFEST.MF
└── net
    └── bounceme
        └── doge
            ├── ejb
            │   ├── NewSessionBean.class
            │   └── NewSessionBeanRemote.class
            └── json
                ├── JsonReader.class
                ├── JsonReaderClient.class
                ├── Main.class
                ├── Marshaller.class
                ├── MarshallJSON.class
                ├── ObjectA.class
                └── PropertiesReader.class

6 directories, 12 files
thufir@doge:~/NetBeansProjects/gradleEAR/build/libs$ 
thufir@doge:~/NetBeansProjects/gradleEAR/build/libs$ cat META-INF/MANIFEST.MF 
Manifest-Version: 1.0

thufir@doge:~/NetBeansProjects/gradleEAR/build/libs$ 
thufir@doge:~/NetBeansProjects/gradleEAR/build/libs$ cat META-INF/application.xml 
<?xml version="1.0"?>
<application xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/application_6.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="6">
  <display-name>gradleEAR</display-name>
  <library-directory>lib</library-directory>
</application>
thufir@doge:~/NetBeansProjects/gradleEAR/build/libs$ 

如上所述,looks like lib是默认设置 - 或者至少是标准配置。当然,resort没有必要去修饰?我期待一个朋友。

0 个答案:

没有答案