I thought dependencyManagement from parents were transitive aren't they?
Never see that explicitely in the doc, but it seemed obvious to me...
Here's what i have:
+-----------------------+
| Parent 1 |
|-----------------------|
| dependencyManagement: |
| lib1: 1.0.0 |
+-----------------------+
^
|
|
+-----------+-----------+
| Parent 2 |
|-----------------------|
| dependencyManagement: |
| lib2: 1.0.0 |
+-----------------------+
^
|
+-----------+-----------+
| Project A |
|-----------------------|
| dependencies: |
| lib1 |
| lib2 |
+-----------------------+
When i try to mvn install Project A, i get:
[ERROR] 'dependencies.dependency.version' for lib1-digester:jar is missing. # line XX, column YY
I also tried to add an entry of Parent 1 in the dependencyManagement of Parent 2 with the import scope, with no success..
How can my Project A have versions managed by all it's parent hierarchy?
It seems you are correct after reading the Maven Docs.
In general, all dependencies of those projects are used in your project, as are any that the project inherits from its parents, or from its dependencies, and so on.
Try to update to the latest version of Maven 3. IIRC, there were a couple of bugs in the inheritance of dependencyManagement elements.
A made a small example with other empty projects, and everything went fine...
Finally, there was something strange, here's what happened.
I was actually more like that:
+-----------------------+
| Parent 1 |
|-----------------------|
| dependencyManagement: |<----------------------+
| lib1: 1.0.0 | |
+-----------------------+ |
^ |
| +-------------+------------+
| | Project B |
+-----------+-----------+ |--------------------------|
| Parent 2 | | dependencies: |
|-----------------------| | somethingWrong: 1.0.0 |
| dependencyManagement: | +--------------------------+
| lib2: 1.0.0 |
+-----------------------+
^
|
+-----------+-----------+
| Project A |
|-----------------------|
| dependencies: |
| lib1 |
| lib2 |
+-----------------------+
There was an error in Project B's pom.xml
It shouldn't have any impact on my problem, but correcting that unrelated pom solved my problem...
Sorry for the wasted time
Related
I am working on a Spring project and I have FlyWay as a dependency to manage my migrations, I made a mistake on the SQL command. When I ran the project I got an error showing a problem with the script, a silly mistake that was easy to fix, I misspelled a column name. However, the undo command from the flyway is not working.
I was trying to undo a migration using FlyWay and I follow the tutorial from FlyWay documentation: link-flyway
However, I got this output:
C:\Users\leonardo.freitas\Documents\workspace\api>C:\Users\leonardo.freitas\Documents\workspace\flyway-9.8.1\flyway undo
A new version of Flyway is available
Upgrade to Flyway 9.8.2: https://rd.gt/2X0gakb
ERROR: The command 'undo' was not recognized. Make sure you have added 'flyway-proprietary' as a dependency.
Caused by: No command extension found to handle command: undo
That's my migration history:
C:\Users\leonardo.freitas\Documents\workspace\api>C:\Users\leonardo.freitas\Documents\workspace\flyway-9.8.1\flyway info
A new version of Flyway is available
Upgrade to Flyway 9.8.2: https://rd.gt/2X0gakb
Flyway Community Edition 9.8.1 by Redgate
See what's new here: https://flywaydb.org/documentation/learnmore/releaseNotes#9.8.1
ERROR: Skipping filesystem location: sql (not found)
Database: jdbc:mysql://localhost:3306/volimed (MySQL 8.0)
Schema version: 5
+-----------+---------+----------------------------------------+------+---------------------+-----------------+----------+
| Category | Version | Description | Type | Installed On | State | Undoable |
C:\Users\leonardo.freitas\Documents\workspace\api>C:\Users\leonardo.freitas\Documents\workspace\flyway-9.8.1\flyway info
A new version of Flyway is available
Upgrade to Flyway 9.8.2: https://rd.gt/2X0gakb
Flyway Community Edition 9.8.1 by Redgate
See what's new here: https://flywaydb.org/documentation/learnmore/releaseNotes#9.8.1
ERROR: Skipping filesystem location: sql (not found)
Database: jdbc:mysql://localhost:3306/volimed (MySQL 8.0)
Schema version: 5
+-----------+---------+----------------------------------------+------+---------------------+-----------------+----------+
| Category | Version | Description | Type | Installed On | State | Undoable |
+-----------+---------+----------------------------------------+------+---------------------+-----------------+----------+
| Versioned | 1 | create-table-medicos | SQL | 2022-11-19 03:12:19 | Future | No |
| Versioned | 2 | alter-table-medicos-add-telefone | SQL | 2022-11-19 13:32:45 | Future | No |
| Versioned | 3 | create-table-pacientes | SQL | 2022-11-19 13:46:17 | Future | No |
| Versioned | 4 | alter-table-medicos-add-column-active | SQL | 2022-11-19 15:28:46 | Future | No |
| Versioned | 5 | alter-table-paciente-add-column-active | SQL | 2022-11-19 15:45:28 | Failed (Future) | No |
+-----------+---------+----------------------------------------+------+---------------------+-----------------+----------+
And I want to redu the last migration.
Undo command is supported in both the Teams and Enterprise edition . Flyway Enterprise is the only version with auto generation of Undo scripts though. Bill, could you point me towards where the information is conflicting?
I find out a way to resolve this problem, I went to the FlyWay table and deleted the last row, when I ran the project the FlyWay applied the migration again.
From my understanding Gradle will carry over all compile dependencies as runtime dependencies.
What is an instance when you should only use runtime? All child dependencies are grabbed from compile and pulled into the compilation when gradle build is called.
For example, when I do a diff on what is printed when I call
> gradle -q dependencies
The list printed out for compile and runtime are identical. Example output may show following for both:
+--- org.springframework.boot:spring-boot-starter-web: -> 1.5.4.RELEASE
| +--- org.springframework.boot:spring-boot-starter:1.5.4.RELEASE
| | +--- org.springframework.boot:spring-boot:1.5.4.RELEASE
| | | +--- org.springframework:spring-core:4.3.9.RELEASE
| | | \--- org.springframework:spring-context:4.3.9.RELEASE
| | | +--- org.springframework:spring-aop:4.3.9.RELEASE
| | | | +--- org.springframework:spring-beans:4.3.9.RELEASE
| | | | | \--- org.springframework:spring-core:4.3.9.RELEASE
| | | | \--- org.springframework:spring-core:4.3.9.RELEASE
| | | +--- org.springframework:spring-beans:4.3.9.RELEASE (*)
| | | +--- org.springframework:spring-core:4.3.9.RELEASE
| | | \--- org.springframework:spring-expression:4.3.9.RELEASE
| | | \--- org.springframework:spring-core:4.3.9.RELEASE
| | +--- org.springframework.boot:spring-boot-autoconfigure:1.5.4.RELEASE
| | | \--- org.springframework.boot:spring-boot:1.5.4.RELEASE (*)
| | +--- org.springframework.boot:spring-boot-starter-logging:1.5.4.RELEASE
| | | +--- ch.qos.logback:logback-classic:1.1.11
| | | | +--- ch.qos.logback:logback-core:1.1.11
| | | | \--- org.slf4j:slf4j-api:1.7.22 -> 1.7.25
| | | +--- org.slf4j:jcl-over-slf4j:1.7.25
| | | | \--- org.slf4j:slf4j-api:1.7.25
I have looked at this answer which helped explain a little about the difference between compile and runtime, but it only showed that runtime is when your code actually executes a dependency. When would you have a runtime dependency, but not a compile time?
A typical case involves dynamically creating classes via reflection. As a contrived example, consider this app:
package net.codetojoy;
public class App {
public static void main(String[] args) throws Exception {
Class c = Class.forName("org.apache.commons.lang3.StringUtils");
Object object = c.getConstructor().newInstance();
System.out.println("object is : " + object);
}
}
It will create an object of StringUtils from Apache Commons Lang. (This example is silly; consider a case where libA will effectively do this for classes in libB).
There is no compile-time dependency so there is no reason to burden the compile-time classpath with the jar. However at run-time, the jar is certainly required. The build.gradle file is below. It uses the application plugin which nicely bundles the dependencies into a runnable deliverable.
apply plugin: 'java'
apply plugin: 'application'
repositories {
jcenter()
}
dependencies {
runtime group: 'org.apache.commons', name: 'commons-lang3', version: '3.6'
}
mainClassName = 'net.codetojoy.App'
Example output:
$ gradle run -q
object is : org.apache.commons.lang3.StringUtils#4aa298b7
In my clojure project I have a dependency on the javax.jms.MessageListener library. I have this class file in my project in the following directory
My-project
|java-
| |src -
| | |myJavaFile.java
| | |jars -
| | |library1.jar
| | |library2.jar
| | |libarary3.jar
| |javax -
| | |jms -
| | |MessageListener.class
|project.clj
|src -
| |my-program1.clj
| |my-program2.clj
| |my-program3.clj
Then in my project.clj file I have my java-source-paths set to
:java-source-paths ["java/src" "java/src/jars/" "java/javax/jms"]
but when I go to run my project via lein repl, I get compilation errors saying
java.lang.NoClassDefFoundError: javax/jms/MessageListener
Caused by: java.lang.ClassNotFoundException: javax.jms.MessageListener
From what I've read the messagelistener.class and my library jars should be included in my classpath when the project is running but that doesn't seem to be the case.
It is my understanding that the directory structure of java projects has to match the name of the namespaces. For instance package_name.classname has to be in the folder package_name on the classpath https://docs.oracle.com/javase/tutorial/java/package/managingfiles.html
But of course using either Leiningen or Boot you just need to add [javax.jms/jms-api "1.1-rev-1"] to the :dependencies.
Simple project, below is my gradle dependency. This is the only CXF dependency that I declare. Also are my gradle dependencies that materialize as the result of that declared dependency. When I run my code I get the exception below. I cannot figure this out.
Help!
compile(group: 'org.apache.cxf', name: 'cxf-rt-frontend-jaxrs', version:'2.7.17')
+--- org.apache.cxf:cxf-rt-frontend-jaxrs:2.7.17
| +--- org.apache.cxf:cxf-api:2.7.17
| | +--- org.codehaus.woodstox:woodstox-core-asl:4.4.1 (*)
| | +--- org.apache.ws.xmlschema:xmlschema-core:2.1.0 -> 2.2.1
| | +--- org.apache.geronimo.specs:geronimo-javamail_1.4_spec:1.7.1
| | \--- wsdl4j:wsdl4j:1.6.3
| +--- org.apache.cxf:cxf-rt-core:2.7.17
| | +--- org.apache.cxf:cxf-api:2.7.17 (*)
| | +--- com.sun.xml.bind:jaxb-impl:2.1.13 -> 2.2.11
| | \--- org.apache.ws.xmlschema:xmlschema-core:2.1.0 -> 2.2.1
| +--- javax.ws.rs:javax.ws.rs-api:2.0-m10
| +--- org.apache.cxf:cxf-rt-bindings-xml:2.7.17
| | \--- org.apache.cxf:cxf-api:2.7.17 (*)
| \--- org.apache.cxf:cxf-rt-transports-http:2.7.17
| +--- org.apache.cxf:cxf-api:2.7.17 (*)
| \--- org.apache.cxf:cxf-rt-core:2.7.17 (*)
java.lang.NoSuchMethodError: org.apache.cxf.common.util.ClassHelper.getRealClass(Lorg/apache/cxf/Bus;Ljava/lang/Object;)Ljava/lang/Class;
at org.apache.cxf.jaxrs.provider.ProviderFactory.setCommonProviders(ProviderFactory.java:499)
at org.apache.cxf.jaxrs.client.ClientProviderFactory.setProviders(ClientProviderFactory.java:85)
at org.apache.cxf.jaxrs.provider.ProviderFactory.initBaseFactory(ProviderFactory.java:137)
at org.apache.cxf.jaxrs.client.ClientProviderFactory.initBaseFactory(ClientProviderFactory.java:77)
at org.apache.cxf.jaxrs.client.ClientProviderFactory.createInstance(ClientProviderFactory.java:56)
at org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean.initClient(JAXRSClientFactoryBean.java:377)
at org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean.createWebClient(JAXRSClientFactoryBean.java:225)
at org.apache.cxf.jaxrs.client.WebClient.create(WebClient.java:113)
java.lang.NoSuchMethodError is generally when you use the new API jar but the implementation is still the old one which doesn't have the new methods implemented. I would suggest you to check the version of the jars and see if that is accurate. If you fix the version then you would not see this error.
I would like to use Apache Ivy to resolve some dependencies(imports) inside my project in Java. I'm using NetBeans 7.1.2 (Java EE version). I've installed IvyBeans plugin (version 1.2). Then I built my project and Ivy has created IvyFiles and IvyLibraries folder inside my project folder (both of them are empty).
The problem is that no libraries are resolved. I obtain following message from builder:
[PATH_TO_PROJECT]\nbproject\ivy-impl.xml:92: settings file does not exist: [PATH_TO_PROJECT]\${ivy.settings.location}
This is the ivy-resolve output:
Resolving COMPILE scope ...
:: loading settings :: url = jar:file:/C:/Users/jakub/.netbeans/7.1.2/modules/ext/ivy-2.1.0.jar!/org/apache/ivy/core/settings/ivysettings.xml
:: resolving dependencies :: IvyThriftApp#IvyThriftApp;1.0
confs: [compile]
:: resolution report :: resolve 6ms :: artifacts dl 0ms
---------------------------------------------------------------------
| | modules || artifacts |
| conf | number| search|dwnlded|evicted|| number|dwnlded|
---------------------------------------------------------------------
| compile | 0 | 0 | 0 | 0 || 0 | 0 |
---------------------------------------------------------------------
Resolving PROCESSOR scope ...
:: loading settings :: url = jar:file:/C:/Users/jakub/.netbeans/7.1.2/modules/ext/ivy-2.1.0.jar!/org/apache/ivy/core/settings/ivysettings.xml
:: resolving dependencies :: IvyThriftApp#IvyThriftApp;1.0
confs: [compile]
:: resolution report :: resolve 3ms :: artifacts dl 0ms
---------------------------------------------------------------------
| | modules || artifacts |
| conf | number| search|dwnlded|evicted|| number|dwnlded|
---------------------------------------------------------------------
| compile | 0 | 0 | 0 | 0 || 0 | 0 |
---------------------------------------------------------------------
Resolving RUNTIME scope ...
:: loading settings :: url = jar:file:/C:/Users/jakub/.netbeans/7.1.2/modules/ext/ivy-2.1.0.jar!/org/apache/ivy/core/settings/ivysettings.xml
:: resolving dependencies :: IvyThriftApp#IvyThriftApp;1.0
confs: [compile, runtime]
:: resolution report :: resolve 3ms :: artifacts dl 0ms
---------------------------------------------------------------------
| | modules || artifacts |
| conf | number| search|dwnlded|evicted|| number|dwnlded|
---------------------------------------------------------------------
| compile | 0 | 0 | 0 | 0 || 0 | 0 |
| runtime | 0 | 0 | 0 | 0 || 0 | 0 |
---------------------------------------------------------------------
Resolving COMPILE_TEST scope ...
:: loading settings :: url = jar:file:/C:/Users/jakub/.netbeans/7.1.2/modules/ext/ivy-2.1.0.jar!/org/apache/ivy/core/settings/ivysettings.xml
:: resolving dependencies :: IvyThriftApp#IvyThriftApp;1.0
confs: [compile, compile-test]
:: resolution report :: resolve 4ms :: artifacts dl 0ms
---------------------------------------------------------------------
| | modules || artifacts |
| conf | number| search|dwnlded|evicted|| number|dwnlded|
---------------------------------------------------------------------
| compile | 0 | 0 | 0 | 0 || 0 | 0 |
| compile-test | 0 | 0 | 0 | 0 || 0 | 0 |
---------------------------------------------------------------------
Resolving RUNTIME_TEST scope ...
:: loading settings :: url = jar:file:/C:/Users/jakub/.netbeans/7.1.2/modules/ext/ivy-2.1.0.jar!/org/apache/ivy/core/settings/ivysettings.xml
:: resolving dependencies :: IvyThriftApp#IvyThriftApp;1.0
confs: [compile, compile-test, runtime, runtime-test]
:: resolution report :: resolve 4ms :: artifacts dl 0ms
---------------------------------------------------------------------
| | modules || artifacts |
| conf | number| search|dwnlded|evicted|| number|dwnlded|
---------------------------------------------------------------------
| compile | 0 | 0 | 0 | 0 || 0 | 0 |
| compile-test | 0 | 0 | 0 | 0 || 0 | 0 |
| runtime | 0 | 0 | 0 | 0 || 0 | 0 |
| runtime-test | 0 | 0 | 0 | 0 || 0 | 0 |
---------------------------------------------------------------------
Is there some misunderstanding from my side of how Apache Ivy works under NetBeans or at all? My vision was that I use some dependencies inside my project - then I build it and Ivy automatically gets the dependencies from the Internet and I dont have to care about adding all external libraries into my project.
Any suggestions how to resolve this problem ?
Thank you very much for help or any recommendations :)
Looks like your ivy resolve is working fine. Within your build file how are using using the resolved jars to populate your ANT project's classpath?
One popular option is to call the ivy retrieve task to populate a local lib directory:
<ivy:retrieve/>
<path id="build.path">
<fileset dir="lib" includes="**/*.jar"/>
</path>
My preference and recommendation is to use ivy's cachepath task:
<ivy:cachepath pathid="build.path"/>
A more complete example (using ivy configurations) is given here:
Ant script to choose between multiple version of classpaths