This discussion is archived
10 Replies Latest reply: Feb 4, 2005 3:39 AM by 416044 RSS

Problems with ActiveX properties for JavaBean

843804 Newbie
Currently Being Moderated
Hi,

i have written some JavaBean test classes to check packager axbridge functionality.
My problem is, that every the registered controls do not have any properties even though I defined get and set methods for my attributes. I've also tried to write an extra BeanInfo class without success.

In the forums I found an exmaple:
<code>
package test;
public class MyBean {
protected int value;
public MyBean()     {     }

public void setValue(int _value)
{          
value = _value;     
}

public int getValue()     
{          
return value;     
}

public MyBean getSelfReference()
{          
return this;     
}
}
</code>

But even this one does not work. Can someone explain some details what has to be defined in class to get ActiveX properties in the created control?

Thanks a lot...
Regards
Michael.
  • 1. Re: Problems with ActiveX properties for JavaBean
    843804 Newbie
    Currently Being Moderated
    I am having the same problems, but since you don't give a lot of details, I at least wanted to give you some information that you might not have.

    First of all, you have to create a jar file and a manifest file. You have to specify in the manifest file that this is a bean. Then you need to create a jar file. You also need to create the folders that are specified in your package. For example com.lastname.firstname, must have folder structure ...\firstname\lastname\com, it will create the package under your com folder.
    Then you need to run the packager to generate the dll. The packager comes with Java sdk, but you need Visual C++ 6.0 SP3 or later to run it!!! Don't ask me why. I know, it's stupid.

    C:\j2sdk1.4.2_04\bin>packager �out c:\j2sdk1.4.2_04\jre\axbridge\bin �reg c:\david\www\simplebean.jar SimpleBean

    Then you need to register the dll using this command:

    C:\j2sdk1.4.2_04\jre\axbridge\bin> c:\winnt\system32\regsvr32 SimpleBean.dll

    You might have to create the axbridge if you don't already have it.
    You should get a popup message saying:
    DllRegisterServer in SimpleBean.dll succeeded.

    So, this is how far I got. I am trying to call the bean from JScript, but I get a memory error.
    PS, I am doing this on Windows 2000 Pro. Also make sure you have Classpath set.

    You can find more info about this topic on this forum (although I don't think anyone is having any success with it):
    http://forum.java.sun.com/forum.jspa?forumID=40&start=50

    Well, I hope this helps.
  • 2. Re: Problems with ActiveX properties for JavaBean
    416044 Newbie
    Currently Being Moderated
    But how do I set the classpath? I got my simple test bean working (used in VisualBasic). But when I want to use a method of the bean that itself uses another class, I just get NoClassDefFoundError.

    I tried

    - setting system CLASSPATH environment variable
    - copying the JAR with the external classes to %JRE%/lib/ext/
    - using additonal "Class-Path:" entry in the manifest
    - copied the JAR with external classes to %JRE%/axbridge/lib
    - set "-cp ..." as VM parameter in the PLugin Control Panel

    but nothing helps - my external class is not found! (The same bean methods work when used within a Java application, so the class is really in the external JAR and works).

    Is there another way to set the classpath for ActiveX bridge?
  • 3. Re: Problems with ActiveX properties for JavaBean
    843804 Newbie
    Currently Being Moderated
    Hmm, strange cause I would think what you did would have worked. did you 'echo %CLASSPATH%' and do you see the path you expect?
    Did you try running it on the command line (java -cp <yourpath> ....)?

    Do you have more than one bean in your Jar?
    Is the bean called as a Main method?

    Like I said, I am having problems myself running this but I figured I try to give you any help I could. You can check out my thread at:
    http://forum.java.sun.com/thread.jspa?threadID=591814

    If you have any suggestions, I would appreciate it!
  • 4. Re: Problems with ActiveX properties for JavaBean
    416044 Newbie
    Currently Being Moderated
    Hmm, strange cause I would think what you did would
    have worked. did you 'echo %CLASSPATH%' and do you
    see the path you expect?
    Yes, echoed %CLASSPATH% in DOS box and see the correct classpath.
    Did you try running it on the command line (java -cp
    <yourpath> ....)?
    Yes, the Java bean itself works also as expected (main() as application or used by other Java application).
    Do you have more than one bean in your Jar?
    No. Just one simple bean with a few methods.
    Is the bean called as a Main method?
    No. It just has simple get/set/callXYZ methods - nothing fancy.
    Like I said, I am having problems myself running this
    but I figured I try to give you any help I could.
    You can check out my thread at:
    http://forum.java.sun.com/thread.jspa?threadID=591814
    I'm going to visit it ...
    If you have any suggestions, I would appreciate it!
    Yep, it seems that there are still just few people using the ActiveX bridge. This forum is quite small. :-(
  • 5. Re: Problems with ActiveX properties for JavaBean
    843804 Newbie
    Currently Being Moderated
    Seems like you have tried just about everything, and I am running out of suggestions.

    This ActiveX is a Royal pain to use! Since Java is so popular these days, you would think they would make it easier to call javabeans/classes from other applications!

    Thanks for your suggestions on my post, I will try them. If I still can't get it to work, I will try a different approach on my project since I can't spend too much more time on this. I would like to spend more time on it, but unfortunately there is a budget I have to stay within :-(

    Do you have any other options, such as using IIS etc? It seems like there are more people using this. Have you looked into NJAWIN? I don't know much about it, but I have seen a few posts on it during my search for ActiveX. Check out this link:
    http://shareware.pcmag.com/product.php%5Bid%5D60701%5BSiteID%5Dpcmag
  • 6. Re: Problems with ActiveX properties for JavaBean
    416044 Newbie
    Currently Being Moderated
    I finally got it to work now. I deinstalled all versions of SDK/JRE of Java I previously had. Ensured that my test DLL ist not registered anymore and also not anywhere in the Windows registry. Rebootet and installed 1.5.0_01. I still got the ClassNotFoundExceptions until I copied my JAR into the JRE's lib/ext/ folder (which I've also done before). And finally, the classes were found.

    But now I get a NoClassDefFoundError when I try to use a method that uses the reflection API. It can't find the className "java.lang.String" when I call
    Class.forName(className);
    Yeah, this ActiveX bridge is still a pain in the ass ... :-(
  • 7. Re: Problems with ActiveX properties for JavaBean
    843804 Newbie
    Currently Being Moderated
    Looks like you are doing some progress, and taking a step back at the same time! I am a little hesitant to installing 1.5 (which I assume is a Beta version) when they (Sun) can't even get an official release to work!
    Maybe this would work better using MS SDK, have you tried this?
    http://www.microsoft.com/downloads/details.aspx?FamilyID=e5bceb12-d919-4b14-8c1b-46a207b845bc&DisplayLang=en

    Looks like M$ also have some ActiveX tools that I wasn't aware of that might work. I am busy with other things so I can't test it out now, but if you are interested you can check out:
    http://www.microsoft.com/downloads/search.aspx?displaylang=en&categoryid=10
    There are some ActiveX components in the drop down menu that might be of interest.
  • 8. Re: Problems with ActiveX properties for JavaBean
    416044 Newbie
    Currently Being Moderated
    Nope, I haven't used the MS SDK, as Microsoft is not supporting Java anymore (the old tools just support the very old Java 1.1 VM of Microsoft).

    1.5 is not beta anymore, indeed, the second version (1.5.0_01) was already released with some bugfixes.

    After I got it to work yesterday, I still got several Automation Errors, ClassNotFoundErrors and found out, that only the very basic datataypes work, like String and numbers. Even though the ActiveX bridge guide (http://java.sun.com/j2se/1.5.0/docs/guide/beans/axbridge/developerguide/index.html) says that Java Objects can be used, I wasn't able to call methods that had an
    Object
    parameter or arrays like
    String[], Object[]).
    
    In the end, I'm writing a wrapper now that only accepts strings and converts them in the Java bean to real Java types via reflection. I also read somewhere that the Microsoft COM model only support these basic datatypes, see also
    
    http://www.javaworld.com/javaworld/jw-09-1998/jw-09-bridge-p4.html                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        
  • 9. Re: Problems with ActiveX properties for JavaBean
    843804 Newbie
    Currently Being Moderated
    Hi,

    It seems that I am having the same problem and I just want to ask if someone found a fix already.

    I am currently running an applet in a Windows 2000/MS IE 5 environment. This applet is inside an HTML page. Inside this html page, I have a javascript that constructs a VBArray object passing an array (Object[] )that came from a method call inside a java class inside the applet. to demonstrate it clearly, here is the code:

    var currentTransaction = orderApplet.getTransaction();
    var myList = new VBArray(currentTransaction.getOrders()));

    This code is running perfectly in my current environment (Windows 2000/MS IE). However, I was asked to migrate this current application and deploy this in a Windows XP/MS IE 6 environment. When I tried running the code above, I got a javascript error saying that a VBArray was expected. I tried to debug the applet if it is actually calling the method inside the getOrders() method by using System.out.println. When I looked at the java console, it is giving me some values meaning that the call to this method was properly set. However, when I tried to "alert" the value of the myList object, this is where it gave me the javascript error, because the getOrders() did not return anything.

    When I tried to research the value of the parameter being used to pass inside the constructor of the VBArray, it states that the parameter should be a type of 'safeArray' which can come from an activeX control or an object.

    I have been reading a lot of threads about the activeX bridge and the problem of Microsoft and Sun in making these two objects (beans/applets and activeX) communicate in MS IE 6. Unfortunately, I cannot find a concrete and more detailed solution to the problem that I am having. As an additional information, I have already downloaded the latest JRE from SUN which is the 1.5 version.

    When I tried running this in a different machine with a MS Windows 2000/IE 5 environment, I did not encounter any problem. Can someone please give me an idea on how to make this thing work on a XP/IE 6 environment using the latest JRE (1.5)?

    I will appreciate any help or advise that you can give me. I have been stuck in this problem in the past 4 days and forums or suggestions that I have found does not seem to solve this problem.

    Thanks a Lot in advance.

    Ja
  • 10. Re: Problems with ActiveX properties for JavaBean
    843804 Newbie
    Currently Being Moderated
    Hi
    I have bean which has a GUI and converted to dll. My converted dll is working fine in VB if the classes in my bean are dependent on the other classes. But if it depends on the classes from another jar it's giving NoClassDef found error. I tried all the solution posted on this forum. like placing all jars in jre\lib\et. Can any of succeeded in this conversion process. Does this activeX convesrion works properly?

    I will really appreciate your reply.

    Thanks