jWebSocket Server side plugin using eclipse
Hello All, because of the lot of questions asked by our users in jwebsocket forum regarding server side plugin development, i would like to list the simple eclipse based java project that uses jWebSocket and other jars as well as custom configuration to write a jWebSocket custom plugin in a separate small eclipse project. This also applies to any other IDE with few minor differences.
Download all the jWebSocket jars from our repository http://code.google.com/p/jwebsocket/downloads/detail?name=jWebSocketServer-0.10.zip&can=2&q= and all the dependency jars, if you are so impatient below is the snapshot of my eclipse project with hello world plugin.
So the above snapshot is the simple java project, which has jwebsocket and other libraries. Only thing that needs attention is jWebSocket.xml file in the conf folder, which is what we used to override the xml file that comes with jWebSocketServer.jar. In your conf/jWebSocket.xml jar you have to define your custom plugin say
<plugin>
<name>com.plugins.HelloWorldPlugin</name></pre>
<id>jws.custom</id>
<ns>com.plugins.custom</ns>
<jar>jWebSocketCustom-0.10.jar</jar>
<server-assignments>
<server-assignment>ts0</server-assignment>
</server-assignments>
</plugin>
NOTE that even though we are not using jar for our custom plugin you still have to specify it because of the known issue in jWebSocket.
Now to start the jWebSocket server you have to specify the jWebSocket main class in eclipse, From the eclipse menu select:
Run ->Run Configurations, then select Java Application which more or less looks like the snapshot below.
Specify the main class as org.jwebsocket.console.JWebSocketServer and in the arguments tab provide the -config argument value as the full path of your jWebSocket.xml file as
-config /Users/puran/project/JWebSocketApp/conf/jWebSocket-override.xml
After that you can select Run->Your application configuration name above.
Here is the sample eclipse project which you can download and get started easily http://code.google.com/p/jwebsocket/downloads/detail?name=JWebSocketApp.zip&can=2&q=
I hope this will be helpful. Feel free to ask any questions or comments.


Thank you!
Hello Puran, thanks again for making this available. I have tried out your posting and have not had success in ‘firing’ the plugin, hope you can help.
First, some notes:
a) I belive the main class for the eclipse project is not org.jwebsocket.console.JWebSocketServer (as posted above) but org.jwebsocket.console.JWebSocket
b) the posted snippet for the override xml has a spurious bit of html in line #2: that needs to be removed
c) the posted snippet of your Eclipse project lists two java files: HelloWorldPlugin.java and RandomData.java; however the downloaded project contains: HelloWorldPlugin.java and CustomInitializer.java?
I was able to build and run the project after making the change to what the main class should be and the engine seems to fire up just fine. Here is the console output:
jWebSocket Ver. 0.9.0.0503 beta
(C) 2010 jWebSocket.org by Innotrade GmbH, Germany, Herzogenrath
Distributed under GNU GPL License Version 3.0 (http://www.gnu.org/licenses/gpl-3.0.html)
JWEBSOCKET_HOME variable not set, using default configuration...
2010-10-19 16:01:41,202 DEBUG - SecurityFactory: Initializing demo rights, roles and users...
2010-10-19 16:01:41,207 INFO - SecurityFactory: Default rights, roles and users initialized.
Engine tcp listening on port 8787, default (sub)prot json, default session timeout: 120000, log-level: debug
2010-10-19 16:01:41,210 DEBUG - TCPEngine: Starting TCP engine...
2010-10-19 16:01:41,228 INFO - TCPEngine: TCP engine started.
2010-10-19 16:01:41,239 DEBUG - SystemFilter: Instantiating system filter...
2010-10-19 16:01:41,239 DEBUG - TokenFilterChain: Adding token filter systemFilter...
2010-10-19 16:01:41,242 DEBUG - SystemPlugIn: Instantiating system plug-in...
2010-10-19 16:01:41,243 DEBUG - RPCPlugIn: Instantiating rpc plug-in...
2010-10-19 16:01:41,244 DEBUG - StreamingPlugIn: Instantiating streaming plug-in...
2010-10-19 16:01:41,248 DEBUG - FlashBridgePlugIn: Starting flash bridge...
2010-10-19 16:01:41,249 INFO - FlashBridgePlugIn: flash bridge started.
2010-10-19 16:01:41,250 DEBUG - JWebSocket: Starting token server...
2010-10-19 16:01:41,250 INFO - TokenServer: Token server started.
2010-10-19 16:01:41,253 DEBUG - TimeStream$TimerThread: Starting time stream...
2010-10-19 16:01:41,254 DEBUG - MonitorStream$MonitorProcess: Starting monitor stream...
2010-10-19 16:01:41,254 DEBUG - JWebSocket: Starting custom server...
Which is good, but I haven't been able to successfully add the 'HelloWorldPlugin' to the plugin chain (as you can see in the above there are no messages corresponding to:
System.out.println("Engine Started on Hello World Plugin");
and the like (I've added a few log4j debug statements of my own)
Here is what I added to your project's jWebSocket.xml file (in ):
com.plugins.HelloWorldPlugin
jws.custom
com.plugins.custom
jWebSocketCustom-0.10.jar
ts0
Do you have any suggestions as to where I have gone wrong with this? I am guessing I haven't configured the override xml file properly. Or possibly, when running the -config wasn't done right (although I tried to follow your post exactly in terms of providing the full path to the file: -config /Users/stevexm/Documents/workspace/JWebSocketApp/conf/jWebSocket-override.xml
Thanks in advance, Steve M
Hi Steve,
sorry for that i got trick by the same file name and uploaded the old zip package.. i have replaced with the new one and i tested it myself in eclipse and it works!!
I am not sure about JWebSocket.java, because we only have org.jwebsocket.console.JWebSocketServer as the main class now i think it’s because of the old jar .. i remember we used to have that name before..
try this one, it will work now.
Follow up of my previous comment:
UTF-8
UTF-8
best regards,
Fernando
Many thanks for the quick turn-around…much appreciated!
Hi Purans! Thanks for the posting. However, I have two things in my eclipse.
1. Complete source code that is set with JWEBSOCKET_HOME.
2. I download this source code and integrated with eclipse as separate project.
When I run your server side plugin example, I got an error
>>
WebSocketException during jWebSocket Server startup: Either JWEBSOCKET_HOME variable is not set or jWebSocket.xml file does neither exist at %JWEBSOCKET_HOME%/conf nor at %CLASSPATH%/conf.
>> Pls can you tell me where is problem?
Thanks again
Thanks for good guide.
but, i have no idea…
———————————-
and in the arguments tab provide the -config argument value as the full path of your jWebSocket.xml file as
-config [MY-PATH]/jWebSocket-override.xml
———————————-
where can i set that line?
1. Run as -> Run Configuration
2. Arguments Tab
Program arguments?, VM arguments? where?
when run my application, eclipse displays below line in console…
———————————-
WebSocketException during jWebSocket Server startup: Either JWEBSOCKET_HOME variable is not set or jWebSocket.xml file does neither exist at %JWEBSOCKET_HOME%/conf nor at %CLASSPATH%/conf.
help me, plz…
Hello im trying to make my own plugin, but im using netbeans. I’ve managed to configure and run the project but there is a problem with proper path to config file.
I did it like that:
-config /Users/lukasz/jWebSocket.xml
but when im trying to run the project it says:
Log files per default in jWebSocket.log if not overwritten in jWebSocket.xml.
WebSocketException during jWebSocket Server startup: Either JWEBSOCKET_HOME variable is not set or jWebSocket.xml file does neither exist at %JWEBSOCKET_HOME%/conf nor at %CLASSPATH%/conf.
BUILD SUCCESSFUL (total time: 0 seconds)
What i did wrong ?
Wait, I cannot fathom it being so starightofwrrad.
There is a video tutorial available on our site which explains in details how to import the jWebSocket maven project into Eclipse.
Please refer to our Documentation section, click developer guide and select “Eclipse”.
Thanks,
Alex