microsoft / spring-data-gremlin

We are in the process of deprecating Spring Data Gremlin. -- Provide generic annotation oriented programming form based on gremlin for graph database
Other
129 stars 76 forks source link

SSL errors if connecting to an AWWS Neptune instance #167

Closed spanierm42 closed 3 years ago

spanierm42 commented 6 years ago

Your issue may already be reported! Please search before creating a new one.

Expected Behavior

Current Behavior

Possible Solution

Steps to Reproduce (for bugs)

The source code used for the tests can be found at spanierm/aws-neptune-spring-boot

As a result, you get the following errors:

com.github.spanierm.awsneptunespringboot.AwsNeptuneSpringBootApplicationTests > contextLoads FAILED
    java.lang.IllegalStateException
        Caused by: java.lang.IllegalStateException
            Caused by: java.lang.RuntimeException
                Caused by: java.lang.RuntimeException
                    Caused by: java.util.concurrent.TimeoutException
2018-10-14 17:39:09.834  WARN 24768 --- [n-driver-loop-1] o.a.tinkerpop.gremlin.driver.Cluster     : SSL configured without a trustCertChainFile and thus trusts all certificates without verification (not suitable for production)
2018-10-14 17:39:09.844 ERROR 24768 --- [n-driver-loop-1] o.a.t.g.d.Handler$GremlinResponseHandler : Could not process the response

io.netty.handler.codec.DecoderException: io.netty.handler.ssl.NotSslRecordException: not an SSL/TLS record: 485454502f312e31203430302042616420526571756573740d0a436f6e74656e742d547970653a206170706c69636174696f6e2f6a736f6e0d0a436f6e74656e742d4c656e6774683a203133340d0a0d0a7b22726571756573744964223a2231386233333964342d383463372d373131652d613336302d646532653030313465336131222c22636f6465223a2242616452657175657374457863657074696f6e222c2264657461696c65644d657373616765223a22556e6578706563746564206572726f722072656164696e67207468652055524c227d
        at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:459) ~[netty-all-4.1.29.Final.jar:4.1.29.Final]
        at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:265) ~[netty-all-4.1.29.Final.jar:4.1.29.Final]
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362) [netty-all-4.1.29.Final.jar:4.1.29.Final]
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348) [netty-all-4.1.29.Final.jar:4.1.29.Final]
        at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340) [netty-all-4.1.29.Final.jar:4.1.29.Final]
        at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1434) [netty-all-4.1.29.Final.jar:4.1.29.Final]
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362) [netty-all-4.1.29.Final.jar:4.1.29.Final]
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348) [netty-all-4.1.29.Final.jar:4.1.29.Final]
        at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:965) [netty-all-4.1.29.Final.jar:4.1.29.Final]
        at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:163) [netty-all-4.1.29.Final.jar:4.1.29.Final]
        at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:628) [netty-all-4.1.29.Final.jar:4.1.29.Final]
        at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:563) [netty-all-4.1.29.Final.jar:4.1.29.Final]
        at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:480) [netty-all-4.1.29.Final.jar:4.1.29.Final]
        at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:442) [netty-all-4.1.29.Final.jar:4.1.29.Final]
        at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:884) [netty-all-4.1.29.Final.jar:4.1.29.Final]
        at java.lang.Thread.run(Thread.java:748) [na:1.8.0_181]
Caused by: io.netty.handler.ssl.NotSslRecordException: not an SSL/TLS record: 485454502f312e31203430302042616420526571756573740d0a436f6e74656e742d547970653a206170706c69636174696f6e2f6a736f6e0d0a436f6e74656e742d4c656e6774683a203133340d0a0d0a7b22726571756573744964223a2231386233333964342d383463372d373131652d613336302d646532653030313465336131222c22636f6465223a2242616452657175657374457863657074696f6e222c2264657461696c65644d657373616765223a22556e6578706563746564206572726f722072656164696e67207468652055524c227d
        at io.netty.handler.ssl.SslHandler.decodeJdkCompatible(SslHandler.java:1178) ~[netty-all-4.1.29.Final.jar:4.1.29.Final]
        at io.netty.handler.ssl.SslHandler.decode(SslHandler.java:1243) ~[netty-all-4.1.29.Final.jar:4.1.29.Final]
        at io.netty.handler.codec.ByteToMessageDecoder.decodeRemovalReentryProtection(ByteToMessageDecoder.java:489) ~[netty-all-4.1.29.Final.jar:4.1.29.Final]
        at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:428) ~[netty-all-4.1.29.Final.jar:4.1.29.Final]
        ... 15 common frames omitted

2018-10-14 17:39:09.859  WARN 24768 --- [n-driver-loop-1] o.a.tinkerpop.gremlin.driver.Cluster     : SSL configured without a trustCertChainFile and thus trusts all certificates without verification (not suitable for production)
2018-10-14 17:39:09.868 ERROR 24768 --- [n-driver-loop-1] o.a.t.g.d.Handler$GremlinResponseHandler : Could not process the response

io.netty.handler.codec.DecoderException: io.netty.handler.ssl.NotSslRecordException: not an SSL/TLS record: 485454502f312e31203430302042616420526571756573740d0a436f6e74656e742d547970653a206170706c69636174696f6e2f6a736f6e0d0a436f6e74656e742d4c656e6774683a203133340d0a0d0a7b22726571756573744964223a2233386233333964342d383464322d643736352d663138362d633031663534356166633963222c22636f6465223a2242616452657175657374457863657074696f6e222c2264657461696c65644d657373616765223a22556e6578706563746564206572726f722072656164696e67207468652055524c227d
        at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:459) ~[netty-all-4.1.29.Final.jar:4.1.29.Final]
        at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:265) ~[netty-all-4.1.29.Final.jar:4.1.29.Final]
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362) [netty-all-4.1.29.Final.jar:4.1.29.Final]
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348) [netty-all-4.1.29.Final.jar:4.1.29.Final]
        at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340) [netty-all-4.1.29.Final.jar:4.1.29.Final]
        at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1434) [netty-all-4.1.29.Final.jar:4.1.29.Final]
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362) [netty-all-4.1.29.Final.jar:4.1.29.Final]
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348) [netty-all-4.1.29.Final.jar:4.1.29.Final]
        at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:965) [netty-all-4.1.29.Final.jar:4.1.29.Final]
        at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:163) [netty-all-4.1.29.Final.jar:4.1.29.Final]
        at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:628) [netty-all-4.1.29.Final.jar:4.1.29.Final]
        at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:563) [netty-all-4.1.29.Final.jar:4.1.29.Final]
        at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:480) [netty-all-4.1.29.Final.jar:4.1.29.Final]
        at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:442) [netty-all-4.1.29.Final.jar:4.1.29.Final]
        at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:884) [netty-all-4.1.29.Final.jar:4.1.29.Final]
        at java.lang.Thread.run(Thread.java:748) [na:1.8.0_181]
Caused by: io.netty.handler.ssl.NotSslRecordException: not an SSL/TLS record: 485454502f312e31203430302042616420526571756573740d0a436f6e74656e742d547970653a206170706c69636174696f6e2f6a736f6e0d0a436f6e74656e742d4c656e6774683a203133340d0a0d0a7b22726571756573744964223a2233386233333964342d383464322d643736352d663138362d633031663534356166633963222c22636f6465223a2242616452657175657374457863657074696f6e222c2264657461696c65644d657373616765223a22556e6578706563746564206572726f722072656164696e67207468652055524c227d
        at io.netty.handler.ssl.SslHandler.decodeJdkCompatible(SslHandler.java:1178) ~[netty-all-4.1.29.Final.jar:4.1.29.Final]
        at io.netty.handler.ssl.SslHandler.decode(SslHandler.java:1243) ~[netty-all-4.1.29.Final.jar:4.1.29.Final]
        at io.netty.handler.codec.ByteToMessageDecoder.decodeRemovalReentryProtection(ByteToMessageDecoder.java:489) ~[netty-all-4.1.29.Final.jar:4.1.29.Final]
        at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:428) ~[netty-all-4.1.29.Final.jar:4.1.29.Final]
        ... 15 common frames omitted

1 test completed, 1 failed

Connections to the AWS Neptune instance do work if you use Gremlin directly to connect to it:

The output looks as follows:

[ec2-user@ip-172-30-1-182 aws-neptune-spring-boot]$ ./gradlew clean build

> Task :test
2018-10-14 17:41:59.066  INFO 24951 --- [      Thread-14] o.s.w.c.s.GenericWebApplicationContext   : Closing org.springframework.web.context.support.GenericWebApplicationContext@17eabf54: startup date [Sun Oct 14 17:41:46 UTC 2018]; root of context hierarchy

BUILD SUCCESSFUL in 24s
7 actionable tasks: 7 executed
[ec2-user@ip-172-30-1-182 aws-neptune-spring-boot]$ java -jar build/libs/aws-neptune-spring-boot-0.0.1-SNAPSHOT.jar

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v2.0.5.RELEASE)

2018-10-14 17:42:18.044  INFO 24991 --- [           main] .g.s.a.AwsNeptuneSpringBootApplicationKt : Starting AwsNeptuneSpringBootApplicationKt on ip-172-30-1-182 with PID 24991 (/home/ec2-user/aws-neptune-spring-boot/build/libs/aws-neptune-spring-boot-0.0.1-SNAPSHOT.jar started by ec2-user in /home/ec2-user/aws-neptune-spring-boot)
2018-10-14 17:42:18.073  INFO 24991 --- [           main] .g.s.a.AwsNeptuneSpringBootApplicationKt : No active profile set, falling back to default profiles: default
2018-10-14 17:42:18.902  WARN 24991 --- [kground-preinit] o.s.h.c.j.Jackson2ObjectMapperBuilder    : For Jackson Kotlin classes support please add "com.fasterxml.jackson.module:jackson-module-kotlin" to the classpath
2018-10-14 17:42:19.044  INFO 24991 --- [           main] ConfigServletWebServerApplicationContext : Refreshing org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@5f5a92bb: startup date [Sun Oct 14 17:42:19 UTC 2018]; root of context hierarchy
2018-10-14 17:42:22.697  INFO 24991 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8080 (http)
2018-10-14 17:42:22.783  INFO 24991 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2018-10-14 17:42:22.783  INFO 24991 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet Engine: Apache Tomcat/8.5.34
2018-10-14 17:42:22.823  INFO 24991 --- [ost-startStop-1] o.a.catalina.core.AprLifecycleListener   : The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: [/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib]
2018-10-14 17:42:23.154  INFO 24991 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2018-10-14 17:42:23.155  INFO 24991 --- [ost-startStop-1] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 4131 ms
2018-10-14 17:42:23.338  INFO 24991 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean  : Servlet dispatcherServlet mapped to [/]
2018-10-14 17:42:23.346  INFO 24991 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'characterEncodingFilter' to: [/*]
2018-10-14 17:42:23.350  INFO 24991 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2018-10-14 17:42:23.350  INFO 24991 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2018-10-14 17:42:23.350  INFO 24991 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'requestContextFilter' to: [/*]
AI: INFO 14-10-2018 17:42, 1: Configuration file has been successfully found as resource
AI: ERROR 14-10-2018 17:42, 1: Failed to create com.microsoft.applicationinsights.web.internal.perfcounter.WebPerformanceCounterModule, com.microsoft.applicationinsights.web.internal.perfcounter.WebPerformanceCounterModule
AI: INFO 14-10-2018 17:42, 1: Configuration file has been successfully found as resource
AI: ERROR 14-10-2018 17:42, 1: Failed to create com.microsoft.applicationinsights.web.internal.perfcounter.WebPerformanceCounterModule, com.microsoft.applicationinsights.web.internal.perfcounter.WebPerformanceCounterModule
2018-10-14 17:42:27.925  INFO 24991 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2018-10-14 17:42:28.503  INFO 24991 --- [           main] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for @ControllerAdvice: org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@5f5a92bb: startup date [Sun Oct 14 17:42:19 UTC 2018]; root of context hierarchy
2018-10-14 17:42:28.675  INFO 24991 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[],methods=[POST]}" onto public java.lang.String com.github.spanierm.awsneptunespringboot.AwsNeptuneController.executeGremlinQuery(java.lang.String)
2018-10-14 17:42:28.682  INFO 24991 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error],produces=[text/html]}" onto public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)
2018-10-14 17:42:28.684  INFO 24991 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error]}" onto public org.springframework.http.ResponseEntity<java.util.Map<java.lang.String, java.lang.Object>> org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController.error(javax.servlet.http.HttpServletRequest)
2018-10-14 17:42:28.760  INFO 24991 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2018-10-14 17:42:28.761  INFO 24991 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2018-10-14 17:42:29.331  INFO 24991 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Registering beans for JMX exposure on startup
2018-10-14 17:42:29.427  INFO 24991 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 8080 (http) with context path ''
2018-10-14 17:42:29.436  INFO 24991 --- [           main] .g.s.a.AwsNeptuneSpringBootApplicationKt : Started AwsNeptuneSpringBootApplicationKt in 12.924 seconds (JVM running for 14.155)
2018-10-14 17:42:29.881  INFO 24991 --- [           main] o.a.tinkerpop.gremlin.driver.Connection  : Created new connection for ws://neptunedbinstance-<SOME_INSTANCE>.eu-west-1.neptune.amazonaws.com:8182/gremlin
2018-10-14 17:42:29.894  INFO 24991 --- [           main] o.a.tinkerpop.gremlin.driver.Connection  : Created new connection for ws://neptunedbinstance-<SOME_INSTANCE>.eu-west-1.neptune.amazonaws.com:8182/gremlin
2018-10-14 17:42:29.894  INFO 24991 --- [           main] o.a.t.gremlin.driver.ConnectionPool      : Opening connection pool on Host{address=neptunedbinstance-<SOME_INSTANCE>.eu-west-1.neptune.amazonaws.com/172.30.2.57:8182, hostUri=ws://neptunedbinstance-<SOME_INSTANCE>.eu-west-1.neptune.amazonaws.com:8182/gremlin} with core size of 2
{name=[Custom id vertex 1]}
{name=[Custom id vertex 2]}
{Name=[Justin]}
2018-10-14 17:42:30.153  INFO 24991 --- [           main] o.a.t.gremlin.driver.ConnectionPool      : Signalled closing of connection pool on Host{address=neptunedbinstance-<SOME_INSTANCE>.eu-west-1.neptune.amazonaws.com/172.30.2.57:8182, hostUri=ws://neptunedbinstance-<SOME_INSTANCE>.eu-west-1.neptune.amazonaws.com:8182/gremlin} with core size of 2

Your Environment

Incarnation-p-lee commented 6 years ago

@spanierm Thanks for interesting spring-data-gremlin. Yes the current code force ssl enabled by default, as we consider it is the recommended way for production. Actually, we can add option to GremlinConfig for disable ssl for debugging, as well as configuration about GraphJson.

Incarnation-p-lee commented 6 years ago

@spanierm Looks this issue can be fixed combine with #166 . It is perfect if you can send a PR for this.

Incarnation-p-lee commented 6 years ago

@spanierm We have add the sslEnabled as gremlinConfig when prepare the env, could you please help to have a try ?

spanierm42 commented 6 years ago

@Incarnation-p-lee sorry for the late response but I did not find time to test it before today.

With your fix, I was now able to connect to the AWS Neptune database :) I am still fixing problems when I want to store something but this is totally unrelated to this issue (and probably the fault of the person sitting in front of the computer ;)).

Thanks for the help :)

spanierm42 commented 6 years ago

@Incarnation-p-lee Before you actually close this ticket, can you give me some guidance why I cannot save any Person object in my test application?

I tried to follow the example project and created data objects and repositories, see. https://github.com/spanierm/aws-neptune-spring-boot/blob/master/src/main/kotlin/com/github/spanierm/awsneptunespringboot/PersonRepository.kt. After accessing the database to delete all entries and count the vertices resp. edges, I tried to save a Person object in https://github.com/spanierm/aws-neptune-spring-boot/blob/master/src/main/kotlin/com/github/spanierm/awsneptunespringboot/AwsNeptuneSpringBootApplication.kt. Unfortunately, it failed with an IllegalArgumentException and the message should contain id property, see the below stacktrace.

Did I miss any obvious configuration?

[ec2-user@ip-172-30-1-83 ~]$ java -jar aws-neptune-spring-boot-0.0.1-SNAPSHOT.jar 

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v2.1.0.RELEASE)

2018-11-04 17:18:50.233  INFO 2698 --- [           main] .g.s.a.AwsNeptuneSpringBootApplicationKt : Starting AwsNeptuneSpringBootApplicationKt on ip-172-30-1-83 with PID 2698 (/home/ec2-user/aws-neptune-spring-boot-0.0.1-SNAPSHOT.jar started by ec2-user in /home/ec2-user)
2018-11-04 17:18:50.243  INFO 2698 --- [           main] .g.s.a.AwsNeptuneSpringBootApplicationKt : No active profile set, falling back to default profiles: default
2018-11-04 17:18:50.880  WARN 2698 --- [kground-preinit] o.s.h.c.j.Jackson2ObjectMapperBuilder    : For Jackson Kotlin classes support please add "com.fasterxml.jackson.module:jackson-module-kotlin" to the classpath
2018-11-04 17:18:52.287  INFO 2698 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data repositories in DEFAULT mode.
2018-11-04 17:18:52.420  INFO 2698 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 128ms. Found 1 repository interfaces.
2018-11-04 17:18:54.237  INFO 2698 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8080 (http)
2018-11-04 17:18:54.306  INFO 2698 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2018-11-04 17:18:54.306  INFO 2698 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet Engine: Apache Tomcat/9.0.12
2018-11-04 17:18:54.337  INFO 2698 --- [           main] o.a.catalina.core.AprLifecycleListener   : The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: [/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib]
2018-11-04 17:18:54.553  INFO 2698 --- [           main] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2018-11-04 17:18:54.554  INFO 2698 --- [           main] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 3444 ms
2018-11-04 17:18:54.620  INFO 2698 --- [           main] o.s.b.w.servlet.ServletRegistrationBean  : Servlet dispatcherServlet mapped to [/]
2018-11-04 17:18:54.629  INFO 2698 --- [           main] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'characterEncodingFilter' to: [/*]
2018-11-04 17:18:54.630  INFO 2698 --- [           main] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2018-11-04 17:18:54.630  INFO 2698 --- [           main] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'formContentFilter' to: [/*]
2018-11-04 17:18:54.630  INFO 2698 --- [           main] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'requestContextFilter' to: [/*]
AI: INFO 04-11-2018 17:18, 1: Configuration file has been successfully found as resource
AI: ERROR 04-11-2018 17:18, 1: Failed to create com.microsoft.applicationinsights.web.internal.perfcounter.WebPerformanceCounterModule, com.microsoft.applicationinsights.web.internal.perfcounter.WebPerformanceCounterModule
AI: INFO 04-11-2018 17:18, 1: Configuration file has been successfully found as resource
AI: ERROR 04-11-2018 17:18, 1: Failed to create com.microsoft.applicationinsights.web.internal.perfcounter.WebPerformanceCounterModule, com.microsoft.applicationinsights.web.internal.perfcounter.WebPerformanceCounterModule
2018-11-04 17:18:58.376  INFO 2698 --- [           main] o.s.s.concurrent.ThreadPoolTaskExecutor  : Initializing ExecutorService 'applicationTaskExecutor'
2018-11-04 17:18:58.987  INFO 2698 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 8080 (http) with context path ''
2018-11-04 17:18:59.000  INFO 2698 --- [           main] .g.s.a.AwsNeptuneSpringBootApplicationKt : Started AwsNeptuneSpringBootApplicationKt in 10.235 seconds (JVM running for 11.521)

personRepository.deleteAll()

2018-11-04 17:19:00.041  INFO 2698 --- [           main] o.a.tinkerpop.gremlin.driver.Connection  : Created new connection for ws://neptunedbinstance-ea5bxx9yu7zp.cxsglve7j1iz.eu-west-1.neptune.amazonaws.com:8182/gremlin
2018-11-04 17:19:00.048  INFO 2698 --- [           main] o.a.tinkerpop.gremlin.driver.Connection  : Created new connection for ws://neptunedbinstance-ea5bxx9yu7zp.cxsglve7j1iz.eu-west-1.neptune.amazonaws.com:8182/gremlin
2018-11-04 17:19:00.048  INFO 2698 --- [           main] o.a.t.gremlin.driver.ConnectionPool      : Opening connection pool on Host{address=neptunedbinstance-ea5bxx9yu7zp.cxsglve7j1iz.eu-west-1.neptune.amazonaws.com/172.30.2.175:8182, hostUri=ws://neptunedbinstance-ea5bxx9yu7zp.cxsglve7j1iz.eu-west-1.neptune.amazonaws.com:8182/gremlin} with core size of 2

personRepository.vertexCount() = 0

personRepository.edgeCount() = 0

personRepository.count() = 0

personRepository.save(Person(id=PERSON_ID, name=PERSON_NAME, age=PERSON_AGE))

2018-11-04 17:19:00.367  INFO 2698 --- [           main] ConditionEvaluationReportLoggingListener : 

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2018-11-04 17:19:00.381 ERROR 2698 --- [           main] o.s.boot.SpringApplication               : Application run failed

java.lang.IllegalStateException: Failed to execute CommandLineRunner
    at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:816) [spring-boot-2.1.0.RELEASE.jar!/:2.1.0.RELEASE]
    at org.springframework.boot.SpringApplication.callRunners(SpringApplication.java:797) [spring-boot-2.1.0.RELEASE.jar!/:2.1.0.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:324) [spring-boot-2.1.0.RELEASE.jar!/:2.1.0.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1260) [spring-boot-2.1.0.RELEASE.jar!/:2.1.0.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1248) [spring-boot-2.1.0.RELEASE.jar!/:2.1.0.RELEASE]
    at com.github.spanierm.awsneptunespringboot.AwsNeptuneSpringBootApplicationKt.main(AwsNeptuneSpringBootApplication.kt:125) [classes!/:na]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_181]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_181]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_181]
    at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_181]
    at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48) [aws-neptune-spring-boot-0.0.1-SNAPSHOT.jar:na]
    at org.springframework.boot.loader.Launcher.launch(Launcher.java:87) [aws-neptune-spring-boot-0.0.1-SNAPSHOT.jar:na]
    at org.springframework.boot.loader.Launcher.launch(Launcher.java:50) [aws-neptune-spring-boot-0.0.1-SNAPSHOT.jar:na]
    at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:51) [aws-neptune-spring-boot-0.0.1-SNAPSHOT.jar:na]
Caused by: java.lang.IllegalArgumentException: should contain id property
    at org.springframework.util.Assert.isTrue(Assert.java:118) ~[spring-core-5.1.2.RELEASE.jar!/:5.1.2.RELEASE]
    at com.microsoft.spring.data.gremlin.conversion.result.GremlinResultVertexReader.read(GremlinResultVertexReader.java:33) ~[spring-data-gremlin-2.0.1-SNAPSHOT.jar!/:2.0.1-SNAPSHOT]
    at com.microsoft.spring.data.gremlin.conversion.source.AbstractGremlinSource.doGremlinResultRead(AbstractGremlinSource.java:111) ~[spring-data-gremlin-2.0.1-SNAPSHOT.jar!/:2.0.1-SNAPSHOT]
    at com.microsoft.spring.data.gremlin.query.GremlinTemplate.recoverDomain(GremlinTemplate.java:341) ~[spring-data-gremlin-2.0.1-SNAPSHOT.jar!/:2.0.1-SNAPSHOT]
    at com.microsoft.spring.data.gremlin.query.GremlinTemplate.insert(GremlinTemplate.java:155) ~[spring-data-gremlin-2.0.1-SNAPSHOT.jar!/:2.0.1-SNAPSHOT]
    at com.microsoft.spring.data.gremlin.query.GremlinTemplate.save(GremlinTemplate.java:275) ~[spring-data-gremlin-2.0.1-SNAPSHOT.jar!/:2.0.1-SNAPSHOT]
    at com.microsoft.spring.data.gremlin.repository.support.SimpleGremlinRepository.save(SimpleGremlinRepository.java:44) ~[spring-data-gremlin-2.0.1-SNAPSHOT.jar!/:2.0.1-SNAPSHOT]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_181]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_181]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_181]
    at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_181]
    at org.springframework.data.repository.core.support.RepositoryComposition$RepositoryFragments.invoke(RepositoryComposition.java:359) ~[spring-data-commons-2.1.2.RELEASE.jar!/:2.1.2.RELEASE]
    at org.springframework.data.repository.core.support.RepositoryComposition.invoke(RepositoryComposition.java:200) ~[spring-data-commons-2.1.2.RELEASE.jar!/:2.1.2.RELEASE]
    at org.springframework.data.repository.core.support.RepositoryFactorySupport$ImplementationMethodExecutionInterceptor.invoke(RepositoryFactorySupport.java:644) ~[spring-data-commons-2.1.2.RELEASE.jar!/:2.1.2.RELEASE]
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.1.2.RELEASE.jar!/:5.1.2.RELEASE]
    at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.doInvoke(RepositoryFactorySupport.java:608) ~[spring-data-commons-2.1.2.RELEASE.jar!/:2.1.2.RELEASE]
    at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.lambda$invoke$3(RepositoryFactorySupport.java:595) ~[spring-data-commons-2.1.2.RELEASE.jar!/:2.1.2.RELEASE]
    at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke(RepositoryFactorySupport.java:595) ~[spring-data-commons-2.1.2.RELEASE.jar!/:2.1.2.RELEASE]
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.1.2.RELEASE.jar!/:5.1.2.RELEASE]
    at org.springframework.data.projection.DefaultMethodInvokingMethodInterceptor.invoke(DefaultMethodInvokingMethodInterceptor.java:59) ~[spring-data-commons-2.1.2.RELEASE.jar!/:2.1.2.RELEASE]
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.1.2.RELEASE.jar!/:5.1.2.RELEASE]
    at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:93) ~[spring-aop-5.1.2.RELEASE.jar!/:5.1.2.RELEASE]
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.1.2.RELEASE.jar!/:5.1.2.RELEASE]
    at org.springframework.data.repository.core.support.SurroundingTransactionDetectorMethodInterceptor.invoke(SurroundingTransactionDetectorMethodInterceptor.java:61) ~[spring-data-commons-2.1.2.RELEASE.jar!/:2.1.2.RELEASE]
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.1.2.RELEASE.jar!/:5.1.2.RELEASE]
    at org.springframework.data.repository.core.support.MethodInvocationValidator.invoke(MethodInvocationValidator.java:99) ~[spring-data-commons-2.1.2.RELEASE.jar!/:2.1.2.RELEASE]
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.1.2.RELEASE.jar!/:5.1.2.RELEASE]
    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:212) ~[spring-aop-5.1.2.RELEASE.jar!/:5.1.2.RELEASE]
    at com.sun.proxy.$Proxy75.save(Unknown Source) ~[na:na]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_181]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_181]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_181]
    at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_181]
    at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:343) ~[spring-aop-5.1.2.RELEASE.jar!/:5.1.2.RELEASE]
    at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:198) ~[spring-aop-5.1.2.RELEASE.jar!/:5.1.2.RELEASE]
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) ~[spring-aop-5.1.2.RELEASE.jar!/:5.1.2.RELEASE]
    at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:139) ~[spring-tx-5.1.2.RELEASE.jar!/:5.1.2.RELEASE]
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.1.2.RELEASE.jar!/:5.1.2.RELEASE]
    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:212) ~[spring-aop-5.1.2.RELEASE.jar!/:5.1.2.RELEASE]
    at com.sun.proxy.$Proxy75.save(Unknown Source) ~[na:na]
    at com.github.spanierm.awsneptunespringboot.SpringDataGremlinConnection.run(AwsNeptuneSpringBootApplication.kt:121) ~[classes!/:na]
    at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:813) [spring-boot-2.1.0.RELEASE.jar!/:2.1.0.RELEASE]
    ... 13 common frames omitted

2018-11-04 17:19:00.388  INFO 2698 --- [           main] o.s.s.concurrent.ThreadPoolTaskExecutor  : Shutting down ExecutorService 'applicationTaskExecutor'
Incarnation-p-lee commented 6 years ago

@spanierm Thanks for try our repo. It looks the the gremlin server return the result of saved entity has no Id field. As your source if is .kt, I am not sure how the annotation works well on .kt. You can setup one in memory gremlin-server to test if this issue existed.

anuragk-sportsbet commented 5 years ago

hi @Incarnation-p-lee I am facing the same issue in spring boot java.

My object is as follows:

import com.microsoft.spring.data.gremlin.annotation.Vertex;
import org.springframework.data.annotation.Id;

import java.io.Serializable;

@Vertex
public class StudentVertex implements Serializable {

    @Id
    private String id;

    private String studentId;
    private String firstName;

    public StudentVertex() {
    }

    public StudentVertex(String id, String studentId, String firstName) {
        this.id = id;
        this.studentId = studentId;
        this.firstName = firstName;
    }

    public String getStudentId() {
        return studentId;
    }

    public void setStudentId(String studentId) {
        this.studentId = studentId;
    }

    public String getFirstName() {
        return firstName;
    }

    public void setFirstName(String firstName) {
        this.firstName = firstName;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    @Override
    public String toString() {
        return "StudentVertex{" +
                "id='" + id + '\'' +
                ", studentId='" + studentId + '\'' +
                ", firstName='" + firstName + '\'' +
                '}';
    }
}

Repository Interface as follows

import com.test.models.graphModels.StudentVertex;
import com.microsoft.spring.data.gremlin.repository.GremlinRepository;
import org.springframework.stereotype.Repository;

@Repository
public interface StudentRepository extends GremlinRepository<StudentVertex, String> {

} 

and the implementation is as follows

StudentVertex studentVertex = new StudentVertex("1", "100" , "Jack Sparrow");
StudentVertex studentVertex1 = studentRepository.save(studentVertex);

When I query the Neptune DB using gremlin I get the following result

gremlin> g.V().hasLabel('StudentVertex').valueMap()
==>{studentId=[100], firstName=[Jack Sparrow], _classname=[com.test.models.graphModels.StudentVertex]}
gremlin> g.V().hasLabel('StudentVertex')
==>v[1]
gremlin> 

So looks like the data is stored correctly in the DB.

My program fails with the error below. Looks like when the data is stored, the vertex gets the id, correctly. However it is not stored as the attribute in the vertex. Hence the return value does not match since id is expected to be present in the attributes of the StudentVertex pojo, as per the standard JPA signature.

java.lang.IllegalArgumentException: should contain id property
    at org.springframework.util.Assert.isTrue(Assert.java:118)
    at com.microsoft.spring.data.gremlin.conversion.result.GremlinResultVertexReader.validate(GremlinResultVertexReader.java:36)
    at com.microsoft.spring.data.gremlin.conversion.result.GremlinResultVertexReader.read(GremlinResultVertexReader.java:52)
    at com.microsoft.spring.data.gremlin.conversion.source.AbstractGremlinSource.doGremlinResultRead(AbstractGremlinSource.java:144)
    at com.microsoft.spring.data.gremlin.query.GremlinTemplate.recoverDomain(GremlinTemplate.java:341)
    at com.microsoft.spring.data.gremlin.query.GremlinTemplate.insert(GremlinTemplate.java:154)
    at com.microsoft.spring.data.gremlin.query.GremlinTemplate.save(GremlinTemplate.java:275)
    at com.microsoft.spring.data.gremlin.repository.support.SimpleGremlinRepository.save(SimpleGremlinRepository.java:45)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.springframework.data.repository.core.support.RepositoryComposition$RepositoryFragments.invoke(RepositoryComposition.java:359)
    at org.springframework.data.repository.core.support.RepositoryComposition.invoke(RepositoryComposition.java:200)
    at org.springframework.data.repository.core.support.RepositoryFactorySupport$ImplementationMethodExecutionInterceptor.invoke(RepositoryFactorySupport.java:644)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
    at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.doInvoke(RepositoryFactorySupport.java:608)
    at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.lambda$invoke$3(RepositoryFactorySupport.java:595)
    at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke(RepositoryFactorySupport.java:595)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
    at org.springframework.data.projection.DefaultMethodInvokingMethodInterceptor.invoke(DefaultMethodInvokingMethodInterceptor.java:59)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
    at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:93)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
    at org.springframework.data.repository.core.support.SurroundingTransactionDetectorMethodInterceptor.invoke(SurroundingTransactionDetectorMethodInterceptor.java:61)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:212)
    at com.sun.proxy.$Proxy79.save(Unknown Source)
Incarnation-p-lee commented 5 years ago

@anuragk-sportsbet Thanks for your issue, could you please share some information about which version are you leverage for this repo ?

Besides that our implementation is DB backend independent and only ensuring it works well on gremlin server. Which means that if the backend DB has comparability issue with gremlin server, there may be something unexpected. You can verify it follow our IT test configuration here.

https://github.com/Microsoft/spring-data-gremlin/blob/91a7a627f0a700df551c35ed2d2d112d5ef50b6a/.travis.yml#L5-L11

anuragk-sportsbet commented 5 years ago

Hi @Incarnation-p-lee

implementation 'com.microsoft.spring.data.gremlin:spring-data-gremlin:2.1.0'

I am connecting to AWS Neptune using the library above.

jamsesso commented 4 years ago

Bumping this issue. It looks like the id property is present, but it's not the top-level in the map. I've got the same set up as @anuragk-sportsbet above. Seems to only happen when connected to neptune.

Screen Shot 2020-07-12 at 4 57 20 PM
chenrujun commented 3 years ago

Closing this issue. Because it's not active for a long time. If anyone have similar issue, please create issue in new repo: https://github.com/Azure/azure-sdk-for-java/issues