Hibernate error when trying to enable .ear file - java

I deployed the ear files to a new server and I'm getting this error when I try to enable the .ear file via the JBoss console. The server it is on is using Wildfly. We are using Java 8 and Gradle. I have a number of Google searches and looked at threads here, but I haven't found a link which gets me close enough to a solution. There is a corresponding EJB info I can add in if need be. MySQL servers are both 5.6.
Error: Access to DialectResolutionInfo cannot be null when 'hibernate.dialect' not set
Request
{
"address" => [("deployment" => "EnsScheduler.ear")],
"operation" => "deploy"
}
Response
Internal Server Error
{
"outcome" => "failed",
"failure-description" => {"JBAS014671: Failed services" => {"jboss.persistenceunit.\"EnsScheduler.ear/EnsSchedulerEJB.jar#EnsDs\"" => "org.jboss.msc.service.StartException in service jboss.persistenceunit.\"EnsScheduler.ear/EnsSchedulerEJB.jar#EnsDs\": org.hibernate.HibernateException: Access to DialectResolutionInfo cannot be null when 'hibernate.dialect' not set
Caused by: org.hibernate.HibernateException: Access to DialectResolutionInfo cannot be null when 'hibernate.dialect' not set"}},
"rolled-back" => true
}
Here's some of the configure files data.
Application.xml
<?xml version="1.0" encoding="UTF-8"?>
<application xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:application="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" version="6">
<display-name>EnsScheduler</display-name>
<module>
<web>
<web-uri>EnsSchedulerWeb.war</web-uri>
<context-root>/</context-root>
</web>
</module>
<module>
<ejb>EnsSchedulerEJB.jar</ejb>
</module>
</application>
JBoss Deployment structure XML
<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure>
<deployment>
<dependencies>
<module name="com.google.guava" export="true" />
<module name="net.sourceforge.cssparser" export="true" />
<module name="org.w3c.css.sac" export="true" />
</dependencies>
</deployment>
</jboss-deployment-structure>
build.gradle
apply plugin: 'ear'
apply plugin: 'eclipse-wtp'
dependencies {
deploy project(':EnsSchedulerEJB')
deploy project(path:':EnsSchedulerWeb', configuration:'archives')
}
eclipse {
wtp {
facet {
facet name: 'jst.ear', version: '7.0'
}
}
project {
//buildCommands.clear()
//buildCommand 'org.eclipse.jdt.core.javabuilder'
natures 'org.eclipse.jdt.core.javanature'
}
classpath {
//file {
// whenMerged { classpath ->
// classpath.entries.removeAll { it.kind =='con' || it.kind == 'lib'}
// }
//}
containers 'org.eclipse.jst.server.core.container/org.jboss.ide.eclipse.as.core.server.runtime.runtimeTarget/WildFly 8.x Runtime'
}
}
build.gradle for the EJB project.
apply plugin: 'java'
apply plugin: 'eclipse-wtp'
configurations{
}
dependencies {
//java ee, jsf, jpa, and such
compile group: 'javax', name: 'javaee-api', version: '7.0'
compile 'javax.inject:javax.inject:1'
compile 'javax.enterprise:cdi-api:1.1'
compile 'javax.validation:validation-api:1.1.0.Final'
compile 'org.jboss.spec.javax.ejb:jboss-ejb-api_3.2_spec:1.0.0.Final'
compile 'org.jboss.spec.javax.ws.rs:jboss-jaxrs-api_2.0_spec:1.0.0.Final'
//hibernate was search 4.5.0 and core 4.3.1, lucene 3.6.2
compile 'org.hibernate.javax.persistence:hibernate-jpa-2.1-api:1.0.0.Final'
compile 'org.hibernate:hibernate-core:4.3.10.Final'
runtime 'org.hibernate:hibernate-core:4.3.10.Final'
runtime 'org.apache.lucene:lucene-core:4.10.4'
//mySql
compile 'mysql:mysql-connector-java:5.1.30'
runtime 'mysql:mysql-connector-java:5.1.30'
//testCompile group: 'junit', name: 'junit', version: '4.11'
}
eclipse {
wtp {
facet {
facets.clear()
facet type: org.gradle.plugins.ide.eclipse.model.Facet.FacetType.fixed, name: 'jst.ejb'
facet name: 'java', version: '1.8'
facet name: 'jst.ejb', version: '3.2'
facet name: 'jst.cdi', version: '1.1'
facet name: 'jpt.jpa', version: '2.1'
file{
whenMerged{ wtpFacet ->
def util = wtpFacet.facets.find{facet ->
facet.name == 'jst.utility' && facet.type == org.gradle.plugins.ide.eclipse.model.Facet.FacetType.installed}
wtpFacet.facets.remove(util)
println("facets: " + wtpFacet.facets)
}
withXml {xml ->
if ( ! xml.asNode().runtime ) {
NodeBuilder bld = new NodeBuilder()
xml.asNode().children().add(0, bld.runtime(name: 'WildFly 8.x Runtime'))
}
}
}
}
}
project {
buildCommands.clear()
buildCommand 'org.eclipse.jdt.core.javabuilder'
buildCommand 'org.eclipse.wst.common.project.facet.core.builder'
buildCommand 'org.hibernate.eclipse.console.hibernateBuilder'
buildCommand 'org.jboss.tools.cdi.core.cdibuilder'
buildCommand 'org.eclipse.wst.validation.validationbuilder'
natures 'org.eclipse.jem.workbench.JavaEMFNature',
'org.eclipse.wst.common.modulecore.ModuleCoreNature',
'org.hibernate.eclipse.console.hibernateNature',
'org.eclipse.jdt.core.javanature',
'org.eclipse.wst.common.project.facet.core.nature',
'org.jboss.tools.cdi.core.cdinature'
linkedResource name: 'lib/mysql-connector-java-5.1.30-bin.jar', type: '1', locationUri: 'PARENT-1-PROJECT_LOC/libraries/mysql-connector-java-5.1.30-bin.jar'
}
classpath{
minusConfigurations += [ configurations.compile ]
plusConfigurations += [ configurations.runtime ]
containers 'org.eclipse.jst.server.core.container/org.jboss.ide.eclipse.as.core.server.runtime.runtimeTarget/WildFly 8.x Runtime'
}
}

Related

error: package javafx.scene.media does not exist

I'm trying to create javafx media player as gradle project, but got this error.error: package javafx.scene.media does not exist on line: import javafx.scene.media.Media;
Here is my build.gradle
plugins {
id 'java'
id 'application'
id 'org.openjfx.javafxplugin' version '0.0.8'
}
group 'life.antonov'
version '1.0'
mainClassName='life.antonov.muza.Main'
sourceCompatibility = 11
jar {
manifest {
attributes "Main-Class": "$mainClassName"
}
from {
configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) }
}
}
javafx {
version = "13"
modules = [ 'javafx.controls', 'javafx.fxml' ]
}
repositories {
mavenCentral()
}
dependencies {
testCompile group: 'junit', name: 'junit', version: '4.12'
compile group: 'org.openjfx', name: 'javafx-controls', version: '13'
compile group: 'org.openjfx', name: 'javafx-fxml', version: '13 '
compile group: 'org.openjfx', name: 'javafx-media', version: '13'
}
I'm tried to unzip downloaded javafx-media jar file and it is almost empty:
$ unzip javafx-media-13.jar
Archive: javafx-media-13.jar
creating: META-INF/
inflating: META-INF/MANIFEST.MF
Why?
Maybe I wrote wrong dependencies?
What I have to do to make my application compile and work?
I have not tested it, but:
Replace:
modules = [ 'javafx.controls', 'javafx.fxml' ]
With
modules = [ 'javafx.controls', 'javafx.fxml', 'javafx.media' ]
If you want to use MediaView control in javafx you must to do 2 steps
Step1: add requires javafx.media;
module com.codegym.videoplayerfx {
requires javafx.controls;
requires javafx.fxml;
requires javafx.media; // You must add this line
opens com.codegym.videoplayerfx to javafx.fxml;
exports com.codegym.videoplayerfx;
}
Step2: Add dependency in pom.xml for maven (or build.gradle for gradle). After that you must press build. Try orther dependency version if does't work
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-media</artifactId>
<version>16</version>
</dependency>

Spring Boot (Gradle) app deployed to Google App Engine returns 404 Not Found

I have a Spring Boot (2.1.7) (Gradle project) that I want to deploy to Google App Engine.
I am able to successfully deploy the app (using the documentation found here) but when visiting the app url it returns a 404 Not Found screen:
<html><head>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<title>404 Not Found</title>
</head>
<body text=#000000 bgcolor=#ffffff>
<h1>Error: Not Found</h1>
</body></html>
Here's what my build.gradle file looks like:
buildscript {
repositories {
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.google.cloud.tools:appengine-gradle-plugin:2.1.0'
classpath 'org.akhikhl.gretty:gretty:+'
}
}
plugins {
id 'org.springframework.boot' version '2.1.7.RELEASE'
id 'io.spring.dependency-management' version '1.0.8.RELEASE'
}
apply plugin: 'java'
apply plugin: 'war'
apply plugin: 'org.akhikhl.gretty'
apply plugin: 'com.google.cloud.tools.appengine'
group = 'com.company'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '1.8'
repositories {
mavenCentral()
}
configurations.all {
exclude group: 'org.springframework.boot', module: 'spring-boot-starter-tomcat'
exclude group: 'org.slf4j', module: 'jul-to-slf4j'
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-jetty'
providedCompile 'javax.servlet:javax.servlet-api:3.1.0'
providedCompile 'com.google.appengine:appengine:+'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
}
gretty {
httpPort = 8080
contextPath = '/'
servletContainer = 'jetty9' // What App Engine Flexible uses
}
appengine {
deploy {
version = "3"
projectId = "apprealtest"
stopPreviousVersion = true // default - stop the current version
promote = true // default - & make this the current version
}
}
Here is what my {projectRoot}/src/main/appengine/app.yaml file looks like:
runtime: java
env: flex
runtime_config: # Optional
jdk: openjdk8
handlers:
- url: /.*
script: this field is required, but ignored
manual_scaling:
instances: 1
This is what my {projectRoot}/src/main/webapp/WEB-INF/appengine-web.xml file looks like:
<?xml version="1.0" encoding="utf-8"?>
<appengine-web-app xmlns="http://appengine.google.com/ns/1.0">
<runtime>java8</runtime>
<threadsafe>true</threadsafe>
</appengine-web-app>
This is what the {projectRoot}/src/main/java/com/company/hello/HelloApplication.java looks like:
package com.company.hello;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
#SpringBootApplication
public class HelloApplication {
public static void main(String[] args) {
SpringApplication.run(HelloApplication.class, args);
}
}
This is what the {projectRoot}/src/main/java/com/company/hello/HelloController.java looks like:
package com.company.hello;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
#RestController
public class HelloController {
#GetMapping("/")
public String get() {
return System.currentTimeMillis() + "";
}
#GetMapping("/greeting")
public String getGreeting() {
return "Greetings!";
}
}
I'm making the call to https://apprealtest.appspot.com and https://apprealtest.appspot.com/greeting.
What am I doing wrong?
To deploy it in GAE Standard you can download this official SpringBoot for App Engine Standard sample.
The instructions are for maven but to do it with Gradle you can simply add this build.gradle file:
buildscript { // Configuration for building
repositories {
jcenter() // Bintray's repository - a fast Maven Central mirror & more
mavenCentral()
}
dependencies {
classpath 'com.google.cloud.tools:appengine-gradle-plugin:1.+' // Latest 1.x.x release
}
}
repositories { // repositories for Jar's you access in your code
maven {
url 'https://oss.sonatype.org/content/repositories/snapshots' // SNAPSHOT repository (if needed)
}
mavenCentral()
jcenter()
}
apply plugin: 'java' // standard Java tasks
apply plugin: 'war' // standard Web Archive plugin
apply plugin: 'com.google.cloud.tools.appengine' // App Engine tasks
apply plugin: 'maven-publish'
dependencies {
compile 'com.google.appengine:appengine-api-1.0-sdk:+' // Latest App Engine Api's
compile 'org.springframework.boot:spring-boot-starter-web:2.1.1.RELEASE'
testCompile 'org.springframework.boot:spring-boot-starter-test:2.1.1.RELEASE'
providedCompile 'org.slf4j:jul-to-slf4j:1.7.25'
providedCompile 'javax.servlet:javax.servlet-api:3.1.0'
}
configurations.all {
exclude group: 'org.springframework.boot', module: 'spring-boot-starter-tomcat'
exclude group: 'org.slf4j', module: 'jul-to-slf4j'
}
group = 'com.google.appengine.demos'
version = '0.0.1-SNAPSHOT'
description = 'springboot-appengine-standard'
sourceCompatibility = '1.8'
publishing {
publications {
maven(MavenPublication) {
from(components.java)
}
}
}
tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
}
And you can deploy it with gradle appengineDeploy.
I tested it myself and it worked. If you want to do it in GAE Flexible the corresponding sample would be this one which also has instructions for Maven so you would have to do the necessary migration to Gradle.
As I have not found a complete example of spring boot with the Gradle build tool.
Added a complete example with updated spring boot version 2.2.3 and AppEngine Gradle plugin 2.2.0.
buildscript {
repositories {
mavenCentral()
maven{
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath 'com.google.cloud.tools:appengine-gradle-plugin:2.2.0'
}
}
plugins {
id 'java'
id 'war'
id 'org.springframework.boot' version '2.2.3.RELEASE'
id 'io.spring.dependency-management' version '1.0.9.RELEASE'
}
repositories {
mavenCentral()
jcenter()
}
configurations.all {
exclude group: 'org.springframework.boot', module: 'spring-boot-starter-tomcat'
exclude group: 'org.slf4j', module: 'jul-to-slf4j'
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-web'
compile "com.google.appengine:appengine-api-1.0-sdk:+"
providedCompile group: 'javax.servlet', name: 'javax.servlet-api', version: '3.0.1'
providedCompile "com.google.appengine:appengine-api-stubs:+"
providedCompile "com.google.appengine:appengine-testing:+"
providedCompile 'org.slf4j:jul-to-slf4j:1.7.25'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
compile group: 'net.bytebuddy', name: 'byte-buddy', version: '1.10.3'
}
apply plugin: "com.google.cloud.tools.appengine"
appengine { // App Engine tasks configuration
run { // local (dev_appserver) configuration (standard environments only)
jvmFlags = ['-Ddatastore.backing_store=../../src/main/webapp/WEB-
INF/appengine-generated/local_db.bin', '-Dappengine.fullscan.seconds=5']
port = 8812 // default
}
deploy { // deploy configuration\
stopPreviousVersion = false // default - stop the current version
promote = false // default - & make this the current version
version = 'pr'
projectId = ''
}
}
This repo has a complete example and the test case for its controller. hope it would help.

Spring Boot JAR not executing as an init.d service

I have created a Spring Boot application with the following build.gradle file (Gradle version 5.4.1):
plugins {
id 'org.springframework.boot' version '2.1.6.RELEASE'
id 'java'
}
apply plugin: 'io.spring.dependency-management'
group = 'com.example'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '1.8'
bootJar {
launchScript()
}
repositories {
mavenCentral()
}
dependencies {
compile group: 'org.springframework.boot', name: 'spring-boot-gradle-plugin', version: '2.1.6.RELEASE', ext: 'pom'
implementation 'org.springframework.boot:spring-boot-starter'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
compile group: 'org.springframework.boot', name: 'spring-boot-starter-web', version: '2.1.6.RELEASE'
compile group: 'org.springframework.boot', name: 'spring-boot-starter-security', version: '2.1.6.RELEASE'
compile group: 'org.springframework', name: 'spring-orm', version: '5.1.7.RELEASE'
compile group: 'mysql', name: 'mysql-connector-java', version: '8.0.16'
compile group: 'org.hibernate', name: 'hibernate-hikaricp', version: '5.3.10.Final'
compile group: 'io.jsonwebtoken', name: 'jjwt', version: '0.9.1'
}
When I try creating a JAR using ./gradlew bootJar and running it using the following command sudo service project start, the following error message shows up:
Failed to restart project.service: Unit project.service not found.
I have added the symlink to the JAR file in /etc/init.d, still it displays the above error when starting. What am I missing here?
Try add :
springBoot {
executable = true
}
I am using maven with :
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<executable>true</executable>
</configuration>
</plugin>
Check if jar file permission is set executable e.g. (755)
Try to start ./$YOURAPP.jar to test if your build was correct
first check if the project.service exists
sudo vim /etc/systemd/system/project.service
if it doesnt you may need to make one.
The contents of this file looks something like:
https://www.baeldung.com/spring-boot-app-as-a-service
dont forget to make the script executable with chmod +x
after you make the service you need to run the folowing comantds to get it to work:
sudo systemctl restart rsyslog
sudo systemctl enable project.service
sudo service project start
sudo service project status

persistence.xml not found - Gradle-Spring-MVC Project with NoSql Database

I am creating an annotation driven Spring MVC application using Intellij 2016 and Gradle. My project structure looks like this:
I deliberately copied the persistence.xml into the folder src/main/java/META-INF/persistence.xml and src/main/resources/META-INF/persistence.xml, but when executing the Gradle bootRun task, I get the following error:
11:18:40: Executing external task 'bootRun'...
:compileJava
:processResources
:classes
:findMainClass
:bootRun
11:18:52.960 [main] DEBUG org.jboss.logging - Logging Provider: org.jboss.logging.Slf4jLoggerProvider
Exception in thread "main" javax.persistence.PersistenceException: No Persistence provider for EntityManager named ogm-jpa-tutorial
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:61)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:39)
at my.app.main.Application.main(Application.java:27)
:bootRun FAILED
It seems that the bootRun tasks is not able to pick up the persistence.xml from the classpath.
Does anyone know whats behind that error and has a fix?
EDIT for javaguy, missing init of EntityManager:
/*
Content of the class my.app.main.Application
*/
package my.app.main;
import my.app.controllers.GreetingController;
import my.app.model.Greeting;
import org.hibernate.validator.internal.util.logging.Log;
import org.hibernate.validator.internal.util.logging.LoggerFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
import javax.transaction.TransactionManager;
#SpringBootApplication
#ComponentScan({"my.app.*"})
public class Application {
private static final Log logger = LoggerFactory.make();
public static void main(String[] args) {
TransactionManager tm = com.arjuna.ats.jta.TransactionManager.transactionManager();
EntityManagerFactory emf = Persistence.createEntityManagerFactory("ogm-jpa-tutorial");
SpringApplication.run(Application.class, args);
}
}
EDIT for Asterisk Ninja missing persistence.xml:
<?xml version="1.0"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
version="2.0">
<persistence-unit name="ogm-jpa-tutorial" transaction-type="JTA">
<!-- Use the Hibernate OGM provider: configuration will be transparent -->
<provider>org.hibernate.ogm.jpa.HibernateOgmPersistence</provider>
<properties>
<!-- Here you will pick which NoSQL technology to use, and configure it;
in this example we start a local in-memory Infinispan node. -->
<property name="hibernate.ogm.datastore.provider" value="infinispan"/>
</properties>
</persistence-unit>
</persistence>
EDIT, missing build.gradle:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:1.4.1.RELEASE")
}
}
apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'spring-boot'
jar {
baseName = 'gs-serving-web-content'
version = '0.1.0'
}
repositories {
mavenCentral()
}
sourceCompatibility = 1.8
targetCompatibility = 1.8
dependencies {
compile("org.springframework.boot:spring-boot-starter-thymeleaf")
compile("org.springframework.boot:spring-boot-devtools")
compile("org.hibernate.ogm:hibernate-ogm-bom:5.0.2.Final")
compile group: 'org.hibernate.javax.persistence', name: 'hibernate-jpa-2.1-api', version: '1.0.0.Final'
compile group: 'javax.transaction', name: 'jta', version: '1.1'
compile group: 'org.jboss.narayana.jta', name: 'narayana-jta', version: '5.3.5.Final'
compile group: 'org.hibernate', name: 'hibernate-annotations', version: '3.5.6-Final'
testCompile("junit:junit")
}
I solved my problem by adapting the build.gradle file in the following fashion:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:1.4.1.RELEASE")
}
}
apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'spring-boot'
jar {
baseName = 'gs-serving-web-content'
version = '0.1.0'
}
repositories {
mavenCentral()
}
sourceCompatibility = 1.8
targetCompatibility = 1.8
dependencies {
compile("org.springframework.boot:spring-boot-starter-thymeleaf")
compile("org.springframework.boot:spring-boot-devtools")
compile("org.hibernate.ogm:hibernate-ogm-bom:5.0.2.Final")
compile group: 'org.hibernate.ogm', name: 'hibernate-ogm-infinispan', version: '5.0.2.Final'
compile group: 'org.jboss.spec.javax.transaction', name: 'jboss-transaction-api_1.2_spec', version: '1.0.0.Final'
compile group: 'org.hibernate.javax.persistence', name: 'hibernate-jpa-2.1-api', version: '1.0.0.Final'
compile group: 'org.jboss.narayana.jta', name: 'narayana-jta', version: '5.3.5.Final'
compile group: 'org.jboss', name: 'jboss-transaction-spi', version: '7.5.0.Final'
compile group: 'javax.transaction', name: 'jta', version: '1.1'
compile group: 'org.hibernate.common', name: 'hibernate-commons-annotations', version: '5.0.1.Final'
testCompile("junit:junit")
}
Comment on that:
It seems that the persistence.xml was picked up correctly, but the
EntitiyManager could not initialize the <provider>HibernateOgmPersistence correctly
therefore the following changes were done:
added some dependencies for the EntitiyManager specific for the
MongoDB in-memory instance

java.util.zip.ZipException: duplicate entry: META_INF/LICENSE.txt

This is my first time using Java Web Start. This is for a demo version of my application. I have uploaded the JAR to my server, and created a JNLP file. When I run the file locally, I get the exception shown below.
This was the reference I was reading, and below is my JNLP file.
DerbyPro.jnlp
<?xml version="1.0" encoding="UTF-8"?>
<jnlp spec="1.0+" codebase="" href="">
<information>
<title>Derby Pro</title>
<vendor>Neon Orb</vendor>
<icon href="http://neonorb.com/images/derby-pro/derby-pro-icon-hd.png"/>
<offline-allowed/>
</information>
<resources>
<j2se version="1.8+" href=
"http://neonorb.com"/>
<jar href="http://neonorb.com/clientportal/derby-pro-demo.jar"
main="true" />
</resources>
<application-desc
name="Derby Pro"
main-class="com.neonorb.derbypro.main.DerbyPro"
width="300"
height="300">
</application-desc>
<update check="background"/>
</jnlp>
Here is my build.gradle file being called like this: ./gradlew -Pversion=0.0.0 -Pdemo=true fatJar
group 'com.neonorb'
apply plugin: 'java'
sourceCompatibility = 1.8
project.description = 'Derby Pro is pinewood derby management software.'
//create a single Jar with all dependencies
task fatJar(type: Jar) {
manifest {
attributes 'Implementation-Version': version,
'Main-Class': 'com.neonorb.derbypro.main.DerbyPro',
'Demo': demo
}
baseName = project.name
from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } }
with jar
}
repositories {
mavenCentral()
maven {
url "http://www.sparetimelabs.com/maven2"
}
mavenLocal()
}
dependencies {
compile files('dfalex-0.9.2.jar')
compile 'com.neonorb:commons:+'
compile group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.5.4'
compile group: 'commons-cli', name: 'commons-cli', version: '1.3.1'
compile group: 'org.apache.commons', name: 'commons-lang3', version: '3.4'
compile group: 'org.controlsfx', name: 'controlsfx', version: '8.40.10'
compile group: 'org.fxmisc.easybind', name: 'easybind', version: '1.0.3'
compile group: 'org.scream3r', name: 'jssc', version: '2.8.0'
compile group: 'com.sparetimelabs', name: 'purejavacomm', version: '0.0.28'
compile 'net.java.dev.jna:jna:4.2.1'
compile 'commons-io:commons-io:2.4'
testCompile group: 'junit', name: 'junit', version: '4.11'
testCompile 'net.jodah:concurrentunit:0.4.2'
}
//Native launchers
//Windows
buildscript {
repositories {
maven {
url 'https://plugins.gradle.org/m2/'
}
}
dependencies {
classpath 'gradle.plugin.edu.sc.seis.gradle:launch4j:1.6.1'
}
}
apply plugin: 'edu.sc.seis.launch4j'
launch4j {
//outputDir = 'native/windows'
bundledJrePath = 'jre'
dontWrapJar = true
jar = 'bin/derby-pro.jar'
mainClassName = 'com.neonorb.derbypro.main.DerbyPro'
icon = '../../src/main/resources/com/neonorb/derbypro/assets/derby-pro-icon-favicon.ico'
outfile = 'DerbyPro.exe'
companyName = 'Neon Orb'
productName = 'Derby Pro'
}
//OS X
/*plugins {
id "edu.sc.seis.macAppBundle" version "2.1.0"
}
macAppBundle {
mainClassName = "com.example.myApp.Start"
icon = "myIcon.icns"
bundleJRE = true
javaProperties.put("apple.laf.useScreenMenuBar", "true")
backgroundImage = "doc/macbackground.png"
}*/
Here is the manifest directory.
And here is the manifest content.
Manifest-Version: 1.0
Implementation-Version: 0.0.0
Main-Class: com.neonorb.derbypro.main.DerbyPro
Demo: true
Your jar file contains duplicate entries which probably cause problems when being deployed. If you run the following command with your jar file you will see the duplicate entries:
$ unzip -l derby-pro-demo.jar |grep META
0 01-26-16 11:47 META-INF/
116 01-26-16 11:47 META-INF/MANIFEST.MF
321 06-09-15 18:42 META-INF/LICENSE
825 06-09-15 18:42 META-INF/NOTICE
...
11358 06-14-15 12:06 META-INF/LICENSE.txt
172 06-14-15 12:06 META-INF/NOTICE.txt
...
11358 04-03-15 14:30 META-INF/LICENSE.txt
301 04-03-15 14:30 META-INF/NOTICE.txt
The problem is caused by the fatJar. See here and here.
When creating a fat jar, the duplicate entries should be resolved. I have no experience with gradle. The issue (first link) is still marked "open", so I assume there may not be an easy fix. As a work around (if this is possible and works for you), I could imagine to copy all jar content first to a temporary directory. This would overwrite duplicate entries. Then you could build the fat jar from the temporary directory. However, I'd be very careful with that. First some duplicate class files may be relevant, and second the LICENSE, NOTICE, etc. files certainly will cause a license problem.
The JNLP file contains a main class attribute, Java Web Start is trying to create the manifest with that main class. Therefore removing the main class attribute from the JNLP file allows it to run.

Categories

Resources