Lou.
Here's how I "fixed" my problem:
In my launched (2nd level) plug-in, I created a new project and added
the same external .jar files as my development environment (1st level)
as follows:
boot.jar
runtime.jar
jdtcore.jar
swt.jar
workbench.jar
resources.jar
xmlParserAPIs.jar
xercesImpl.jar
Having done this, my test code (see below) runs without the previously
reported problems. Specifying the VM Arguments as previously reported
is necessary. Absent doing this, I'm not able to test my plug-in.
This seems wrong to me. Where am I screwing up?
Thanks.
Lou.
-----
MyHandler.java
package com.ibm.degenaro;
import java.io.FileReader;
import org.xml.sax.XMLReader;
import org.xml.sax.Attributes;
import org.xml.sax.InputSource;
import org.xml.sax.helpers.XMLReaderFactory;
import org.xml.sax.helpers.DefaultHandler;
/** class MyHandler */
/** @author Lou Degenaro, degenaro@xxxxxxxxxx, 06/21/2002 */
public class MyHandler extends DefaultHandler {
private static final boolean debug = false;
// public instance method(s)
/** constructor(s) */
public MyHandler()
{
super();
};
/** startDocument */
public void startDocument()
{
if(debug)
{
System.out.println("Start document");
}
};
/** endDocument */
public void endDocument()
{
if(debug)
{
System.out.println("End document");
}
};
/** startElement */
public void startElement(String uri, String name, String qName,
Attributes atts)
{
if ("".equals (uri))
{
if(debug)
{
System.out.println("<" + qName
+ ">");
}
}
else
{
if(debug)
{
System.out.println("Start element:
{" + uri + "}" + name);
}
}
};
/** endElement */
public void endElement(String uri, String name, String
qName)
{
if ("".equals (uri))
{
if(debug)
{
System.out.println("</" + qName + ">");
}
}
else {
if(debug)
{
System.out.println("End element: {"
+ uri + "}" + name);
}
}
};
/** characters */
public void characters(char ch[], int start, int length)
{
String string = "";
for (int i = start; i < start + length; i++)
{
string += ch[i];
}
if(debug) {
System.out.println(string);
}
};
}
-----
MyXMLReader.java
package com.ibm.degenaro;
import java.io.FileReader;
import org.xml.sax.XMLReader;
import org.xml.sax.Attributes;
import org.xml.sax.InputSource;
import org.xml.sax.helpers.XMLReaderFactory;
import org.xml.sax.helpers.DefaultHandler;
/** class MyXMLReader */
/** @author Lou Degenaro, degenaro@xxxxxxxxxx, 06/21/2002 */
public class MyXMLReader
{
private XMLReader xmlReader = null;
private MyHandler MyHandler = null;
// public instance method(s)
/** constructor(s) */
public MyXMLReader() throws Exception
{
xmlReader = XMLReaderFactory.createXMLReader();
MyHandler = new MyHandler();
xmlReader.setContentHandler(MyHandler);
xmlReader.setErrorHandler(MyHandler);
};
/** parse */
public void parse(String fileName) throws Exception
{
FileReader fileReader = new FileReader(fileName);
xmlReader.parse(new InputSource(fileReader));
};
}
-----
Test.java
package com.ibm.degenaro;
import com.ibm.degenaro.MyXMLReader;
public class Test
{
// public static method(s)
public static void main(String args[]) throws Exception
{
System.out.println("<Test>");
MyXMLReader MyXMLReader = new MyXMLReader();
for (int i = 0; i < args.length; i++)
{
MyXMLReader.parse(args[i]);
}
System.out.println("</Test>");
};
}
Bob Foster wrote:
What
you are doing seems a bit of overkill. You shouldn't need to specify those
VM arguments, as the platform should set up these defaults for you, and
probably does it so as to override yours. At least, I don't have VM arguments
and I don't have any problem using the SAX parser. I
don't know why this stuff is scattered all over and duplicated, but you
might try this: Remove the
VM arguments. Go to Run > Run... > Run-time Workbench > configuration-name
> Plug-ins and Fragments tab, select Choose plug-ins and fragments to launch
from the list, then check External Plugins (all of 'em - unless your own
plugin appears in the list; uncheck that one to avoid an annoying alert).
Then Run. At least, this
is what I have and in my code I just do "new SAXParser()" and it works.
Bob "Lou DeGenaro"
<degenaro@xxxxxxxxxxxxxx>
wrote in message news:3D80C2F9.8EBD5ED5@xxxxxxxxxxxxxx...
I'm
still unable to use the SAX Parser. In the launch window I specify:
VM Arguments: -Dorg.xml.sax.driver=org.apache.xerces.parsers.SAXParser
as well as the plug-in addition previously mentioned in the requires
section.
What am I missing?
Thanks.
Lou.
Lou DeGenaro wrote:
I added the following to my plug-in:
<requires>
<import plugin="org.eclipse.core.runtime"/>
<import plugin="org.eclipse.core.resources"/>
<import plugin="org.eclipse.ui"/>
<import plugin="org.eclipse.swt"/>
<import plugin="org.eclipse.jdt.core"/>
<import plugin="org.apache.xerces"/>
</requires>
I still get the subject exception when I launch the plug-in for testing.
Lou.
John Arthorne wrote:
See the following FAQ entry on this topic:
http://eclipsewiki.swiki.net/114#eclipseClassloading
-
Lou DeGenaro wrote:
>I launch a plug-in for testing. As part of the plug-in, there's
a
>wizard that invokes the SAX Parser. What do I have to do in
order for
>the SAX Parser class to be found? Under Window -> Preferences
->
>Plug-In Development -> Target Platform, I selected all (including
>org.apache.xerces).
>
>Thanks.
>
>Lou.
>