EAR application and application.xml: library-directory element values

1.8k Views Asked by At

Starting with basic EAR file documentation and proceeding to official Oracle documentation, can't find much on application.xml. What should the application.xml file have for the library-directory element?

deploy fails:

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'
}

project:

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

ear file:

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$ 

It looks like lib, as above, is the default -- or at least standard. Surely it's not necessary to resort to groovy? I'd expect a gradle.

0

There are 0 best solutions below