Integer Context Variable causing generate error in tMongoDBConnection

One Star

Integer Context Variable causing generate error in tMongoDBConnection

Hello,
I am using an integer context variable to specify the connect port to a MongoDB database, which is different for DEV and PROD and other environments. This is in the tMongoDBConnection
However, whenever I define the context variable for PORT in the component section, I get a generate failed message like below:
Execution failed : Failed to generate code.
[org.eclipse.emf.codegen.jet.JETException: InvocationTargetException in ....
The following is captured in the logs...
Caused by: org.eclipse.emf.codegen.jet.JETException: InvocationTargetException
at org.eclipse.emf.codegen.jet.JETEmitter.generate(JETEmitter.java:475)
at org.eclipse.emf.codegen.jet.JETEmitter.generate(JETEmitter.java:447)
at org.eclipse.emf.codegen.jet.JETEmitter.generate(JETEmitter.java:438)
at org.talend.designer.codegen.proxy.JetProxy.generate(JetProxy.java:54)
at org.talend.designer.codegen.CodeGenerator.generateComponentCode(CodeGenerator.java:928)
... 44 more
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.GeneratedMethodAccessor22.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.emf.codegen.jet.JETEmitter.generate(JETEmitter.java:467)
... 48 more
Caused by: java.lang.NumberFormatException: For input string: "context.target_port"
at java.lang.NumberFormatException.forInputString(Unknown Source)
at java.lang.Integer.parseInt(Unknown Source)
at java.lang.Integer.<init>(Unknown Source)
at org.talend.designer.codegen.translators.nosql.mongodb.TMongoDBConnectionBeginJava.generate(TMongoDBConnectionBeginJava.java:62)
I entered a numeric value in the Port field of the connection so I can get the code generated. Here is the image from the code.
Five Stars

Re: Integer Context Variable causing generate error in tMongoDBConnection

Have you tried defining it as a String rather than an int?
One Star

Re: Integer Context Variable causing generate error in tMongoDBConnection

Yes, I had tried defining the variable as a string as well but getting the same issue.
Note that the port number expects a numeric value.
Moderator

Re: Integer Context Variable causing generate error in tMongoDBConnection

Hi,
Execution failed : Failed to generate code.
[org.eclipse.emf.codegen.jet.JETException: InvocationTargetException in ....

Could you use other talend version to see if this issue repro? Or restart your studio..
Best regards
Sabrina
--
Don't forget to give kudos when a reply is helpful and click Accept the solution when you think you're good with it.