I am having an existing java dynamic web project which I created using eclipse. I usually just create a war file via eclipse and then deploy it to tomcat.
Now I want to use Gradle to build my project and create the war file. Is there an eclipse plugin to do that? If not then how can I use gradle with my existing project?
My existing project structure is what you get when you create a dynamic web project via eclipse and I don't want to change it.
I have tried going through tutorials and using converting to Gradle project using gradle plugin. Can someone atleast point to a blog or tutorial or a way to start things?
MyProject
|java resources
|--src
|-- -- packages
|-- -- .properties files
|--test
|-- -- packages
|build
|-- classes
|WebContent
|-- MetaINF
|-- WEB-INF
|-- -- lib // all my libraries are here. there is no specific repo for now
|-- -- web.xml
My build.gradle :
apply plugin: 'java'
apply plugin: 'eclipse-wtp'
apply plugin: 'war'
sourceCompatibility = 1.7
targetCompatibility = 1.7
version = '2.0'
war {
baseName = 'Gradle'
version = '1.2'
}
repositories {
mavenCentral()
}
repositories {
flatDir {
dirs 'lib'
}
}
dependencies {
compile group: 'commons-collections', name: 'commons-collections', version: '3.2'
testCompile group: 'junit', name: 'junit', version: '4.+'
compile files('./lib/myjar.jar')
compile 'commons-codec:commons-codec:1.5'
compile 'commons-lang:commons-lang:2.6'
compile 'org.hibernate:hibernate-entitymanager:4.3.8.Final'
compile 'org.apache.axis2:axis2-kernel:1.6.2'
compile 'org.apache.axis2:axis2-adb:1.6.2'
compile 'com.sun.jersey:jersey-server:1.19'
compile 'com.sun.jersey:jersey-client:1.19'
compile 'log4j:log4j:1.2.17'
compile 'org.apache.axis2:axis2-transport-local:1.6.2'
compile 'org.apache.axis2:axis2-transport-http:1.6.2'
providedCompile 'javax.servlet:servlet-api:2.3'
testCompile 'junit:junit:4.9'
testCompile 'org.jmock:jmock:2.6.0'
testCompile 'org.jmock:jmock-junit4:2.6.0'
testCompile 'org.jmock:jmock-legacy:2.6.0'
}
test {
systemProperties 'property': 'value'
}
web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<display-name>Gradle</display-name>
<servlet>
<servlet-name>HTTP REST Service</servlet-name>
<servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
//in the above line It is showing a warning: servlet-class references to non-existent class "com.sun.jersey.spi.container.servlet.ServletContainer"
<init-param>
<param-name>com.sun.jersey.config.property.packages</param-name>
<param-value>org.gradle</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>HTTP REST Service</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
My proj structure
Here's a minimal build.gradle file that should get you going. Build with the command gradle war.
apply plugin: 'war'
// See http://gradle.org/docs/current/userguide/war_plugin.html
// Section 26.5. Convention properties
webAppDirName = 'WebContent'
// See http://gradle.org/docs/current/userguide/java_plugin.html
// Section 23.4.1. Changing the project layout
sourceSets {
main {
// where does the Java source code live?
java {
srcDir 'Java Resources/src'
}
// where do classpath resources like *.properties files live?
resources {
srcDir 'Java Resources/src'
}
}
}
// See http://gradle.org/docs/current/userguide/dependency_management.html
// Section 51.4.4. File dependencies
dependencies {
// Where do the JARs live on the filesystem?
compile fileTree(dir: "${webAppDirName}/WEB-INF/lib", include: '*.jar')
}
Related
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'
}
}
I am using the Gradle plugin in Eclipse to create a JSF project. I am running the project on Tomcat 9. When I attempt run on server in Eclipse, I get the java.lang.ClassNotFoundException: javax.faces.webapp.FacesServlet exception.
My gradle.build looks like this:
// Apply the java-library plugin to add support for Java Library
apply plugin: 'java-library'
apply plugin: 'war'
apply plugin: 'eclipse'
apply plugin: 'eclipse-wtp'
repositories {
// Use jcenter for resolving your dependencies.
// You can declare any Maven/Ivy/file repository here.
jcenter()
}
dependencies {
api 'org.apache.commons:commons-math3:3.6.1'
implementation 'com.google.guava:guava:21.0'
// Use JUnit test framework
testImplementation 'junit:junit:4.12'
//Jersey
implementation 'org.glassfish.jersey.containers:jersey-container-servlet:2.26'
implementation 'org.glassfish.jersey.inject:jersey-hk2:2.26'
implementation 'org.glassfish.jersey.core:jersey-common:2.26'
//JAXB
implementation 'org.glassfish.jersey.media:jersey-media-json-jackson:2.26'
//Javax Servlet
implementation 'javax.servlet:javax.servlet-api:3.1.0'
//JSF
implementation 'org.glassfish:javax.faces:2.2.16'
}
eclipse {
wtp {
facet {
facet name: "java", version: "1.8" // Java version
facet name: "jst.web", version: "3.1" // Dynamic Web Application
facet name: "jst.jsf", version: "2.2" // Java Server Faces
facet name: "wst.jsdt.web", version: "1.0" // JavaScript
}
}
}
project.webAppDirName='WebContent'
My web.xml looks like this:
<web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
version="2.4" id="WebApp_ID">
<display-name>com.xxx</display-name>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.xhtml</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.xhtml</welcome-file>
</welcome-file-list>
</web-app>
I can see that gradle has added the correct library to my resources:
I cannot think of anything else that could be wrong. Any help is appreciated.
UPDATE: If I build a WAR file from the project, and then import that WAR as a new Dynamic Web Project, it runs fine, with no errors. So, there is obviously some other issue going on here, probably related to Gradle.
UPDATE2:
Stack Trace:
SEVERE: Servlet [Faces Servlet] in web application [/com.foo.bar] threw load() exception
java.lang.ClassNotFoundException: javax.faces.webapp.FacesServlet
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1275)
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1104)
at org.apache.catalina.core.DefaultInstanceManager.loadClass(DefaultInstanceManager.java:540)
at org.apache.catalina.core.DefaultInstanceManager.loadClassMaybePrivileged(DefaultInstanceManager.java:521)
at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:150)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1032)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:971)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4765)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5075)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1427)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1417)
at java.util.concurrent.FutureTask.run(Unknown Source)
at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
at java.util.concurrent.AbstractExecutorService.submit(Unknown Source)
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:943)
at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:839)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1427)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1417)
at java.util.concurrent.FutureTask.run(Unknown Source)
at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
at java.util.concurrent.AbstractExecutorService.submit(Unknown Source)
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:943)
at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:258)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.core.StandardService.startInternal(StandardService.java:422)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:770)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.startup.Catalina.start(Catalina.java:682)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:353)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:493)
Build Path:
Class location:
Changing "implementation" to "compile" for the required libraries fixed the issue.
/*
* This build file was generated by the Gradle 'init' task.
*
* This generated file contains a sample Java Library project to get you started.
* For more details take a look at the Java Libraries chapter in the Gradle
* user guide available at https://docs.gradle.org/3.5/userguide/java_library_plugin.html
*/
// Apply the java-library plugin to add support for Java Library
apply plugin: 'java-library'
apply plugin: 'war'
apply plugin: 'eclipse-wtp'
// In this section you declare where to find the dependencies of your project
repositories {
// Use jcenter for resolving your dependencies.
// You can declare any Maven/Ivy/file repository here.
jcenter()
}
dependencies {
// This dependency is exported to consumers, that is to say found on their compile classpath.
api 'org.apache.commons:commons-math3:3.6.1'
// This dependency is used internally, and not exposed to consumers on their own compile classpath.
implementation 'com.google.guava:guava:21.0'
// Use JUnit test framework
testImplementation 'junit:junit:4.12'
//Jersey
compile 'org.glassfish.jersey.containers:jersey-container-servlet:2.26'
compile 'org.glassfish.jersey.inject:jersey-hk2:2.26'
compile 'org.glassfish.jersey.core:jersey-common:2.26'
//JAXB
compile 'org.glassfish.jersey.media:jersey-media-json-jackson:2.26'
//Javax Servlet
compile 'javax.servlet:javax.servlet-api:3.0.1'
//JSF
compile 'org.glassfish:javax.faces:2.2.16'
compile 'javax.inject:javax.inject:1'
compile 'org.glassfish.jersey.containers:jersey-container-servlet:2.25.1'
}
eclipse {
wtp {
facet {
facets = []
facet name: "java", version: "1.8" // Java version
facet name: "jst.web", version: "3.0" // Dynamic Web Application
facet name: "jst.jsf", version: "2.2" // Java Server Faces
facet name: "wst.jsdt.web", version: "1.0" // JavaScript
}
}
}
project.webAppDirName='WebContent'
I have a project for which I use gradle, and I wanted to use the logger slf4j provides.
Running in Android Studio produces the following error:
Exception in thread "main" java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory
at com.mypkg.Main.<clinit>(Main.java:9)
Caused by: java.lang.ClassNotFoundException: org.slf4j.LoggerFactory
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 1 more
My build.gradle for the project:
task wrapper(type: Wrapper) {
gradleVersion = '3.5'
}
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.github.jengelman.gradle.plugins:shadow:2.0.0'
}
}
apply plugin: 'com.github.johnrengelman.shadow'
apply plugin: 'java'
apply plugin: 'application'
jar {
manifest {
attributes 'Main-Class': "Main"
}
}
shadowJar {
mergeServiceFiles('META-INF/spring.*')
}
mainClassName = 'com.mypkg.Main'
dependencies {
compile 'com.squareup:otto:1.3.5'
compile 'com.fasterxml.jackson.core:jackson-databind:2.4.4'
compile 'com.squareup.okhttp:okhttp:2.7.4'
compile 'com.squareup.okhttp:okhttp-ws:2.7.4'
compile 'com.parse.bolts:bolts-android:1.2.1'
compile 'org.json:json:20140107'
compile 'org.bouncycastle:bcprov-jdk15on:1.52'
compile 'commons-codec:commons-codec:1.10'
compile 'org.scream3r:jssc:2.8.0'
compile 'ch.qos.logback:logback-classic:1.1.3'
compile 'ch.qos.logback:logback-core:1.1.3'
compile 'org.json:json:20140107'
compile group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.0.1'
compile group: 'org.springframework.shell', name: 'spring-shell', version: '1.2.0.RELEASE'
compile group: 'org.springframework', name: 'spring-context-support', version: '4.2.4.RELEASE'
compile group: 'org.springframework', name: 'spring-core', version: '4.2.4.RELEASE'
compile group: 'org.slf4j', name: 'slf4j-log4j12', version: '1.7.25'
}
sourceCompatibility = "1.8"
targetCompatibility = "1.8"
If I build this project with gradle, the shadow plugin generates a fat jar, which runs from the console nicely, it includes the logger, but from the IDE I'm having difficulties finding the LoggerFactory. I read here that I should add the logger to the classpath but since I don't explicitly include a jar, rather than marking it as a dependency, I'm not sure how this would be possible.
Please advise.
Cheers!
The classpath is out of sync, few options here
Refresh the project in IntelliJ (the older versions of IntelliJ are not ideal with gradle integration)
add apply plugin: 'idea' to your build.gradle and then run gradle idea to regenerate .iml .ipr .iws files in your project and pick up dependencies from gradle.(Not ideal! see why)
Download latest version of IntelliJ and redo option 1
Edit: Thanks #CrazyCoder for this hint.
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
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.