I have written Junit for a camel route. The route accepts json input. The service is building and installing fine. I have installed JsonPath bundle in karaf, but I am getting the below exception while running my Junit. I have specified the maven dependency as compile.
<dependency>
<groupId>com.jayway.jsonpath</groupId>
<artifactId>json-path</artifactId>
<version>1.2.0</version>
<scope>compile</scope>
</dependency>
Exception message:
Bundle Test is waiting for dependencies [(&(language=jsonpath)(objectClass=org.apache.camel.spi.LanguageResolver))]
I think the problem is in the Camel test. If you provide the source, probably we can give you some ideas.
BTW for a good reference for "How to write Camel test about something" you can check the official repo. I'm attaching you a link to the tests of jsonPath component:
https://github.com/apache/camel/tree/master/components/camel-jsonpath/src/test/java/org/apache/camel/jsonpath
Related
It seems that I got the wires crossed & ask you to point me the right direction.
I have a problem with the Eclipse IDE for Enterprise Java Developers (version: 2019-06 (4.12.0), build id: 20190614-1200). There is a code part where I get the error message MysqlDataSource cannot be resolved to a type. Searching the Web, I found out that this class is included in the download of mysql-connector-java JAR 8.0.14 with all dependencies. I added it over the 'Fix project setup…', where I added the JAR file to the libraries of the Java Build Path.
Unfortunately, the error message does not vanish. Can you see what I am doing wrong?
Edit 1:
With the hint from another Website, I found out that the hibernate JAR included was the source files JAR. So, I corrected it the hibernate-entitymanager JAR, clicked "Clean…" under "Project", but to no avail: the EntityManager is still unlocatable. (Well, after several tries, the first error message to resolve is no more with MySQL.)
As I learned from somebody on another Web site, the following lines have to be added to the pom.xml file:
<dependency>
<groupId>org.hibernate.javax.persistence</groupId>
<artifactId>hibernate-jpa-2.1-api</artifactId>
<version>1.0.2.Final</version>
</dependency>
or
<dependency>
<groupId>javax.persistence</groupId>
<artifactId>javax.persistence-api</artifactId>
<version>2.2</version>
</dependency>
Hi I am facing this issue while launching the driver.
Starting ChromeDriver 2.35.528161 (5b82f2d2aae0ca24b877009200ced9065a772e73) on port 4097
Only local connections are allowed.
Exception in thread "main" java.lang.NoSuchMethodError: com.google.gson.GsonBuilder.setLenient()Lcom/google/gson/GsonBuilder;
at org.openqa.selenium.json.Json.<clinit>(Json.java:47)
at org.openqa.selenium.logging.profiler.HttpProfilerLogEntry.constructMessage(HttpProfilerLogEntry.java:37)
at org.openqa.selenium.logging.profiler.HttpProfilerLogEntry.<init>(HttpProfilerLogEntry.java:29)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:141)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:83)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:601)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:219)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:142)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:181)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:168)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:123)
at isf.Login.main(Login.java:21)
Can anybody tell what i am missing ..because same libs i am using for another project and its working fine there.
I was facing the same issue and got resolved using below approach:
If you check JSON class at line 47, setLenient() is missing.
This issue is possibly due to conflicts in Gson versions.
Go to your repository:
C:\Users\User_name\.m2\repository\com\google\code\gson
Delete all the existing folders.
Now, add below maven dependency in your pom file:
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.5</version>
<scope>provided</scope>
</dependency>
Re-build your pom.xml file and execute the script.
In case you are using maven, you should add the following dependency:
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.5</version>
</dependency>
That should solve it. Gson package version should be correlated with latest Selenium version.
I am trying to use com.google.maps in my OSGi bundle. I've added the dependency like this:
<dependency>
<groupId>com.google.maps</groupId>
<artifactId>google-maps-services</artifactId>
<version>0.1.7</version>
</dependency>
However, when I try to deploy this bundle to AEM, I get an error:
Unable to resolve 392.38: missing requirement [392.38] osgi.wiring.package; (&(osgi.wiring.package=com.google.gson)(version>=2.3.0)(!(version>=3.0.0))))
How can I resolve this?
go to maven central: http://search.maven.org
Advanced search
Write to the By Classname section: com.google.gson
In the list of results, find the ones that might be good for you
Download the jars and check the manifest header if the required package is exported
If you do that, you will find the following maven dependency:
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.3.1</version>
</dependency>
Alternatively, you can use JPM website for the search as it indexes all OSGi related MANIFEST headers and it mirrors the whole maven central repo. After you find the artifact that is necessary for you, there is a good chance that it is from maven central originally (so you do not have to set alternate repositories in your maven project). You can check the origin of the bundle in the details page.
I have an Eclipse RCP Project with multiple plugins. I am writing plain JUnit tests (no dependencies to Eclipse/UI) as separate fragments to the plugin-under-test.
When using Mockito and trying to mock an interface from another plugin (which is exported correctly; I can use the interface in my code), I get a SecurityException related to class signing:
org.mockito.exceptions.base.MockitoException:
Mockito cannot mock this class: interface ch.sbb.polar.client.communication.inf.service.IUserService
Mockito can only mock visible & non-final classes.
If you're not sure why you're getting this error, please report to the mailing list.
at org.mockito.internal.runners.JUnit45AndHigherRunnerImpl$1.withBefores(JUnit45AndHigherRunnerImpl.java:27)
[...]
Caused by: org.mockito.cglib.core.CodeGenerationException: java.lang.reflect.InvocationTargetException-->null
at org.mockito.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:238)
[...]
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[...]
Caused by: java.lang.SecurityException: Signers of 'ch.sbb.polar.client.communication.inf.service.IUserService$$EnhancerByMockitoWithCGLIB$$a8bfe723' do not match signers of other classes in package
at java.lang.ClassLoader.checkPackageSigners(ClassLoader.java:361)
at java.lang.ClassLoader.defineClass(ClassLoader.java:295)
... 40 more
When I run the tests as "JUnit Plugin tests", i.e. with an OSGi environment, everything works as expected. But I'd like to use the plain JUnit execution because of speed; in the class under test, I don't need the OSGi environment.
Does anybody know a way to do that?
As is mentioned in the comments, the root cause is that the Eclipse Orbit package of Mockito (which I had added to my target platform) is signed, and because of a bug in the underlying CGLIB, you cannot mock unsigned classes/interfaces with a signed Mockito.
See https://code.google.com/p/mockito/issues/detail?id=393 for the most detailed description. The bug is fixed in CGLIB head, but has not yet appeared in a release. Mockito only uses released versions as dependencies, so the fix is not yet in Mockito, with an unknown (to me) timeline, as when this will be in.
Workaround: Provide unsigned Mockito in separate bundle
The workaround is to package the Mockito JAR (and its dependencies) in its own bundle and export the necessary API packages.
When using Maven Tycho, JUnit, Hamcrest, and Mockito, the only way I was able to make this work and resolve all dependency / classpath / classloader issues correctly was the following way:
Create Maven module with the following entries in the pom.xml:
<packaging>eclipse-plugin</packaging>
[...]
<dependencies>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>1.10.19</version>
</dependency>
</dependencies>
[...]
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy-test-libs</id>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>lib</outputDirectory>
<stripVersion>true</stripVersion>
<includeScope>runtime</includeScope>
</configuration>
</execution>
</executions>
</plugin>
Use following entries in the MANIFEST.MF:
Bundle-ClassPath: lib/mockito-core.jar,
lib/objenesis.jar
Export-Package: org.mockito,
org.mockito.runners
Require-Bundle: org.junit;bundle-version="4.11.0";visibility:=reexport,
org.hamcrest.library;bundle-version="1.3.0";visibility:=reexport,
org.hamcrest.core;bundle-version="1.3.0";visibility:=reexport
And finally in your unit test fragment, add this new bundle as a dependency.
I ran into this same issue and was able to resolve it by using a more recent Orbit repository which pulls Mockito 2.x:
http://download.eclipse.org/tools/orbit/downloads/drops/R20181128170323/?d
This repository contains Mockito 2.23.0 which uses Byte Buddy instead of CGLIB.
In my target, I simply pull mockito-core 2.23.0 and Byte Buddy Java Agent 1.9.0 from the Orbit repository above.
<unit id="org.mockito" version="2.23.0.v20181106-1534"/>
<unit id="org.mockito.source" version="2.23.0.v20181106-1534"/>
<unit id="net.bytebuddy.byte-buddy-agent" version="1.9.0.v20181106-1534"/>
<unit id="net.bytebuddy.byte-buddy-agent.source" version="1.9.0.v20181106-1534"/>
The Short Version:
I am using Jersey 1.17 and Jackson 2.1.4, but Jersey is ignoring every single Jackson-annotation that I use. Why!? Has anybody encountered the same problem?
The Long Version:
I have a RESTful Web Service that was using Jersey 1.17 and Jackson 1.9.2 and I was using the #JsonManagedReference and #JsonBackReference annotations to solve the problem with bidirectional relationships and everything was working fine.
The other day I saw the 2.1.4 version of Jackson that included the #JsonIdentityInfo annotation which seemed like a great solution for my problems so I changed the jar files to Jackson 2.1.4. However, the promising #JsonIdentityInfo annotation was not working and Jersey was ignoring it completely, and after a bit of debugging and changing the code, I found out that even the previous #JsonManagedReference and #JsonBackReference annotations are being ignored by Jersey. So it seems that Jersey is completely ignoring the Jackson 2.1.4 annotations. Why!? Has anybody encountered the same problem?
As stated in http://wiki.fasterxml.com/JacksonAnnotations:
Important note: Jackson 1.x and 2.x annotations live in different Java
and Maven packages: see Jackson 2.0 for full explanation:
1.x annotations are in Java package org.codehaus.jackson.annotate, in Jackson core jar
2.x annotations are in Java package com.fasterxml.jackson.annotation, in "jackson-databind" jar.
So could be an "import-related" problem.
Another reason (as already stated by #HiJon89) is to use the right JacksonJsonProvider version. For version 2.x it's automatically registered while inserting the "jackson-jaxrs-json-provider" combined with "jersey-core".
My currently working update to jackson 2.1.4 (from a 1.9.2 jersey required dependency) was:
remove jersey-json dependency
add jersey-core and jackson-jaxrs-json-provider
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-core</artifactId>
<version>${jersey.version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.jaxrs</groupId>
<artifactId>jackson-jaxrs-json-provider</artifactId>
<version>${jackson-jaxrs-json-provider.version}</version>
</dependency>
The latter jar has a file "META-INF/services/javax.ws.rs.ext.MessageBodyWriter" that tell jersey what class act as a provider.
So I've no other advise than to double-check that you don't have the old jars anymore in your classpath.
In my case jackson annotations were ignored because of proguard