How to get EclipseLink 2.6.0-m3 working with Jersey 1.18.3 - eclipselink

when using jersey moxy
<!-- Jersey moxy -->
<dependency>
<groupId>com.sun.jersey.contribs</groupId>
<artifactId>jersey-moxy</artifactId>
<version>1.18.3</version>
<scope>provided</scope>
</dependency>
together with eclipse link 2.6.0-M3
<!-- Eclipse Link persistence -->
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>eclipselink</artifactId>
<!-- <version>2.4.2-RC1</version> -->
<!-- <version>2.5.1-RC3</version> -->
<!-- <version>2.5.1</version> -->
<!-- <version>2.5.2-M1</version> -->
<!-- <version>2.5.2</version> -->
<version>2.6.0-M3</version>
<exclusions>
<exclusion>
<artifactId>commonj.sdo</artifactId>
<groupId>commonj.sdo</groupId>
</exclusion>
</exclusions>
</dependency>
i get
java.lang.NoClassDefFoundError: javax/validation/ConstraintViolationException
at org.eclipse.persistence.jaxb.JAXBMarshaller.<init>(JAXBMarshaller.java:102)
at org.eclipse.persistence.jaxb.JAXBContext$JAXBContextState.createMarshaller(JAXBContext.java:1527)
at org.eclipse.persistence.jaxb.JAXBContext.createMarshaller(JAXBContext.java:385)
at org.eclipse.persistence.jaxb.JAXBContext.createMarshaller(JAXBContext.java:1)
i tried to work-around the issue by changing the order in my pom.xml and that
works in some of my projects. In a nested environment where some projects depend on another the issue showed up again.
http://dev.eclipse.org/mhonarc/lists/eclipselink-users/msg08372.html
suggest that a dependeny might be missing so I added:
<!--
http://dev.eclipse.org/mhonarc/lists/eclipselink-users/msg08372.html
http://mvnrepository.com/artifact/javax.validation/validation-api/1.1.0.Final
-->
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>1.1.0.Final</version>
</dependency>
right where the eclipselink dependency shows up. This seems also to help.
Is this really a bug? What would be a "proper" way to solve this issue?
Unfortunately there is no option for me to upgrade Jersey to 2.x since there are too many incompatibilities and (as I hear) bugs.

The proper way to solve this issue is to add javax.validation:validation-api dependency.
Bean validation is new feature in EclipseLink 2.6.0 as stated in Design Doc https://bugs.eclipse.org/bugs/attachment.cgi?id=241506
The result is, that there is now required dependency.
I have filed new enhancement request against EclipseLink to make this dependency optional.
https://bugs.eclipse.org/bugs/show_bug.cgi?id=460330

Related

Spring doesn't see h2 database hence complain about database not available

I'm building a simple reactive web application ( Following Josh long's tech talk ) Simply put I have reactive web, r2dbc and h2 as dependencies.
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webflux</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-r2dbc</artifactId>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.projectreactor</groupId>
<artifactId>reactor-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
So I expect spring would configure everything for me( It does for Josh ). But I get error saying not being able to connect to a database and there is a suggestion asking to include h2(which I already have). What am I doing wrong here?
Description:
Failed to configure a ConnectionFactory: 'url' attribute is not specified and no embedded database could be configured.
Reason: Failed to determine a suitable R2DBC Connection URL
Action:
Consider the following:
If you want an embedded database (H2), please put it on the classpath.
If you have database settings to be loaded from a particular profile you may need to activate it (no profiles are currently active).
Ok it was missing r2dbc-h2 dependency. This happened because I didn't add r2dbc when I created the project with start.spring.io then added it and inspect the pom but only copied spring-boot-starter-data-r2dbc.
<dependency>
<groupId>io.r2dbc</groupId>
<artifactId>r2dbc-h2</artifactId>
<scope>runtime</scope>
</dependency>
Still bit confusing though. Spring boot says it looks in to the class path and auto configure dependencies but seems like sometimes it need given combination of dependencies.

How can I implement log4j2 (2.14.0) 'JSON Template Layout' in a mule application?

Log4j2 has implemented a 'JSON Template Layout'. I have been able to implemented this in a standard maven java application, however I am not able to implement it in a Mule 4.3 application. I have added the log4j2 (2.14.0) dependencies to my POM:
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>2.14.0</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.14.0</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-layout-template-json</artifactId>
<version>2.14.0</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.12.1</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.12.1</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>2.12.1</version>
</dependency>
Log4j2 Appender Config
<Appenders>
<Console name="CONSOLE" target="SYSTEM_OUT">
<JsonTemplateLayout />
</Console>
</Appenders>
And I see that they are loaded in the log, but I get an error:
2021-02-06 07:17:39,175 WrapperListener_start_runner DEBUG Building Plugin[name=layout, class=org.apache.logging.log4j.layout.template.json.JsonTemplateLayout].
2021-02-06 07:17:39,179 WrapperListener_start_runner ERROR Could not create plugin of type class org.apache.logging.log4j.layout.template.json.JsonTemplateLayout for element JsonTemplateLayout: java.util.UnknownFormatConversionException: Conversion = 'interface org.apache.logging.log4j.layout.template.json.util.RecyclerFactory' java.util.UnknownFormatConversionException: Conversion = 'interface org.apache.logging.log4j.layout.template.json.util.RecyclerFactory'
at org.apache.logging.log4j.core.config.plugins.convert.TypeConverterRegistry.findCompatibleConverter(TypeConverterRegistry.java:103)
at org.apache.logging.log4j.core.config.plugins.convert.TypeConverters.convert(TypeConverters.java:412)
at org.apache.logging.log4j.core.config.plugins.visitors.AbstractPluginVisitor.convert(AbstractPluginVisitor.java:151)
Is Mule somehow dynamically loading an older version of log4j2 that does not implement the 'JSON Template Layout'?
Mule 4 provides log4j2 to applications. It is one of few libraries that actually may override application's libraries in Mule 4. You should use what is provided. Do not try to change any provided libraries with different versions, that is not supported.

cannot resolve symbol "CucumberOptions" in IntelliJ

I am seeing "cannot resolve CucumberOptions" error in IntelliJ even after adding "cucumber-java" and "cucumber-junit" to my pom.xml
After spending lot of time, I found the issue with the dependency in pom.xml
You need to add "cucumber-core" in addition to "cucumber-java" and "cucumber-junit"
<!-- https://mvnrepository.com/artifact/info.cukes/cucumber-core -->
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-core</artifactId>
<version>1.2.5</version>
</dependency>

Exclude org.codehouse.jackson.* from my War on Wildfly 8.2.0 to use com.fasterxml.jackson.*

I try to use the com.fasterxml.jackson for my JSON Deserialization and Serialization. I put the dependencies for the com.fasterxml version in the pom.xml of my war-project and also added the org.jboss.resteasy.resteasy-jackson2-provider dependency there. However my WildFly throws the exception that it can not find the class org.codehouse.jackson.jaxrs.JacksonJsonProvider. I also tried excluding the resteasy-jackson-provider in my jboss-deployment-structure.xml and added the new resteasy-jackson2-provider as dependency with the service-attribute set to "import" as i found on some previous questions. None of this resolved my problem. The important files (hope i did not miss one):
Jboss-deployment-structure:
<jboss-deployment-structure>
<deployment>
<exclusions>
<module name="org.jboss.resteasy.resteasy-jackson-provider"/>
<module name="org.jboss.resteasy.resteasy-json-provider"/>
</exclusions>
<dependencies>
<module name="org.jboss.resteasy.resteasy-jackson2-provider" services="import"/>
</dependencies>
</deployment>
</jboss-deployment-structure>
Dependencies from pom.xml:
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-jackson2-provider</artifactId>
<version>3.0.10.Final</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.4.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>2.4.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.4.1</version>
<scope>provided</scope>
</dependency>
EDIT: I noticed that there are several duplicate jars in my war (including the resteasy-jackson-provider). To fix this i tried to exclude as much general poms (for example wildfly-parent) from my poms as possible. I now have only the directly necessary dependencies in my poms and the issue still stands (multiple jars i did not include or include with the scope provided in my war). Does anybody have an idea why this might occure?
EDIT 2: Issue is fixed there was a problem with my maven script, which did not clean the war... stupid mistake by my part
I faced the same problem too
Im' not really sure about it but when i tryed i found out that Wildfly has packaged all his module under javaee.api so you couldn't exclude any module or have to exclude all. You have to upgrade your Wildfly version and upgrade package.
I can tell you at least than in the most recent version they use fasterxml. So if you don't need a specific version of fasterXML's jackson, just upgrade wildfly.
For anyone who arrives here I would like to comment that, for me, the key has been this exclusions, expecially important the second one:
<exclusions>
<module name="org.jboss.resteasy.resteasy-jackson-provider"/>
<module name="org.jboss.resteasy.resteasy-json-binding-provider"/>
</exclusions>
So, I hope this can be helpfull for somebody.

Maven/Ivy: Identical artifact with different name in dependency

Currently I am using Ivy for dependency management. And quite often I come across problem of getting identical jar files with different name due to transitive dependency.
Example:
<dependency>
<groupId>javax.mail</groupId>
<artifactId>mail</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-javamail_1.4_spec</artifactId>
<version>1.4</version>
</dependency>
I am thinking of trying out Maven as well.
Any best practice to eliminate these identical artifact in either Ivy or Maven?
Global exclusion of artifacts would be a nice feature to deal with this kind of situation - same artifact with different names - until Maven provides a better way to deal with "Specs JARs" aka Virtual Dependencies.
Unfortunately, such a feature is currently not available (see MNG-3196 and MNG-1977) so you will have to declare dependency exclusions to exclude the unwanted artifact from the dependency pulling it transitively. In Maven, this is done by adding an <exclusions> tag under the <dependency> section of the pom.
<project>
...
<dependencies>
<dependency>
<groupId>sample.ProjectA</groupId>
<artifactId>Project-A</artifactId>
<version>1.0</version>
<scope>compile</scope>
<exclusions>
<exclusion> <!-- declare the exclusion here -->
<groupId>sample.ProjectB</groupId>
<artifactId>Project-B</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
</project>
If Project-A-1.0.jar is used by all projects, one possible solution would be to declare this under the dependencyManagement section of a corporate POM to not repeat yourself.
In this particular example i would select the the javax one. And if you have artifacts which are coming under different names you can use excludes in Maven. I don't know if this is possible in Ivy.