SAP jscoverage-plugin does not work on new Java/JDK - sapui5

I have run the auto test of my UI5 app locally successfully. When I tried to generate the cobertura coverage report with:
mvn verify -f pom.xml com.sap.ca:jscoverage-plugin:1.36.0:jscoverage
I got following error.
[ERROR] Failed to execute goal
com.sap.ca:jscoverage-plugin:1.36.0:jscoverage (default-cli) on
project sap.support.sccd: Execution default-cli of goal
com.sap.ca:jscoverage-plugin:1.36.0:jscoverage failed: A required
class was missing while executing
com.sap.ca:jscoverage-plugin:1.36.0:jscoverage:
javax/xml/bind/JAXBException
The javax is not available in JDK>7 anymore for a such long time. Why SAP jscoverage-plugin still use it? Is there any method to get rid of the issue.
I have tried all following dependencies with version 2.3.2 and 3.0.0 in my pom:
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-runtime</artifactId>
<version>2.3.2</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>jakarta.xml.bind</groupId>
<artifactId>jakarta.xml.bind-api</artifactId>
<version>2.3.2</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
<version>2.3.2</version>
<scope>runtime</scope>
</dependency>
However, they can't solve the problem.
How can I mitigate the issue and go on cobertura coverage report generation with this plugin?

Related

MyBatis-Guice fails to initialize with java 17

I am getting the following exception when starting mybatis with java17.
java.lang.NoSuchMethodError: 'void org.mybatis.guice.AbstractMyBatisModule.bindInterceptor(com.google.inject.matcher.Matcher, com.google.inject.matcher.Matcher, org.aopalliance.intercept.MethodInterceptor[])'
Maven dependencies:
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis</artifactId>
<version>3.5.11</version>
</dependency>
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis-guice</artifactId>
<version>3.18</version>
</dependency>
<dependency>
<groupId>com.google.inject</groupId>
<artifactId>guice</artifactId>
<version>5.1.0</version>
</dependency>
I tried downgrading to mybatis-guice version 3.12 but it did not help.
works in intelliJ does not work on a standalone server
The issue there was a 3rd party dependency that was pulling in guice no_aop from 4.0.1. once excluded it worked fine.
Verify no guice dependencies using
mvn dependency:tree

Error running cucumber in eclipse- Could not find or load main class cucumber.api.cli.Main

I'm trying to run a maven project using Oxygen.1 a release. I have the cucumber plugin installed. But when I run the default feature file, I'm getting an error Error: Could not find or load main class cucumber.api.cli.Main
Please help!
I've never used Cucumber, but I guess you need to add it as a dependency to your Maven pom.xml as described in the Cucumber JVM documentation.
The Eclipse plugin adds syntax highlighting, content assists and other IDE related convenience. But you still need to tell the JVM where to find the Cucumber classes and in a Maven project this is defined by the dependencies in pom.xml.
You may rise a feature request at the Cucumber-Eclipse issue tracker to extend the plugin to allow adding the dependency to Maven projects automatically.
Add these dependencies to the pom.xml and the issue gets resolved. I was trying with the latest versions so was facing this problem. When I changed the version then it worked for me.
<dependencies>
<!-- https://mvnrepository.com/artifact/io.cucumber/cucumber-java -->
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-java</artifactId>
<version>2.3.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/io.cucumber/cucumber-junit -->
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-junit</artifactId>
<version>2.3.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/net.masterthought/cucumber-reporting -->
<dependency>
<groupId>net.masterthought</groupId>
<artifactId>cucumber-reporting</artifactId>
<version>3.14.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/io.cucumber/gherkin -->
<dependency>
<groupId>info.cukes</groupId>
<artifactId>gherkin</artifactId>
<version>2.12.2</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java -->
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.14.0</version>
</dependency>
</dependencies>

How to integrate JUnit 5 with an existing Eclipse project?

The existing Eclipse project uses Maven but does not know about JUnit. Should/can I integrate JUnit into the existing project or should I make a new project dedicated to JUnit or is there a better option?
You can add JUnit5 to that project by including the following dependencies in the pom.xml:
<properties>
<junit.jupiter.version>5.0.1</junit.jupiter.version>
<junit.platform.version>1.0.1</junit.platform.version>
</properties>
<!--
JUnit5 dependencies:
* junit-jupiter-api: for writing JUnit5 tests
* junit-jupiter-engine: for running JUnit5 tests
* junit-platform-xxx: the foundation for JUnit5
* (Optionally) you might want to include junit-vintage-engine for running JUnit4 tests
-->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>${junit.jupiter.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>${junit.jupiter.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-launcher</artifactId>
<version>${junit.platform.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-runner</artifactId>
<version>${junit.platform.version}</version>
<scope>test</scope>
</dependency>
To enable Maven Surefire to run JUnit5 tests just include the following plugin definition in the pom.xml:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven.surefire.plugin.version}</version>
<configuration>
<excludes>
<exclude>**/MongoPopulatorTool.java</exclude>
</excludes>
</configuration>
<dependencies>
<!-- integrates JUnit5 with surefire -->
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-surefire-provider</artifactId>
<version>${junit.platform.version}</version>
</dependency>
<!-- ensures that a JUnit5-aware test engine is available on the classpath when running Surefire -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>${junit.jupiter.version}</version>
</dependency>
</dependencies>
</plugin>
And, finally, to enable Eclipse's test runner to run JUnit5 tests you must be running Eclipse Oxygen.1a (4.7.1a) release (or later), have a look at the Eclipse docs.
The other answer gives the technical answer how to add JUnit to your project setup.
But sorry, the real answer is: don't add your unit tests to your other project. Create a new one instead.
One of the most important rules when doing development is the Single Responsibility Principle. Any class/method/xyz should be doing one thing.
In other words: your existing eclipse project has the responsibility to provide the context for your "product". Providing context for testing is a different responsibility.
And beyond that, you should always follow "best practices". And best practice is again to not have test and production code within the same project.
You see, you absolutely do not want that your test source code sits in the same directory as your production code. Therefore, you have two projects, that can both use the same packages - but have their source code sitting in different folders!
( the reason why you don't want to have that: you only want to allow your tests to depend from your production code. but when files sit in the same directory, you might inadvertently create dependencies in the other direction )

Code-changes in dependencies are not updated automatically

I'm having some dependencies in my projects which I'm including in my pom.xml:
<packaging>war</packaging>
<dependencies>
<dependency>
<groupId>com.mahlzeit</groupId>
<artifactId>mz-data-model</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>mz-web-shared</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
However, my problem is that changes in the code of these projects are not visible to my web server when I'm running it.
I always have to run
mvn clean install
in mz-web-shared/ and mz-data-model/ such that the jar files are getting compiled and the repository updated.
Why do I have to do that and how can I make this work without me having to run mvn clean install manually in my dependencies?

Adding dependency to OSGI Bundle

I am trying to setup a maven project and added following dependencies
<dependency>
<groupId>com.adobe.granite.bundles</groupId>
<artifactId>json</artifactId>
<version>20090211_1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.day.cq.wcm</groupId>
<artifactId>cq-wcm-foundation</artifactId>
<version>5.6.4</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.adobe.cq.social</groupId>
<artifactId>cq-social-commons</artifactId>
<version>1.4.172</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.adobe.cq.social</groupId>
<artifactId>cq-social-blog</artifactId>
<version>1.1.8</version>
<scope>provided</scope>
</dependency>
On running maven clean install i am getting the following error.
[ERROR] Failed to execute goal on project falcon-utils: Could not
resolve dependencies for project
com.test.wem:test-utils:bundle:0.1-SNAPSHOT: Failed to collect
dependencies at com.adobe.cq.social:cq-social-commons:jar:1.4.172:
Failed to read artifact descriptor for
com.adobe.cq.social:cq-social-commons:jar:1.4.172: Failure to find
com.adobe.cq.social:socialcommunities-parent:pom:1.1.34 in
https://repo.adobe.com/nexus/content/groups/public/ was cached in the
local repository, resolution will not be reattempted until the update
interval of adobe has elapsed or updates are forced -> [Help 1]
I do not think this to be proxy issue because this was working before.
Kindly help me on this.
Thanks,
Jai
The jar is there at https://repo.adobe.com/nexus/content/groups/public/com/adobe/cq/social/cq-social-commons/1.4.172/
Running mvn clean install -U should force update it..