flywaydb: unable to instantiate jdbc driver - flyway

The JDBC drivers need to be in an non-classpath directory. I'm using Maven to setup the configuration for Flyway DB and migrate as a goal. I provided in jarDir configuration section the location of the JDBC drivers, but when I execute the migrate goal it still does not recognize the JDBC drivers concerned.
<plugin>
<groupId>org.flywaydb</groupId>
<artifactId>flyway-maven-plugin</artifactId>
<version>3.0</version>
<executions>
<execution>
<id>sql-enrichment-setup</id>
<phase>pre-integration-test</phase>
<goals>
<goal>migrate</goal>
</goals>
<configuration>
<url>jdbc:postgresql://localhost/enrichment?charSet=utf8</url>
<user>enrichment</user>
<password>enrichment</password>
<schemas>
<schema>public</schema>
</schemas>
<table>schema_history</table>
<initVersion>1.0</initVersion>
<initDescription>Base Migration</initDescription>
<jarDir>/Users/abc/jars</jarDir>
<skip>${skipITs}</skip>
<locations>
<location>
filesystem:${basedir}/integration-test-helpers/sql/enrichment/migrations
</location>
</locations>
</configuration>
</execution>
</executions>
</plugin>
But, when I execute I still get:
Failed to execute goal org.flywaydb:flyway-maven-plugin:3.0:migrate (sql-enrichment-setup) on project esa-core: org.flywaydb.core.api.FlywayException: Unable to instantiate jdbc driver: org.postgresql.Driver
How do I resolve this issue?

jarDir is not a configuration parameter for the Maven Plugin. It is only available in the command-line tool.
In your case you should add the JDBC driver as a dependency to the plugin. This way it won't show up on the application's classpath.

Related

Alfresco, embed a binary inside the amp

I have an alfresco community amp module, which also need a client msi to be installed on the client PC.
To solve the distribution problem I tought about embedding the installer inside the amp to give the user the possibility to download it and install it when needed.
It is a correct approach? and which is the best correct to put the biniry file in?
The file should be downloaded from a link inside alfresco share, displayed when the user permorm some actions on a document
I have resolved my problem with maven-resoures-plugin configured as followed. Maybe this is not the best options, but it worked.
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<executions>
<execution>
<id>copy-resources</id>
<!-- here the phase you need -->
<phase>validate</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<nonFilteredFileExtensions>
<nonFilteredFileExtension>msi</nonFilteredFileExtension>
</nonFilteredFileExtensions>
<resources>
<resource>
<directory>/src/main/myLib</directory>
<filtering>false</filtering>
</resource>
</resources>
<outputDirectory>${basedir}/target/amp/web/myShare/js/myLib/</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>

Javafx application doesnt work after install

I'm creating new JavaFX application. I have done it, now i need to build exe file. After build I have installed it, then i launch the program and nothing. There is no application window, it was showing only in task manager...
Project have no errors, just some warrnings. I'am using http connections in it, maybe i need to declare permissions or something? Where can i do it if it's a problem?
I've tried to generate new build.xml, include newest sdk/jre, installed new version of java in my computer.
Java cannot build an exe file by itself. Every client who needs to run the application needs an appropriate JRE installed to run the application. Therefore you would need some software that packages the jar and the JRE into an exe file to install it or packages the jar and JRE into one single exe file which executes your program.
It has nothing to do with your http connections or build.xml.
However your app will run when you call it via the command line java -jar YOUR_APP.jar
If you just want to run your program by double clicking the jar file (and not build an exe), you can take a look at the following paragraphs.
For Maven
If you are building your project with Maven you can try the following POM settings to have your program be executable from the jar file (double click the jar file to start the JavaFX application):
[...]
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>com.zenjava</groupId>
<artifactId>javafx-maven-plugin</artifactId>
<version>8.1.4</version>
<configuration>
<mainClass>PATH TO YOUR MAIN CLASS (e.g. com.foo.Main)</mainClass>
<allPermissions>true</allPermissions>
</configuration>
<executions>
<execution>
<id>create-jfxjar</id>
<phase>package</phase>
<goals>
<goal>build-jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>PATH TO YOUR MAIN CLASS (e.g. com.foo.Main)</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
[...]
I recommend you exporting it as an jar file because it can be excecuted on linux, too and it fixes your problem because it can contain all the data you need just like fxmls!
Just export your project as an runnable jar and this window will appear!
Click here! I don't have enough reputation (but it works ;) )
And now you are finished!

Publish spring-restdocs html documentation with application

I have spring-boot application with spring-restdocs and I want to create endpoint in that application for generated documentation. What is the best approach to expose endpoint with generated html documentation(by asciidoctor)?
I can include index.html to jar-file but don't really know how to create endpoint that will consume that html and expose outside.This html generated after test-stage and before build-jar-stage.
From official documentation:
You could publish the HTML documentation you created to a static website, or package it up and serve it from the application itself.
e.g. I have index.html in 'build/asctiidoctor/html5' folder and want to create controller that will return that index.html.
According to documentation you can configure your build system (Maven, Gradle) to package HTML into spring-boot jar as static content so that it will be served by Spring Boot 'automagically'
In case of Gradle 4.6 and Spring Boot 2.0.0.RELEASE:
bootJar {
dependsOn asciidoctor
from ("${asciidoctor.outputDir}/html5") {
into 'static/docs'
}
}
Then it can be verified locally via 'localhost:<your-port>/<your-context-path/docs/index.html
To access the api guide locally using spring boot using the url http://localhost:8081/docs/api-guide.html , add the following plugins:
<plugin>
<groupId>org.asciidoctor</groupId>
<artifactId>asciidoctor-maven-plugin</artifactId>
<version>${asciidoctor-maven-plugin.version}</version>
<executions>
<execution>
<id>generate-docs</id>
<phase>post-integration-test</phase>
<goals>
<goal>process-asciidoc</goal>
</goals>
<configuration>
<backend>html</backend>
<doctype>book</doctype>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.springframework.restdocs</groupId>
<artifactId>spring-restdocs-asciidoctor</artifactId>
<version>${spring-restdocs.version}</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>${maven-resources-plugin.version}</version>
<executions>
<execution>
<id>copy-resources</id>
<phase>post-integration-test</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>
${project.build.outputDirectory}/static/docs
</outputDirectory>
<resources>
<resource>
<directory>
${project.build.directory}/generated-docs
</directory>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>`
After generating html out of the AsciiDoc just copy the html files into target/generated-docs (see https://spring.io/guides/gs/testing-restdocs/). Spring-Boot then will take and host the documentation within the endpoint <...>/docs/index.html.
You could use maven-resources-plugin for this job.

Disable auto compilation of LESS

I am in Eclipse environment. I want LESS to compile only when explicitly invoked via mvn package. At the moment, as soon as I make any changes in my less file it propagates the change to CSS. What should I do to avoid this behaviour?
<plugin>
<groupId>org.lesscss</groupId>
<artifactId>lesscss-maven-plugin</artifactId>
<version>1.7.0.1.1</version>
<configuration>
<watch>false</watch>
<sourceDirectory>src/main/webapp/css</sourceDirectory>
<outputDirectory>src/main/webapp/css</outputDirectory>
<compress>true</compress>
<force>true</force>
</configuration>
<executions>
<execution>
<goals>
<goal>compile</goal>
</goals>
<phase>package</phase>
</execution>
</executions>
</plugin>
also posted this issue here
As a workaround I have encapsulated LESS plugin inside a profile. On server side I invoke that profile to do LESS compilation
mvn package -pless_compile
M2Eclipse is an Eclipse plugin which provides tight integration for Maven. It determines who and when plugins should be executed. Each plugin can store lifecycle mapping metadata with data on which it based its decision (see M2E compatible maven plugins). By default this plugin is called on incremental builds:
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<goals>
<goal>compile</goal>
</goals>
</pluginExecutionFilter>
<action>
<execute>
<runOnIncremental>true</runOnIncremental>
<runOnConfiguration>false</runOnConfiguration>
</execute>
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
If you want to disable automatic compilation, then you need to add the following entry to your pom.xml:
<pluginManagement>
<plugins>
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>org.lesscss</groupId>
<artifactId>lesscss-maven-plugin</artifactId>
<versionRange>[0,)</versionRange>
<goals>
<goal>compile</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore />
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>
You need to define in which maven phase you want to execute your plugin, basically adding the phase tag under the execution tag. Take look to the following examples: http://maven.apache.org/guides/mini/guide-configuring-plugins.html#Using_the_executions_Tag.

Getting JNotify into Maven/Archiva

I am currently working on a project that includes using JNotify to monitor when a directory/file has been created, renamed/modified, and deleted. The project is being built in Java 6, not Java 7. JNotify uses JNI to hook into the native OS to monitor the directory/file. My problem is that I need to get JNotify into our repo but I want it to be built so that the java.library.path (DLL) is packaged with the JNI JAR. How would I go about doing that in Maven?
I was able to find the solution I needed using the following maven plugin: http://code.google.com/p/mavennatives/
You must probably upload the jar manually to your archiva instance.
The repository format is fixed, so you will need to perform the rename after retrieving the artifact. That depends how you intend to use it after it is retrieved.
This is a common pattern is something like this:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<configuration>
<stripVersion>true</stripVersion>
</configuration>
<executions>
<execution>
<id>copy-jnotify</id>
<configuration>
<includeArtifactIds>JNotify</includeArtifactIds>
<outputDirectory>${project.build.directory}/my-app</outputDirectory>
</configuration>
<goals>
<goal>copy-dependencies</goal>
</goals>
</execution>
</executions>
</plugin>
You can use this with the appropriate list of artifacts that will all be copied into the target/my-app directory

Resources