gradle searching jar in artifactory without version - gradle

My Gradle build has below dependency
| | +--- org.spire-math:spire_2.10:0.7.4
| | | +--- org.scala-lang:scala-library:2.10.2 -> 2.10.5
| | | +--- org.spire-math:spire-macros_2.10:0.7.4
| | | | +--- org.scala-lang:scala-library:2.10.2 -> 2.10.5
| | | | \--- org.scala-lang:scala-reflect:2.10.2 -> 2.10.5 (*)
| | | \--- org.scala-lang:scala-reflect:2.10.2 -> 2.10.5 (*)
| | \--- org.slf4j:slf4j-api:1.7.5 -> 1.7.10
I get the following error on running the build
* What went wrong:
Could not resolve all dependencies for configuration ':myProject
:compileClasspath'.
> Could not find scala-reflect.jar (org.scala-lang:scala-reflect:2.10.5).
Searched in the following locations:
http://company_intranet:port/artifactory/vr-trunk/org/scala-lang/scala-reflect/2.10.5/scala-reflect-2.10.5.jar
I am not sure why the jar is searched without the version
Could not find scala-reflect.jar
I see that the version number is not appended to the jar
The jar with the right version is available in the artifactory

The cache in my local machine was causing this error.
Once i used gradlew clean build -x test --refresh-dependencies , it worked

Related

How to resolve JAXB classpath issues on Java 12

Im porting application using JAXB to JDK 11/12 but am completely lost when trying to fix those JAXB classpath issues. I have googled and read basically everything related to this so Im aware of the changes made in Java11, i.e. removal of JAXB from JDK ... However in that case I would assume a trivial fix consisting of adding api and impl JARs on classpath. But this is not working and despite I have those JARs on classpath Im still getting the known exception, despite using 2.3.2 JAXB:
javax.xml.bind.JAXBException
- with linked exception:
[java.lang.ClassNotFoundException: com.sun.xml.internal.bind.v2.ContextFactory]
even if I see the class is in different package and I instruct to use correct package via system variable it does not work either:
gradle -Djavax.xml.bind.context.factory=com.sun.xml.bind.v2.ContextFactory build
javax.xml.bind.JAXBException
- with linked exception:
[java.lang.ClassNotFoundException: com.sun.xml.bind.v2.ContextFactory]
Does anyone have clue how to resolve this? I dont want to play with manifest files etc. It should be possible to just place the right JARs on classpath and that is it, or not?
Summary here but unable to get it working:
http://www.descher.at/descher-vu/2019/01/java-11-jaxb-and-osgi/
Update, dependencies used in Gradle:
- jaxb-xjc has jaxb-runtime (impl.) as transitive dependency. I see it is picked by Gradle but still the same error.
classpath "com.sun.activation:javax.activation:1.2.0"
classpath "jakarta.xml.bind:jakarta.xml.bind-api:2.3.2"
classpath "org.glassfish.jaxb:jaxb-xjc:2.3.2"
classpath"org.glassfish.jaxb:jaxb-core:2.3.0.1"
[org.gradle.internal.operations.DefaultBuildOperationExecutor] Build operation 'Resolve jaxb-runtime.jar (org.glassfish.jaxb:jaxb-runtime:2.3.2)' completed
[org.gradle.internal.component.model.ComponentAttributeMatcher] Selected match org.glassfish.jaxb:jaxb-runtime:2.3.2 configuration runtime from candidates [org.glassfish.jaxb:jaxb-runtime:2.3.2 configuration runtime] for {org.gradle.dependency.bundling=external, org.gradle.jvm.version=12, org.gradle.usage=java-runtime}
This is output of "gradle dependencies" and all the JAXB jars are there, still classpath error is being thrown. The JAR file jaxb-runtime from Glassfish for sure has this ContextFactory class.
runtimeClasspath - Runtime classpath of source set 'main'.
+--- org.springframework.boot:spring-boot-starter-log4j2 -> 2.1.0.RELEASE
| +--- org.apache.logging.log4j:log4j-slf4j-impl:2.11.1
| | +--- org.slf4j:slf4j-api:1.7.25
| | +--- org.apache.logging.log4j:log4j-api:2.11.1
| | \--- org.apache.logging.log4j:log4j-core:2.11.1
| | \--- org.apache.logging.log4j:log4j-api:2.11.1
| +--- org.apache.logging.log4j:log4j-core:2.11.1 (*)
| +--- org.apache.logging.log4j:log4j-jul:2.11.1
| | \--- org.apache.logging.log4j:log4j-api:2.11.1
| \--- org.slf4j:jul-to-slf4j:1.7.25
| \--- org.slf4j:slf4j-api:1.7.25
+--- org.projectlombok:lombok -> 1.18.2
+--- org.apache.commons:commons-lang3 -> 3.8.1
+--- org.apache.commons:commons-collections4 -> 4.4
+--- com.google.guava:guava -> 23.0
| +--- com.google.code.findbugs:jsr305:1.3.9
| +--- com.google.errorprone:error_prone_annotations:2.0.18
| +--- com.google.j2objc:j2objc-annotations:1.1
| \--- org.codehaus.mojo:animal-sniffer-annotations:1.14
+--- org.apache.ws.xmlschema:xmlschema-core -> 2.0.1
+--- org.glassfish.jaxb:jaxb-runtime:2.3.2
| +--- jakarta.xml.bind:jakarta.xml.bind-api:2.3.2
| | \--- jakarta.activation:jakarta.activation-api:1.2.1
| +--- org.glassfish.jaxb:txw2:2.3.2
| +--- com.sun.istack:istack-commons-runtime:3.0.8
| | \--- jakarta.activation:jakarta.activation-api:1.2.1
| +--- org.jvnet.staxex:stax-ex:1.8.1
| | +--- jakarta.activation:jakarta.activation-api:1.2.1
| | \--- jakarta.xml.bind:jakarta.xml.bind-api:2.3.2 (*)
| +--- com.sun.xml.fastinfoset:FastInfoset:1.2.16
| \--- jakarta.activation:jakarta.activation-api:1.2.1
\--- org.glassfish.jaxb:jaxb-core:2.3.0.1
+--- javax.xml.bind:jaxb-api:2.3.0 -> 2.3.1
| \--- javax.activation:javax.activation-api:1.2.0
+--- org.glassfish.jaxb:txw2:2.3.0.1 -> 2.3.2
\--- com.sun.istack:istack-commons-runtime:3.0.5 -> 3.0.8 (*)
From some reason I had no luck with Glassfish JARs, but those original Sun/Oracle dependencies worked.

Codenarc strange dependencies

We are using codenarc plugin and gradle, and i see the strange things in dependencies:
codenarc - The CodeNarc libraries to be used for this project.
\--- org.codenarc:CodeNarc:0.25.2
+--- junit:junit:4.8.1 -> 4.12
| \--- org.hamcrest:hamcrest-core:1.3
+--- org.codehaus.groovy:groovy-xml:2.1.8 -> 2.6.0-alpha-1
| \--- org.codehaus.groovy:groovy:2.6.0-alpha-1
+--- org.codehaus.groovy:groovy:2.1.8 -> 2.6.0-alpha-1
+--- org.codehaus.groovy:groovy-ant:2.1.8 -> 2.6.0-alpha-1
| +--- org.codehaus.groovy:groovy:2.6.0-alpha-1
| +--- org.codehaus.groovy:groovy-groovydoc:2.6.0-alpha-1 -> 2.4.9
| | +--- org.codehaus.groovy:groovy-templates:2.4.9
| | | +--- org.codehaus.groovy:groovy:2.4.9 -> 2.6.0-alpha-1
| | | \--- org.codehaus.groovy:groovy-xml:2.4.9 -> 2.6.0-alpha-1 (*)
| | \--- org.codehaus.groovy:groovy:2.4.9 -> 2.6.0-alpha-1
| +--- org.apache.ant:ant-junit:1.9.9
| \--- org.apache.ant:ant-antlr:1.9.9
\--- org.gmetrics:GMetrics:0.7
+--- org.codehaus.groovy:groovy:[2.1.0,) -> 2.6.0-alpha-1
+--- org.codehaus.groovy:groovy-xml:[2.1.0,) -> 2.6.0-alpha-1 (*)
\--- org.codehaus.groovy:groovy-ant:[2.1.0,) -> 2.6.0-alpha-1 (*)
Version of codenark is 0.25.2 and in pom it depends on groovy 2.1.8, but wtf - why it links to 2.6.0-alpha-1? How i can tell for codenark to use version of Groovy 2.1.8?
Thanks for help.
As you can see in your output the culprit is GMetrics.
CodeNarc 0.25.2 depends on GMetrics 0.7 which in turn depends on Groovy 2.1.0 or newer which resolves to the newest available version 2.6.0-alpha-1.
Default version conflict resolution strategy is to use the newest version on conflict, which then is the 2.6.0-alpha-1.
It is an error (in my opinion) for a lib to publish with a dynamic range.
GMetrics obviously also have seen this as error and fixed this dependency in 1.0 where they depend on a specific Groovy version instead.
CodeNarc 1.0 in turn depends on GMetrics 1.0.
So the easiest you could do if feasible, is to depend on CodeNarc 1.0 and your problem will be gone.
Alternatively you can also declare the Groovy version to be used in your own dependencies with force true which will force the version you define.
Alternatively you can configure the dependency resolution to influence the version selected.

Gradle dependency gets excluded from EAR

I have a gradle project with several subprojects. and I have defined several dependencies in library with version numbers and aliases in the root project. Now whenever subproject needs it it can define that alias with what level it wants e.g. compile.
root
- build.gradle
- libraries
- xercesImpl: 'xerces:xercesImpl:2.8.1',
- xalan: 'xalan:xalan:2.7.1',
\ project1 : ear
- build.gradle
- ear project('project2')
\ project2 : jar
- build.gradle
- compile libraries.xercesImpl
- compile libraries.xalan
Since I have defined xercesImpl and xalan as dependencies of project1 and project1 is included in project2 ear those jars should be added to EAR, but it's getting excluded from EAR. I checked and transitive dependencies is not declared anywhere as false.
I have printed dependency tree with gradlew and it prints only above 2 jars as excluded others are included:
+--- org.hibernate:hibernate:3.1.3
| +--- commons-logging:commons-logging:1.0.4 -> 1.1
| | +--- log4j:log4j:1.2.12
| | +--- logkit:logkit:1.0.1
| | +--- avalon-framework:avalon-framework:4.1.3
| | \--- javax.servlet:servlet-api:2.3
| +--- ehcache:ehcache:1.1
| | \--- commons-logging:commons-logging:1.0.4 -> 1.1 (*)
| +--- cglib:cglib:2.1_3
| | \--- asm:asm:1.5.3
| +--- asm:asm:1.5.3
| +--- asm:asm-attrs:1.5.3
| +--- commons-collections:commons-collections:2.1.1 -> 3.1
| +--- dom4j:dom4j:1.6.1
| +--- javax.transaction:jta:1.0.1B
| \--- antlr:antlr:2.7.6rc1 -> 2.7.6
+--- net.sf.ehcache:ehcache:2.9.0
| \--- org.slf4j:slf4j-api:1.7.7
+--- xerces:xercesImpl:2.8.1 (*)
+--- xalan:xalan:2.7.1 (*)

Gradle | Spring boot dependencies are not excluding

I'm trying to get log4j to work in a project that I'm working on. I added the relevant log4j dependencies in build.gradle and excluded the Spring boot starter logging so it can work.
This worked fine when I used Maven as the build tool, but once I switched to Gradle it's not working at all (excepts the logging from Spring boot starter). Here are the dependencies in my build.gradle
dependencies {
compile('org.springframework.boot:spring-boot-starter-data-jpa')
compile('org.springframework.boot:spring-boot-starter-web'){
exclude module: 'org.springframework.boot:spring-boot-starter-logging'
}
compile('org.springframework.boot:spring-boot-starter-log4j')
compile('org.springframework.boot:spring-boot-starter-data-rest')
compile('org.springframework.boot:spring-boot-starter-actuator')
compile('org.postgresql:postgresql:9.3-1101-jdbc41')
compile('org.scala-lang:scala-library:2.10.4')
testCompile('org.springframework.boot:spring-boot-starter-test') {
exclude module: 'commons-logging'
}
providedCompile('org.springframework.boot:spring-boot-starter-tomcat')
}
But as you can clearly see in the dependency tree the spring-boot-starter-logging is still there. I'm guessing that this is the issue why the logging isn't working.
Here's the dependency tree:
+--- org.springframework.boot:spring-boot-starter-data-jpa: -> 1.2.1.RELEASE
| +--- org.springframework.boot:spring-boot-starter:1.2.1.RELEASE
| | +--- org.springframework.boot:spring-boot:1.2.1.RELEASE
| | | +--- org.springframework:spring-core:4.1.4.RELEASE
| | | \--- org.springframework:spring-context:4.1.4.RELEASE
| | | +--- org.springframework:spring-aop:4.1.4.RELEASE
| | | | +--- aopalliance:aopalliance:1.0
| | | | +--- org.springframework:spring-beans:4.1.4.RELEASE
| | | | | \--- org.springframework:spring-core:4.1.4.RELEASE
| | | | \--- org.springframework:spring-core:4.1.4.RELEASE
| | | +--- org.springframework:spring-beans:4.1.4.RELEASE (*)
| | | +--- org.springframework:spring-core:4.1.4.RELEASE
| | | \--- org.springframework:spring-expression:4.1.4.RELEASE
| | | \--- org.springframework:spring-core:4.1.4.RELEASE
| | +--- org.springframework.boot:spring-boot-autoconfigure:1.2.1.RELEASE
| | | \--- org.springframework.boot:spring-boot:1.2.1.RELEASE (*)
| | +--- org.springframework.boot:spring-boot-starter-logging:1.2.1.RELEASE
Here's my log4j.properties file
log4j.rootLogger=INFO, fileout, CONSOLE
PID=????
LOG_PATTERN=[%d{yyyy-MM-dd HH:mm:ss.SSS}] log4j%X{context} - ${PID} %5p [%t] --- %c{1}: %m%n
# CONSOLE is set to be a ConsoleAppender using a PatternLayout.
log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
log4j.appender.CONSOLE.layout.ConversionPattern=${LOG_PATTERN}
# Log4j configurations for with file appender
log4j.category.org.hibernate.validator.internal.util.Version=WARN
log4j.category.org.apache.coyote.http11.Http11NioProtocol=WARN
log4j.category.org.apache.tomcat.util.net.NioSelectorPool=WARN
log4j.category.org.apache.catalina.startup.DigesterFactory=ERROR
log4j.appender.fileout=org.apache.log4j.RollingFileAppender
log4j.appender.fileout.File=sampleLog.log
log4j.appender.fileout.MaxFileSize=1024KB
log4j.appender.fileout.MaxBackupIndex=1
log4j.appender.fileout.layout=org.apache.log4j.PatternLayout
log4j.appender.fileout.layout.conversionPattern=${LOG_PATTERN}
UPDATE
I managed to fix the exclusion of jar file dependency. But the logging is still not working, log4j.properties is also in the WAR distribution under classes.
UPDATE 02
It worked issue is with the my IDE (STS)
All the spring-boot-starter-* projects are dependent on spring-boot-starter project, which in turn in dependent on spring-boot-starter-logging. I was able to remove this dependency by adding the following line in configurations section:
configurations {
compile.exclude module: 'spring-boot-starter-logging'
}
You have excluded the spring-boot-starter-logging module from spring-boot-starter-web, but as you clearly can see from the dependency tree, the module spring-boot-starter-data-jpa also has a dependency to spring-boot-starter-logging, so you also have to exclude it from there (and from all other spring-boot-starter-* dependencies, since all of them depend on spring-boot-starter-logging).
I have removed all logging dependencies using the below code
configurations {
all*.exclude module : 'spring-boot-starter-logging'
}

Grails 2.2 to 2.3 - jersey jaxrs plugin dependencies could not be resolved

I'm migrating my project from grails 2.2 to 2.3 and everything work fine except jaxrs plugin
My BuildConfig.groovy looks like:
...
grails.project.dependency.resolver = "maven"
grails.project.dependency.resolution = {
plugins {
compile ':jaxrs:0.8'
}
}
I got this error message:
| Error Resolve error obtaining dependencies: The following artifacts could not be resolved: org.restlet.gae:org.restlet.ext.json:jar:2.0.0, org.restlet.gae:org.restlet:jar:2.0.0, org.restlet.gae:org.restlet.ext.servlet:jar:2.0.0: Could not find artifact org.restlet.gae:org.restlet.ext.json:jar:2.0.0 in grailsCentral (http://repo.grails.org/grails/plugins) (Use --stacktrace to see the full trace)
| Error Resolve error obtaining dependencies: The following artifacts could not be resolved: org.restlet.gae:org.restlet.ext.json:jar:2.0.0, org.restlet.gae:org.restlet:jar:2.0.0, org.restlet.gae:org.restlet.ext.servlet:jar:2.0.0: Could not find artifact org.restlet.gae:org.restlet.ext.json:jar:2.0.0 in grailsCentral (http://repo.grails.org/grails/plugins) (Use --stacktrace to see the full trace)
| Error Resolve error obtaining dependencies: The following artifacts could not be resolved: org.restlet.gae:org.restlet.ext.json:jar:2.0.0, org.restlet.gae:org.restlet:jar:2.0.0, org.restlet.gae:org.restlet.ext.servlet:jar:2.0.0: Could not find artifact org.restlet.gae:org.restlet.ext.json:jar:2.0.0 in grailsCentral (http://repo.grails.org/grails/plugins) (Use --stacktrace to see the full trace)
| Error The following artifacts could not be resolved: org.restlet.gae:org.restlet.ext.json:jar:2.0.0, org.restlet.gae:org.restlet:jar:2.0.0, org.restlet.gae:org.restlet.ext.servlet:jar:2.0.0: Could not find artifact org.restlet.gae:org.restlet.ext.json:jar:2.0.0 in grailsCentral (http://repo.grails.org/grails/plugins)
| Run 'grails dependency-report' for further information.
When I run the report, I got:
+--- org.grails.plugins:jaxrs:0.8
| >>>> org.restlet.gae:org.restlet.ext.json:2.0.0
| >>>> org.restlet.gae:org.restlet:2.0.0
| \--- com.sun.jersey:jersey-core:1.14
| \--- javax.ws.rs:jsr311-api:1.1.1
| \--- com.sun.jersey:jersey-json:1.14
| >>>> org.restlet.gae:org.restlet.ext.servlet:2.0.0
| \--- com.sun.jersey.contribs:jersey-spring:1.14
| \--- org.springframework:spring-core:3.0.0.RC3
| \--- org.springframework:spring-asm:3.0.0.RC3
| \--- commons-logging:commons-logging:1.1.1
| \--- org.springframework:spring-beans:3.0.0.RC3
| \--- org.springframework:spring-context:3.0.0.RC3
| \--- org.springframework:spring-web:3.0.0.RC3
| \--- org.springframework:spring-aop:3.0.0.RC3
| \--- com.sun.jersey:jersey-server:1.14
| \--- com.sun.jersey:jersey-servlet:1.14
| \--- asm:asm:3.3
| \--- org.spockframework:spock-grails-support:0.7-groovy-2.0
| \--- org.grails.plugins:spock:0.7
How can I fix this ?
I found this post. There's a beta version being develop.
I've done what is suggested:
I added the mavenRepo
mavenRepo 'https://noams.artifactoryonline.com/noams/grails-jaxrs-plugin-snapshots'
And as I use the new Aether (Maven) resolver I configure the jaxrs plugin like this:
compile (':jaxrs:0.10-SNAPSHOT') {
excludes 'spring-core', 'spring-beans', 'spring-context', 'spring-web', 'spring-aop'
}
But org.restlet.ext.json:jar:2.1.4 was still missing so I also have to add this mavenRepo:
mavenRepo 'http://maven.restlet.org'
Application cleaned! Tests Passed!

Resources