views:

293

answers:

3

I am working with a vendor applet, The applet works fine with JRE 1.4.2_X and 1.6.X but fails on every version of 1.5.X. Running with 1.6 is not an option due to another application conflict that does not play nice with Java 6.

The issue I believe is that the DTD is not being validated. This is causing the "not declared" problem and the resulting nullpointer.

 Error: Fri Aug 28 11:21:29 EDT 2009 org.xml.sax.SAXParseException: 
 Element type "UserSessionList" is not declared.
 java.lang.NullPointerException

I tried changing the default validation class but the problem remains unchanged.

 -Djavax.xml.validation.SchemaFactory:http://relaxng.org/ns/structure
 /1.0=org.apache.xerces.jaxp.validation.XMLSchemaFactory

Is there another validation I can use for this?

I don't really have the option of modifying the code the applet is beyond end of life from the vendor so getting support from them is unlikely. So any workarounds cannot involve changing code since we do not own it.

A: 

You can deploy the applet with all the existing code unmodified and specify which version of Java it executes under. You do this by declaring a classid parameter with the applet, like so:

<OBJECT
    classid="clsid:CAFEEFAC-0014-0002-FFFF-ABCDEFFEDCBA"
    width="200" height="200">
    <PARAM name="code" value="Applet1.class">
</OBJECT>

There are different classids for the last four major releases of Java

1.3 use CAFEEFAC-0013-0001-FFFF-ABCDEFFEDCBA
1.4 use CAFEEFAC-0014-0002-FFFF-ABCDEFFEDCBA
1.5 use CAFEEFAC-0015-0000-FFFF-ABCDEFFEDCBA
1.6 use CAFEEFAC-0016-0000-FFFF-ABCDEFFEDCBA

The caveat is that the client machine must have that version of Java installed, but the JREs are still available on Sun's site. More information here: http://java.sun.com/javase/6/webnotes/family-clsid.html

You can therefore mandate that your applet runs only 1.4, and it will not matter if the end user has another version of Java installed, as long as they have a 1.4 to run your applet.

banjollity
I understand what your saying with the classid's. However with 1.5 installed it will refuse to run a JRE outside of that family. You can put in a registry change to turn off secure static versioning but this breaks 1 of the other 3 applets on the client machine. I can load up 1.6 and that will allow an older JRE to run after passing a security prompt but 1.6 also breaks the other applets. If I can just get this to work with 1.5 I can run all the applets off that just fine.
Knife-Action-Jesus
+1  A: 

Try putting a current version of Xerces into the classspath, and get rid of all of those -D's. The SPI in Xerces will take over all of this and might behave better.

bmargulies
I will try and grab the xml, I don't think I remember seeing it in the snifer log. I didn't expect relaxng to work really, I am just trying to get this to do something different. This applet fails 100% of the time on 1.5. I was mainly trying to to figure out what the difference was between 1.5 and 1.6 that was causing the failure. Will post the xml when I get it. Reproducing this as a poja would not be easy as I don't own the source but with the xml maybe.
Knife-Action-Jesus
A: 

It looks like there might have been a bug present in Xerces when used with Java 1.5. See the last comment on this Tomcat bug.

jt
Thanks for the update, Will def give this a shot.
Knife-Action-Jesus