How to easily upgrade Karate Version? - karate

I would like to upgrade to Karate 0.9.0 which is released recently. How can i do this easily. My existing .pom file contains many dependencies in 0.8.0 version. Should i replace each with updated one? Or, is there a better way to do this?
And again, i can see many RC versions of dependencies in maven repository which one's stable?
And, Finally, Is there any separate dependency for KarateOptions? Because, I was using 0.8.0 and was not able to find any dependency jars for this.

This is actually a maven question. But yes the recommended practice is to define a maven "property" once and then use it in the multiple places.
I'm surprised, because at the max you should have only 2.
<properties>
<karate.version>0.9.0</karate.version>
</properties>
<dependencies>
<dependency>
<groupId>com.intuit.karate</groupId>
<artifactId>karate-apache</artifactId>
<version>${karate.version}</version>
</dependency>
<dependency>
<groupId>com.intuit.karate</groupId>
<artifactId>karate-junit4</artifactId>
<version>${karate.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
And yes, KarateOptions is new in 0.9.0 - please read the release notes carefully and you don't even need to change that immediately when you upgrade: https://github.com/intuit/karate/releases/tag/v0.9.0

Related

karate-config.js failed after update of karate-core

I'm trying to update my karate project with the newest version of karate-junit5 library.
In the documentation for Maven it's mentioned that only one dependency is required to run karate.
<dependency>
<groupId>com.intuit.karate</groupId>
<artifactId>karate-junit5</artifactId>
<version>1.3.0</version>
<scope>test</scope>
</dependency>
Previously I was using karate-jersey and karate-junit4 and everything was working flawless.
<dependency>
<groupId>com.intuit.karate</groupId>
<artifactId>karate-jersey</artifactId>
<version>0.9.6</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/com.intuit.karate/karate-junit5 -->
<dependency>
<groupId>com.intuit.karate</groupId>
<artifactId>karate-junit4</artifactId>
<version>0.9.6</version>
<scope>test</scope>
</dependency>
I managed to update karate-junit4 to karate-junit5 but I see that karate-core is still using 0.9.6
When I want to replace jersey with karate-core 1.3.0 and run my tests I have an error with loading my karate-config.js
karate-config.js failed
js failed:
org.graalvm.polyglot.PolyglotException: SyntaxError: Unnamed:82:0 Expected ) but found function
This is strange because I didn't change anything besides the dependencies.
Do I still have to use karate-jersey in my project? The documentation doesn't mention this.
I tried to update the dependency to the newest version. Now I got a failing karate-config.js
There's no such thing as karate-jersey. Get rid of that dependency, the HTTP client is now built-in.
Since you are upgrading from such an old version, you need to read all the release notes. For example this one: https://github.com/karatelabs/karate/wiki/1.0-upgrade-guide#java-projects
But let's hope you get by with just this one change. Else be prepared to scan all the release notes. The JS engine has changed, but all those who kept tracking the project and tried RC versions (we spend a lot of time on this) have been having a smooth experience.
I guess this is what folks call "technical debt" ;)

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.

NoClassDefFoundError using with boxable plugin

I am using boxable plugin with pdfbox and I am trying to create a teble. I am getting error:
2015-09-09T10:36:52.453+0200|Severe: java.lang.NoClassDefFoundError: org/apache/pdfbox/pdmodel/edit/PDPageContentStream
at the line of code:
BaseTable table = new BaseTable(yStart,yStartNewPage, bottomMargin, tableWidth, margin, doc, page, true, drawContent);
Here is a part from pom.xml, describing the dependencies that I am using:
<dependency>
<groupId>org.apache.pdfbox</groupId>
<artifactId>pdfbox</artifactId>
<version>2.0.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.github.dhorions</groupId>
<artifactId>boxable</artifactId>
<version>1.2</version>
</dependency>
Is there a bug in current version of dependencies or am I missing something?
Thank you very much for any help.
Remove this:
<dependency>
<groupId>org.apache.pdfbox</groupId>
<artifactId>pdfbox</artifactId>
<version>2.0.0-SNAPSHOT</version>
</dependency>
2.0 is an unreleased version and is in development, and it has a different API. Boxable has its dependencies in its own pom.xml, it is currently requesting 1.8.8. (Which is not the latest version, but I don't think this matters for simple PDF creation)

apache mime4j maven dependency for 0.7.2

Trying to use the Apache Mime4J dependency for Version 0.7.2 like this:
<repositories>
<repository>
<id>org.apache.james</id>
<url>http://repo1.maven.org/maven2/</url>
</repository>
</repositories>
<dependency>
<groupId>org.apache.james</groupId>
<artifactId>apache-mime4j</artifactId>
<version>0.7.2</version>
</dependency>
I got an error message that the dependency could not be downloaded.
After checking that
http://uk.maven.org/maven2/org/apache/james/apache-mime4j/0.7.2/apache-mime4j-0.7.2.jar
indeed does not exist
but http://uk.maven.org/maven2/org/apache/james/apache-mime4j/0.7.2/
had .bin.tar.gz files I worked around the problem using:
<dependency>
<groupId>org.apache.james</groupId>
<artifactId>apache-mime4j</artifactId>
<version>0.6.1</version>
</dependency>
This will therefore not reference the more current 0.7.2 release.
This is my "set of questions":
Why does the 0.7.2 release not contain a Jar file?
How should I reference the dependency to get the latest Jar?
Do I need it anyway?
What differences are there between the 0.7.2 and the
0.6.1 release?
Question 1: Why an artifact might not exist
According to the changelog there has been some refactoring going on to split the functionality into the three parts: core,dom and storage.
Question 2: How to get the latest artifact
modify the dependencies to:
<dependency>
<groupId>org.apache.james</groupId>
<artifactId>apache-mime4j-core</artifactId>
<version>0.7.2</version>
</dependency>
<dependency>
<groupId>org.apache.james</groupId>
<artifactId>apache-mime4j-dom</artifactId>
<version>0.7.2</version>
</dependency>
<dependency>
<groupId>org.apache.james</groupId>
<artifactId>apache-mime4j-storage</artifactId>
<version>0.7.2</version>
</dependency>
Question 3: Do I need it?
if you'd like to use the improved DOM API: yes. You will need to modify your
import statements and can not use new Message() any more. Use
MessageServiceFactory.newInstance().newMessageBuilder().newMessage();
instead. The multipart.getBodyParts() function has also changed and returns an Entity now.
There is no isMimeType() for the Entity. You might want to use getMimeType() instead.
Question 4: What changed between versions?
See the change log between 0.7.2 and 0.6.1.

where is the correct and recent ehcache maven repository

I've been struggling to get ehcache 2.1.0 in my environment. Anytime I thought I got it right, it's just not downloading it. Here is where I set the repository:
<repository>
<!--<url>https://oss.sonatype.org/content/repositories/releases/</url>-->
<url>http://oss.sonatype.org/content/repositories/sourceforge-releases</url>
<id>sonatype-mirror</id>
<layout>default</layout>
<name>Repository for library including ehcache recent ones</name>
</repository>
And I add the dependency this way :
<dependency>
<groupId>net.sf.ehcache</groupId>
<artifactId>ehcache</artifactId>
<version>2.1.0</version>
</dependency>
Is there anything that's i'm doing wrong or not properly?
Ehcache is available in the maven central repository, there is no need to add a particular repository.
However, the ehcache artifact is special, it's an "aggregating" artifact which is of type pom. So the dependency should be declared like this:
<dependency>
<groupId>net.sf.ehcache</groupId>
<artifactId>ehcache</artifactId>
<version>2.1.0</version>
<type>pom</type>
</dependency>
Of course, you can also declare dependencies on individual modules if you want (e.g. ehcache-core) in which case you don't need to specify the type.
References
Ehcache Documentation
Java Requirements and Dependencies
net.sf.ehcache:ehcache:2.1.0 is a dependency of type pom therefore you need to specify it:
<dependency>
<groupId>net.sf.ehcache</groupId>
<artifactId>ehcache</artifactId>
<version>2.1.0</version>
<type>pom</type>
</dependency>
See also:
3.6. POM Best Practices