Comments (7)
Ok - if you run this:
java -Dspring.aot.enabled=true -agentlib:native-image-agent=config-output-dir=. -jar target/couchbase-demo-0.0.1-SNAPSHOT.jar
And then copy the output:
cp *.json src/main/resources/META-INF/native-image
then build
./mvnw -Pnative clean native:compile
it will run without erroring out at that point. And even do the insert/get in my CommandRunner (CommandRunner: found document ...)
target/couchbase-demo
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v3.2.1)
2024-01-08T15:38:12.533-08:00 INFO 39945 --- [ main] [ ] c.k.c.CouchbaseDemoApplication : Starting AOT-processed CouchbaseDemoApplication using Java 20.0.1 with PID 39945 (/Users/michaelreiche/jackson/couchbase-demo/target/couchbase-demo started by michaelreiche in /Users/michaelreiche/jackson/couchbase-demo)
2024-01-08T15:38:12.533-08:00 INFO 39945 --- [ main] [ ] c.k.c.CouchbaseDemoApplication : No active profile set, falling back to 1 default profile: "default"
2024-01-08T15:38:12.540-08:00 WARN 39945 --- [ main] [ ] trationDelegate$BeanPostProcessorChecker : Bean 'couchbaseConfig' of type [com.korkutkose.couchbasedemo.configuration.CouchbaseConfig$$SpringCGLIB$$0] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying). Is this bean getting eagerly injected into a currently created BeanPostProcessor [transactionInterceptorCustomizer]? Check the corresponding BeanPostProcessor declaration and its dependencies.
mapper is : class com.fasterxml.jackson.databind.ObjectMapper
generator: com.fasterxml.jackson.core.json.UTF8JsonGenerator@73d2a41b
value: com.couchbase.client.java.codec.JacksonJsonSerializer$PreflightCheckSubject@3764c3e7
result: [B@111e518e
2024-01-08T15:38:12.814-08:00 WARN 39945 --- [ main] [ ] trationDelegate$BeanPostProcessorChecker : Bean 'couchbaseClusterEnvironment' of type [com.couchbase.client.java.env.ClusterEnvironment] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying). Is this bean getting eagerly injected into a currently created BeanPostProcessor [transactionInterceptorCustomizer]? Check the corresponding BeanPostProcessor declaration and its dependencies.
2024-01-08T15:38:12.847-08:00 WARN 39945 --- [ main] [ ] trationDelegate$BeanPostProcessorChecker : Bean 'couchbaseCluster' of type [com.couchbase.client.java.Cluster] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying). Is this bean getting eagerly injected into a currently created BeanPostProcessor [transactionInterceptorCustomizer]? Check the corresponding BeanPostProcessor declaration and its dependencies.
2024-01-08T15:38:12.848-08:00 WARN 39945 --- [ main] [ ] trationDelegate$BeanPostProcessorChecker : Bean 'couchbaseClientFactory' of type [org.springframework.data.couchbase.SimpleCouchbaseClientFactory] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying). Is this bean getting eagerly injected into a currently created BeanPostProcessor [transactionInterceptorCustomizer]? Check the corresponding BeanPostProcessor declaration and its dependencies.
2024-01-08T15:38:12.848-08:00 WARN 39945 --- [ main] [ ] trationDelegate$BeanPostProcessorChecker : Bean 'couchbaseTransactionManager' of type [org.springframework.data.couchbase.transaction.CouchbaseCallbackTransactionManager] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying). Is this bean getting eagerly injected into a currently created BeanPostProcessor [transactionInterceptorCustomizer]? Check the corresponding BeanPostProcessor declaration and its dependencies.
2024-01-08T15:38:12.868-08:00 INFO 39945 --- [ main] [ ] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port 8080 (http)
2024-01-08T15:38:12.868-08:00 INFO 39945 --- [ main] [ ] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2024-01-08T15:38:12.868-08:00 INFO 39945 --- [ main] [ ] o.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/10.1.17]
2024-01-08T15:38:12.873-08:00 INFO 39945 --- [ main] [ ] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2024-01-08T15:38:12.873-08:00 INFO 39945 --- [ main] [ ] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 340 ms
2024-01-08T15:38:12.933-08:00 INFO 39945 --- [ cb-events] [ ] com.couchbase.core : [com.couchbase.core][DnsSrvLookupFailedEvent][26ms] DNS SRV lookup failed (name not found). This is expected if the there is no DNS SRV record associated with the hostname in the connection string. Will now try to bootstrap directly from the given hostname. To suppress this message, specify an IP address instead of a hostname (for example: 127.0.0.1 instead of localhost), specify more than one hostname, or set the `io.enableDnsSrv` client setting to false.
2024-01-08T15:38:12.934-08:00 INFO 39945 --- [ cb-events] [ ] com.couchbase.core : [com.couchbase.core][CoreCreatedEvent] {"clientVersion":"3.4.11","clientGitHash":"${buildNumber}","coreVersion":"2.4.11","coreGitHash":"${buildNumber}","userAgent":"couchbase-java/3.4.11 (Mac OS X 13.3.1 amd64; Substrate VM 20.0.1+9-jvmci-23.0-b12)","maxNumRequestsInRetry":32768,"ioEnvironment":{"nativeIoEnabled":true,"eventLoopThreadCount":6,"eventLoopGroups":["KQueueEventLoopGroup"]},"ioConfig":{"captureTraffic":[],"mutationTokensEnabled":true,"networkResolution":"auto","dnsSrvEnabled":true,"tcpKeepAlivesEnabled":true,"tcpKeepAliveTimeMs":60000,"configPollIntervalMs":2500,"kvCircuitBreakerConfig":"disabled","queryCircuitBreakerConfig":"disabled","viewCircuitBreakerConfig":"disabled","searchCircuitBreakerConfig":"disabled","analyticsCircuitBreakerConfig":"disabled","managerCircuitBreakerConfig":"disabled","eventingCircuitBreakerConfig":"disabled","backupCircuitBreakerConfig":"disabled","numKvConnections":1,"maxHttpConnections":12,"idleHttpConnectionTimeoutMs":1000,"configIdleRedialTimeoutMs":300000,"memcachedHashingStrategy":"StandardMemcachedHashingStrategy"},"compressionConfig":{"enabled":true,"minRatio":0.83,"minSize":32},"securityConfig":{"tlsEnabled":false,"nativeTlsEnabled":true,"hostnameVerificationEnabled":true,"trustCertificates":null,"trustManagerFactory":null,"ciphers":[]},"timeoutConfig":{"kvMs":2500,"kvDurableMs":10000,"kvScanMs":75000,"managementMs":75000,"queryMs":75000,"viewMs":75000,"searchMs":75000,"analyticsMs":75000,"connectMs":10000,"disconnectMs":10000,"eventingMs":75000,"backupMs":75000},"loggerConfig":{"customLogger":null,"fallbackToConsole":false,"consoleLogLevel":{"name":"INFO","resourceBundleName":"sun.util.logging.resources.logging","localizedName":"INFO"},"consoleLoggerFormatter":"DefaultLoggerFormatter","disableSlf4j":false,"loggerName":"CouchbaseLogger","diagnosticContextEnabled":false},"orphanReporterConfig":{"emitIntervalMs":10000,"sampleSize":10,"queueLength":1024,"enabled":true},"thresholdLoggingTracerConfig":{"enabled":true,"emitIntervalMs":10000,"sampleSize":10,"queueLength":1024,"kvThresholdMs":500,"queryThresholdMs":1000,"searchThresholdMs":1000,"analyticsThresholdMs":1000,"viewThresholdMs":1000,"transactionsThresholdMs":5000},"loggingMeterConfig":{"enabled":true,"emitIntervalMs":600000},"retryStrategy":"BestEffortRetryStrategy","requestTracer":"ThresholdLoggingTracer","meter":"LoggingMeter","numRequestCallbacks":0,"scheduler":"ParallelScheduler","schedulerThreadCount":12,"transactionsConfig":{"durabilityLevel":"MAJORITY","timeoutMs":15000,"cleanupConfig":{"runLostAttemptsCleanupThread":true,"runRegularAttemptsCleanupThread":true,"cleanupWindowMs":60000,"cleanupSet":""},"numAtrs":1024,"metadataCollection":"none","scanConsistency":"none"}} {"connectionString":"couchbase://localhost","coreId":"0x45504ae00000001","numCoreInstances":1,"seedNodes":[{"address":"localhost"}]}
2024-01-08T15:38:12.935-08:00 INFO 39945 --- [ cb-events] [ ] com.couchbase.transactions : [com.couchbase.transactions][TransactionsStartedEvent] Transactions successfully initialised, regular cleanup enabled=true, lost cleanup enabled=true
2024-01-08T15:38:12.935-08:00 INFO 39945 --- [ cb-events] [ ] com.couchbase.node : [com.couchbase.node][NodeCreatedEvent] Node created {"coreId":"0x45504ae00000001","managerPort":"8091","remote":"localhost"}
2024-01-08T15:38:12.938-08:00 INFO 39945 --- [ main] [ ] .i.s.PathMatchingResourcePatternResolver : Skipping search for files matching pattern [**/*.class]: directory [/com/korkutkose/couchbasedemo/persistence] does not exist
2024-01-08T15:38:12.988-08:00 INFO 39945 --- [ main] [ ] o.s.b.a.e.web.EndpointLinksResolver : Exposing 1 endpoint(s) beneath base path '/actuator'
2024-01-08T15:38:12.994-08:00 INFO 39945 --- [ main] [ ] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port 8080 (http) with context path ''
2024-01-08T15:38:12.994-08:00 INFO 39945 --- [ main] [ ] c.k.c.CouchbaseDemoApplication : Started CouchbaseDemoApplication in 0.476 seconds (process running for 0.485)
2024-01-08T15:38:12.996-08:00 INFO 39945 --- [ main] [ ] c.k.c.controller.CommandRunner : runner
2024-01-08T15:38:12.998-08:00 INFO 39945 --- [ main] [ ] c.k.c.controller.CommandRunner : CommandRunner: found document with id: {id:1,seasonSnapshotId:null,day:null}
2024-01-08T15:38:13.039-08:00 INFO 39945 --- [ cb-events] [ ] com.couchbase.core : [com.couchbase.core][BucketOpenedEvent][97ms] Opened bucket "my_bucket" {"coreId":"0x45504ae00000001"}
package com.korkutkose.couchbasedemo.controller;
import com.korkutkose.couchbasedemo.persistence.DemoDocument;
import com.korkutkose.couchbasedemo.persistence.DocumentRepository;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;
@Component
public class CommandRunner implements CommandLineRunner {
private static final Logger logger = LoggerFactory.getLogger(CommandRunner.class);
private final DocumentRepository repository;
public CommandRunner(DocumentRepository repository) {
this.repository = repository;
}
@Override
public void run(String...args) throws Exception {
logger.info("runner");
DemoDocument doc = new DemoDocument();
doc.setId("1");
this.repository.save(doc);
final var sampleDocument = this.repository
.findById(doc.getId());
logger.info("CommandRunner: found document with id: "+ sampleDocument.get());
if (sampleDocument.isPresent()) {
// cleanup for next run
this.repository.deleteById(sampleDocument.get().getId());
}
}
}
from spring-data-couchbase.
Hi @mikereiche,
Thanks for the quick responses. That’s correct, when we comment it out we also can successfully build the artifact. That’s why I specifically mentioned “run fails” in subject.
However, when you run that artifact it throws the exception above (nothing is wrong for the java -jar command, issue only happens in native mode)
Do we need to do something extra to include jackson in runtime?
Yea my bad, forgot to fix that typo in main branch.
from spring-data-couchbase.
Which JDK are you using? These are my current choices, and only 21.0.1 is accepted by mvnw (apparently), and it's not a graalVm. (even though it will run with ./mvnw native:compile -Pnative
)
The downloads have GraalVM 21 and 22, but the highest JDK version they are for is 17. https://www.oracle.com/downloads/graalvm-downloads.html
% /usr/libexec/java_home -V
Matching Java Virtual Machines (8):
21.0.1 (x86_64) "Homebrew" - "OpenJDK 21.0.1" /usr/local/Cellar/openjdk/21.0.1/libexec/openjdk.jdk/Contents/Home
20.0.1 (x86_64) "Oracle Corporation" - "Oracle GraalVM 20.0.1+9.1" /Library/Java/JavaVirtualMachines/graalvm-jdk-20.0.1+9.1/Contents/Home
20 (x86_64) "Oracle Corporation" - "Java SE 20" /Library/Java/JavaVirtualMachines/jdk-20.jdk/Contents/Home
17.0.9 (x86_64) "Oracle Corporation" - "GraalVM EE 21.3.8" /Library/Java/JavaVirtualMachines/graalvm-ee-java17-21.3.8/Contents/Home
17.0.1 (x86_64) "Oracle Corporation" - "Java SE 17.0.1" /Library/Java/JavaVirtualMachines/jdk-17.0.1.jdk/Contents/Home
16 (x86_64) "Oracle Corporation" - "Java SE 16" /Library/Java/JavaVirtualMachines/jdk-16.jdk/Contents/Home
11.0.20 (x86_64) "Homebrew" - "OpenJDK 11.0.20" /usr/local/Cellar/openjdk@11/11.0.20/libexec/openjdk.jdk/Contents/Home```
```
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.11.0:compile (default-compile) on project couchbase-demo: Fatal error compiling: error: release version 21 not supported
```
from spring-data-couchbase.
Was able to reproduce with the 20.0.1 that I have after changing the java.version in pom.xml from 21 to 20 <java.version>20</java.version>
couchbase-demo % target/couchbase-demo
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v3.2.1)
2024-01-08T13:40:04.855-08:00 INFO 35143 --- [ main] [ ] c.k.c.CouchbaseDemoApplication : Starting AOT-processed CouchbaseDemoApplication using Java 20.0.1 with PID 35143 (/Users/michaelreiche/jackson/couchbase-demo/target/couchbase-demo started by michaelreiche in /Users/michaelreiche/jackson/couchbase-demo)
.
.
.
Caused by: com.couchbase.client.core.error.CouchbaseException: non-shadowed Jackson not present
at org.springframework.data.couchbase.config.AbstractCouchbaseConfiguration.couchbaseClusterEnvironment(AbstractCouchbaseConfiguration.java:175) ~[couchbase-demo:na]
at com.korkutkose.couchbasedemo.configuration.CouchbaseConfig$$SpringCGLIB$$0.CGLIB$couchbaseClusterEnvironment$29(<generated>) ~[couchbase-demo:na]
at com.korkutkose.couchbasedemo.configuration.CouchbaseConfig$$SpringCGLIB$$FastClass$$1.invoke(<generated>) ~[couchbase-demo:na]
at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:258) ~[couchbase-demo:6.1.2]
at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:331) ~[na:na]
at com.korkutkose.couchbasedemo.configuration.CouchbaseConfig$$SpringCGLIB$$0.couchbaseClusterEnvironment(<generated>) ~[couchbase-demo:na]
at org.springframework.data.couchbase.config.AbstractCouchbaseConfiguration__BeanDefinitions.lambda$getCouchbaseClusterEnvironmentInstanceSupplier$2(AbstractCouchbaseConfiguration__BeanDefinitions.java:75) ~[na:na]
at org.springframework.util.function.ThrowingFunction.apply(ThrowingFunction.java:63) ~[couchbase-demo:6.1.2]
at org.springframework.util.function.ThrowingFunction.apply(ThrowingFunction.java:51) ~[couchbase-demo:6.1.2]
at org.springframework.beans.factory.aot.BeanInstanceSupplier.lambda$withGenerator$0(BeanInstanceSupplier.java:171) ~[na:na]
at org.springframework.util.function.ThrowingBiFunction.apply(ThrowingBiFunction.java:68) ~[couchbase-demo:6.1.2]
at org.springframework.util.function.ThrowingBiFunction.apply(ThrowingBiFunction.java:54) ~[couchbase-demo:6.1.2]
at org.springframework.beans.factory.aot.BeanInstanceSupplier.lambda$get$2(BeanInstanceSupplier.java:206) ~[na:na]
at org.springframework.util.function.ThrowingSupplier.get(ThrowingSupplier.java:58) ~[couchbase-demo:6.1.2]
at org.springframework.util.function.ThrowingSupplier.get(ThrowingSupplier.java:46) ~[couchbase-demo:6.1.2]
at org.springframework.beans.factory.aot.BeanInstanceSupplier.invokeBeanSupplier(BeanInstanceSupplier.java:218) ~[na:na]
at org.springframework.beans.factory.aot.BeanInstanceSupplier.get(BeanInstanceSupplier.java:206) ~[na:na]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.obtainInstanceFromSupplier(DefaultListableBeanFactory.java:949) ~[couchbase-demo:6.1.2]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.obtainFromSupplier(AbstractAutowireCapableBeanFactory.java:1216) ~[couchbase-demo:6.1.2]
... 111 common frames omitted
from spring-data-couchbase.
It sounds like this issue : https://stackoverflow.com/questions/74908739/spring-boot-3-native-image-with-jackson . We just need to figure out how to solve it.
see also https://docs.spring.io/spring-boot/docs/current/reference/html/native-image.html
and https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-with-GraalVM
from spring-data-couchbase.
Hi @mikereiche,
Sorry for the delay, timezone issues :) So yeah, I just noticed that I haven't provided enough information for the sake of this ticket about the environments we have.
I was on GraalVM 21.0.1 (with latest spring boot dependencies) and another colleague of mine was on GraalVM 17.0.8 (with spring boot 3.0.9). We both tried to build a GraalVM native executable with the help of native-maven-plugin and hit the same wall on different projects.
I've just updated my sample with the Dockerfile, so that we would definitely have the same environments for both building and running the sample. If you wanna build, do not forget to give some juice to your docker desktop since native builds are resource hoarders.
After created this ticket, I had run the native tracing agent and generated bunch of reflections already. But to be frank, I haven't had to generate any reflections for a managed dependency up until now. That's why I had to open to this ticket and ask if this library is fully spring-native compatible or not.
It's totally fine generating additional reflections but maybe we can add this in a doc or something for feature references. WDYT?
Thanks again for all your efforts,
Cheers.
<plugin>
<groupId>org.graalvm.buildtools</groupId>
<artifactId>native-maven-plugin</artifactId>
</plugin>
java -version ─╯
java version "21.0.1" 2023-10-17
Java(TM) SE Runtime Environment Oracle GraalVM 21.0.1+12.1 (build 21.0.1+12-jvmci-23.1-b19)
Java HotSpot(TM) 64-Bit Server VM Oracle GraalVM 21.0.1+12.1 (build 21.0.1+12-jvmci-23.1-b19, mixed mode, sharing)
./mvnw -version ─╯
Apache Maven 3.9.5 (57804ffe001d7215b5e7bcb531cf83df38f93546)
Maven home: /Users/mehmetkorkut/.m2/wrapper/dists/apache-maven-3.9.5-bin/32db9c34/apache-maven-3.9.5
Java version: 21.0.1, vendor: Oracle Corporation, runtime: /Library/Java/JavaVirtualMachines/graalvm-jdk-21.0.1+12.1/Contents/Home
Default locale: en_TR, platform encoding: UTF-8
OS name: "mac os x", version: "14.2.1", arch: "aarch64", family: "mac"
from spring-data-couchbase.
I mean the question is that is spring-data-couchbase fully spring-native supported or some reflections have to be generated?
After created this ticket, I had run the native tracing agent and generated bunch of reflections already.
As you determined, it doesn't work without adding reflections and it does work with adding reflections.
It's totally fine generating additional reflections but maybe we can add this in a doc or something for feature references.
We could say something like - "For using GraalVM Native Images with Spring Boot refer to Spring Boot GraalVM Native Image Support". But given that the Couchbase Java SDK is not supported for GraalVM Native Images, I don't want to send developers down that path.
from spring-data-couchbase.
Related Issues (20)
- Release 5.3 M2 (2024.0.0)
- Reintroduce Javadoc legacy mode
- Remove Querydsl and `com.couchbase` split packages HOT 2
- How to set the different config for different environments while using AbstractCouchbaseConfiguration HOT 2
- Bug: Regression - Spring Boot 3.2.3 app fails to compile with Spring Data Couchbase HOT 1
- issue with querydsl HOT 2
- "TypeAlias" does't work along with abstraction HOT 12
- update Couchbase Java SDK to 3.6.0 in main
- javax.inject dependency HOT 1
- Release 5.1.11 (2023.0.11)
- Release 5.2.5 (2023.1.5)
- Release 5.3 RC1 (2024.0.0)
- java.lang.NoClassDefFoundError: javax/inject/Inject: javax.inject.Inject when upgrading to Spring Boot 3.2.4 HOT 7
- Auto Index Creation creates indexes under _default scope HOT 2
- Sorry for the delay @mikereiche , Thanks for all the clarification.
- Compilation error due to QueryDSL annotation processor in Spring Data Couchbase 5.2.4 HOT 4
- Release 5.1.12 (2023.0.12)
- Release 5.2.6 (2023.1.6)
- Release 5.3 GA (2024.0.0)
- Runtime error when calling DeleteAllById(Iterable<T> list) if the repository extends DynamicProxyable
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from spring-data-couchbase.