# Using third party library in servoy plugin

**URL:** <https://forum.servoy.com/t/using-third-party-library-in-servoy-plugin/14456>\
**Category:** Classic Servoy\
**Created:** [August 10, 2011, 2:24pm UTC](https://forum.servoy.com/t/using-third-party-library-in-servoy-plugin/14456 "2011-08-10T14:24:56Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![sambitc](https://avatars.discourse-cdn.com/v4/letter/s/5e9695/32.png) [@sambitc](https://forum.servoy.com/u/sambitc)\
**Post date:** [August 10, 2011, 2:24pm UTC](https://forum.servoy.com/t/using-third-party-library-in-servoy-plugin/14456/1 "2011-08-10T14:24:56Z")

</div>

Hi friends,

I have created a servoy plugin where I have used third party libraries one of them is “ **tika-app-0.9.jar**" which is provided by apache foundation.  
when I am trying to use one of the method of that plugin in my servoy solution it is showing some error like :–”“ **Error during evaluation:org/apache/tika/Tika** ”".

I think error appears because java class of plugin is unable to access the method of the third party library.  
But I am not sure where is the actual problem .

Is it allowed to use third party library in servoy plugin ?

plese provide me any solution ![:(]( "Sad")

---

<div class="post-metadata">

**Author:** ![ROCLASI](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/roclasi/32/4371_2.png) [@ROCLASI](https://forum.servoy.com/u/ROCLASI)\
**Post date:** [August 12, 2011, 2:33pm UTC](https://forum.servoy.com/t/using-third-party-library-in-servoy-plugin/14456/2 "2011-08-12T14:33:04Z")

</div>

Hi,

Yes you can use third party libs in Servoy plugins and beans. Servoy and others do that all the time.  
Did you take a look at the [excellent tutorials](https://www.servoyforge.net/projects/tutorials-stuff) from Patrick Talbot ?

---

<div class="post-metadata">

**Author:** ![ptalbot](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/ptalbot/32/4952_2.png) [@ptalbot](https://forum.servoy.com/u/ptalbot)\
**Post date:** [August 12, 2011, 5:26pm UTC](https://forum.servoy.com/t/using-third-party-library-in-servoy-plugin/14456/3 "2011-08-12T17:26:00Z")

</div>

Also, since you want to use Tika, why not have a look at the SmartDoc plugin which already leverages Tika/Solr/Lucene for you?  
It’s Open Source on ServoyForge: [Overview - SmartDoc Plugin - ServoyForge](https://www.servoyforge.net/projects/smartdoc)

---

<div class="post-metadata">

**Author:** ![tysonj](https://avatars.discourse-cdn.com/v4/letter/t/f14d63/32.png) [@tysonj](https://forum.servoy.com/u/tysonj)\
**Post date:** [September 7, 2011, 7:50am UTC](https://forum.servoy.com/t/using-third-party-library-in-servoy-plugin/14456/4 "2011-09-07T07:50:56Z")

</div>

Hi,  
I am also facing the same type of problem.

I am creating a plugin in which I need a functionality to detect the mime type of file, for that I am using an third party jar “ **mime-util-2.1.3.jar** ”.  
From servoy form I am calling one of the method of my servoy plugin by passing the complete path of the file(ex. **c:/ppt/samplePPT.ppt** ), the plugin should call the method " **MimeUtil.getMimeTypes( “c:/ppt/samplePPT.ppt” )**" to get the mime type of the file, but I am not getting the result.  
When I debug my code I get error :- " **Error during evaluation:eu/medsea/mimeutil/MimeUtil"**

I do not know where I am wrong ![:(]( "Sad")

---

<div class="post-metadata">

**Author:** ![Harjo](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/harjo/32/4873_2.png) [@Harjo](https://forum.servoy.com/u/Harjo)\
**Post date:** [September 7, 2011, 9:29am UTC](https://forum.servoy.com/t/using-third-party-library-in-servoy-plugin/14456/5 "2011-09-07T09:29:46Z")

</div>

for mime-type you can use the image-plugin or the file-plugin of Servoy! look for: getContentType()

does’nt that work for you, right out of the box?

---

<div class="post-metadata">

**Author:** ![tysonj](https://avatars.discourse-cdn.com/v4/letter/t/f14d63/32.png) [@tysonj](https://forum.servoy.com/u/tysonj)\
**Post date:** [September 7, 2011, 9:49am UTC](https://forum.servoy.com/t/using-third-party-library-in-servoy-plugin/14456/6 "2011-09-07T09:49:50Z")

</div>

Actually I do not need a separate plugin because, I need to detect mime type of a file in my plugin so that I can use that mime type to implement another functionality in my plugin.

Another thing, In my plugin I am using no of third party jars to implement different functionality.  
But from very first I am getting error when I am calling **“MimeUtil.getMimeTypes( “c:/ppt/samplePPT.ppt” )”** to get mime type of a file.  
Since I am getting error by calling method of one third party jar, I do not think methods of other third party jars that I have used in my plugin will work.

---

<div class="post-metadata">

**Author:** ![ptalbot](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/ptalbot/32/4952_2.png) [@ptalbot](https://forum.servoy.com/u/ptalbot)\
**Post date:** [September 7, 2011, 2:34pm UTC](https://forum.servoy.com/t/using-third-party-library-in-servoy-plugin/14456/7 "2011-09-07T14:34:27Z")

</div>

Check for dependencies of this jar, if they are not present as well, this might be the cause of your problem.

Try to catch (Exception ex) in your plugin around the call to the MimeUtil method and put a Debug.error(ex) statement in there, so that you will have a full stackTrace of it in servoy\_log.txt.

Hope this helps.

---

<div class="post-metadata">

**Author:** ![tysonj](https://avatars.discourse-cdn.com/v4/letter/t/f14d63/32.png) [@tysonj](https://forum.servoy.com/u/tysonj)\
**Post date:** [September 9, 2011, 1:43pm UTC](https://forum.servoy.com/t/using-third-party-library-in-servoy-plugin/14456/8 "2011-09-09T13:43:30Z")

</div>

HI,  
I have tried to catch exception but I did not get any message in servoy\_log.txt

Jar provied by servoy in **“installation/application\_server/lib”** folder( j2db.jar, j2dbdev.jar etc.) is working fine when creating plugin  
but I do not know why I am unable to call methods of thrid-party jar included by me .

I have made a small experiment and again failed. If you have some time then please go through it and please please help me to find out any solution

**1)**  
I have created a java project which contain only one class named **“Access”** having one method **“returnString”** using java perspective.  
Method “returnString” returns only a string.  
Then I created jar of the above project.

**2)**  
Then I created a plugin( **demoPlugin** ) and included the above jar in it.  
From the plugin I tried to call the above method “ **returnString** ” .  
//----------  
public String **js\_getString()**{  
return new Access().returnString();  
}  
//----------

**3)**  
Then I included that plugin in servoy and tried to call **getString()** on button event which suppose to return a string, but it does not return anything.  
//----------  
function get(event) {  
// TODO Auto-generated method stub  
var str = plugins.demoPlugin.getString();  
application.output(str);  
}

//----------

When I debug my code I got the same message “Error during evaluation:com/java/access/Access”. ![:cry:]( "Crying or Very sad")  
I do not why it is happening, is their any process to create a jar for servoy plugin. ![:!:]( "Exclamation")

---

<div class="post-metadata">

**Author:** ![jcarlos](https://avatars.discourse-cdn.com/v4/letter/j/46a35a/32.png) [@jcarlos](https://forum.servoy.com/u/jcarlos)\
**Post date:** [September 9, 2011, 1:51pm UTC](https://forum.servoy.com/t/using-third-party-library-in-servoy-plugin/14456/9 "2011-09-09T13:51:26Z")

</div>

> ptalbot:  
> Also, since you want to use Tika, why not have a look at the SmartDoc plugin which already leverages Tika/Solr/Lucene for you?  
> It’s Open Source on ServoyForge: [Overview - SmartDoc Plugin - ServoyForge](https://www.servoyforge.net/projects/smartdoc)

- 1

---

<div class="post-metadata">

**Author:** ![ptalbot](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/ptalbot/32/4952_2.png) [@ptalbot](https://forum.servoy.com/u/ptalbot)\
**Post date:** [September 9, 2011, 2:29pm UTC](https://forum.servoy.com/t/using-third-party-library-in-servoy-plugin/14456/10 "2011-09-09T14:29:45Z")

</div>

Where is your created jar (the one that contains your Access class)?  
Did you put it in /application\_server/plugins/ somewhere?

---

<div class="post-metadata">

**Author:** ![tysonj](https://avatars.discourse-cdn.com/v4/letter/t/f14d63/32.png) [@tysonj](https://forum.servoy.com/u/tysonj)\
**Post date:** [September 9, 2011, 5:23pm UTC](https://forum.servoy.com/t/using-third-party-library-in-servoy-plugin/14456/11 "2011-09-09T17:23:23Z")

</div>

I have stored my jar inside “ **application\_server/lib** ” folder and plugin inside “ **application\_server/plugins** ” folder.

---

<div class="post-metadata">

**Author:** ![ptalbot](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/ptalbot/32/4952_2.png) [@ptalbot](https://forum.servoy.com/u/ptalbot)\
**Post date:** [September 9, 2011, 5:37pm UTC](https://forum.servoy.com/t/using-third-party-library-in-servoy-plugin/14456/12 "2011-09-09T17:37:37Z")

</div>

> tysonj:  
> I have stored my jar inside “ **application\_server/lib** ” folder and plugin inside “ **application\_server/plugins** ” folder.

You should put your jar in application\_server/plugins/ in a subfolder with the same name as your plugin (this is only a convention though, but you need it to be in /plugins as well)

---

<div class="post-metadata">

**Author:** ![tysonj](https://avatars.discourse-cdn.com/v4/letter/t/f14d63/32.png) [@tysonj](https://forum.servoy.com/u/tysonj)\
**Post date:** [September 10, 2011, 7:07am UTC](https://forum.servoy.com/t/using-third-party-library-in-servoy-plugin/14456/13 "2011-09-10T07:07:05Z")

</div>

HI ptalbot ,  
Thank you for your help. It is now working fine ![:D]( "Very Happy")

---

<div class="post-metadata">

**Author:** ![ptalbot](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/ptalbot/32/4952_2.png) [@ptalbot](https://forum.servoy.com/u/ptalbot)\
**Post date:** [September 10, 2011, 5:27pm UTC](https://forum.servoy.com/t/using-third-party-library-in-servoy-plugin/14456/14 "2011-09-10T17:27:41Z")

</div>

It works automatically in Developer because Servoy is adding everything that is under /plugins to the classpath, but take care that if you want your jar to be used on the client side in Smart client, you will need to add a jnlp to tell the client to download it, and you will also need to sign your jars…

---

<div class="post-metadata">

**Author:** ![tysonj](https://avatars.discourse-cdn.com/v4/letter/t/f14d63/32.png) [@tysonj](https://forum.servoy.com/u/tysonj)\
**Post date:** [September 13, 2011, 2:51pm UTC](https://forum.servoy.com/t/using-third-party-library-in-servoy-plugin/14456/15 "2011-09-13T14:51:05Z")

</div>

Hi patalbot,  
1)I have created a plugin **MyPlugin.jar**

2)Then I have signed that jar using following steps:

-Creating a keystore with a self signed certificate ([http://wiki.servoy.com/display/public/t … ertificate](http://wiki.servoy.com/display/public/tutorials/Creating+a+keystore+with+a+self+signed+certificate))  
i.e by using:- **keytool -genkey -alias MyPlugins -keyalg RSA -keystore mykeystore.ks -validity 10000**  
-JAR signing ([http://wiki.servoy.com/display/public/t … AR+signing](http://wiki.servoy.com/display/public/tutorials/JAR+signing))  
i.e by using:- **java -jar signtester.jar mykeystore.ks yourpassword MyPlugins**  
-created a jnlp file ( MyPlugin.jar.jnlp ) :-

\<?xml version="1.0" encoding="utf-8"?\> Servoy Client Plugins Servoy and Others

3)Then I included **MyPlugin.jar** and **MyPlugin.jar.jnlp** in Plugins folder.  
4)Then I import my solution in a separate application server.  
5)When I tried to access that solution from **web client** it is working fine.  
6)But when I tried to l **unch servoy client** I got some error like this :-

com.sun.deploy.net.JARSigningException: Found unsigned entry in resource: ([http://localhost:8080/plugins/MyPlugin.jar](http://localhost:8080/plugins/MyPlugin.jar), 1315900062000)  
at com.sun.javaws.security.SigningInfo.getCommonCodeSignersForJar(Unknown Source)  
at com.sun.javaws.security.SigningInfo.check(Unknown Source)  
at com.sun.javaws.LaunchDownload.checkSignedResourcesHelper(Unknown Source)  
at com.sun.javaws.LaunchDownload.checkSignedResources(Unknown Source)  
at com.sun.javaws.Launcher.prepareResources(Unknown Source)  
at com.sun.javaws.Launcher.prepareAllResources(Unknown Source)  
at com.sun.javaws.Launcher.prepareToLaunch(Unknown Source)  
at com.sun.javaws.Launcher.prepareToLaunch(Unknown Source)  
at com.sun.javaws.Launcher.launch(Unknown Source)  
at com.sun.javaws.Main.launchApp(Unknown Source)  
at com.sun.javaws.Main.continueInSecureThread(Unknown Source)  
at com.sun.javaws.Main$1.run(Unknown Source)  
at java.lang.Thread.run(Unknown Source)

It seems the error is due to unsigned jar, but I have signed my jar( “MyPlugin.jar” ) using above steps .  
So, I am confused … ![:roll:]( "Rolling Eyes")

---

<div class="post-metadata">

**Author:** ![ptalbot](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/ptalbot/32/4952_2.png) [@ptalbot](https://forum.servoy.com/u/ptalbot)\
**Post date:** [September 14, 2011, 12:07pm UTC](https://forum.servoy.com/t/using-third-party-library-in-servoy-plugin/14456/16 "2011-09-14T12:07:25Z")

</div>

1/ Are you sure that your jar was signed?

You can use the signtester tool this way:  
java -jar signtester.jar mykeystore.ks yourpassword MyPlugins log  
It will create a sign\_log.txt wih the result of each sign attempt on all the jars.

2/ If you only have one jar, you don’t need a jnlp. Servoy generates one automatically for you.  
If you have dependencies, then you need a jnlp and declare these dependencies in there.

And you shouldn’t put a full URL path in the hrefs, you have already set a codebase which is the serverURL.  
Have a look at how other JNLPs are done in /plugins.
