Lombok plugin is integrated with IJ IDE and I don't see any compilation errors in the service, but while starting the spring boot app getting
Error: java: cannot find symbol. (for setter method).
Is there any additional settings we need to do in IDE for it to understand and recognize the methods?
Adding the below missing plugin section in pom file fixed the issue.
<build>
<plugins>
<plugin>
<configuration>
<annotationProcessorPaths>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.16.20</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
</plugins>
</build>
Related
I created a JHipster project. I would like to run the liquibase changesets manually. By default the changesets are included from the classpath. The changelog is in src/main/resources/config/liquibase/master.xml, and the changesets are in src/main/resources/config/liquibase/changelog.
<?xml version="1.0" encoding="utf-8"?>
<databaseChangeLog
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.5.xsd">
<include file="classpath:config/liquibase/changelog/00000000000000_initial_schema.xml" relativeToChangelogFile="false"/>
<!-- jhipster-needle-liquibase-add-changelog - JHipster will add liquibase changelogs here -->
<!-- jhipster-needle-liquibase-add-constraints-changelog - JHipster will add liquibase constraints changelogs here -->
</databaseChangeLog>
When running mvn liquibase:update, I get an error because the changesets are not in the classpath even though the file exists:
[ERROR] Failed to execute goal org.liquibase:liquibase-maven-plugin:3.5.3:update (default-cli) on project playground: Error setting up or running Liquibase: liquibase.exception.SetupException: classpath:config/liquibase/changelog/00000000000000_initial_schema.xml does not exist -> [Help 1]
So I try to run from the command line by setting the classpath.
liquibase --classpath=src/main/resources --classpath=postgresql-42.1.3.jar
--url=jdbc:postgresql://localhost:5432/playground
--driver=org.postgresql.Driver
--changeLogFile=src/main/resources/config/liquibase/master.xml
--username playground --password=***** update
with the same error: Unexpected error running Liquibase: classpath:config/liquibase/changelog/00000000000000_initial_schema.xml does not exist
A workaround is to remove the reference classpath: in the include part but I would like to avoid to edit the file each time a changeset is added by jhipster when using jhipster entity or jhipster import-jdl.
The solution is to run mvn process-resources before running a liquibase command, so the files under src/main/resources will be in the target/classes folder. And then remove the classpath: part as stated in https://github.com/jhipster/generator-jhipster/pull/6121
well... I faced the same problem due I don't want that jhipster automatically update the production database.
So starting with #Sydney suggestion I decided to write a new profile in POM that changes the 'classpath:' word in process-resources phase, and for that I used an ANT plugin for make an replacement over master.xml file to <empty>. So this was a result:
<profile>
<id>only-liquibase</id>
<build>
<plugins>
<plugin>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-maven-plugin</artifactId>
<version>${liquibase.version}</version>
<configuration>
<changeLogFile>target/classes/config/liquibase/master.xml</changeLogFile>
<driver></driver>
<url></url>
<defaultSchemaName></defaultSchemaName>
<username>dentalaser</username>
<password></password>
<referenceUrl>hibernate:spring:ec.com.dentalaser.domain?dialect=&hibernate.physical_naming_strategy=org.springframework.boot.orm.jpa.hibernate.SpringPhysicalNamingStrategy&hibernate.implicit_naming_strategy=org.springframework.boot.orm.jpa.hibernate.SpringImplicitNamingStrategy</referenceUrl>
<verbose>true</verbose>
<logging>debug</logging>
</configuration>
<dependencies>
<dependency>
<groupId>org.javassist</groupId>
<artifactId>javassist</artifactId>
<version>${javassist.version}</version>
</dependency>
<dependency>
<groupId>org.liquibase.ext</groupId>
<artifactId>liquibase-hibernate5</artifactId>
<version>${liquibase-hibernate5.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
<version>${project.parent.version}</version>
</dependency>
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>${validation-api.version}</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<phase>process-resources</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<echo>Reemplazando el classpath el archivo a desplegar en AWS</echo>
<replace file="${project.build.directory}/classes/config/liquibase/master.xml" token="classpath:" value=""/>
</target>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
After that from command line execute something like this:
./mvnw process-resources liquibase:updateSQL -DskipTests -Dliquibase.url="jdbc:postgresql://<IP>:<PORT>/<DATABASE>" -Dliquibase.password="<supersecret>" -Ponly-liquibase
or this:
./mvnw process-resources liquibase:updateSQL -DskipTests -Dliquibase.url="offline:postgresql" -Ponly-liquibase
I really hope that this help you!!!
I have a web project with a dependency I want to compile on a different profile so it generates some additional files I want on the web project.
To be more specific, a Web project with a Netbeans Application as dependency. The Netbeans project has a deployment profile that created the update center (just a folder with files in it). I want this update center to be added to the war file for deployment.
Is there a way to make the web project build the dependency on this profile so I get the files I need?
Is there other options to make this work?
Update: Example
<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>
<!-- The Basics -->
<groupId>...</groupId>
<artifactId>...</artifactId>
<version>...</version>
<dependencies>
<dependency>
<groupId>project-of-interest</groupId>
<artifactId>project-id</artifactId>
<version>4.0</version>
<type>jar</type>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.6</version>
<configuration>
<webResources>
<resource>
<!-- this is relative to the pom.xml directory -->
<directory>resource2</directory>
</resource>
</webResources>
</configuration>
</plugin>
</plugins>
</build>
</project>
project-of-interest has a deployment profile in which the files I need are generated and somehow resource2 points to the location of those files.
My main issue is making sure the files I need are available.
you can point to specific profile with maven command
mvn clean install -P $profile
we are having such a weird error. Our Tests are running in the local machines (windows) but not running on jenkins (linux).
We get a
Caused by: java.lang.RuntimeException: There was an error in the forked process
java.lang.NoClassDefFoundError:
I'm being looking for solution and got this info on bugzilla
or archive.
Has anybody an idea about this issue and how to solve it?
Thanks
UPDATE
maven-surefire-plugin is also defined in the parent pom.xml for using with cobertura. The Tests are running twice but the second time the tests fails as described above.
I'm defining 2 profiles that are using the surefire-plugin and a surefire plugin definition in the section.
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven-surefire-plugin.version}</version>
<configuration>
<useSystemClassLoader>false</useSystemClassLoader>
<excludes>
<exclude>**/*IntegrationTest.java</exclude>
<exclude>**/*SoapUiTest.java</exclude>
</excludes>
<excludes>
<!--exclude>**/*.java</exclude -->
</excludes>
<additionalClasspathElements>
<additionalClasspathElement>${basedir}/src/main/java</additionalClasspathElement>
</additionalClasspathElements>
</configuration>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>soapUi</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven-surefire-plugin.version}</version>
<configuration>
<excludes>
<exclude>**/*EntityTest.java</exclude>
</excludes>
<includes>
<include>**/*SoapUiTest.java</include>
</includes>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>integration</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven-surefire-plugin.version}</version>
<configuration>
<excludes>
<exclude>**/*EntityTest.java</exclude>
</excludes>
<includes>
<include>**/*IntegrationTest.java</include>
</includes>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
What I'm doing wrong?
I remember having similar issue. It might be related to ulimit - number of allowed opened files. ClassLoader needs to open file for loading. Since class is not loaded/available NoClassDefFoundError is thrown on method call.
Check how many files can be opened:
ulimit -a
To increase number of opened files:
ulimit -n NEW_NUMBER
In order to change it permanently follow instructions from this link
Follow the steps:
vi /etc/security/limits.conf and add below the mentioned
soft nofile 65535
hard nofile 65535
It was an ussue with cobertura itself (-Dcobertura.test=true). Activating it resolved the Problem.
I am using maven-jaxb2-plugin to generate some classes from xsd.
It is defined in child pom as follows:
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>org.jvnet.jaxb2.maven2</groupId>
<artifactId>maven-jaxb2-plugin</artifactId>
<version>0.8.0</version>
<executions>
<execution>
<id>jaxb2-generate</id>
<phase>generate-sources</phase>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
<configuration>
<forceRegenerate>true</forceRegenerate>
<!-- Generate classes from XSD (XML Schema) using JAXB -->
<schemaDirectory>src/main/resources/com/reportcenter/settings/</schemaDirectory>
<generatePackage>com.reportcenter.settings</generatePackage>
<schemaIncludes>
<include>**/*.xsd</include>
</schemaIncludes>
<strict>false</strict>
<extension>true</extension>
<plugins>
<plugin>
<groupId>org.jvnet.jaxb2_commons</groupId>
<artifactId>jaxb2-basics</artifactId>
<version>0.6.2</version>
</plugin>
<plugin>
<groupId>org.jvnet.jaxb2_commons</groupId>
<artifactId>jaxb2-basics-annotate</artifactId>
<version>0.6.2</version>
</plugin>
</plugins>
<args>
<arg>-Xannotate</arg>
<arg>-XtoString</arg>
<arg>-Xcopyable</arg>
</args>
</configuration>
</plugin>
</plugins>
</pluginManagement>
The problem is the jaxb2 is not called from mvn install or mvn compile or mv generate-sources.
If I call mvn jaxb2:generate (as the name of the goal) the classes are created OK.
I looked at some questions here and used the answers provided, but I am still missing something.
Thank you.
Disclaimer: I am the author of the maven-jaxb2-plugin.
Seems like you only configure the plugin in pluginManagement but don't actualy use it in your build part.
This is how it should look like:
<project ...>
...
<build>
<plugins>
...
<plugin>
<groupId>org.jvnet.jaxb2.maven2</groupId>
<artifactId>maven-jaxb2-plugin</artifactId>
<version>0.12.3</version>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
</plugin>
...
</plugins>
</build>
...
</project>
Few other comments on your configuration:
0.8.0 is a very old version, 0.12.3 is the actual one.
With modern Maven you no longer need to configure maven-compiler-plugin with source/target version 1.6.
Do not use forceRegenerate.
Consider using binding files instead of generatePackage.
Current version of jaxb2-basics is 0.9.2.
I ran into an error related to this plugin, and the Eclipse Maven integration.
Most searches for an answer were fruitless, but often lead to this thread. So, I'm going to post the issue, and a workaround here, for any others that run into it.
While using the maven-jaxb2-plugin:0.12.3 plugin correctly in maven on the command line - in Eclipse, source generation would fail with the following error:
Execution default of goal
org.jvnet.jaxb2.maven2:maven-jaxb2-plugin:0.12.3:generate failed: A
required class was missing while executing
org.jvnet.jaxb2.maven2:maven-jaxb2-plugin:0.12.3:generate:
com/sun/xml/bind/api/ErrorListener
Various attempts at adding jar files that contain the class it was looking for would just result in another class missing, going to a rabbit hole of jar file hell and mis-matched classes that wasn't resolvable.
I don't know if the problem here is something that is broken in the Eclipse / M2E integration, or if the problem is in the dependency stack of maven-jaxb2-plugin.
But the solution is to launch Eclipse itself (not the JREs / JDKs installed into eclipse) with a JDK, instead of a JRE.
The easiest way to do that is to add -vm parameter to your eclipse.ini file:
-startup plugins/org.eclipse.equinox.launcher_1.3.0.v20140415-2008.jar
-vm C:\Program Files\Java\jdk1.8.0_31\bin\javaw.exe
--launcher.library plugins/org.eclipse.equinox.launcher.win32.win32.x86_64_1.1.200.v20150204-1316
-product
...snip...
Upgrade to version 0.13.2 +
Kudos to #lexicore for the comment below
The same pom.xml is working with maven-jaxb2-plugin v0.11 but not with v0.12.
<plugin>
<groupId>org.jvnet.jaxb2.maven2</groupId>
<artifactId>maven-jaxb2-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
<configuration>
<extension>true</extension>
<schemaDirectory>${basedir}/src/wsdl</schemaDirectory>
<schemaIncludes>
<schemaInclude>*.wsdl</schemaInclude>
</schemaIncludes>
<bindingDirectory>${basedir}/src/jaxws/</bindingDirectory>
<generateDirectory>${basedir}/target/jaxws/java</generateDirectory>
<strict>false</strict>
<verbose>true</verbose>
<forceRegenerate>true</forceRegenerate>
<args>
<arg>-Xfluent-api</arg>
</args>
<plugins>
<plugin>
<groupId>org.jvnet.jaxb2_commons</groupId>
<artifactId>jaxb2-fluent-api</artifactId>
<version>3.0</version>
</plugin>
</plugins>
</configuration>
</plugin>
The reason is because after the fix#23 null is returned rather than "systemId" in the MavenCatalogResolver.java (line:64)
Caused by: java.lang.NullPointerException
at java.net.URI$Parser.parse(URI.java:3003)
at java.net.URI.<init>(URI.java:578)
at org.jvnet.jaxb2.maven2.resolver.tools.MavenCatalogResolver.getResolvedEntity(MavenCatalogResolver.java:64) at com.sun.org.apache.xml.internal.resolver.tools.CatalogResolver.resolveEntity(CatalogResolver.java:192)
What would be the right configuration for my pom.xml in order to make it work?
Disclaimer: I am the author of the maven-jaxb2-plugin.
Please file an issue here ans send me a sample project to reproduce (the best would be a pull request to tests.
I'll be fixing this ASAP.
I wonder how a passed systemId can be null but it's a bug anyway. Will be fixed ASAP, I just need a test project to reproduce.
Update.
The 0.12.2 release fixes the NPE you're reporting. However, I'm not sure that it fixes your build. It may well be that you have a different problem. I wonder how systemId can be null.
Please send me the reproducing project for further tests.
Generally it would be better for file bugs and issues on GitHub rather than posting on SO.