I'm trying to adopt debugging in graaljs:
Context.newBuilder("js")
.option("inspect", port)
.option("inspect.Path", path)
.option("inspect.Remote", remoteConnect)
java.lang.IllegalArgumentException: Could not find option with name inspect.
My build.gradle dependencies look as follows:
def graalVersion = "1.0.0-rc15"
dependencies {
compile "org.graalvm.sdk:graal-sdk:${graalVersion}"
compile "org.graalvm.js:js:${graalVersion}"
compile "org.graalvm.js:js-scriptengine:${graalVersion}"
}
And I definitely remember that there used to be yet another dependency I should add to make it possible to debug in chrome - however I'm failing to remember - or find in any code source or documentation - what exactly I should add as a dependency
I think you should also include the chromeinspector.
In maven that would be:
<dependency>
<groupId>org.graalvm.tools</groupId>
<artifactId>chromeinspector</artifactId>
<version>1.0.0-rc15</version>
</dependency>
Related
I'm trying to migrate from Dagger (for Android) to Dagger Hilt.
I get the following error:
Execution failed for task ':app:getDependencies'.
> Cannot change dependencies of dependency configuration ':app:prodDebugAndroidTestRuntimeClasspath' after it has been included in dependency resolution. Use 'defaultDependencies' instead of 'beforeResolve' to specify default dependencies for a configuration.
My dependencies
implementation "com.google.dagger:dagger:$daggerVersion"
implementation "com.google.dagger:dagger-android-support:$daggerVersion"
kapt "com.google.dagger:dagger-compiler:$daggerVersion"
kapt "com.google.dagger:dagger-android-processor:$daggerVersion"
kaptAndroidTest "com.google.dagger:dagger-android-processor:$daggerVersion"
implementation "com.google.dagger:hilt-android:$hilt_version"
kapt "com.google.dagger:hilt-android-compiler:$hilt_version"
Where both daggerVersion and hilt_version is 2.40.5
Any tips?
The issue is caused by some Google License plugin (which I don't even know what is used for in the codebase, but doesn't matter, removing it solved the error).
plugins {
id 'com.android.application'
id 'kotlin-android'
id 'kotlin-kapt'
id 'dagger.hilt.android.plugin'
id 'kotlin-parcelize'
id 'androidx.navigation.safeargs.kotlin'
id 'com.google.firebase.appdistribution'
//id 'com.google.android.gms.oss-licenses-plugin'
...
}
I'm using 2.1.16 of Swagger with Jetty/Jersey and I get this exception. I have tried to turn off classpath scanning with readAllResources(false) on SwaggerConfiguration because I don't want this feature anyway but it didn't help. I'm probably doing something wrong here. But what?
Thanks,
Jonathan
java.lang.NoClassDefFoundError: io/github/classgraph/ClassGraph
at io.swagger.v3.jaxrs2#2.1.6/io.swagger.v3.jaxrs2.integration.JaxrsAnnotationScanner.classes(JaxrsAnnotationScanner.java:60)
at io.swagger.v3.jaxrs2#2.1.6/io.swagger.v3.jaxrs2.integration.JaxrsApplicationAndAnnotationScanner.classes(JaxrsApplicationAndAnnotationScanner.java:10)
at io.swagger.v3.oas.integration#2.1.6/io.swagger.v3.oas.integration.GenericOpenApiContext.read(GenericOpenApiContext.java:555)
at io.swagger.v3.jaxrs2#2.1.6/io.swagger.v3.jaxrs2.integration.OpenApiServlet.doGet(OpenApiServlet.java:55)
at javax.servlet.api#3.1.0/javax.servlet.http.HttpServlet.service(HttpServlet.java:687)
at javax.servlet.api#3.1.0/javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
at org.eclipse.jetty.servlet#9.4.36.v20210114/org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:791)
at org.eclipse.jetty.servlet#9.4.36.v20210114/org.eclipse.jetty.servlet.ServletHandler$ChainEnd.doFilter(ServletHandler.java:1626)
at wicket.core#9.2.0/org.apache.wicket.protocol.http.WicketFilter.processRequestCycle(WicketFilter.java:293)
at wicket.core#9.2.0/org.apache.wicket.protocol.http.WicketFilter.processRequest(WicketFilter.java:208)
at wicket.core#9.2.0/org.apache.wicket.protocol.http.WicketFilter.doFilter(WicketFilter.java:307)
at org.eclipse.jetty.servlet#9.4.36.v20210114/org.eclipse.jetty.servlet.FilterHolder.doFilter(FilterHolder.java:193)
at org.eclipse.jetty.servlet#9.4.36.v20210114/org.eclipse.jetty.servlet.ServletHandler$Chain.doFilter(ServletHandler.java:1601)
at org.eclipse.jetty.servlet#9.4.36.v20210114/org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:548)
at org.eclipse.jetty.server#9.4.36.v20210114/org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:233)
at org.eclipse.jetty.server#9.4.36.v20210114/org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:1624)
at org.eclipse.jetty.server#9.4.36.v20210114/org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:233)
at org.eclipse.jetty.server#9.4.36.v20210114/org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1435)
at org.eclipse.jetty.server#9.4.36.v20210114/org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:188)
at org.eclipse.jetty.servlet#9.4.36.v20210114/org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:501)
at org.eclipse.jetty.server#9.4.36.v20210114/org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:1594)
at org.eclipse.jetty.server#9.4.36.v20210114/org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:186)
at org.eclipse.jetty.server#9.4.36.v20210114/org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1350)
at org.eclipse.jetty.server#9.4.36.v20210114/org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
at org.eclipse.jetty.server#9.4.36.v20210114/org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:127)
at org.eclipse.jetty.server#9.4.36.v20210114/org.eclipse.jetty.server.Server.handle(Server.java:516)
at org.eclipse.jetty.server#9.4.36.v20210114/org.eclipse.jetty.server.HttpChannel.lambda$handle$1(HttpChannel.java:388)
at org.eclipse.jetty.server#9.4.36.v20210114/org.eclipse.jetty.server.HttpChannel.dispatch(HttpChannel.java:633)
at org.eclipse.jetty.server#9.4.36.v20210114/org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:380)
at org.eclipse.jetty.server#9.4.36.v20210114/org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:273)
at org.eclipse.jetty.io#9.4.36.v20210114/org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:311)
at org.eclipse.jetty.io#9.4.36.v20210114/org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:105)
at org.eclipse.jetty.io#9.4.36.v20210114/org.eclipse.jetty.io.ChannelEndPoint$1.run(ChannelEndPoint.java:104)
at org.eclipse.jetty.util#9.4.36.v20210114/org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.runTask(EatWhatYouKill.java:336)
at org.eclipse.jetty.util#9.4.36.v20210114/org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:313)
at org.eclipse.jetty.util#9.4.36.v20210114/org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.tryProduce(EatWhatYouKill.java:171)
at org.eclipse.jetty.util#9.4.36.v20210114/org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.produce(EatWhatYouKill.java:135)
at org.eclipse.jetty.util#9.4.36.v20210114/org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:773)
at org.eclipse.jetty.util#9.4.36.v20210114/org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.run(QueuedThreadPool.java:905)
at java.base/java.lang.Thread.run(Thread.java:835)
Swagger includes an outdated version of the io.github.classgraph that causes the java.lang.NoClassDefFoundError. I was able to exclude the classgraph version that was being included by Swagger and include the most recent version. After that I was missing the requires statement in module-info.java and now it works. This issue has been fixed in master of Swagger repo, but it is not yet in any release.
I had a problem with this with the maven dependency:
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-ui</artifactId>
<version>1.6.4</version>
</dependency>
The only thing that worked for me was to downgrade to 1.6.3 and it got rid of the Cannot resolve io.github.classgraph:classgraph:4.8.138 error.
I'm currently attempting to start a project using JavaCV in Kotlin. I'm using IntelliJ Idea as my IDE. I'm using JavaCV 1.3.2 and OpenCV 3.20.
This is my setup for the module's dependancies for OpenCV:
and for JavaCV:
I have opencv before javacv in the dependancies.
To test that OpenCV is present and valid, I wrote the below to test. As I can loadLibrary and the version number shows correctly I can assume that OpenCV is actually working.
import org.opencv.core.Core
import org.opencv.core.Mat
import org.opencv.core.CvType
import org.opencv.core.Scalar
import org.bytedeco.javacv.OpenCVFrameGrabber
fun main(args : Array<String>) {
println("Test Built Successfully")
System.loadLibrary(Core.NATIVE_LIBRARY_NAME)
println("Running OpenCV Version ${Core.VERSION}")
val grabber = OpenCVFrameGrabber(1)
}
The line where we initialize the grabber rasies the following exception:
Exception in thread "main" java.lang.UnsatisfiedLinkError: no jniopencv_core in java.library.path
Caused by: java.lang.UnsatisfiedLinkError: no opencv_imgproc320 in java.library.path
Perhaps I am missing something here, but I have followed the instructions provided by the README.md in the Git repository for JavaCV. I haven't seen anybody else trying to use this library with Kotlin on StackOverflow, though have checked out some posts about the same exception being raised using java.
Handling this error is no different in Kotlin from Java; you need to specify the path to the native libraries for opencv. By default on Windows it will look for the native libraries in whatever is set in your PATH environment variable.
You can also explicitly specify which directory to look for the native libraries by specifying the system property java.library.path (as indicated by the error message).
For example, you can add a run configuration like this:
Where ${PATH_TO_DYNAMIC_LIB} would be where ever the native lib opencv_imgproc320.dll is - I think in your case it would be C:/Users/ms/IdeaProjects/CVTest/opencv/build/java/x64.
I was able to resolve this by leaving my VM options blank and adding all necessary OpenCV libraries as native library paths in my JavaCV library configuration.
on MacOS, you don't need to install a native library. On OpenCV3.41, as fetched from
<!-- https://mvnrepository.com/artifact/org.openpnp/opencv -->
<dependency>
<groupId>org.openpnp</groupId>
<artifactId>opencv</artifactId>
<version>3.4.2-1</version>
</dependency>
I looked in the library (jar tf ~/.m2/repository/org/openpnp/opencv/3.4.2-1/opencv-3.4.2.-1.jar) and found dlls and whatnot in it:
jar tf *1.jar | grep nu
...
nu/pattern/opencv/osx/
nu/pattern/opencv/osx/x86_64/
nu/pattern/opencv/osx/x86_64/README.md
nu/pattern/opencv/osx/x86_64/cmake.log
nu/pattern/opencv/osx/x86_64/libopencv_java342.dylib
...
This led me to this StackOverflow question on nu.pattern which show how to use the nu.pattern in code.
static {
nu.pattern.OpenCV.loadShared();
System.loadLibrary(org.opencv.core.Core.NATIVE_LIBRARY_NAME);
}
This prologue code enabled sample apps which used to fail as above to run.
We're running a modular application plattform using Apache ServiceMix 5.3.0. I need to extend our system with a persistence service - so I want to build an OSGi bundle containing Neo4J 2.1.6.
In my pom.xml (Maven) I'm using maven-bundle-plugin (org.apache.felix) to build the bundle. I've added nearly every package from neo4j-kernel and neo4j-lucene-index libs to the <Export-Package> section.
When deployed my bundle shows up in "resolved" state. But when beeing started it throws this:
org.osgi.framework.BundleException: Activator start error ...
...
Caused by: java.lang.ArrayIndexOutOfBoundsException: 0
at org.neo4j.graphdb.factory.GraphDatabaseSettings.<clinit (GraphDatabaseSettings.java:69)
My activator code looks like this (the exception occurs at the last command):
GraphDatabaseFactory factory = new GraphDatabaseFactory();
/*
ArrayList<CacheProvider> caches = new ArrayList();
caches.add(new SoftCacheProvider());
factory.setCacheProviders(caches);
*/
GraphDatabaseBuilder builder = factory.newEmbeddedDatabaseBuilder("neo4j-db");
graphDb = builder.newGraphDatabase();
(It doesn't make a difference if the commented part is active or not.)
The error pattern looks similar like the one in this question.
I suspect the devil sitting in the following method from org.neo4j.graphdb.factory.GraphDatabaseSettings (line 259f) unable to find any CacheProvider instances, although they are packed and referenced in my bundle (org.neo4j.kernel.impl.cache...):
private static String[] availableCaches()
{
List<String> available = new ArrayList<>();
for ( CacheProvider cacheProvider : Service.load( CacheProvider.class ) )
{
available.add( cacheProvider.getName() );
}
...
return available.toArray( new String[available.size()] );
}
I believe this is very much an OSGi classloader issue rather than a Neo4J issue. Any ideas how to proceed here?
I managed to solve my problem meanwhile. As Neil already supposed, it was neither an OSGi-issue nor a Neo4J-bug. Instead I had to learn some more lessons about how Neo4J binds its extensions and how to shape OSGi dependencies accordingly in order to get ahead.
These are the results of my yesterday's research:
(1) Collect all packages
My mistake was to rely on maven-bundle-plugin's capability to parse the project and automatically break down all internal dependencies to package level (which is neccessary for OSGi). This works perfectly for class relations that are declared by import statements, but, of course, will fail where reflection methods are used to bind external stuff.
As the application worked perfectly in my JUnit environment the reasons for my problem had to include missing resources in the OSGi envirmonment.
The solution was to religiously list each single package of every library in the plugins Export-Package, Private-Package and Import-Package section accordingly (the list got quite lengthly) instead of trusting to wildcards.
(2) Neo4J kernel extensions
Heeding the above topics I got rid of the mentioned ArrayIndexOutOfBoundsException but I right ran into other (similar) exceptions. I got ahead after I learned about Neo4J's "kernel extension" concept.
Neo4J (I have version 2.1.6) has introduced "kernel extensions" to couple exchangeable modules for caching and indexing purpose at runtime. In order to apply a certain extension one just needs to add the according jar to the classpath. Each library carries one or more descriptor files under META-INF/services telling about the available implementations. These files are looked up and processed by the kernel in order to find and bind its extensions (extension for indexing and caching are mandatory).
After I securely had all neccessary java packages included in my bundly only the descriptor files in META-INF/services were missing. This code showed me a way how to add those resources to the bundle (search for the <Embed-Dependency> section in the maven-bundle-plugin.
Neo4J libs also contain a blueprint descriptor to automatically publish major classes as service (e.g. GraphDatabaseFactory). These resources are placed under OSGI-INF/blueprint/, which should also be included in the bundle.
The final pom.xml for my Neo4J OSGi bundle looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<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>
<groupId>my.group</groupId>
<artifactId>neo4jBundle</artifactId>
<version>0.1.0</version>
<packaging>bundle</packaging>
<properties>
<neo4j-version>2.1.6</neo4j-version>
<lucene-version>3.6.2</lucene-version>
</properties>
<dependencies>
<dependency>
<groupId>org.neo4j</groupId>
<artifactId>neo4j-kernel</artifactId>
<version>${neo4j-version}</version>
</dependency>
<dependency>
<groupId>org.neo4j</groupId>
<artifactId>neo4j-lucene-index</artifactId>
<version>${neo4j-version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-nop</artifactId>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.1.2</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<instructions>
<Bundle-Name>org.neo4j.kernel</Bundle-Name>
<Export-Package>org.neo4j.graphdb.*;version=${neo4j-version},
... {all neo4j packages} ...
org.apache.lucene;version=${lucene-version},
... {all lucene packages} ...
org.slf4j.impl
</Export-Package>
<Private-Package>
javax.transaction,
javax.transaction.xa,
ch.qos.logback.classic,
... {all logback.classic packages} ...
ch.qos.logback.core,
... {all logback.core packages} ...
org.slf4j.*
</Private-Package>
<Import-Package>
javax.lang.model,
... {some javax packages to be imported from the runtime} ...
!sun.misc,
... {exclude uneccessary packages to limit dependency} ...
*
</Import-Package>
<Embed-Dependency>
*;groupId=org.neo4j;artifactId=neo4j-kernel;inline=META-INF/services/*,
*;groupId=org.neo4j;artifactId=neo4j-kernel;inline=OSGI-INF/blueprint/*,
*;groupId=org.neo4j;artifactId=neo4j-lucene-index;inline=META-INF/services/*,
*;groupId=org.neo4j;artifactId=neo4j-lucene-index;inline=OSGI-INF/blueprint/*
</Embed-Dependency>
</instructions>
</configuration>
</plugin>
</plugins>
</build>
</project>
Remarks: This is a pure library bundle without any additional code. My application with the Activator resides in a seperate bundle.
This example only shows my aproach in solving my problems. My example doesn't claim to produce a general-purpose Neo4J bundle. Depending on the features you want and the society of already deployed stuff in the runtime you might need to add or leave out certain packages to get everything to work.
If I include compile "org.jasig.cas.client:cas-client-core:3.3.3" in my BuildConfig.groovy, I get a stack overflow as seen below. If I change compile to runtime the error goes away, but I do have dependencies at compile time as well as runtime.
It looks like some kind of circular reference related to logging, and just getting a stack dump like this isn't helpful. How would I fix it?
at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:253)
at org.apache.log4j.Category.<init>(Category.java:52)
at org.apache.log4j.Logger.<init>(Logger.java:35)
at org.apache.log4j.Log4jLoggerFactory.getLogger(Log4jLoggerFactory.java:59)
at org.apache.log4j.LogManager.getLogger(LogManager.java:42)
at org.slf4j.impl.GrailsSlf4jLoggerFactory.getLogger(GrailsSlf4jLoggerFactory.java:43)
at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:253)
at org.apache.log4j.Category.<init>(Category.java:52)
at org.apache.log4j.Logger.<init>(Logger.java:35)
at org.apache.log4j.Log4jLoggerFactory.getLogger(Log4jLoggerFactory.java:59)
at org.apache.log4j.LogManager.getLogger(LogManager.java:42)
at org.slf4j.impl.GrailsSlf4jLoggerFactory.getLogger(GrailsSlf4jLoggerFactory.java:43)
at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:253)
| Error Error executing script RefreshDependencies: null
You may have multiple versions of log4j-over-slf4j in your dependency chain. If you run 'grails dependency-report runtime', you will see a list of libs that your app sucks in.
Using transitive=false will exclude all dependencies of the lib, but you could try 'exclude "log4j-over-slf4j"' as a more focused exclude if you have multiple slf4j versions in your dependency chain. E.g.,
compile("org.jasig.cas.client:cas-client-core:3.3.3") {
exclude "log4j-over-slf4j"
}
adding transitive=false made the error go away:
compile("org.jasig.cas.client:cas-client-core:3.3.3") {
transitive=false
}
I'm not clear what I needed to exclude specifically, or how anyone could have figured that out from the stack overflow.