Gradle IntelliJ Idea - java

when i add slf4j-api-1.6.4.jar and slf4j-nop-1.6.4.jar in my libs folder it works fine but if i replaced them with gradle dependency then while executing the jar it gives me below error.
Exception in thread "main" java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory
these are gradle dependencies for my project for above libraries.
compile group: 'org.slf4j', name: 'slf4j-api', version: '1.6.4'
compile group: 'org.slf4j', name: 'slf4j-nop', version: '1.6.4'

Make sure you've run Gradle Build, it may not have pulled your dependencies.

Make sure that you include these dependencies in the jar file (like this).

Related

Caused by: java.lang.NoClassDefFoundError: org/glassfish/jersey/server/model/Parameter$Source

I'm working with a REST Api built using Gradle + Jersey and running on Tomcat-7. I noticed when I am trying to run my JUnit tests that I am getting 500 errors for any api call.
Caused by: java.lang.NoClassDefFoundError: org/glassfish/jersey/server/model/Parameter$Source
at org.glassfish.jersey.media.multipart.internal.FormDataParamValueParamProvider.<init>(FormDataParamValueParamProvider.java:371)
at org.glassfish.jersey.media.multipart.internal.FormDataParamInjectionFeature$1.configure(FormDataParamInjectionFeature.java:76)
at org.glassfish.jersey.internal.inject.AbstractBinder.invokeConfigure(AbstractBinder.java:256)
at org.glassfish.jersey.internal.inject.AbstractBinder.getBindings(AbstractBinder.java:246)
at org.glassfish.jersey.internal.inject.Bindings.getBindings(Bindings.java:44)
at org.glassfish.jersey.internal.inject.AbstractBinder.lambda$getBindings$1(AbstractBinder.java:248)
at java.util.stream.ReferencePipeline$7$1.accept(ReferencePipeline.java:269)
I have noticed in other solutions that were similar to what I am having have mentioned that my jersey version numbers are off. However my Gradle has every jersey version in Sync.
compile group: 'org.glassfish.jersey.containers', name: 'jersey-container-servlet', version: '2.26'
compile group: 'org.glassfish.jersey.core', name: 'jersey-common', version: '2.26'
compile group: 'org.glassfish.jersey.inject', name: 'jersey-hk2', version: '2.26'
compile group: 'org.glassfish.jersey.media', name: 'jersey-media-multipart', version: '2.26'
Is there something else I could be missing?
So the problem that I was having that another library that I had custom built but not listed had used a different version of jersey in its own gradle. Syncing up my other projects gradle to 2.26 worked.

Gradle war fails with compile task

In order to set war file into Tomcat server, I try :
Gradle war (5.3.1)fails with
provided group: 'javax.servlet', name: 'javax.servlet-api', version: '3.1.0'
Could not find provided
Do you know why ?
Do not hesitate to merge request or commit at https://github.com/moueza/spring-mvc-hello-world-example-mkyong-gradle/issues/2
Because there is no such providedconfiguration. There is providedCompile and providedRuntime. Read the documentation.

IntelliJ - module not found: java.xml.ws.annotation

Project has Gradle 5 (gradle-5.0-milestone-1), Java 11 (OpenJDK11) and latest IntelliJ Professional.
With sourceCompatibility = 10 in gradle.properties it builds/runs tests, but with sourceCompatibility = 11 it shows
module not found: java.xml.ws.annotation
Note that If I run test task from Gradle it runs everything successfully but it only fails when running directly from IntelliJ (pointing on method, right click and run).
Does anyone have any idea what is going wrong here?
For those who run into similar problem. Removing .idea folder and reimporting whole project helped.
Add to gradle
compile group: 'javax.xml.ws', name: 'jaxws-api', version: '2.3.1'
compile 'com.sun.xml.bind:jaxb-osgi:2.4.0-b180830.0438'
compile group: 'com.sun.xml.ws', name: 'jaxws-ri', version: '2.3.1', ext: 'pom'
compile group: 'com.sun.xml.bind', name: 'jaxb-impl', version: '2.4.0-b180830.0438'
Could you please verify that you don't have '--add-modules', 'java.xml.ws.annotation' in your build.gradle, because this module was removed in JDK11, but is still needed for JDK 10.
https://jaxenter.com/jdk-11-java-ee-modules-140674.html

gradle dependency unusable after refresh in intellij

as in the title, gradle dependency unusable after refreshing. I can see twitter4j is added in external libraries along with other gradle dependencies.
Gradle file:
compile group: 'org.twitter4j', name: 'twitter4j', version: '4.0.6', ext: 'pom'
java:
import twitter4j.*;
error:
cannot resolve symbol "twitter4j"
changing the gradle line to
compile 'org.twitter4j:twitter4j-core:4.0.6'
resolves this problem.

Intellij can't find commons.dbcp2

I have a problem which drives me insane, since it should work.
I have compiled dbcp dependency in my gradle file
compile group: 'org.apache.commons', name: 'commons-dbcp2', version: '2.1.1'
still, it can't resolve if i refer to it like this:
import org.apache.commons.dbcp2.BasicDataSource;
Any idea? (using intellij)
The problem was that the gradle project was unlinked, so the dependencies - even thought the dependencies was there in the external libraries, i had to re-link the gradle.

Categories

Resources