I’m trying to develop my own plugin. I’m using the very detailed tutorial from Patrick (thx a lot btw) to build it .
I have “finished” it. It is recognised correctly by Servoy (all arguments/method visible, sample data, tooltips working ok). For my Servoy solution I can get/set all arguments values.
But when I try to run the only method I have done (there is only one method for the moment) it does nothing. The method is supposed to return a String (not null) in any case but it doesn’t return anything. The function is working normally when running the Java Project but when triggering it from the plugin nothing. I have try/catch in it as well, but not exception raised
Here is the function in Servoy which calls the plugin function:
function TestPlugin() {
// adds/edits a Contact record in MS Exchange Server depending on the exchange contact unique id generated by EPiC
// all parameters need to be entered. Put null if no data to provide
application.output(plugins.AGxChangePlugin.sApplicationUserAccountName)
application.output(plugins.AGxChangePlugin.sApplicationUserPassword)
application.output(plugins.AGxChangePlugin.sContactsFolder)
application.output(plugins.AGxChangePlugin.sExchangeServerUrl)
application.output(plugins.AGxChangePlugin.sPublicMailbox)
application.output(plugins.AGxChangePlugin.SetContactRecord(99518161,'Tom','Tomson','Asset Guardian Solutions Limited','Software Engineer','tom.t@assetguardian.com','01506597908','01506597913',null,'Elite House Starlaw Business Park', 'Livingston','West Lothian','EH54 8SF','United Kingdom'));
All outputs are ok except the one of the function SetContactRecord.
Indeed an exception is thrown from my plugin.
I have detected in which class and method it’s happening. But this method works perfectly in my Java Project.
So I think it’s due to my jnlp file which is wrong and doesn’t provide all the classes for it to work.
I need 4 external jars to run this plugin: jakarta-slide-webdavlib-2.1.jar, jdom.jar, commons-httpclient.jar, commons-logging.jar
Here is my current jnlp file:
I have tried to build it using existing jnlp I have in Servoy. But I’m not sure at all if it’s the right way to do it.
commons-httpclient.jar is already in Servoy lib folder. Is that a problem if I copy the one I use in my Java Project into the plugin folder and have it twice (one in the plugin folder and one in the servoy lib folder)?
For the “version” tag, do I need to enter the right one?
Actually what are the rules to build a proper jnlp file for Servoy?
I think is not a problem related with jnlp file… If you are executing from Developer, jnlp file is not used (I think). That file is used when launched from SC against a Servoy Server over the net…
gerardo.gomez:
I think is not a problem related with jnlp file… If you are executing from Developer, jnlp file is not used (I think). That file is used when launched from SC against a Servoy Server over the net…
Not sure about that
Because plugin files (jar file) do not contain the library files. So how can it find them without the jnlp file?
What do you mean by ‘Interactive Console’? The ‘Console’ tab next to ‘Profiler View’, ‘Debug’ ?!
Yes, that’s where my exception is displayed.
But if it’s not a problem of library, then I don’t understand why it’s working in Java and not in Servoy (it’s exactly the same code which is run)
gerardo.gomez:
In “Debug perspective” > Window > Show View > Interactive Console
Ok, found it. But I cannot manage to use it
When I run my solution nothing prints on this console. If I paste the line I want to run the button to run the code is still disabled. If I put a breakpoint on the line nothing happens in this console.
I’ve managed to find the issue.
It’s on the last line of this code.
HttpsURL hrl = new HttpsURL(sNewContactUrlUnformatted);
hrl.setUserinfo(m_sUsername, m_sPassword);
wdrNewContact = new WebdavResource(hrl);
In fact the constructor of WebdavResource only accepts HttpURL objects. But HttpsURL is a subclass of HttpURL.
It works fine in Java but here for some reason it doesn’t
Any idea? (My connection to the Exchange Server has to be done through https)
Actually “wdrNewContact = new WebdavResource(hrl);” throws also an exception in Java. But I didn’t catch it and for some reason the code was still doing the job I wanted.
So now I have changed it to get no exception. Here is the code:
wdrNewContact = new WebdavResource(sNewContactUrlUnformatted,new UsernamePasswordCredentials(m_sUsername, m_sPassword));
This works well in Java. But in Servoy I still get an Exception and the job is not done (unlike in Java).
What is the Exception exactly? Do you have a stacktrace for this?
I believe that commons-httpclient.jar is already part of Servoy, so you shouldn’t put it into your subfolder.
There might be some jar version collision. Also when you say it works from Java, what is the classpath you use in that case, it must be different from the one used in the debug smart client.
The jar that you use can also have some dependencies themselves… Are you sure that all of these are in the debug client classpath vs when you use it ‘from Java’?
ptalbot:
I believe that commons-httpclient.jar is already part of Servoy, so you shouldn’t put it into your subfolder.
Yes indeed. My Java project was still using my commons-httpclient.jar and the Smart Client project uses the one from Servoy libs.
When I have changed the one of the Java with the one of Servoy I got an exception as well (classnotfound)
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/codec/DecoderException
at org.apache.webdav.lib.WebdavResource.setHttpURL(WebdavResource.java:1426)
at org.apache.webdav.lib.WebdavResource.<init>(WebdavResource.java:397)
at com.bright.framework.exchange.service.ExchangeBridge.getExchangeWebdavResource(ExchangeBridge.java:1083)
at com.bright.framework.exchange.service.ExchangeBridge.updateContact(ExchangeBridge.java:638)
at com.assetguardian.plugin.agxchange.AGxChangePluginProvider.js_SetContactRecord(AGxChangePluginProvider.java:104)
at com.assetguardian.plugin.agxchange.AGxChangePluginProvider.main(AGxChangePluginProvider.java:35)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.codec.DecoderException
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
... 6 more
The funny thing is that Servoy lib is more recent than mine (2004 vs 2006)
Must be a deprecated method?! I don’t understand why I don’t get an error/warning before running it
Edit: Now I’m even more confused. None of the 2 jars have the class “org.apache.commons.codec.DecoderException”. They don’t even have a folder “codec”. But when I swap them it fixes/raises the exception