Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
Schrauber
Contributor
Contributor

@Suggestable and @Proposable throw NullPointerExceptions

Hi,

I am working on a custom component developed with talend component kit.

In my UI, I have one field with selection. I tried @Suggestable and also @Proposable to achieve this.

This seems to be working. I get my selection list an I can select one entry. But with both methods I find NullPointerExceptions in the .log file in my studio workspace.

What is wrong here?

My Studio is Open Studio 7.3.1

The version of talend component kit from studio is 1.1.15 and I have set the version in pom also to 1.1.15.

 

I implemented @Suggestable as follows:

   @Option

   @Required

   @Suggestable(GET_PATH_LIST)

   @Documentation("TODO fill the documentation for this parameter")

   private String path;

 

And in @Service:

   public static final String GET_PATH_LIST = "getPathList";

   @Suggestions(GET_PATH_LIST)

   public SuggestionValues getPathList() {

       List<SuggestionValues.Item> items = new ArrayList<>();

       items.add(new SuggestionValues.Item("/api/rest/v1/locales", "/api/rest/v1/locales"));

       items.add(new SuggestionValues.Item("/api/rest/v1/channels", "/api/rest/v1/channels"));

       items.add(new SuggestionValues.Item("/api/rest/v1/currencies", "/api/rest/v1/currencies"));

       items.add(new SuggestionValues.Item("/api/rest/v1/attributes", "/api/rest/v1/attributes"));

       items.add(new SuggestionValues.Item("/api/rest/v1/attributes/{attributeCode}/options", "/api/rest/v1/attributes/{attributeCode}/options"));

       items.add(new SuggestionValues.Item("/api/rest/v1/attribute-groups", "/api/rest/v1/attribute-groups"));

       items.add(new SuggestionValues.Item("/api/rest/v1/families", "/api/rest/v1/families"));

       items.add(new SuggestionValues.Item("/api/rest/v1/products", "/api/rest/v1/products"));

       return new SuggestionValues(true, items);

   }

 

What I have read from the docs, this should be OK.

 

But now I get this NullPointerException:

!ENTRY org.talend.platform.logging 2 0 2020-11-21 21:36:18.616

!MESSAGE 2020-11-21 21:36:18,615 WARN org.talend.sdk.component.studio.logging.JULToOsgiHandler - [org.talend.sdk.component.server.configuration.WebSocketBroadcastSetup$JAXRSEndpoint.onError] Error for session 0

!STACK 0

java.lang.NullPointerException

   at org.talend.sdk.component.server.front.memory.AsyncContextImpl.complete(AsyncContextImpl.java:156)

   at org.apache.cxf.transport.http.Servlet3ContinuationProvider$Servlet3Continuation.reset(Servlet3ContinuationProvider.java:158)

   at org.apache.cxf.transport.http.Servlet3ContinuationProvider.complete(Servlet3ContinuationProvider.java:71)

   at org.apache.cxf.transport.http.AbstractHTTPDestination.invokeComplete(AbstractHTTPDestination.java:295)

   at org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:268)

   at org.talend.sdk.component.server.configuration.WebSocketBroadcastSetup$WebSocketDestination.invoke(WebSocketBroadcastSetup.java:516)

   at org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:234)

   at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:208)

   at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:160)

   at org.talend.sdk.component.server.configuration.WebSocketBroadcastSetup$JAXRSEndpoint.lambda$onOpen$4(WebSocketBroadcastSetup.java:292)

   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.apache.tomcat.websocket.pojo.PojoMessageHandlerWholeBase.onMessage(PojoMessageHandlerWholeBase.java:80)

   at org.apache.tomcat.websocket.WsFrameBase.sendMessageBinary(WsFrameBase.java:582)

   at org.apache.tomcat.websocket.server.WsFrameServer.sendMessageBinary(WsFrameServer.java:131)

   at org.apache.tomcat.websocket.WsFrameBase.processDataBinary(WsFrameBase.java:541)

   at org.apache.tomcat.websocket.WsFrameBase.processData(WsFrameBase.java:300)

   at org.apache.tomcat.websocket.WsFrameBase.processInputBuffer(WsFrameBase.java:133)

   at org.apache.tomcat.websocket.server.WsFrameServer.onDataAvailable(WsFrameServer.java:82)

   at org.apache.tomcat.websocket.server.WsFrameServer.doOnDataAvailable(WsFrameServer.java:171)

   at org.apache.tomcat.websocket.server.WsFrameServer.notifyDataAvailable(WsFrameServer.java:151)

   at org.apache.tomcat.websocket.server.WsHttpUpgradeHandler.upgradeDispatch(WsHttpUpgradeHandler.java:148)

   at org.apache.coyote.http11.upgrade.UpgradeProcessorInternal.dispatch(UpgradeProcessorInternal.java:54)

   at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:53)

   at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:861)

   at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1579)

   at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)

   at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)

   at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)

   at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)

   at java.lang.Thread.run(Thread.java:748)

 

Any Ideas on that?

Best regards,

Schrauber

Labels (3)
2 Replies
ozhelezniak
Contributor
Contributor

Hi @Maik Opitz​ 

I suggest using @Proposable and dynamic values https://talend.github.io/component-runtime/main/1.28.2/ref-actions.html#_dynamic_values

for your example.

 

What did you mean when you said: "But with both method". I see only one method that marked with "@Suggestions(GET_PATH_LIST)".

 

undx
Creator
Creator

Hi @Maik Opitz​ ,

Everything seems fine in your code...

Can you reproduce with the `talend-component:web` goal ?

Also, in studio `configuration/config.ini` put the following property

```

component.java.port=8181

```

restart your studio and do the following curl call

```

curl -X POST "localhost:8181/api/v1/action/execute?family=YourFamilyName&type=suggestions&action=getPathList&language=en" -H "accept: application/json" -H "Content-Type: application/json" -d '{}'

```

Do you get ?

```

{"cacheable":true,"items":[{"id":"/api/rest/v1/locales","label":"/api/rest/v1/locales"},{"id":"/api/rest/v1/channels","label":"/api/rest/v1/channels"},{"id":"/api/rest/v1/currencies","label":"/api/rest/v1/currencies"},{"id":"/api/rest/v1/attributes","label":"/api/rest/v1/attributes"},{"id":"/api/rest/v1/attributes/{attributeCode}/options","label":"/api/rest/v1/attributes/{attributeCode}/options"},{"id":"/api/rest/v1/attribute-groups","label":"/api/rest/v1/attribute-groups"},{"id":"/api/rest/v1/families","label":"/api/rest/v1/families"},{"id":"/api/rest/v1/products","label":"/api/rest/v1/products"}]}

```

Otherwise post the result and st.

 

thanks

 

br