Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vpc.fromLookup() throwing exception - CDK 1.5.0 #3774

Closed
smoghal opened this issue Aug 23, 2019 · 8 comments
Closed

Vpc.fromLookup() throwing exception - CDK 1.5.0 #3774

smoghal opened this issue Aug 23, 2019 · 8 comments
Assignees
Labels
bug This issue is a bug. language/dotnet Related to .NET bindings language/java Related to Java bindings language/python Related to Python bindings

Comments

@smoghal
Copy link

smoghal commented Aug 23, 2019

I have upgraded to CDK/Java 1.5.0 + 0.15.1 and now this basic code is not working:

VpcLookupOptions vpcLookupOption = new VpcLookupOptions.Builder().vpcId(<myVpcID>).build();
IVpc vpc = Vpc.fromLookup(this, "my-VPC", vpcLookupOption);

Same with this line:

VpcLookupOptions vpcLookupOption = new VpcLookupOptions.Builder().isDefault(true).build();
IVpc vpc = Vpc.fromLookup(this, "my-VPC", vpcLookupOption);

Exception:

java.lang.ExceptionInInitializerError
    at ….LambdaStack.<init> (LambdaStack.java:111)
    at ….LambdaStack.<init> (LambdaStack.java:73)
    at ….CDK_App.main (CDK_App.java:127)
    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.codehaus.mojo.exec.ExecJavaMojo$1.run (ExecJavaMojo.java:282)
    at java.lang.Thread.run (Thread.java:748)
Caused by: software.amazon.jsii.JsiiException: com.fasterxml.jackson.databind.JsonMappingException: Unable to instantiate a new object for FQN @aws-cdk/aws-ec2.SubnetConfiguration: null (through reference chain: java.util.ArrayList[0])
    at software.amazon.jsii.JsiiObjectMapper.treeToValue (JsiiObjectMapper.java:57)
    at software.amazon.jsii.JsiiObject.jsiiStaticGet (JsiiObject.java:125)
    at software.amazon.awscdk.services.ec2.Vpc.<clinit> (Vpc.java:38)
       …
Caused by: com.fasterxml.jackson.databind.JsonMappingException: Unable to instantiate a new object for FQN @aws-cdk/aws-ec2.SubnetConfiguration: null (through reference chain: java.util.ArrayList[0])
    at com.fasterxml.jackson.databind.JsonMappingException.wrapWithPath (JsonMappingException.java:394)
    at com.fasterxml.jackson.databind.JsonMappingException.wrapWithPath (JsonMappingException.java:365)
    at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize (CollectionDeserializer.java:302)
    at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize (CollectionDeserializer.java:245)
    at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize (CollectionDeserializer.java:27)
    at com.fasterxml.jackson.databind.ObjectMapper._readValue (ObjectMapper.java:3985)
    at com.fasterxml.jackson.databind.ObjectMapper.readValue (ObjectMapper.java:2277)
    at com.fasterxml.jackson.databind.ObjectMapper.treeToValue (ObjectMapper.java:2759)
    at software.amazon.jsii.JsiiObjectMapper.treeToValue (JsiiObjectMapper.java:55)
    at software.amazon.jsii.JsiiObject.jsiiStaticGet (JsiiObject.java:125)
    at software.amazon.awscdk.services.ec2.Vpc.<clinit> (Vpc.java:38)

This worked well before the latest CDK version.

@smoghal smoghal added the bug This issue is a bug. label Aug 23, 2019
@rhboyd
Copy link
Contributor

rhboyd commented Aug 25, 2019

What version were you using before when it was working? I'm trying to recreate the bug.

@smoghal
Copy link
Author

smoghal commented Aug 25, 2019

1.4.0

@joezhou888
Copy link

I have same problem different error message:
Exception in thread "main" java.lang.ExceptionInInitializerError
at edu.sydney.ict.ldsws.aws.env.InfrastructureStack.(InfrastructureStack.java:40)
at edu.sydney.ict.ldsws.aws.env.InfrastructureApp.main(InfrastructureApp.java:13)
Caused by: software.amazon.jsii.JsiiException: com.fasterxml.jackson.databind.JsonMappingException: Unable to instantiate a new object for FQN @aws-cdk/aws-ec2.SubnetConfiguration: null (through reference chain: java.util.ArrayList[0])
at software.amazon.jsii.JsiiObjectMapper.treeToValue(JsiiObjectMapper.java:57)
at software.amazon.jsii.JsiiObject.jsiiStaticGet(JsiiObject.java:125)
at software.amazon.awscdk.services.ec2.Vpc.(Vpc.java:38)
... 2 more
Caused by: com.fasterxml.jackson.databind.JsonMappingException: Unable to instantiate a new object for FQN @aws-cdk/aws-ec2.SubnetConfiguration: null (through reference chain: java.util.ArrayList[0])
at com.fasterxml.jackson.databind.JsonMappingException.wrapWithPath(JsonMappingException.java:394)
at com.fasterxml.jackson.databind.JsonMappingException.wrapWithPath(JsonMappingException.java:365)
at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:302)
at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:245)
at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:27)
at com.fasterxml.jackson.databind.ObjectMapper._readValue(ObjectMapper.java:4057)
at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:2416)
at com.fasterxml.jackson.databind.ObjectMapper.treeToValue(ObjectMapper.java:2835)
at software.amazon.jsii.JsiiObjectMapper.treeToValue(JsiiObjectMapper.java:55)
... 4 more
Caused by: software.amazon.jsii.JsiiException: Unable to instantiate a new object for FQN @aws-cdk/aws-ec2.SubnetConfiguration: null
at software.amazon.jsii.JsiiEngine.createNativeProxy(JsiiEngine.java:248)
at software.amazon.jsii.JsiiEngine.nativeFromObjRef(JsiiEngine.java:133)
at software.amazon.jsii.JsiiObjectMapper$JsiiDeserializer.deserialize(JsiiObjectMapper.java:140)
at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:286)
... 10 more
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at software.amazon.jsii.JsiiEngine.createNativeProxy(JsiiEngine.java:238)
... 13 more
Caused by: java.lang.IllegalArgumentException: No enum constant software.amazon.awscdk.services.ec2.SubnetType.undefined
at java.lang.Enum.valueOf(Enum.java:238)
at software.amazon.jsii.JsiiEngine.findEnumValue(JsiiEngine.java:272)
at software.amazon.jsii.JsiiObjectMapper$JsiiDeserializer.deserialize(JsiiObjectMapper.java:137)
at com.fasterxml.jackson.databind.ObjectMapper._readValue(ObjectMapper.java:4057)
at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:2416)
at com.fasterxml.jackson.databind.ObjectMapper.treeToValue(ObjectMapper.java:2835)
at software.amazon.jsii.JsiiObjectMapper.treeToValue(JsiiObjectMapper.java:55)
at software.amazon.jsii.JsiiObject.jsiiGet(JsiiObject.java:111)
at software.amazon.awscdk.services.ec2.SubnetConfiguration$Jsii$Proxy.(SubnetConfiguration.java:140)

@rhboyd
Copy link
Contributor

rhboyd commented Aug 26, 2019

I can reproduce it and it also affects Vpc.fromVpcAttributes(...)

@RomainMuller
Copy link
Contributor

This is caused by a bug in the JSII kernel, which has always been there but is triggered by a change in behavior with respects to object initialization in the Java runtime.

@RomainMuller RomainMuller added language/java Related to Java bindings language/dotnet Related to .NET bindings language/python Related to Python bindings labels Aug 29, 2019
@RomainMuller
Copy link
Contributor

Created issue on JSII side to track that: aws/jsii#753

@RomainMuller
Copy link
Contributor

This would be fixed with the next CDK release that builds with jsii >= 0.16.0.

@rix0rrr
Copy link
Contributor

rix0rrr commented Oct 24, 2019

Fixed in cdk 1.7.0.

@rix0rrr rix0rrr closed this as completed Oct 24, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug. language/dotnet Related to .NET bindings language/java Related to Java bindings language/python Related to Python bindings
Projects
None yet
Development

No branches or pull requests

5 participants