Comments (16)
  • Add a Comment
  • Edit
  • More Actions v
  • Quarantine this Entry

1 Alex Dvinsky commented Permalink

Fixed the missing "install" directive in module installation command and added a note about Java libraries.

2 DivyaMahendran commented Permalink

I am getting 'Adapter deployment failed: Failed to start Node.js adapter' error when trying to deploy the adapter. Followed all the steps as described.

3 Alex Dvinsky commented Permalink

@DivyaMahendran Sorry for a late reply - just got back from a vacation.
This error usually appears if the env entries in the web.xml file are not properly configured. Please verify that the path to node executable is correct and that the workarea directory exists and is writable by the user running the server.

 
Note, if you are testing this with the internal Liberty server from Eclipse then you don't have a direct control over the web.xml file (because the WAR file is being regenerated on the fly each time a project is changed). A little hack can be used for this case - add the env entries to:
<EclipseInstallationPath>/plugins/com.worklight.worklight-build-tools-<version>/war/web.xml
 
This file will be used in the generated WAR file. Once this is done and the project is republished to the internal server you'll be able to deploy a Node.js adapter to it as well.

4 ddougherty commented Permalink

Hi...I downloaded and got this running right away - very slick. One question - if I add WL.Logger.x statements (or just console.log) to the adapter-impl, where does the output go? I've looked in the usual places but can't seem to find anything. thx,dave

5 Alex Dvinsky commented Permalink

@ddougherty Hi, I'm glad the installation was easy :-) now about the logging. First the easy part - console.log won't be shown anywhere, as the stdout of the adapter process is not monitored.
About the WL..Logger.* methods: The methods call their exact counterparts in the regular API, just travel through an HTTP socket beforehand. According to the documentation here: http://pic.dhe.ibm.com/infocenter/wrklight/v6r0m0/index.jsp?topic=%2Fcom.ibm.help.doc%2Fwl_home.html
whether the messages are seen or not is configured at the App Server level. I'll check it a bit more in depth and update.

6 RohitSh commented Permalink

Alex -
I've tried this sample. However, I'm unable to deploy this.
Steps I've done:
1. install nodejs and wl packages as mentioned above.
2. updated web.xml in eclipse plugins folder. I've given following path for mentioned entry:
<env-entry>
<env-entry-name>node/executable</env-entry-name>
<env-entry-type>java.lang.String</env-entry-type>
<env-entry-value>/home/myuser/Programming/node-v0.10.24/node</env-entry-value>
</env-entry>
3. updated eclipse.ini
4. imported testNode project, ran the adapters within eclipse. Got below mentioned error on invoking simple adapter getValue procedure:
{
"errors": [
"Runtime: Http request failed: org.apache.http.conn.HttpHostConnectException: Connection to http:\/\/localhost:11002 refused"
],
"info": [
],
"isSuccessful": false,
"warnings": [
]
}
However, eclipse showed adapter is deployed successfully. IMO these adapters are not deployed in node. How can i do so ?
Is there's a way for automating the deploy process like ANT or Maven or else as we may plan to take this to production ?
I think there's something fishy with my deployment. can you help me with this ?

7 Alex Dvinsky commented Permalink

@RohitSh
If the adapter was successfully deployed, then the hardest part of the job was done. :-) Maybe it crashed, for some reason, sometimes could be something as silly as port number collision.
Could you check whether you see a Node.js process appearing after the adapter (successful) deploy?
Does the adapter show up in the Worklight console?
Anything shows up in the Worklight logs immediately following the deploy?

8 PaulDeepakRaj commented Permalink

Alex,
I am also getting the same exception as RohitSh. I am able to follow instructions and deploy adapter successfully but when i invoke them, i am getting same exception as below.

 
[Http request failed: org.apache.http.conn.HttpHostConnectException: Connection to http://localhost:11010 refused
FWLSE0101E: Caused by: [project TestNode]org.apache.http.conn.HttpHostConnectException: Connection to http://localhost:11010 refusedjava.lang.RuntimeException: Http request failed: org.apache.http.conn.HttpHostConnectException: Connection to http://localhost:11010 refused
at com.worklight.adapters.http.HTTPConnectionManager.execute(HTTPConnectionManager.java:241)
at com.worklight.adapters.http.HttpClientContext.doExecute(HttpClientContext.java:176)
at com.worklight.adapters.http.HttpClientContext.execute(HttpClientContext.java:160)
at com.worklight.adapters.http.HTTP.execRequest(HTTP.java:135)
at com.worklight.adapters.http.HTTP.invoke(HTTP.java:124)
at com.worklight.integration.model.ProcedureInvoker.invokeProcedure(ProcedureInvoker.java:57)
at com.worklight.adapters.node.NodeJJsInvoker.invokeProcedure(NodeJJsInvoker.java:62)
at com.worklight.integration.model.Procedure.invoke(Procedure.java:166)
at com.worklight.integration.model.InvocationContext.call(InvocationContext.java:169)
at com.worklight.integration.model.InvocationContext.call(InvocationContext.java:38)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at com.worklight.server.util.ProjectLocal$1RunnableWrapper.run(ProjectLocal.java:267)
at java.lang.Thread.run(Thread.java:724)
]
 
Please see your suggestions and my response.
 
[Alex] Maybe it crashed, for some reason, sometimes could be something as silly as port number collision.
[Paul] I dont think, it is crashed. I had problem with port number but resolved it.
[Alex] Could you check whether you see a Node.js process appearing after the adapter (successful) deploy?
[Paul] I dont see the process for Nodejs even though the adapter says it is deployed successfully..
[Alex] Does the adapter show up in the Worklight console?
[Paul] Yes. Node Adapter shows on worklight console.
[Alex] Anything shows up in the Worklight logs immediately following the deploy?
[Paul] I dont see any exception about the adapter deploy in the log.
 
Appreciate your help. Thanks.

9 Alex Dvinsky commented Permalink

@PaulDeepakRaj
Please try to run the adapter process manually and see whether any error is printed. The command line executed by the Worklight server is:
<Node executable="executable"> <Full path="path" to="to" deployed="deployed" adapter="adapter" JS="JS" file="file" in="in" workspace="workspace"> <adapter port="port"> <Worklight server="server" port="port"> <Integration serv.="serv." path="path"> <AdapterName>

 
For example:
"C:\Program Files\nodejs\node.exe" C:\TestNode\workspace\SimpleAdapter-impl.js 11000 10080 /TestNode/node/integration SimpleAdapter</AdapterName></Integration></Worklight></adapter></Full></Node>

10 Alex Dvinsky commented Permalink

Formatting problems with previous comment, probably the engine thinks there are XML tags. Retry:

 
@PaulDeepakRaj
Please try to run the adapter process manually and see whether any error is printed. The command line executed by the Worklight server is:
{Node executable} {Full path to deployed adapter JS file in workspace} {adapter port} {Worklight server port} {Integration servlet path} {AdapterName}
 
For example:
"C:\Program Files\nodejs\node.exe" C:\TestNode\workspace\SimpleAdapter-impl.js 11000 10080 /TestNode/node/integration SimpleAdapter

11 PaulDeepakRaj commented Permalink

Thanks Alex for your prompt reply.

 
I ran the command as you suggested. Below are the response i am getting in command line and console.
 
C:\Program\JavaScript\Node\workarea>"C:\Program\JavaScript\Node\node.exe" C:\Program\JavaScript\Node\workarea\SimpleAdapter-impl.js 11010 10080 /TestNode/node/integration SimpleAdapter
Failed to retrieve Worklight configuration - Unexpected token E
 
I see below exception in Worklight console.
 
[WARNING ] WARNING: Cannot set status. Response already committed.
[ERROR ] FWLSE0048E: Unhandled exception caught: Authentication filter not defined for the current request.
java.lang.RuntimeException: Authentication filter not defined for the current request.
at com.worklight.core.auth.impl.AuthenticationServiceBean.getAuthenticationContext(AuthenticationServiceBean.java:189)
at com.worklight.core.auth.impl.AuthenticationServiceBean.getContextPlugin(AuthenticationServiceBean.java:202)
at com.worklight.core.auth.impl.PlatformUsageServicePlugin.getInstance(PlatformUsageServicePlugin.java:28)
at com.worklight.core.auth.impl.AuthenticationContext.saveInternalUserName(AuthenticationContext.java:355)
at com.worklight.core.auth.impl.AuthenticationFilter.doFilter(AuthenticationFilter.java:206)
at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:194)
at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:85)
at com.ibm.ws.webcontainer.filter.WebAppFilterManager.doFilter(WebAppFilterManager.java:949)
at com.ibm.ws.webcontainer.filter.WebAppFilterManager.invokeFilters(WebAppFilterManager.java:1029)
at com.ibm.ws.webcontainer.servlet.CacheServletWrapper.handleRequest(CacheServletWrapper.java:78)
at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:885)
at com.ibm.ws.webcontainer.osgi.DynamicVirtualHost$2.run(DynamicVirtualHost.java:252)
at com.ibm.ws.http.dispatcher.internal.channel.HttpDispatcherLink$TaskWrapper.run(HttpDispatcherLink.java:584)
at com.ibm.ws.threading.internal.Worker.executeWork(Worker.java:439)
at com.ibm.ws.threading.internal.Worker.run(Worker.java:421)
at java.lang.Thread.run(Unknown Source)
[project TestNode]
Authentication filter not defined for the current request.
[WARNING ] SRVE8094W: WARNING: Cannot set header. Response already committed.

12 Alex Dvinsky commented Permalink

Hi, Paul.

 
I'm forwarding this to the core WL development team - will update when we have something.
 
Thanks,
Alex.

13 PaulDeepakRaj commented Permalink

Thanks Alex. Just wanted to let you know that I have tried this example in Worklight 6.1, even though article title says WL 6.0.0.

 
Please share if you have any finding. Thanks.

14 Alex Dvinsky commented Permalink

Hi, Paul.

 
After some investigations the WL team confirmed that you suspected - it must be due to "devices implementation", a change that was done in 6.1.0. :-(
I've filed a defect report about it (unfortunately not visible from the outside).
 
Thanks,
Alex.

15 NagaRamanan commented Permalink

Hi Alex,

 
Any clue, whether the above raised bug has been fixed? If so, please let me know the version in which it is resolved.
 
Thanks.