"Cannot find database driver: Driver class was not specified and could not be determined from the url" error on using liquibase-hibernate plugin - liquibase

I am trying to generate changeLog from diffs between a Database and Persistence Entities.
I am using the liquibase hibernate plugin
<plugins>
<plugin>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-maven-plugin</artifactId>
<version>3.4.1</version>
<configuration>
<propertyFile>src/main/resources/liquibase.properties</propertyFile>
</configuration>
<dependencies>
<dependency>
<groupId>org.liquibase.ext</groupId>
<artifactId>liquibase-hibernate4</artifactId>
<version>3.5</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>4.1.7.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-jpa</artifactId>
<version>1.7.3.RELEASE</version>
</dependency>
</dependencies>
</plugin>
</plugins>
and my liquibase.properties goes like this
changeLogFile=classpath:liquibase-changeLog.xml
url=jdbc:postgres://localhost:5432/oauth_reddit
username=tutorialuser
password=tutorialmy5ql
driver=org.postgresql.Driver
referenceUrl=com.sample.App
?dialect=org.hibernate.dialect.PostgreSQLDialect
diffChangeLogFile=src/main/resources/liquibase-diff-changeLog.xml
while executing mvn liquibase:diff, I am getting the following error
[ERROR] Failed to execute goal org.liquibase:liquibase-maven-plugin:3.4.1:diff (default-cli) on project prototype-liquibase-migration: Error setting up or running Liquibase: liquibase.exception.DatabaseException: java.lang.RuntimeException: Cannot find database driver: Driver class was not specified and could not be determined from the url (com.sample.App?dialect=org.hibernate.dialect.PostgreSQLDialect) -> [Help 1]
I have specified the Driver in the liquibase properties, but it seems that it is not taking.What could have I done wrong ?

The problem was with my referenceUrl in liquibase.properties The referenceUrl is using package scan, so the url has to start with hibernate:spring:.
I changed
referenceUrl=com.sample.App?=org.hibernate.dialect.PostgreSQLDialect
into
referenceUrl=hibernate:spring:com.sample.App?dialect=org.hibernate.dialect.PostgreSQLDialect
This solved my problem.

Related

tycho-maven-plugin 3.0.0 Failed to collect dependencies

I'm trying to migrate to tycho 3.0.0 and get
Failed to collect dependencies at org.eclipse.tycho:tycho-maven-plugin:jar:3.0.0 -> org.eclipse.platform:org.eclipse.core.runtime:jar:3.12.0 -> org.eclipse.platform:org.eclipse.equinox.preferences:jar:3.10.0 -> org.osgi.service:org.osgi.service.prefs:jar:[1.1.0,1.2.0)
Obviously this is related to maven-build-failed-due-to-jdt-dependencies-no-versions-available-for-org-osgi
Any attempt to force org.eclipse.equinox.preferences to resolve to something above 3.10.0 failed.
The following worked for org.eclipse.core.runtime (forced version 3.26.0) but not for org.eclipse.equinox.preferences
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-maven-plugin</artifactId>
<version>3.0.0</version>
<extensions>true</extensions>
<dependencies>
<dependency>
<groupId>org.eclipse.platform</groupId>
<artifactId>org.eclipse.core.runtime</artifactId>
<version>3.26.0</version>
</dependency>
<dependency>
<groupId>org.eclipse.platform</groupId>
<artifactId>org.eclipse.equinox.preferences</artifactId>
<version>3.10.100</version>
</dependency>
</dependencies>
</plugin>
The problem turned out to be an issue of the repository manager (archiva 2.2.4), which seems to provide the wrong versions. So I was completely on the wrong track.

Liquibase coming with Spring Boot handles the database well with changelog.xml. How can it generate its sql at the same time?

I'm using the default Liquibase configuration coming with Spring Boot.
I have:
a changelog.xml file in src/main/resources/db/changelog that works fine,
along with url, changeLogFile, driver, username, password properties in application.properties,
and a Maven pom.xml having this for <dependency> and <dependencyManagement>:
<dependencies>
...
<dependency>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-core</artifactId>
<scope>runtime</scope>
</dependency>
</dependencies>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-maven-plugin</artifactId>
<configuration>
<promptOnNonLocalDatabase>true</promptOnNonLocalDatabase>
<propertyFile>${project.basedir}/../ApplicationMetierEtGestion/src/main/resources/application.properties</propertyFile>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
Aside from the update of the database structure led by changelog.xml that is working fine at development time, I would like Liquibase to generate also the related SQL files (by the mean of its updateSQL command).
This, because the next environments might not have Liquibase to handle the database updates.
How can I do that from here?
Liquibase has a goal that generates this SQL for you which is called updateSQL.
Have a look as it might be interesting in your case.
https://docs.liquibase.com/tools-integrations/maven/commands/maven-updatesql.html

failed to resolve junit platform launcher 1.6.3 intellij

I am trying to run tests in Intellij which used to work earlier in spring boot 2.2.x. I recently upgraded to spring boot 2.3.9. When I try to run the test from Run Configurations, it doesn't run the test and throws the error:
'failed to resolve junit platform launcher 1.6.3 intellij'.
However if I run the test in cli, it works fine.
It turns out that, junit5-platform-launcher dependency needs to be added in order for Junit5 tests to run in IntelliJ.
https://youtrack.jetbrains.com/issue/IDEA-231927?_ga=2.5997872.2063517257.1613993298-1098513328.1597974168
https://junit.org/junit5/docs/current/user-guide/#running-tests-ide-intellij-idea
Add this dependency explicitly in pom.xml, and it will solve the issue.
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-launcher</artifactId>
<scope>test</scope>
</dependency>
I was facing same issue "failed to resolve junit platform launcher 1.8.1" intellij.
IntellJ version: 2021.3
I found answer here and it worked, no need to add any dependency to pom.
Go to settings >> HTTP Proxy >> choose auto-detect proxy settings
For IntelliJ Idea 2021.1, I fixed a similar problem with:
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-launcher</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
<scope>test</scope>
</dependency>
Maybe an even better fix is:
<dependencyManagement>
<dependencies>
<!-- https://mvnrepository.com/artifact/org.junit/junit-bom -->
<dependency>
<groupId>org.junit</groupId>
<artifactId>junit-bom</artifactId>
<version>5.7.1</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
Found the above solution on Jetbrains issue tracker
If you have no direct internet connection but a repository manager like artifactory, idea tries to resolve junit-platform-launcher from there. Make sure u have a mirror to maven central repository (virtual repository) configured and the artifactory url to this mirror is accessible WITHOUT authentication (in the settings for the repo "Force Authentication" should be unchecked).
Check also the idea proxy settings and if needed, configure an exception for the artifactory domain.
Check your proxy settings in IntelliJ Idea settings. I turned ON the proxy and it solved the problem.
Here's the official way to do this
Maven Surefire and Maven Failsafe can run JUnit 4 based tests
alongside Jupiter tests as long as you configure test scoped
dependencies on JUnit 4 and the JUnit Vintage TestEngine
implementation similar to the following.
<!-- ... -->
<build>
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.2</version>
</plugin>
<plugin>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.22.2</version>
</plugin>
</plugins>
</build>
<!-- ... -->
<dependencies>
<!-- ... -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
<version>5.7.2</version>
<scope>test</scope>
</dependency>
<!-- ... -->
</dependencies>
<!-- ... -->

Running Karate tests from commandline returns surefire-plugin error

I've been trying to run my .feature karate files from command line. I've been trying to follow the docs, so that I've found below instruction:
mvn test -Dtest=CatsRunner
When I run above command, I see that my tests are running, and all of them are passing. However, there are some errors being popped up at the end of my command line. Below is the log part:
1 Scenarios (1 passed)
16 Steps (16 passed)
0m2.388s
Karate version: 0.8.0
html report: (paste into browser to view)
-----------------------------------------
file:/D:/Dev/xxx/yyy/karate/target/surefire-reports/TEST-tvplus.singleuseroperations.authenticate.auth-existing-IPTV-user.html
[INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 4.302 s - in tvplus.singleuseroperations.authenticate.AuthenticateRunner
[INFO]
[INFO] Results:
[INFO]
[INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 14.204 s
[INFO] Finished at: 2018-12-12T15:50:06+03:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.22.1:test (default-test) on project karate: No tests were executed!
(Set -DfailIfNoTests=false to ignore this error.) -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1]
http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
I am also pasting my pom file below:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.xxx.yyy.zzz</groupId>
<artifactId>karate</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>
<maven.compiler.version>3.6.0</maven.compiler.version>
<karate.version>0.8.0</karate.version>
<jdbc.version>5.1.3.RELEASE</jdbc.version>
<maven.surefire.version>2.22.1</maven.surefire.version>
</properties>
<dependencies>
<dependency>
<groupId>com.intuit.karate</groupId>
<artifactId>karate-apache</artifactId>
<version>${karate.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.intuit.karate</groupId>
<artifactId>karate-junit4</artifactId>
<version>${karate.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>${jdbc.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc6</artifactId>
<version>11.2.0.4</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.intuit.karate</groupId>
<artifactId>karate-testng</artifactId>
<version>${karate.version}</version>
</dependency>
<dependency>
<groupId>com.intuit.karate</groupId>
<artifactId>karate-core</artifactId>
<version>${karate.version}</version>
</dependency>
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.12.4</version>
</dependency>
</dependencies>
<build>
<testResources>
<testResource>
<directory>src/test/java</directory>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</testResource>
</testResources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven.compiler.version}</version>
<configuration>
<encoding>UTF-8</encoding>
<source>${java.version}</source>
<target>${java.version}</target>
<compilerArgument>-Werror</compilerArgument>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven.surefire.version}</version>
<configuration>
<argLine>-Dfile.encoding=UTF-8</argLine>
</configuration>
</plugin>
</plugins>
</build>
Also, here is my CatsRunner.java:
package xyz;
import com.intuit.karate.junit4.Karate;
import cucumber.api.CucumberOptions;
import org.junit.runner.RunWith;
#RunWith(Karate.class)
#CucumberOptions(features = "classpath:xxx/singleuseroperations/authenticate/auth-existing-user.feature")
public class CatsRunner {
}
EDIT: Below part is not related with the question. No need to think about it. Upgrading karate version solved the problem.
I've been using #CucumberOptions at the top of my runner class since I've encountered some trouble when adding #KarateOptions annotation to my code.
Thanks in advance.
To eliminate the surefire-plugin error, you may want to add DfailIfNoTests=false to your command line run script. Surefire pluging integrates with the tests you've written. This option will compile and run your tests, but not fail the whole build if some of the tests fail.
The #KarateOptions is available only in 0.9.0: https://github.com/intuit/karate/releases/tag/v0.9.0
EDIT: If you simplify your pom.xml and avoid using things not needed for Karate you will be able to solve the problem with "surefire-plugin". This is what I have been trying to explain by pointing you to this link: https://github.com/intuit/karate/wiki/How-to-Submit-an-Issue

Maven bundle packaging problem, known as MNG-4338

I'm having trouble with the maven-bundle-plugin:
I want to deploy my project as a osgi bundle, wherefore I use the packaging as bundle.
But it seems that the pom does not know a packaging as a bundle. Here you can see my pom.xml:
<project ...>...
<packaging>bundle</packaging>
<version>1.0.0</version>
<name>Simple CXF project using spring configuration</name>
<properties>
<cxf-version>2.4.2</cxf-version>
</properties>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
<version>2.3.5</version>
<configuration>
<instructions>
<Bundle-SymbolicName>${project.groupId}.${project.artifactId}</Bundle-SymbolicName>
<Bundle-Name>${project.name}</Bundle-Name>
<Bundle-Version>${project.version}</Bundle-Version>
<Export-Package>demo.hw.server</Export-Package>
<Bundle-Activator>demo.hw.server.Activator</Bundle-Activator>
<Require-Bundle>org.apache.cxf.bundle</Require-Bundle>
</instructions>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
<dependencies>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
<version>${cxf-version}</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
<version>${cxf-version}</version>
</dependency>
<dependency>
<groupId>org.apache.felix</groupId>
<artifactId>org.osgi.core</artifactId>
<version>1.4.0</version>
</dependency>
</dependencies>
</project>
They say, this bug has already been fixed (http://jira.codehaus.org/browse/MNG-4338), but to me it seems it hasn't. Has anyone encountered this problem before and found a solution?
The Error message is like this:
[INFO] Scanning for projects...
[ERROR] The build could not read 1 project -> [Help 1]
[ERROR]
[ERROR] The project com.talend.liugang.cxf:java_first_jaxws:1.0.0 (C:\Users\Andreas\workspace\java_first_jaxws\pom.xml) has 1 error
[ERROR] Unknown packaging: bundle # line 7, column 13
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/ProjectBuildingException
Best regards,
saen
Given your pom example above, you should just move the maven-bundle-plugin outside of the <pluginManagement> node. <pluginManagement> is normally used for inheritance purposes in parent poms. The bundle packaging type is provided by the maven-bundle-plugin (which is why you need <extensions>true</extensions>), so this plugin is required to be outside <pluginManagement> in this case.
<project ...>...
<packaging>bundle</packaging>
<version>1.0.0</version>
<name>Simple CXF project using spring configuration</name>
<properties>
<cxf-version>2.4.2</cxf-version>
</properties>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
<version>2.3.5</version>
<configuration>
<instructions>
<Bundle-SymbolicName>${project.groupId}.${project.artifactId}</Bundle-SymbolicName>
<Bundle-Name>${project.name}</Bundle-Name>
<Bundle-Version>${project.version}</Bundle-Version>
<Export-Package>demo.hw.server</Export-Package>
<Bundle-Activator>demo.hw.server.Activator</Bundle-Activator>
<Require-Bundle>org.apache.cxf.bundle</Require-Bundle>
</instructions>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
<version>${cxf-version}</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
<version>${cxf-version}</version>
</dependency>
<dependency>
<groupId>org.apache.felix</groupId>
<artifactId>org.osgi.core</artifactId>
<version>1.4.0</version>
</dependency>
</dependencies>
</project>
Yeap, the issue is that <groupId>org.apache.felix</groupId> needs to be outside of the <pluginManagement>.
I see a similar issue. It occurs to me that it happens when the group id ends like the artifact id starts. I try to bundle something like that:
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api.plugin</artifactId>
The slf4j from the artifact id is deleted at it ends up like: org.slf4j.api.plugin in the Manifest as symbolic name.