1st own plugin: method called doesn't do anything

that class is commons-codec.jar not the httpclient. So somehow thats not in the classpath…

jcompagner:
that class is commons-codec.jar not the httpclient. So somehow thats not in the classpath…

But the only thing I do change is swapping “C:\Program Files\Servoy\application_server\lib\commons-httpclient.jar” with “C:\MyLibPath\commons-httpclient.jar”.
I don’t add or remove commons-codec.jar :roll:

Here are 2 screenshots of my project when it works fine (with my library) and when it throws the exception (Servoy lib):

Here are the two jar files. It might help you?! :roll:
[attachment=1]commons-httpclient.jar[/attachment]
[attachment=0]commons-httpclient.jar[/attachment]

Also I have noticed that in Servoy lib folder there is commons-codec.jar and not in my jar folder. But I get the classnotfound exception with Servoy jar :shock:

commons-httpclient.jar (217 KB)

commons-httpclient.jar (282 KB)

maybe it is then some kind of classloading stuff that org.apache.webdav.lib.WebdavResource can get to codec.
dont know where that one is coming from exactly?

jcompagner:
dont know where that one is coming from exactly?

Is that a question for me? What do you mean?

I have tried to remove common-codec.jar from Servoy lib folder but same exception.

removing is not the solution
This is quite a hard problem to see right away. the thing is the classloader who loads this class:

org.apache.webdav.lib.WebdavResource

isnt able to load the classes from common-codec.jar
So to figure this out we first need to know where that WebdavResource class comes from…

I think the good think is that in smart client this will work just fine…

So, I’ve done several tests this afternoon.

First, it still doesn’t work on the Smart Client.
But I have discovered that I get different exceptions between the Java Project and the Smart Client one BUT on the same line of code:

wdrExchange = new WebdavResource(sUrl,new UsernamePasswordCredentials(m_sUsername, m_sPassword));

In fact I have a method called UpdateContact:

	public void updateContact(String a_sPrefix,
			String a_sMailboxName,
			String a_sFolderName,
			ExchangeContact a_exContact)
	throws ExchangeException
	{
		try {
			final String ksMethodName = "updateContact";

			[...]

			WebdavResource wrFolder = null;
			
			try {
//Where I get the exception in the Java Project
				wrFolder = getExchangeWebdavResource(a_sPrefix,
													a_sMailboxName,
													a_sFolderName);
			} catch (RuntimeException e2) {
				throw new ExchangeException(c_ksClassName + "." + ksMethodName + "| Pos1 | "+e2.getMessage()+
						"\n---Args---\n"+a_sPrefix+" | "+a_sFolderName+" | "+a_sMailboxName+
						"\n---Msg---\n"+msg);
			}
			
			[...]

					try {
//Where I get the exception in Servoy Smart Client
						wdrNewContact = new WebdavResource(sNewContactUrlUnformatted,new UsernamePasswordCredentials(m_sUsername, m_sPassword));						
					} catch (HttpException e) {
						throw new ExchangeException("-----HttpException: "+e.toString()+"----------\n");
					} 
					wdrNewContact.setFollowRedirects(true);	


				[...]


		} catch (RuntimeException e) {
			throw new ExchangeException(c_ksClassName + "." + "UpdateContact" + "| Pos9 | "+e.toString()+
					"\n---Args---\n"+a_sPrefix+" | "+a_sFolderName+" | "+a_sMailboxName+
					"\n---Msg---\n"+msg);
		}
	}

So, in the Java Project the exception comes from this line of code run inside getExchangeWebdavResource(…) and in Smart Client it comes from the same line but further down in the UpdateContact method. Why? I don’t know.

In the Smart Client version I can display that it’s an HttpException, but nothing more (e.getMessage() returns “null” and e.toString() returns “org.apache.commons.httpclient.HttpException”).
However in the Java Project when I try to catch an HttpException where the exception is thrown it doesn’t catch it! But I have the proper Java Stack error

try {
 		System.out.println("Before\n");
	   	wdrExchange = new WebdavResource(sUrl,new UsernamePasswordCredentials(m_sUsername, m_sPassword));
	   	System.out.println("After\n");
	} catch (HttpException e) {
		System.out.println("Exception!!!\n");
		e.printStackTrace();
	}

Result in the console:

Before

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.(WebdavResource.java:397)
at com.bright.framework.exchange.service.ExchangeBridge.getExchangeWebdavResource(ExchangeBridge.java:1159)
at com.bright.framework.exchange.service.ExchangeBridge.updateContact(ExchangeBridge.java:639)
at com.assetguardian.plugin.agxchange.AGxChangePluginProvider.js_SetContactRecord(AGxChangePluginProvider.java:111)
at com.assetguardian.plugin.agxchange.AGxChangePluginProvider.main(AGxChangePluginProvider.java:38)
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

Even with catch (Exception e) or catch (RuntimeException e) it doesn’t catch it.

However I have to admit that I’m a novice in Exceptions Handling :oops:

Foobrother:
Here are 2 screenshots of my project when it works fine (with my library) and when it throws the exception (Servoy lib):

Where did you get the one that works?

When I look at your stack trace, this part:

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)

seems to indicate that you have security problems, your ClassLoader might not have been granted access to the org.apache.commons.codec package.

Could it be that you have mixed code between your jars and the commons-httpclient.jar (the one from Servoy are signed by Servoy), yours is signed by? Or maybe not signed at all?

With Java 6u19+ depending on the parameters you chose to use in your java property panel about security, you will not be able to access signed code from non signed code (and vice-versa).

wait you say you are testing really in smart client (not debug)
and it doesnt work?

but then you just dont ship commons-codec.jar to the client somehow.

Johan is right, looking at your jnlp, you will need to add an extension which will add these jars: /lib/commons-codec.jar /lib/commons-httpclient.jar and /lib/commons-logging.jar

ptalbot:
Where did you get the one that works?

I got it from the API I use to work on the exchange. It’s part of the API libraries used.

ptalbot:
When I look at your stack trace, this part:
seems to indicate that you have security problems, your ClassLoader might not have been granted access to the org.apache.commons.codec package.

Could it be that you have mixed code between your jars and the commons-httpclient.jar (the one from Servoy are signed by Servoy), yours is signed by? Or maybe not signed at all?

With Java 6u19+ depending on the parameters you chose to use in your java property panel about security, you will not be able to access signed code from non signed code (and vice-versa).

This library is probably not signed, you are right. But I’m using Java 6u18 at the moment. So it should be ok :roll:
Also all the tests I did (the ones explained in my last post) were with Servoy’s commons-httpclient.jar. If I use the API lib on the Java project I don’t get any error. I’ll use signtester.jar to make sure my Servoy lib are properly signed anyway.

jcompagner:
wait you say you are testing really in smart client (not debug)
and it doesnt work?

but then you just dont ship commons-codec.jar to the client somehow.

When I say “Smart Client” I mean “Smart Client launched from Servoy Developer”.

Discovered something interesting.
I have included Servoy’s commons-codec.jar as library in my Java Project. And now I don’t have the java.lang.ClassNotFoundException: org.apache.commons.codec.DecoderException anymore and no error in the console. However it doesn’t do the job (another exception somewhere that I have to catch).
And if I replace the commons-httpclient.jar of Servoy with the one of my API it works fine.

So now I need to find why it doesn’t work with Servoy’s commons-httpclient.jar

I have found that it’s an HttpException I’m getting on the 2nd place where I have ```
wdrNewContact = new WebdavResource(sNewContactUrlUnformatted,new UsernamePasswordCredentials(m_sUsername, m_sPassword));


> org.apache.commons.httpclient.HttpException
> at org.apache.webdav.lib.WebdavResource.propfindMethod(WebdavResource.java:3467)
> at org.apache.webdav.lib.WebdavResource.propfindMethod(WebdavResource.java:3423)
> at org.apache.webdav.lib.WebdavResource.setNamedProp(WebdavResource.java:967)
> at org.apache.webdav.lib.WebdavResource.setBasicProperties(WebdavResource.java:912)
> at org.apache.webdav.lib.WebdavResource.setProperties(WebdavResource.java:1894)
> at org.apache.webdav.lib.WebdavResource.setHttpURL(WebdavResource.java:1301)
> at org.apache.webdav.lib.WebdavResource.setHttpURL(WebdavResource.java:1320)
> at org.apache.webdav.lib.WebdavResource.setHttpURL(WebdavResource.java:1408)
> at org.apache.webdav.lib.WebdavResource.setHttpURL(WebdavResource.java:1426)
> at org.apache.webdav.lib.WebdavResource.<init>(WebdavResource.java:397)
> ...

sNewContactUrlUnformatted is in this format: "https://monsite/path/file.eml" and when I try with "https://monsite/path/" I don't get any exception but obviously the job is not done.
Once again, when I try it with the API commons-httpclient.jar library it works fine.

What is the version of the commons-httpclient you use?
If I look into the Servoy jar, the MANIFEST.MF tells me it is 3.0.1 (Implementation Version).
Yours must be of a different version.

ptalbot:
What is the version of the commons-httpclient you use?
If I look into the Servoy jar, the MANIFEST.MF tells me it is 3.0.1 (Implementation Version).
Yours must be of a different version.

Mine is much older (from 2004 vs 2006 for Servoy one): Implementation-Version: 2.0-final

Which is not surprising as such since the Jakarta Slide project has been retired since november 2007!

I would try to find some newer library to deal with WebDav if I were you, quickly googling java webdav gave a few options:
http://sourceforge.net/projects/webdavclient4j/ (which is the successor of slide - based on the same code, may be the easiest to use for you), or http://jackrabbit.apache.org/jackrabbit … brary.html

If you don’t use a newer project which is more up to date then you will have to ship an older version of httpclient and this can potentially lead to any sort of jar hell, as you have found already…

ptalbot:
Which is not surprising as such since the Jakarta Slide project has been retired since november 2007!

I would try to find some newer library to deal with WebDav if I were you, quickly googling java webdav gave a few options:
http://sourceforge.net/projects/webdavclient4j/ (which is the successor of slide - based on the same code, may be the easiest to use for you), or http://jackrabbit.apache.org/jackrabbit … brary.html

If you don’t use a newer project which is more up to date then you will have to ship an older version of httpclient and this can potentially lead to any sort of jar hell, as you have found already…

Ok, I have switched to webdavclient4j as you advised me. I have included only the libraries which are not provided by Servoy and use the ones of Servoy instead (common-httpclient.jar, common-logging.jar, etc…).
Guess what… the Java Project works! The most surprising is that I have not touched my code at all. It is providing exactly the same classes apparently :D
Now I need to try it on Developer Smart Client. In theory it should work if it works with Servoy’s library in the Java Project :roll:

Works with Developer Smart Client as well :D

I’ll probably need help for the future features I’ll try to develop using this API but for the moment, many thanks for your help! :wink:

Glad to know it works in the end!

You will also need to test it in a real smart client (not debug smart client launched from developer), there you will a proper jnlp to tell the client what to download, and for the Servoy libs, you will need to use an node.

“ node” ?

I though I could do a jnlp similar to the other plugins one ?!
Something like that:

<?xml version="1.0" encoding="UTF-8"?>

<jnlp spec="1.0+" codebase="%%serverURL%%" href="/servoy-client/plugins/myPlugin.jar.jnlp">
	<information>
		<title>My Plug-in</title>
		<vendor>Shop</vendor>
		<homepage href="http://www.shop.com/"/>
		<description>My Client Plug-in for Servoy</description>
		<description kind="short">A Component to add additional functionality to Servoy.</description> 
		<offline-allowed/>
	</information>
	<resources>
		<jar href="/plugins/myPlugin.jar" download="eager" version="2.0-016"/>
		<jar href="/plugins/myplugin/1st-lib.jar" download="%%loadmethod%%" version="2.1-039"/>
		<jar href="/plugins/myplugin/2nd-lib.jar" download="%%loadmethod%%" version="2.0-021"/>
	</resources>
	<component-desc/>
</jnlp>