I am getting the warning
WARNING: javax.persistence.spi::No valid providers found.
I have code with JPA annotations, but I need them only to use with JOOQ.
How to remove this warning?
Adding my gradle file:
dependencies {
compile project(':common:packages:autogenerated_dao')
externalLib group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: jackson_databind_version
externalLib group: 'javax.validation', name: 'validation-api', version: javax_validation_version
externalLib group: 'org.hibernate', name: 'hibernate-validator', version: hibernate_validator_version
externalLib group: 'javax.el', name: 'javax.el-api', version: javax_el_version
externalLib group: 'org.glassfish', name: 'javax.el', version: glassfish_el_version
externalLib group: 'javax.persistence', name: 'javax.persistence-api', version: javax_persistence_version
}
Mentioned warning raised because javax.persistence-api dependency present in build file, but obviously here is no implementations for it. To get rid from warning, remove javax.persistence-api dependency.
Bean Validation provided by validation-api and its implementation hibernate-validator, so you will be fine.
I was facing same "WARNING: javax.persistence.spi::No valid providers found."
I added below artifact in pom.xml and issue resolved.
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
</dependency>
OR
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>2.0.1.Final</version>
</dependency>
Related
I'm working on a new project using Gradle and JavaFX.
I have previously been able to create a cross-platform build using Maven, with the following pom dependencies:
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-graphics</artifactId>
<version>13</version>
<classifier>win</classifier>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-graphics</artifactId>
<version>13</version>
<classifier>linux</classifier>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-graphics</artifactId>
<version>13</version>
<classifier>mac</classifier>
</dependency>
How do i go about doing something similar with Gradle?
I have tried the following, with no success.
Is the classifier syntax incorrect?
compile group: 'org.openjfx', name: 'javafx-graphics', version: '11.0.2:win'
compile group: 'org.openjfx', name: 'javafx-graphics', version: '11.0.2:linux'
compile group: 'org.openjfx', name: 'javafx-graphics', version: '11.0.2:mac'
Any hints would be greatly appreciated!
The solution turned out to be the following gradle build dependencies:
implementation group: 'org.openjfx', name: 'javafx-base', version: javaFxVersion, classifier: 'win'
implementation group: 'org.openjfx', name: 'javafx-base', version: javaFxVersion, classifier: 'mac'
implementation group: 'org.openjfx', name: 'javafx-base', version: javaFxVersion, classifier: 'linux'
implementation group: 'org.openjfx', name: 'javafx-controls', version: javaFxVersion, classifier: 'win'
implementation group: 'org.openjfx', name: 'javafx-controls', version: javaFxVersion, classifier: 'mac'
implementation group: 'org.openjfx', name: 'javafx-controls', version: javaFxVersion, classifier: 'linux'
implementation group: 'org.openjfx', name: 'javafx-fxml', version: javaFxVersion, classifier: 'win'
implementation group: 'org.openjfx', name: 'javafx-fxml', version: javaFxVersion, classifier: 'mac'
implementation group: 'org.openjfx', name: 'javafx-fxml', version: javaFxVersion, classifier: 'linux'
implementation group: 'org.openjfx', name: 'javafx-graphics', version: javaFxVersion, classifier: 'win'
implementation group: 'org.openjfx', name: 'javafx-graphics', version: javaFxVersion, classifier: 'mac'
implementation group: 'org.openjfx', name: 'javafx-graphics', version: javaFxVersion, classifier: 'linux'
This allows a javafx gradle build to be run on any OS.
The syntax is indeed incorrect in Gradle. Documentation will show you the different supported syntax.
The two most common are the map style you used and the : separated notation.
So taking one of your dependency as an example, you need to use either:
compile group: 'org.openjfx', name: 'javafx-graphics', version: '11.0.2', classifier: 'win'
compile 'org.openjfx:javafx-graphics:11.0.2:win'
Note that you should also stop using the compile configuration and instead use implementation. See this explanation to understand more on this topic.
I am using Gradle as a build tool and during deployment I am facing some issues which I have mentioned below.
Gradle build task has no issues but when I deployed it on tomcat8 it shows below error.
build.gradle dependencies file is as follows:
dependencies {
testCompile group: 'junit', name: 'junit', version: '4.12'
compile group: 'javax.servlet', name: 'javax.servlet-api', version: '3.1.0'
compile group: 'org.json', name: 'json', version: '20090211'
// Apache Kafka Dependencies
compile group: 'org.apache.kafka', name: 'kafka-clients', version: '2.0.0'
compile group: 'org.apache.kafka', name: 'connect-json', version: '2.0.0'
// Office365 authentication Dependencies
compile group: 'com.microsoft.azure', name: 'adal4j', version: '1.6.0'
runtime group: 'com.nimbusds', name: 'oauth2-oidc-sdk', version: '5.24.1'
// Apache Hadoop HDFS Dependencies
compile group: 'org.apache.hadoop', name: 'hadoop-hdfs', version: '2.9.1'
compile group: 'org.apache.hadoop', name: 'hadoop-hdfs-client', version: '2.9.1'
compile group: 'org.apache.hadoop', name: 'hadoop-common', version: '2.9.1'
compile group: 'org.apache.hive', name: 'hive-jdbc', version: '2.3.3'
// Spring Dependencies
compile group: 'opensymphony', name: 'sitemesh', version: '2.4.2'
compile group: 'org.springframework', name: 'spring-webmvc', version: '4.3.14.RELEASE'
compile group: 'org.springframework', name: 'spring-tx', version: '4.3.14.RELEASE'
// Mysql Connector Dependency
compile group: 'mysql', name: 'mysql-connector-java', version: '6.0.6'
// Apache Spark Dependencies
compile group: 'com.databricks', name: 'spark-csv_2.11', version: '1.5.0'
compile group: 'org.apache.spark', name: 'spark-sql_2.11', version: '2.3.0'
compile group: 'org.apache.spark', name: 'spark-core_2.11', version: '2.3.0'
compile group: 'com.fasterxml.jackson.module', name: 'jackson-module-scala_2.11', version: '2.8.8'
// Apache Storm & Apache Kafka Consumer Dependencies
compile group: 'org.apache.storm', name: 'storm-core', version: '1.2.0'
compile group: 'org.apache.storm', name: 'storm-kafka', version: '1.2.0'
compile group: 'org.apache.kafka', name: 'kafka_2.10', version: '0.9.0.1'
// Elasticsearch Dependencies
compile group: 'org.elasticsearch.client', name: 'elasticsearch-rest-high-level-client', version: '6.5.2'
compile group: 'org.elasticsearch', name: 'elasticsearch', version: '6.5.2'
//compile group: 'org.apache.logging.log4j', name: 'log4j-core', version: '2.11.1'
//compile group: 'org.apache.logging.log4j', name: 'log4j-api', version: '2.11.1'
//compile group: 'org.slf4j', name: 'slf4j-log4j12'
}
The error message:
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/home/sagarjoshi/opt/tomcat-analytics/apache-tomcat-8.0.53/webapps/analytics/WEB-INF/lib/slf4j-log4j12-1.7.25.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/home/sagarjoshi/opt/tomcat-analytics/apache-tomcat-8.0.53/webapps/analytics/WEB-INF/lib/log4j-slf4j-impl-2.8.2.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/home/sagarjoshi/opt/tomcat-analytics/apache-tomcat-8.0.53/webapps/analytics/WEB-INF/lib/logback-classic-1.0.9.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Detected both log4j-over-slf4j.jar AND slf4j-log4j12.jar on the class path, preempting StackOverflowError.
SLF4J: See also http://www.slf4j.org/codes.html#log4jDelegationLoop for more details.
17-Dec-2018 11:32:29.244 SEVERE [RMI TCP Connection(2)-127.0.0.1] org.apache.catalina.core.StandardContext.startInternal Error during ServletContainerInitializer processing
javax.servlet.ServletException: Failed to instantiate WebApplicationInitializer class
at org.springframework.web.SpringServletContainerInitializer.onStartup(SpringServletContainerInitializer.java:155)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5352)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:755)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:731)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:717)
at org.apache.catalina.startup.HostConfig.manageApp(HostConfig.java:1730)
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.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:300)
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819)
at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801)
at org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:485)
at org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:434)
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.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:300)
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819)
at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801)
at javax.management.remote.rmi.RMIConnectionImpl.doOperation(RMIConnectionImpl.java:1468)
at javax.management.remote.rmi.RMIConnectionImpl.access$300(RMIConnectionImpl.java:76)
at javax.management.remote.rmi.RMIConnectionImpl$PrivilegedOperation.run(RMIConnectionImpl.java:1309)
at javax.management.remote.rmi.RMIConnectionImpl.doPrivilegedOperation(RMIConnectionImpl.java:1401)
at javax.management.remote.rmi.RMIConnectionImpl.invoke(RMIConnectionImpl.java:829)
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 sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:357)
at sun.rmi.transport.Transport$1.run(Transport.java:200)
at sun.rmi.transport.Transport$1.run(Transport.java:197)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:196)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:573)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:834)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:688)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:687)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
SLF4J API is designed to bind with one and only one underlying logging framework at a time. If more than one binding is present on the classpath, SLF4J will emit a warning, listing the location of those bindings.
When multiple bindings are available on the class path, select one and only one binding you wish to use, and remove the other bindings. For example, if you have both slf4j-simple-2.0.0-alpha2.jar and slf4j-nop-2.0.0-alpha2.jar on the class path and you wish to use the nop (no-operation) binding, then remove slf4j-simple-2.0.0-alpha2.jar from the class path.
The list of locations that SLF4J provides in this warning usually provides sufficient information to identify the dependency transitively pulling in an unwanted SLF4J binding into your project. In your project's pom.xml file, exclude this SLF4J binding when declaring the unscrupulous dependency. For example, cassandra-all version 0.8.1 declares both log4j and slf4j-log4j12 as compile-time dependencies. Thus, when you include cassandra-all as a dependency in your project, the cassandra-all declaration will cause both slf4j-log4j12.jar and log4j.jar to be pulled in as dependencies. In case you do not wish to use log4j as the the SLF4J backend, you can instruct Maven to exclude these two artifacts as shown next:
<dependencies>
<dependency>
<groupId> org.apache.cassandra</groupId>
<artifactId>cassandra-all</artifactId>
<version>0.8.1</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</exclusion>
<exclusion>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
Check your project dependencies. Do really need so many compile dependencies? Check all APIs and use the matching scope. Probably runtime is often enough.
Your proejct has more than one definition for a logging API and bridging (log4 and logback with slf4j). Decide which one you want to use and declare your dependencies accordingly. Provide the configuration for the used logging API.
See slf4j - bridges how bridging works.
If you want to identify the the projects with the offending transient dependencies, use the gradle dependency tree (see gradle - inspecting dependencies)
gradlew dependencies
Probably after analyzing your dependencies, you might need to exclude some dependencies according to your runtime environmen. See gradle - managing transient dependencies how to do this.
I created plugin with the following dependencies:
compile group: 'org.apache.httpcomponents', name: 'fluent-hc', version: '4.5.6'
compile group: 'com.google.code.gson', name: 'gson', version: '2.8.5'
compile group: 'joda-time', name: 'joda-time', version: '2.10'
compile group: 'com.google.guava', name: 'guava', version: '26.0-jre'
and it is working perfect.
Then I added more dependencies:
compile group: 'javax.validation', name: 'validation-api', version: '2.0.1.Final'
compile group: 'org.hibernate.validator', name: 'hibernate-validator', version: '6.0.13.Final'
compile group: 'javax.el', name: 'javax.el-api', version: '3.0.0'
compile group: 'org.glassfish', name: 'javax.el', version: '3.0.0'
and it is working perfect when I tested plugin with runIde task on local.
When I added jar file to IDEA I got exception: java.lang.NoClassDefFoundError: javax/validation/Validation
In both cases jar file does't contain any dependencies.
What did I miss?
UPDATE
6 years old question:
How does Intellij IDEA manage plugin dependencies?
Is it still valid? If so how I can put my dependencies in the plugin jar?
Im doing now:
gradle clean buildPlugin
Update build.gradle
jar {
from configurations.compile.collect { it.isDirectory() ? it : zipTree(it) }
}
Based on response here I need to submit zip file instead of jar. Zip contains all dependencies.
I've got problem with using #PostConstruct and#PostDestroy annotations in my project. I can't use these annotations and it looks like these doesn't exist despite the fact that I imported Java's annotations. I am using Java 11 and that is content of my build.gradle file:
dependencies {
testCompile group: 'junit', name: 'junit', version: '4.11'
testCompile group: 'junit', name: 'junit', version: '4.12'
compile group: 'org.springframework', name: 'spring-webmvc', version: '5.1.0.RELEASE'
compile group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.9.7'
compile group: 'javax.annotation', name: 'javax.annotation-api', version: '1.3.2'
provided group: 'javax.servlet', name: 'javax.servlet-api', version: '4.0.1'
}
Note that both #PostConstruct and #PreDestroy annotations are part of Java EE. And since Java EE has been deprecated in Java 9 and removed in Java 11 we have to add an additional dependency to use these annotations:
For Maven
<dependency>
<groupId>javax.annotation</groupId>
<artifactId>javax.annotation-api</artifactId>
<version>1.3.2</version>
</dependency>
If using Gradle
implementation "javax.annotation:javax.annotation-api:1.3.2"
Found here: https://www.baeldung.com/spring-postconstruct-predestroy
You have only spring-webmvc, you need the rest of the spring to be able to use their annotations. Probably spring-core and spring-annotations.
Another solution which worked for me is this.
Go to https://mvnrepository.com/artifact/javax.annotation/javax.annotation-api/1.2
and download the jar file.
Then copy the the jar file to your project lib directory.
Finally point the project build path, under class path to the file you pasted into your local lib folder.
So in my build.gradle file I have this dependencies added.
dependencies {
testCompile group: 'junit', name: 'junit', version: '4.12'
// https://mvnrepository.com/artifact/org.hibernate/hibernate-core
compile group: 'org.hibernate', name: 'hibernate-core', version: '5.3.6.Final'
// https://mvnrepository.com/artifact/mysql/mysql-connector-java
compile group: 'mysql', name: 'mysql-connector-java', version: '8.0.12'
// https://mvnrepository.com/artifact/javax.xml.bind/jaxb-api
compile group: 'javax.xml.bind', name: 'jaxb-api', version: '2.3.0'
// https://mvnrepository.com/artifact/javax.xml/jaxb-impl
compile group: 'javax.xml', name: 'jaxb-impl', version: '2.1'
// https://mvnrepository.com/artifact/org.openjfx/javafx-controls
compile group: 'org.openjfx', name: 'javafx-controls', version: '11'
}
The class of other dependencies were added except for javafx classes. It wasn't downloaded all I get is just the meta-inf directory.
I am using JDK 11, so I really need openjfx repo to use JavaFX. because in JDK 11, javafx is decoupled.
Update: I am using Intellij Idea
Each supported platform has its own version of JavaFx module artifacts, so you need to specify it too:
compile group: 'org.openjfx', name: 'javafx-controls', version: '11', classifier: 'linux' //'win', 'mac'
Additionally, you will need to explicitly add all transitive dependencies of the included javafx modules, because gradle cannot resolve platform specific modules by itself:
compile group: 'org.openjfx', name: 'javafx-base', version: '11', classifier: 'linux'
compile group: 'org.openjfx', name: 'javafx-graphics', version: '11', classifier: 'linux'
Check official documentation: https://openjfx.io/openjfx-docs/#gradle