Re: [Htmlparser-user] htmlparser.jar error
Brought to you by:
derrickoswald
From: Derrick O. <der...@ro...> - 2008-02-22 17:31:24
|
Anirban, The exception indicates that the cast to List in the line "items = (List)map.get (key);" is failing: public static String getRequestHeader (HttpURLConnection connection) { // dump it StringBuffer buffer; Map map; String key; List items; buffer = new StringBuffer (1024); buffer.append (connection.getRequestMethod ()); buffer.append (" "); buffer.append (connection.getURL ()); buffer.append (" HTTP/1.1\n"); map = connection.getRequestProperties (); for (Iterator iter = map.keySet ().iterator (); iter.hasNext (); ) { key = (String)iter.next (); items = (List)map.get (key); buffer.append (key); buffer.append (": "); for (int i = 0; i < items.size (); i++) { if (0 != i) buffer.append (", "); buffer.append (items.get (i)); } buffer.append ("\n"); } return (buffer.toString ()); } The (Sun Java) specification for both 1.4.2 and 1.5.0 says that each map entry is an unmodifiable List of Strings, so the cast should always work. I would suspect the gij implementation is at fault and would look for an updated version. Derrick ----- Original Message ---- From: Anirban Banerjee <ban...@gm...> To: htmlparser user list <htm...@li...> Sent: Friday, February 22, 2008 4:25:54 AM Subject: Re: [Htmlparser-user] htmlparser.jar error I set the CLASSPATH to the current directory where the .jar file is placed and it still gives an error. Also tried $> jar xvf htmlparser.jar lib but still did not work On Fri, Feb 22, 2008 at 1:21 AM, Ali <to...@ya...> wrote: Check the classpath, you must have entered a wrong class path. --- Anirban Banerjee <ban...@gm...> wrote: > Hello everyone :-), > This is my first post on > this list and I have just > started using htmlparser. The latest jar file works > fine on my mac but > gives me an error on my linux box. I am new to Java > and so am not really > sure as to what the exact cause of the exception is. > > My linux box has the following config: Linux Nirvana > 2.6.11-1.1369_FC4 #1 > Thu Jun 2 22:55:56 EDT 2005 i686 i686 i386 GNU/Linux > > with java version: > java version "1.4.2" > gij (GNU libgcj) version 4.0.0 20050519 (Red Hat > 4.0.0-8) > > my mac has > java version "1.5.0_13" > Java(TM) 2 Runtime Environment, Standard Edition > (build 1.5.0_13-b05-237) > Java HotSpot(TM) Client VM (build 1.5.0_13-119, > mixed mode, sharing) > > Do I have to upgrade to libgcj 6.0.0 to make it > work? The dump is attached > below. > > Thanks, > -A > > [me@Nirvana]sandbox/>java -jar ./htmlparser.jar > http://www.google.com > Exception in thread "main" > java.lang.ClassCastException: java.util.List > at > org.htmlparser.http.HttpHeader.getRequestHeader( > java.net.HttpURLConnection) (Unknown Source) > at > org.htmlparser.Parser.preConnect(java.net.HttpURLConnection) > (Unknown > Source) > at > org.htmlparser.http.ConnectionManager.openConnection(java.net.URL) > (Unknown Source) > at > org.htmlparser.http.ConnectionManager.openConnection(java.lang.String) > (Unknown Source) > at > org.htmlparser.Parser.setResource(java.lang.String) > (Unknown Source) > at org.htmlparser.Parser.main(java.lang.String[]) > (Unknown Source) > at gnu.java.lang.MainThread.call_main() > (/usr/lib/libgcj.so.6.0.0) > at gnu.java.lang.MainThread.run() > (/usr/lib/libgcj.so.6.0.0) > > -- > "The reason Santa is so jolly is because he knows > where all the bad girls > live." > -George Carlin > > ------------------------------------------------------------------------- > This SF.net email is sponsored by: Microsoft > Defy all challenges. Microsoft(R) Visual Studio > 2008. > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/> _______________________________________________ > Htmlparser-user mailing list > Htm...@li... > https://lists.sourceforge.net/lists/listinfo/htmlparser-user > ____________________________________________________________________________________ Looking for last minute shopping deals? Find them fast with Yahoo! Search. http://tools.search.yahoo.com/newsearch/category.php?category=shopping ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ _______________________________________________ Htmlparser-user mailing list Htm...@li... https://lists.sourceforge.net/lists/listinfo/htmlparser-user -- "The reason Santa is so jolly is because he knows where all the bad girls live." -George Carlin -----Inline Attachment Follows----- ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ -----Inline Attachment Follows----- _______________________________________________ Htmlparser-user mailing list Htm...@li... https://lists.sourceforge.net/lists/listinfo/htmlparser-user |