Bean access to plugin

Questions and answers on developing, deploying and using plugins and JavaBeans

Bean access to plugin

Postby cybersack » Sat Mar 26, 2005 8:58 am

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 ?
User avatar
cybersack
 
Posts: 302
Joined: Sun Jan 02, 2005 1:17 am

Postby jcompagner » Mon Mar 28, 2005 1:14 pm

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())
Johan Compagner
Servoy
User avatar
jcompagner
 
Posts: 8833
Joined: Tue May 27, 2003 7:26 pm
Location: The Internet

Postby cybersack » Wed Apr 13, 2005 9:27 am

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):
<quote>
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
</quote>

OR
<quote>
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
</quote>

OR
<quote>
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
</quote>

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
User avatar
cybersack
 
Posts: 302
Joined: Sun Jan 02, 2005 1:17 am

Postby cybersack » Wed Apr 13, 2005 9:29 am

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)
User avatar
cybersack
 
Posts: 302
Joined: Sun Jan 02, 2005 1:17 am

Postby cybersack » Thu Apr 14, 2005 1:10 am

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.

<JWS-DEBUG>
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: <package>part

EXCEPTION:
MissingFieldException[ The following required field is missing from the launch file: <package>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">

<information>

<title>Servoy Client Libs</title>

<vendor>Others</vendor>

</information>

<resources>

<jar href="/beans/IClock.jar" part="IClock" download="lazy" version="1038561746000"/>

<package name="com.ibm.clock.*" part="IClock" recursive="true"/>

<jar href="/beans/htmlbean.jar" part="htmlbean" download="lazy" version="1107937646385"/>

<package name="HTMLPane.*" part="htmlbean" recursive="true"/>

<jar href="/beans/molecule.jar" part="molecule" download="lazy" version="1048602127735"/>

<package name="sunw.demo.molecule.*" part="molecule" recursive="true"/>

<jar href="/beans/s11_chart.jar" part="s11_chart" download="lazy" version="1055778081000"/>

<package name="com.ibm.eou.*" part="s11_chart" recursive="true"/>

<jar href="/beans/mybean.jar" part="mybean" download="lazy" version="1113432622000"/>

<package name="au.com.practica.*" part="mybean" recursive="true"/>

<jar href="/beans/mybean.jar" part="mybean" download="lazy" version="1113432622000"/>

<package name="au.com.practica.*" part="mybean" recursive="true"/>

<jar href="/beans/../plugins/practica/mycommon.jar" part="" download="lazy" version="1113432622000"/>

<package name="au.com.practica.*" part="" recursive="true"/>

<jar href="/beans/dbtreeview.jar" part="dbtreeview" download="lazy" version="1107937646385"/>

<package name="com.servoy.r2.*" part="dbtreeview" recursive="true"/>

<jar href="/beans/swingbeans.jar" part="swingbeans" download="lazy" version="1107937646405"/>

<package name="javax.swing.*" part="swingbeans" recursive="true"/>

<jar href="/lafs/kunststoff.jar" part="kunststoff" download="lazy" version="1077716002550"/>

<package name="com.incors.plaf.*" part="kunststoff" recursive="true"/>

<jar href="/lafs/skinlf.jar" part="skinlf" download="lazy" version="1029384167012"/>

<package name="com.l2fprod.gui.*" part="skinlf" recursive="true"/>

</resources>

<component-desc/>

</jnlp>

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 (???)

</JWS-DEBUG>


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)
User avatar
cybersack
 
Posts: 302
Joined: Sun Jan 02, 2005 1:17 am

Postby jcompagner » Thu Apr 14, 2005 3:50 pm

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?
Johan Compagner
Servoy
User avatar
jcompagner
 
Posts: 8833
Joined: Tue May 27, 2003 7:26 pm
Location: The Internet


Return to Plugins and Beans

Who is online

Users browsing this forum: No registered users and 46 guests