Bean access to plugin

My bean requires access to one of my plugins.

I support a static instance of the plugin in the plugin class.
This instance value is set in the constructor of the plugin and the IClientPluginAccess reference is maintained within that instance after the callback to initialize(IClientPluginAccess access)is made.

If it were posible to get access to an IClientPluginAccess reference from Servoy, then I would not need to rely on the static instance, but that seems unlikely.

I need the IClientPluginAccess ref in order to lookup some server-side services.

Judging by the ‘null’ state of a known-initialized [via initialize(IClientPluginAccess access)] instance, I can only assume that different classloaders are involved. [aside:This makes sense because I find that I am having to duplicate jars to get my beans to work with the same binaries as my plugins].

So…how do I get access to a loaded plugin ?

classloading problems in the developer are fixed now.
All the classes a plugin has can also be accessed by a bean (but not the other way around, so a plugin should have all the needed jars and the bean only the one of them self)

If you have support jars by a bean don’t forget to specify this in the manifest of the jar. And then with the classpath entry, if you don’t do that then on the client the beans support jars will not be loaded.
The entry looks like this:

Class-Path: PATH/xerces.jar

that path is relative from the beans dir.

But what you could do to have access to a plugin in youre bean you could do this in a onLoad method of the form the bean is on:

bean_name.setPlugin(plugins.myplugin)

or just let youre plugin return something the bean can use:

bean_name.setXXX(plugins.myplugin.getXXX())

There is something really inconsistent here :(

When I run Developer mode, I get a ClassNotFoundException.
But, running the client via Java Web Start (connecting to the same running Developer instance that just displayed the problem), I have no such exception.

Strange. Sounds like a claspath issue in the Developer (still ?).

Here’s the synopsis:

/plugins/*jar and *.jar.jnlp files define my plugins.
/plugins/mycompany/mycommon.jar has some common classes
/beans/mybean.jar defines the bean with a single bean class.

The single bean class extends a class in mycommon.jar.

With any of the following 3 manifest definitions in mybean.jar, the Developer client fails, yet the JWS client succeeds :(

Please tell me what’s up here, because if I understood your previous post, this should not be happening.

My stack trace is shown at the bottom of this post.

The Manifest for the bean is EITHER (varying the path to the common jar):

Manifest-Version: 1.0
Ant-Version: Apache Ant 1.6.2
Created-By: 1.4.2_06-b03 (Sun Microsystems Inc.)
Version: 1.0rc5
Class-Path: mybean.jar mycommon.jar

Name: MyBeanClass.class
Java-Bean: True

OR

Manifest-Version: 1.0
Ant-Version: Apache Ant 1.6.2
Created-By: 1.4.2_06-b03 (Sun Microsystems Inc.)
Version: 1.0rc5
Class-Path: mybean.jar ../plugins/mycommon.jar

Name: MyBeanClass.class
Java-Bean: True

OR

Manifest-Version: 1.0
Ant-Version: Apache Ant 1.6.2
Created-By: 1.4.2_06-b03 (Sun Microsystems Inc.)
Version: 1.0rc5
Class-Path: mybean.jar /plugins/mycommon.jar

Name: MyBeanClass.class
Java-Bean: True

StackTrace:
java.lang.ClassNotFoundException: MyBeanClass
Continuing …
java.lang.NullPointerException
Continuing …
java.lang.NullPointerException
Continuing …
java.lang.NullPointerException
Continuing …
java.lang.NullPointerException
Continuing …
java.lang.NullPointerException
Continuing …
java.lang.NullPointerException
Continuing …
java.lang.NullPointerException
Continuing …
java.lang.ClassNotFoundException: MyBeanClass
java.lang.ClassNotFoundException: MyBeanClass
at java.net.URLClassLoader$1.run(URLClassLoader.java:199)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:187)
at java.lang.ClassLoader.loadClass(ClassLoader.java:289)
at java.lang.ClassLoader.loadClass(ClassLoader.java:235)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:302)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:219)
at com.servoy.j2db.q.createInstance(Unknown Source)
at com.servoy.j2db.runtime.b.createInstance(Unknown Source)
at com.servoy.j2db.dataui.k.a(Unknown Source)
at com.servoy.j2db.dataui.k.a(Unknown Source)
at com.servoy.j2db.dataui.k.if(Unknown Source)
at com.servoy.j2db.dataui.k.a(Unknown Source)
at com.servoy.j2db.dataui.i.a(Unknown Source)
at com.servoy.j2db.dataui.i.a(Unknown Source)
at com.servoy.j2db.FormPanel.cS(Unknown Source)
at com.servoy.j2db.FormManager.if(Unknown Source)
at com.servoy.j2db.FormManager.a(Unknown Source)
at com.servoy.j2db.FormManager.do(Unknown Source)
at com.servoy.j2db.develop.ad.do(Unknown Source)
at com.servoy.j2db.FormManager$2.run(Unknown Source)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:178)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:454)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:201)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:151)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:145)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:137)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:100)
No 1.5 found for pack200

sorry…forgot to mention 2 things:

  1. this is a real pain because I can never successfully work with the solution in Layout mode :(

  2. Forgot to state my environment:

Servoy Client
Version R2 2.2rc4-build 322
Java version 1.4.2_06-b03 (Windows XP)

Additionally, I should mention that one of these manifest configurations breaks the web-start client. The version that defines :

Class-Path: mybean.jar ../plugins/mycommon.jar

breaks the JWS client with the following detail.

GENERAL: An error occurred while launching/running the application.

Title: Servoy Client
Vendor: Servoy
Category: Launch File Error

The following required field is missing from the launch file: part

EXCEPTION:
MissingFieldException[ The following required field is missing from the launch file: part]

at com.sun.javaws.xml.XMLUtils.getRequiredAttribute(Unknown Source)
at com.sun.javaws.jnl.XMLFormat.handleResourceElement(Unknown Source)
at com.sun.javaws.jnl.XMLFormat.access$600(Unknown Source)
at com.sun.javaws.jnl.XMLFormat$4.visitElement(Unknown Source)
at com.sun.javaws.xml.XMLUtils.visitChildrenElements(Unknown Source)
at com.sun.javaws.jnl.XMLFormat$3.visitElement(Unknown Source)
at com.sun.javaws.xml.XMLUtils.visitElements(Unknown Source)
at com.sun.javaws.jnl.XMLFormat.buildResourcesDesc(Unknown Source)
at com.sun.javaws.jnl.XMLFormat.parse(Unknown Source)
at com.sun.javaws.jnl.LaunchDescFactory.buildDescriptor(Unknown Source)
at com.sun.javaws.jnl.LaunchDescFactory.buildDescriptor(Unknown Source)
at com.sun.javaws.jnl.LaunchDescFactory.buildDescriptor(Unknown Source)
at com.sun.javaws.LaunchDownload.downloadExtensionsHelper(Unknown Source)
at com.sun.javaws.LaunchDownload.downloadExtensions(Unknown Source)
at com.sun.javaws.Launcher.downloadResources(Unknown Source)
at com.sun.javaws.Launcher.handleApplicationDesc(Unknown Source)
at com.sun.javaws.Launcher.handleLaunchFile(Unknown Source)
at com.sun.javaws.Launcher.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

LAUNCH-FILE:

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

<jnlp spec=“1.0+”

codebase=“http://localhost:8080

href=“/servoy-client/unsigned.jnlp”>

Servoy Client Libs

Others

And, from this jnlp the only thing I can guess is that possibly a SEAL protocol has been borken, but I do not seal any of my jars. I think this because there appears to be a package issue across the jars (???)

Now, this is the only manifest which does not complain to Developer stderr that the dependent jar (mycommon.jar) cannot be found ! Even still, in the Servoy Developer, when the classpath from the manifest appears valid in this way to the servoy application, a slightly different exception still results prohibiting me still from working with the bean:

Starting service Tomcat-Standalone
Apache Tomcat/4.0.1
Starting service Tomcat-Apache
Apache Tomcat/4.0.1
java.lang.reflect.InvocationTargetException
Continuing …
java.lang.NullPointerException
Continuing …
java.lang.reflect.InvocationTargetException
Continuing …
java.lang.NullPointerException
Continuing …
java.lang.reflect.InvocationTargetException
Continuing …
java.lang.NullPointerException
Continuing …
java.lang.reflect.InvocationTargetException
Continuing …
java.lang.NoClassDefFoundError
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:219)
at com.servoy.j2db.q.createInstance(Unknown Source)
at com.servoy.j2db.runtime.b.createInstance(Unknown Source)
at com.servoy.j2db.dataui.k.a(Unknown Source)
at com.servoy.j2db.dataui.k.a(Unknown Source)
at com.servoy.j2db.dataui.k.if(Unknown Source)
at com.servoy.j2db.dataui.k.a(Unknown Source)
at com.servoy.j2db.dataui.i.a(Unknown Source)
at com.servoy.j2db.dataui.i.a(Unknown Source)
at com.servoy.j2db.FormPanel.cS(Unknown Source)
at com.servoy.j2db.FormManager.if(Unknown Source)
at com.servoy.j2db.FormManager.a(Unknown Source)
at com.servoy.j2db.FormManager.do(Unknown Source)
at com.servoy.j2db.develop.ad.do(Unknown Source)
at com.servoy.j2db.FormManager$2.run(Unknown Source)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:178)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:454)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:201)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:151)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:145)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:137)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:100)

something that is loaded by a plugin (a jar) doesn’t or shouldn’t be referenced in a bean.
Everything that a plugin loads can also be loaded by a bean (in developer and client)

so a classpath to ../plugin/ of a bean isn’t nessesary.

can i have a copy of youre bean/plugin and a small solution that access them?