Gradle build,ojdbc6-11.2.0.3 - gradle

My demo has a Maven-Dependencies ,it contains an ojdbc6.jar.
I want to build a runnable jar with Gradle.
When i run:gradle build in command line.It works well,and create a Test.jar
In build/libs folder.when i run with:java -jar Test.jar. it shows: Unable to load class: oracle.jdbc.OracleDriverclass not found.
Any one can help me out?Thanks a lot!
Caused by: java.lang.ClassNotFoundException: Unable to load class: oracle.jdbc.OracleDriver from ClassLoader:org.springframework.boot.loader.LaunchedURLClass
ssLoader:org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl$TcclSafeAggregatedClassLoader#60cbbfcd
at org.apache.tomcat.jdbc.pool.ClassLoaderUtil.loadClass(ClassLoaderUtil.java:56)
at org.apache.tomcat.jdbc.pool.PooledConnection.connectUsingDriver(PooledConnection.java:268)
... 46 common frames omitted
Caused by: java.lang.ClassNotFoundException: Could not load requested class : oracle.jdbc.OracleDriver
at org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl$AggregatedClassLoader.findClass(ClassLoaderServiceImpl.java:230)
at org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl$TcclSafeAggregatedClassLoader.findClass(ClassLoaderServiceImpl.java:456)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at org.apache.tomcat.jdbc.pool.ClassLoaderUtil.loadClass(ClassLoaderUtil.java:38)

I have resolved it!
Download the ojdbc7.jar in F:\
please visit oracle.com to download!
Run "cmd",then input below command:
mvn install:install-file -Dfile=f:\ojdbc7.jar -DgroupId=com.oracle.weblogic -DartifactId=ojdbc7 -
Dversion=12.1.0.2.0 -Dpackaging=jar
If setup success,you will see ojdbc7 in the bellow path:
C:\Users\Administrator.m2\repository\com\oracle\weblogic\ojdbc7\12.1.0.2.0
Here is my build.gradle:
buildscript {
repositories {
mavenCentral()
maven { url "http://repo.spring.io/libs-release" }
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-
plugin:1.2.4.RELEASE")
}
}
apply plugin: "java"
apply plugin: "eclipse"
apply plugin: "idea"
apply plugin: "spring-boot"
jar {
baseName = "Test"
version = "0.1.0"
}
repositories {
mavenCentral()
mavenLocal();
maven { url "http://repo.spring.io/libs-release" }
}
dependencies {
compile("org.springframework.boot:spring-boot-starter-web")
compile("org.springframework.boot:spring-boot-starter-thymeleaf")
compile("org.springframework.boot:spring-boot-starter-data-jpa")
compile("org.springframework.flex:spring-flex-core:1.6.0.RC1")
compile("com.oracle.weblogic:ojdbc7:12.1.0.2.0")
testCompile("org.springframework.boot:spring-boot-starter-test")
}
task wrapper(type: Wrapper) {
gradleVersion = "2.4"
}
tasks.withType(JavaCompile) {
options.encoding = "UTF-8"
}
The most important is add mavenLocal() to repositories

Related

org.spockframework.runtime.SpockEngine Unable to get public no-arg constructor encountered while upgrading Groovy and Spock

Using Gradle 7.1.1, Java 16, Groovy 3.0.8 and Spock 2.0-groovy-3.0
I'm getting this error when running ./gradlew clean test
Caused by: java.util.ServiceConfigurationError: org.junit.platform.engine.TestEngine: org.spockframework.runtime.SpockEngine Unable to get public no-arg constructor
at java.base/java.util.ServiceLoader.fail(ServiceLoader.java:582)
at java.base/java.util.ServiceLoader.getConstructor(ServiceLoader.java:673)
at java.base/java.util.ServiceLoader$LazyClassPathLookupIterator.hasNextService(ServiceLoader.java:1232)
at java.base/java.util.ServiceLoader$LazyClassPathLookupIterator.hasNext(ServiceLoader.java:1264)
at java.base/java.util.ServiceLoader$2.hasNext(ServiceLoader.java:1299)
at java.base/java.util.ServiceLoader$3.hasNext(ServiceLoader.java:1383)
at java.base/java.lang.Iterable.forEach(Iterable.java:74)
at org.junit.platform.launcher.core.LauncherFactory.create(LauncherFactory.java:95)
at org.junit.platform.launcher.core.LauncherFactory.create(LauncherFactory.java:75)
at org.gradle.api.internal.tasks.testing.junitplatform.JUnitPlatformTestClassProcessor$CollectAllTestClassesExecutor.processAllTestClasses(JUnitPlatformTestClassProcessor.java:97)
at org.gradle.api.internal.tasks.testing.junitplatform.JUnitPlatformTestClassProcessor$CollectAllTestClassesExecutor.access$000(JUnitPlatformTestClassProcessor.java:79)
at org.gradle.api.internal.tasks.testing.junitplatform.JUnitPlatformTestClassProcessor.stop(JUnitPlatformTestClassProcessor.java:75)
at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.stop(SuiteTestClassProcessor.java:61)
... 25 more
Caused by: java.lang.NoClassDefFoundError: org/junit/platform/engine/support/discovery/SelectorResolver
at java.base/java.lang.Class.getDeclaredConstructors0(Native Method)
at java.base/java.lang.Class.privateGetDeclaredConstructors(Class.java:3305)
at java.base/java.lang.Class.getConstructor0(Class.java:3510)
at java.base/java.lang.Class.getConstructor(Class.java:2238)
at java.base/java.util.ServiceLoader$1.run(ServiceLoader.java:660)
at java.base/java.util.ServiceLoader$1.run(ServiceLoader.java:657)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:554)
at java.base/java.util.ServiceLoader.getConstructor(ServiceLoader.java:668)
... 36 more
Caused by: java.lang.ClassNotFoundException: org.junit.platform.engine.support.discovery.SelectorResolver
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:636)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:182)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:519)
... 44 more
This is the build.gradle for the module where error is reported:
dependencies {
implementation 'io.rest-assured:rest-assured'
implementation 'org.yaml:snakeyaml'
implementation 'com.fasterxml.jackson.core:jackson-databind'
testImplementation 'org.junit.jupiter:junit-jupiter'
testImplementation('org.spockframework:spock-core') {
transitive = false
}
}
Parent module build.gradle file:
ext {
jupiterVersion = '5.7.2'
}
jar.enabled = false
subprojects {
apply plugin: 'java'
apply plugin: 'groovy'
apply plugin: 'codenarc'
jar.enabled = true
codenarc {
toolVersion = '1.4'
reportFormat = 'html'
configFile = new File('../../tool/codenarc/groovy-ruleset.groovy')
}
dependencyManagement {
imports {
mavenBom("org.springframework.boot:spring-boot-dependencies:2.5.1") {
bomProperties(['selenium.version' : '3.141.59',
'rest-assured.version': '4.1.1'])
}
}
dependencies {
dependency 'org.codehaus.groovy.modules.http-builder:http-builder:0.7.1'
dependency 'org.spockframework:spock-core:2.0-groovy-3.0'
dependency 'com.athaydes:spock-reports:2.0-groovy-3.0'
dependency 'com.codeborne:selenide:5.3.1'
dependency 'org.hamcrest:hamcrest:2.1'
dependencySet(group: 'org.junit.jupiter', version: jupiterVersion) {
entry 'junit-jupiter'
entry 'junit-jupiter-api'
}
dependencySet(group: 'org.slf4j', version: '1.7.28') {
entry 'jcl-over-slf4j'
entry 'jul-to-slf4j'
}
dependencySet(group: 'org.aspectj', version: '1.9.4') {
entry 'aspectjrt'
entry 'aspectjweaver'
}
dependency 'io.rest-assured:rest-assured:4.1.1'
dependency 'org.postgresql:postgresql:42.2.8'
dependency 'org.yaml:snakeyaml:1.25'
dependency 'org.apache.poi:poi-ooxml:4.1.1'
dependency 'com.opencsv:opencsv:4.0'
dependency 'org.junit.platform:junit-platform-launcher:1.4.0'
}
}
test {
useJUnitPlatform()
}
}
Any help would be appreciated.
PS. This was working with Java 11, Groovy 2.5 and Spock 1.3-groovy-2.5
Have you added useJUnitPlatform()?
https://github.com/spockframework/spock-example/blob/master/build.gradle#L34
test {
useJUnitPlatform()
}
It was a problem with the parent project's build.gradle file.
I recently upgraded the spring boot version to 2.5.1.
After updating this entry in the build.gradle file the error went away.
imports {
mavenBom("org.springframework.boot:spring-boot-dependencies:2.5.1") {
bomProperties(['selenium.version' : '3.141.59',
'rest-assured.version': '4.1.1'])
}
}

Apache Flink + Spring boot + Gradle

I have a Flink application that runs inside Spring Boot application.
The application fails to run as a jar in a Flink cluster.
I am able to run the application on my local windows machine(mini-cluster) as a jar.
The exception stack trace look like this:
org.apache.flink.client.program.ProgramInvocationException: The main method caused an error: null
at org.apache.flink.client.program.PackagedProgram.callMainMethod(PackagedProgram.java:546)
at org.apache.flink.client.program.PackagedProgram.invokeInteractiveModeForExecution(PackagedProgram.java:421)
at org.apache.flink.client.program.OptimizerPlanEnvironment.getOptimizedPlan(OptimizerPlanEnvironment.java:83)
at org.apache.flink.client.program.PackagedProgramUtils.createJobGraph(PackagedProgramUtils.java:80)
at org.apache.flink.runtime.webmonitor.handlers.utils.JarHandlerUtils$JarHandlerContext.toJobGraph(JarHandlerUtils.java:126)
at org.apache.flink.runtime.webmonitor.handlers.JarRunHandler.lambda$getJobGraphAsync$6(JarRunHandler.java:142)
at java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1590)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48)
at org.springframework.boot.loader.Launcher.launch(Launcher.java:87)
at org.springframework.boot.loader.Launcher.launch(Launcher.java:50)
at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:51)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.apache.flink.client.program.PackagedProgram.callMainMethod(PackagedProgram.java:529)
... 9 more
Caused by: org.apache.flink.client.program.OptimizerPlanEnvironment$ProgramAbortException
at org.apache.flink.streaming.api.environment.StreamPlanEnvironment.execute(StreamPlanEnvironment.java:70)
at org.apache.flink.streaming.api.environment.StreamPlanEnvironment.execute(StreamPlanEnvironment.java:53)
at cdc.il.cdm.application.IngestionJob.execute(IngestionJob.java:61)
at cdc.il.cdm.application.CdmApplication.run(CdmApplication.java:28)
at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:813)
at org.springframework.boot.SpringApplication.callRunners(SpringApplication.java:797)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:324)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1260)
I am using Gradle and spring-boot-gradle-plugin to build the artifact. It seems that the artifact that is built does not match what Flink's runtime expects.
Does anyone has an example of a good recipe to create an artifact using Gradle ?
EDIT :
I have found a solution using shadow plugin - https://imperceptiblethoughts.com/shadow/
The following gradle build file works for me on a Flink machine. The jar was built by the shadow plugin
buildscript {
repositories {
jcenter()
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:2.1.6.RELEASE")
classpath 'com.github.jengelman.gradle.plugins:shadow:5.1.0'
}
}
apply plugin: 'com.github.johnrengelman.shadow'
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
ext {
javaVersion = '1.8'
flinkVersion = '1.8.0'
scalaBinaryVersion = '2.11'
slf4jVersion = '1.7.7'
log4jVersion = '1.2.17'
}
repositories {
mavenCentral()
}
sourceCompatibility = 1.8
targetCompatibility = 1.8
dependencies {
compile('org.springframework.boot:spring-boot-starter-actuator')
compile('org.springframework.boot:spring-boot-starter-web')
compile project(':common')
compile project(':ingestion')
compile project(':enrichment')
compile project(':filter')
compile "org.apache.flink:flink-java:${flinkVersion}"
compile "org.apache.flink:flink-connector-kafka_2.11:${flinkVersion}"
compile "org.apache.flink:flink-streaming-java_${scalaBinaryVersion}:${flinkVersion}"
compile "log4j:log4j:${log4jVersion}"
compile "org.slf4j:slf4j-log4j12:${slf4jVersion}"
compile group: 'org.apache.flink', name: 'flink-connector-kafka_2.12', version: '1.8.0'
}
configurations {
all*.exclude module : 'spring-boot-starter-logging'
}
bootJar {
enabled false
}
import com.github.jengelman.gradle.plugins.shadow.transformers.*
//def timestamp = new Date().format('yyyy-MM-dd-HHmm')
shadowJar {
zip64 true
mergeServiceFiles()
baseName = 'cdm-flink-app'
classifier=null
//version = timestamp
manifest {
attributes 'Main-Class': 'cdc.il.cdm.application.CdmApplication'
}
append 'META-INF/spring.handlers'
append 'META-INF/spring.schemas'
append 'META-INF/spring.tooling'
transform(PropertiesFileTransformer) {
paths = ['META-INF/spring.factories' ]
mergeStrategy = "append"
}
}
Looks to me like you probably aren't defining mainClassName, as in
mainClassName = 'org.myorg.quickstart.StreamingJob'
Take a look at Flink's Gradle quickstart docs for more info: https://ci.apache.org/projects/flink/flink-docs-stable/dev/projectsetup/java_api_quickstart.html#gradle.

Gradle Spring Boot Project Cannot Run From IDEA [duplicate]

This question already has answers here:
NoClassDefFoundError after IntelliJ IDEA upgrade
(3 answers)
Closed 5 years ago.
I am struggling to set up the spring boot project that i have imported in intelliJ IDEA 2016 1.4.
Every time i run . I get the below Exception:
Exception in thread "main" java.lang.NoClassDefFoundError: org/springframework/boot/SpringApplication
at com.patientConnect.DemoApplication.main(DemoApplication.java:24)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)
Caused by: java.lang.ClassNotFoundException: org.springframework.boot.SpringApplication
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)
... 6 more
My gradle settings (linked gradle projects,user gradle wrapper ) all looks good.
package com.Demo;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
#SpringBootApplication
public class DemoApplication {
public DemoApplication() {
}
public static void main(String[] args) {
SpringApplication.run(DemoApplication.class, args);
}
}
build.gradle:
buildscript {
repositories {
mavenLocal()
mavenCentral()
maven {
url 'https://plugins.gradle.org/m2/'
}
}
dependencies {
classpath 'org.springframework.boot:spring-boot-gradle-plugin:1.4.2.RELEASE'
classpath 'gradle.plugin.com.jamesward:atom-gradle-plugin:0.0.1'
}
}
apply plugin: 'java'
apply plugin: 'org.springframework.boot'
repositories {
mavenLocal()
mavenCentral()
}
dependencies {
compile 'org.springframework.boot:spring-boot-starter-parent:1.5.4.RELEASE'
compile 'org.springframework.boot:spring-boot-starter-web'
compile 'org.springframework.boot:spring-boot-devtools'
compile 'org.springframework.boot:spring-boot-starter-security'
compile 'org.springframework.security.oauth:spring-security-oauth2'
compile 'org.apache.httpcomponents:httpclient'
compile 'org.springframework.boot:spring-boot-starter-data-jpa'
compile 'org.postgresql:postgresql'
compile 'org.springframework.boot:spring-boot-starter-jdbc'
compile 'org.hibernate:hibernate-entitymanager'
}
allprojects {
sourceCompatibility = 1.8
targetCompatibility = 1.8
}
import org.gradle.internal.os.OperatingSystem
task devClasses(type: Exec) {
if (OperatingSystem.current().isWindows())
commandLine 'gradlew', '-t', 'classes'
else
commandLine './gradlew', '-t', 'classes'
}
task devBootRun(type: Exec) {
if (OperatingSystem.current().isWindows())
commandLine 'gradlew', 'bootRun'
else
commandLine './gradlew', 'bootRun' //, '--debug-jvm'
}
import java.util.concurrent.*
task dev() << {
def devClassesFuture = Executors.newSingleThreadExecutor().submit({ devClasses.execute() } as Callable)
def devBootRunFuture = Executors.newSingleThreadExecutor().submit({ devBootRun.execute() } as Callable)
devClassesFuture?.get()
devBootRunFuture?.get()
}
task stage {
dependsOn build
}
Try deleting your SpringBoot dependency on your computer.
It will be located at ~/.gradle/caches/modules-2/files-2.1/org.springframework.boot Assuming you kept your gradle dependencies in the default location.
rm -rf ~/.gradle/caches/modules-2/files-2.1/org.springframework.boot
or to delete all dependencies (Just to be sure if no other dependencies is corrupted)
rm -rf ~/.gradle/caches/modules-2/files-2.1/*
then to re-download
gradle build --refresh-dependencies

Failing to run .WAR using java -jar

On an early stage of development of my Spring Boot project I was used to run the application using java -jar build\libs\online_store-0.1.0.jar. Now I need to deliver a WAR. I followed the links below to build a deployable WAR file with Gradle. After that I was able to deploy the resulting built file on Tomcat 8 webapp directory and it is working fine. But I also need to run the embedded server using java -jar. Every time I try to do it (java -jar build\libs\online_store-0.1.0.war) I get a FileNotFoundException related to some missing dependency JAR (please see the stack trace below). After I add the corresponding dependency to the requiresUnpack option the error message changes but I am afraid I will never finish adding dependencies. What am I missing to get the WAR file both deployable and runnable by java -jar? Thanks in advance.
requiresUnpack = [ "org.webjars:less", "org.webjars:jshint", "org.webjars:emberjs",
"org.webjars:handlebars", "org.webjars:coffee-script", "org.webjars:jslint", "org.webjars:json2",
"org.webjars:jquery", "org.webjars:handlebars", "org.slf4j:slf4j-api"
]
http://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#howto-create-a-deployable-war-file
http://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#build-tool-plugins-gradle-packaging
Snippet of stack trace:
Caused by: java.lang.RuntimeException: java.io.FileNotFoundException: C:\Users\hcorzo\workspace\online_mvp\online_store\build\libs\online_store-0.1.0.war!\WEB-INF\lib\validate.js-0.8.0.jar (The system cannot find the path specified)
at org.webjars.urlprotocols.JarUrlProtocolHandler.getAssetPaths(JarUrlProtocolHandler.java:54)
at org.webjars.WebJarAssetLocator.getAssetPaths(WebJarAssetLocator.java:91)
at org.webjars.WebJarAssetLocator.getFullPathIndex(WebJarAssetLocator.java:121)
at org.webjars.WebJarAssetLocator.<init>(WebJarAssetLocator.java:152)
at org.springframework.web.servlet.resource.WebJarsResourceResolver.<init>(WebJarsResourceResolver.java:52)
at org.springframework.web.servlet.config.annotation.ResourceChainRegistration.getResourceResolvers(ResourceChainRegistration.java:108)
at org.springframework.web.servlet.config.annotation.ResourceHandlerRegistration.getRequestHandler(ResourceHandlerRegistration.java:164)
at org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry.getHandlerMapping(ResourceHandlerRegistry.java:113)
at org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport.resourceHandlerMapping(WebMvcConfigurationSupport.java:409)
at org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration$EnableWebMvcConfiguration$$EnhancerBySpringCGLIB$$7c82d476.CGLIB$resourceHandlerMapping$33(<generated>)
at org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration$EnableWebMvcConfiguration$$EnhancerBySpringCGLIB$$7c82d476$$FastClassBySpringCGLIB$$7c23c9ca.invoke(<generated>)
at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228)
at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:356)
at org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration$EnableWebMvcConfiguration$$EnhancerBySpringCGLIB$$7c82d476.resourceHandlerMapping(<generated>)
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.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:162)
... 25 more
Caused by: java.io.FileNotFoundException: C:\Users\hcorzo\workspace\online_mvp\online_store\build\libs\online_store-0.1.0.war!\WEB-INF\lib\validate.js-0.8.0.jar (The system cannot find the path specified)
at java.util.zip.ZipFile.open(Native Method)
at java.util.zip.ZipFile.<init>(Unknown Source)
at java.util.zip.ZipFile.<init>(Unknown Source)
at java.util.jar.JarFile.<init>(Unknown Source)
at java.util.jar.JarFile.<init>(Unknown Source)
at org.webjars.urlprotocols.JarUrlProtocolHandler.getAssetPaths(JarUrlProtocolHandler.java:36)
... 43 more
And this is my build.gradle file:
buildscript {
repositories {
mavenCentral()
jcenter()
maven { url 'http://dl.bintray.com/sbuettner/maven' }
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:1.3.3.RELEASE")
classpath 'ro.isdc.wro4j.gradle:wro4j-gradle-plugin:1.8.0.Beta3'
classpath "io.spring.gradle:dependency-management-plugin:0.5.6.RELEASE"
}
}
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'spring-boot'
apply plugin: 'wro4j'
apply plugin: "io.spring.dependency-management"
apply plugin: 'war'
dependencyManagement {
imports {
mavenBom 'org.springframework.cloud:spring-cloud-netflix:1.1.0.RELEASE'
}
}
jar {
baseName = 'online_store'
version = '0.1.0'
}
war {
baseName = 'online_store'
version = '0.1.0'
}
repositories {
mavenCentral()
maven { url 'http://dl.bintray.com/sbuettner/maven' }
maven { url "http://repo.spring.io/libs-snapshot" }
}
sourceCompatibility = 1.8
targetCompatibility = 1.8
ext {
versionJQuery = '2.1.1'
versionBootstrap = '3.2.0'
versionAngular = '1.3.8'
}
springBoot {
mainClass = "com.grupomedicus.store.server.UiApplication"
executable = true
requiresUnpack = [ "org.webjars:less", "org.webjars:jshint", "org.webjars:emberjs",
"org.webjars:handlebars", "org.webjars:coffee-script", "org.webjars:jslint", "org.webjars:json2",
"org.webjars:jquery", "org.webjars:handlebars", "org.slf4j:slf4j-api"
]
}
bootRepackage {
mainClass = "com.grupomedicus.store.server.UiApplication"
}
bootRun {
addResources = true
}
configurations {
providedRuntime
}
webResources {
bundle ('core') {
js 'js/**/*.js'
preProcessor 'jsMin'
}
bundle ('angular-bootstrap') {
js "webjars/jquery/$versionJQuery/jquery.min.js"
js "webjars/angularjs/$versionAngular/angular.min.js"
js "webjars/angularjs/$versionAngular/angular-route.min.js"
}
bundle ('angular-bootstrap') {
css "webjars/bootstrap/$versionBootstrap/css/bootstrap.min.css"
css 'themes/default/main.css'
cssRewriteUrl()
}
assets {
include 'themes/default/images/**'
}
}
dependencies {
compile('org.springframework.boot:spring-boot-starter-security')
compile("org.springframework.boot:spring-boot-starter-web")
providedRuntime("org.springframework.boot:spring-boot-starter-tomcat")
compile("org.springframework.boot:spring-boot-starter-data-jpa")
compile("org.springframework.security:spring-security-core")
compile 'org.apache.commons:commons-lang3'
compile(group: 'de.infinit', name: 'spring-boot-autoconfigure-wro4j', version: '0.0.6')
compile "org.springframework.boot:spring-boot-starter-redis"
compile "org.springframework.session:spring-session"
compile "org.springframework.cloud:spring-cloud-starter-zuul"
webjars "org.webjars:jquery:$versionJQuery"
webjars "org.webjars:angularjs:$versionAngular"
webjars "org.webjars:bootstrap:$versionBootstrap"
testCompile("org.springframework.boot:spring-boot-starter-test")
testCompile("junit:junit")
runtime('mysql:mysql-connector-java:5.1.6')
}
task wrapper(type: Wrapper) {
gradleVersion = '2.13'
}

org.gradle.api.internal.LocationAwareException from gradle

I have a gradle build error from the following gradle file. But I am clueless why it failed.
Please advise.
Thanks,
buildscript {
repositories {
maven { url "http://repo.spring.io/libs-snapshot" }
mavenLocal()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:1.0.0.RC4")
}
}
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'spring-boot' <== This is line 14
jar {
baseName = 'gs-spring-boot'
version = '0.1.0'
}
repositories {
mavenCentral()
maven { url "http://repo.spring.io/libs-snapshot" }
}
dependencies {
// tag::jetty[]
compile("org.springframework.boot:spring-boot-starter-web") {
exclude module: "spring-boot-starter-tomcat"
}
compile("org.springframework.boot:spring-boot-starter-jetty")
// end::jetty[]
// tag::actuator[]
compile("org.springframework.boot:spring-boot-starter-actuator")
// end::actuator[]
testCompile("junit:junit")
}
task wrapper(type: Wrapper) {
gradleVersion = '1.11'
}
#localhost hello]$ gradle
org.gradle.api.internal.LocationAwareException: Build file '/home/xxx/dev/src/main/java/hello/build.gradle' line: 14
A problem occurred evaluating root project 'hello'.
at org.gradle.initialization.DefaultExceptionAnalyser.transform(DefaultExceptionAnalyser.java:85)
at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:112)
at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:78)
at org.gradle.launcher.cli.RunBuildAction.execute(RunBuildAction.java:42)
at org.gradle.launcher.cli.RunBuildAction.execute(RunBuildAction.java:28)
at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:201)
at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:174)
at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:170)
at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:139)
at org.gradle.launcher.exec.ExceptionReportingAction.execute(ExceptionReportingAction.java:31)
at org.gradle.launcher.exec.ExceptionReportingAction.execute(ExceptionReportingAction.java:20)
at org.gradle.launcher.Main.doAction(Main.java:48)
at org.gradle.launcher.exec.EntryPoint.run(EntryPoint.java:45)
at org.gradle.launcher.Main.main(Main.java:39)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.gradle.launcher.ProcessBootstrap.runNoExit(ProcessBootstrap.java:50)
at org.gradle.launcher.ProcessBootstrap.run(ProcessBootstrap.java:32)
at org.gradle.launcher.GradleMain.main(GradleMain.java:24)
Caused by: org.gradle.api.GradleScriptException: A problem occurred evaluating root project 'hello'.
at org.gradle.groovy.scripts.internal.DefaultScriptRunnerFactory$ScriptRunnerImpl.run(DefaultScriptRunnerFactory.java:54)
at org.gradle.configuration.DefaultScriptPluginFactory$ScriptPluginImpl.apply(DefaultScriptPluginFactory.java:127)
at org.gradle.configuration.BuildScriptProcessor.evaluate(BuildScriptProcessor.java:38)
at org.gradle.configuration.LifecycleProjectEvaluator.evaluate(LifecycleProjectEvaluator.java:43)
at org.gradle.api.internal.project.AbstractProject.evaluate(AbstractProject.java:462)
at org.gradle.api.internal.project.AbstractProject.evaluate(AbstractProject.java:74)
at org.gradle.configuration.ProjectEvaluationConfigurer.execute(ProjectEvaluationConfigurer.java:23)
at org.gradle.configuration.ProjectEvaluationConfigurer.execute(ProjectEvaluationConfigurer.java:21)
at org.gradle.configuration.DefaultBuildConfigurer$1.execute(DefaultBuildConfigurer.java:38)
at org.gradle.configuration.DefaultBuildConfigurer$1.execute(DefaultBuildConfigurer.java:35)
at org.gradle.api.internal.project.AbstractProject.configure(AbstractProject.java:438)
at org.gradle.api.internal.project.AbstractProject.allprojects(AbstractProject.java:433)
at org.gradle.configuration.DefaultBuildConfigurer.configure(DefaultBuildConfigurer.java:35)
at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:139)
at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:110)
... 19 more
Caused by: java.lang.NoSuchMethodError: org.gradle.api.tasks.TaskContainer.create(Ljava/lang/String;Ljava/lang/Class;)Lorg/gradle/api/Task;
at org.springframework.boot.gradle.SpringBootPlugin.addRepackageTask(SpringBootPlugin.java:94)
at org.springframework.boot.gradle.SpringBootPlugin.applyRepackage(SpringBootPlugin.java:60)
at org.springframework.boot.gradle.SpringBootPlugin.apply(SpringBootPlugin.java:48)
at org.springframework.boot.gradle.SpringBootPlugin.apply(SpringBootPlugin.java:1)
at org.gradle.api.internal.plugins.DefaultProjectsPluginContainer.providePlugin(DefaultProjectsPluginContainer.java:107)
at org.gradle.api.internal.plugins.DefaultProjectsPluginContainer.addPluginInternal(DefaultProjectsPluginContainer.java:71)
at org.gradle.api.internal.plugins.DefaultProjectsPluginContainer.apply(DefaultProjectsPluginContainer.java:37)
at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction.applyPlugin(DefaultObjectConfigurationAction.java:101)
at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction.access$200(DefaultObjectConfigurationAction.java:32)
at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction$3.run(DefaultObjectConfigurationAction.java:72)
at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction.execute(DefaultObjectConfigurationAction.java:114)
at org.gradle.api.internal.project.AbstractProject.apply(AbstractProject.java:840)
That method create(String,Class<?>) was introduced in Gradle 1.6, so I suspect you have a mouldy Gradle wrapper (or some other messed up Gradle environment). The configuration says the wrapper generated is 1.11, but I think maybe you are running with an older version?

Resources