tika-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Joseph Vychtrle (JIRA)" <j...@apache.org>
Subject [jira] Updated: (TIKA-607) ParseUtils.getStringContent( ) of a text file - parser is null
Date Sat, 26 Feb 2011 17:29:58 GMT

     [ https://issues.apache.org/jira/browse/TIKA-607?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Joseph Vychtrle updated TIKA-607:
---------------------------------

    Description: 
Hey, I'm trying to get content of a text file (mysql config file).
{code}
	public void testTikaParserUtils() throws Exception {
		String resourceLocation = "files/my.cnf";
		String content = ParseUtils.getStringContent(new File(resourceLocation), new TikaConfig());
		System.out.println(content);
	}
{code}

OR
{code}
	public void testTikaParserUtils() throws Exception {
		String resourceLocation = "files/my.cnf";
		String content = ParseUtils.getStringContent(new File(resourceLocation), TikaConfig.getDefaultConfig());
		System.out.println(content);
	}
{code}
 
but I get null pointer exception, because "parser" is null

{code:title=ParseUtils.java|borderStyle=solid}
public static String getStringContent(
            InputStream stream, TikaConfig config, String mimeType)
            throws TikaException, IOException {
        try {
            Parser parser = config.getParser(MediaType.parse(mimeType));
            ContentHandler handler = new BodyContentHandler();
            parser.parse(stream, handler, new Metadata());
            return handler.toString();
        } catch (SAXException e) {
            throw new TikaException("Unexpected SAX error", e);
        }
    }}
{code} 
{color:red} 
java.lang.NullPointerException
	at org.apache.tika.utils.ParseUtils.getStringContent(ParseUtils.java:112)
	at org.apache.tika.utils.ParseUtils.getStringContent(ParseUtils.java:171)
	at org.apache.tika.utils.ParseUtils.getStringContent(ParseUtils.java:189)
	at cz.instance.transl.tests.TikaTest.testTikaParserUtils(TikaTest.java:53)
	at org.apache.maven.surefire.testng.TestNGExecutor.run(TestNGExecutor.java:73)
	at org.apache.maven.surefire.testng.TestNGXmlTestSuite.execute(TestNGXmlTestSuite.java:95)
	at org.apache.maven.surefire.testng.TestNGProvider.invoke(TestNGProvider.java:101)
	at org.apache.maven.surefire.booter.ProviderFactory$ClassLoaderProxy.invoke(ProviderFactory.java:101)
	at $Proxy0.invoke(Unknown Source)
	at org.apache.maven.surefire.booter.SurefireStarter.invokeProvider(SurefireStarter.java:139)
	at org.apache.maven.surefire.booter.SurefireStarter.runSuitesInProcess(SurefireStarter.java:82)
	at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:81)
... Removed 24 stack frames
{color}

  was:
Hey, I'm trying to get content of a text file (mysql config file).
{code}
	public void testTikaParserUtils() throws Exception {
		String resourceLocation = "files/my.cnf";
		String content = ParseUtils.getStringContent(new File(resourceLocation), new TikaConfig());
		System.out.println(content);
	}
{code} 
but I get null pointer exception, because "parser" is null

{code:title=ParseUtils.java|borderStyle=solid}
public static String getStringContent(
            InputStream stream, TikaConfig config, String mimeType)
            throws TikaException, IOException {
        try {
            Parser parser = config.getParser(MediaType.parse(mimeType));
            ContentHandler handler = new BodyContentHandler();
            parser.parse(stream, handler, new Metadata());
            return handler.toString();
        } catch (SAXException e) {
            throw new TikaException("Unexpected SAX error", e);
        }
    }}
{code} 
{color:red} 
java.lang.NullPointerException
	at org.apache.tika.utils.ParseUtils.getStringContent(ParseUtils.java:112)
	at org.apache.tika.utils.ParseUtils.getStringContent(ParseUtils.java:171)
	at org.apache.tika.utils.ParseUtils.getStringContent(ParseUtils.java:189)
	at cz.instance.transl.tests.TikaTest.testTikaParserUtils(TikaTest.java:53)
	at org.apache.maven.surefire.testng.TestNGExecutor.run(TestNGExecutor.java:73)
	at org.apache.maven.surefire.testng.TestNGXmlTestSuite.execute(TestNGXmlTestSuite.java:95)
	at org.apache.maven.surefire.testng.TestNGProvider.invoke(TestNGProvider.java:101)
	at org.apache.maven.surefire.booter.ProviderFactory$ClassLoaderProxy.invoke(ProviderFactory.java:101)
	at $Proxy0.invoke(Unknown Source)
	at org.apache.maven.surefire.booter.SurefireStarter.invokeProvider(SurefireStarter.java:139)
	at org.apache.maven.surefire.booter.SurefireStarter.runSuitesInProcess(SurefireStarter.java:82)
	at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:81)
... Removed 24 stack frames
{color}

If I switch the text file to  MS word .doc, I get :
{color:red} 
java.lang.NoSuchMethodError: org.apache.poi.poifs.filesystem.DirectoryNode.iterator()Ljava/util/Iterator;
	at org.apache.tika.parser.microsoft.OfficeParser.parse(OfficeParser.java:168)
	at org.apache.tika.parser.microsoft.OfficeParser.parse(OfficeParser.java:237)
	at org.apache.tika.utils.ParseUtils.getStringContent(ParseUtils.java:112)
	at org.apache.tika.utils.ParseUtils.getStringContent(ParseUtils.java:171)
	at org.apache.tika.utils.ParseUtils.getStringContent(ParseUtils.java:189)
{color}


> ParseUtils.getStringContent( ) of a text file - parser is null 
> ---------------------------------------------------------------
>
>                 Key: TIKA-607
>                 URL: https://issues.apache.org/jira/browse/TIKA-607
>             Project: Tika
>          Issue Type: Bug
>          Components: parser
>    Affects Versions: 0.9
>         Environment: java version "1.6.0_16", linux 64bit
>            Reporter: Joseph Vychtrle
>
> Hey, I'm trying to get content of a text file (mysql config file).
> {code}
> 	public void testTikaParserUtils() throws Exception {
> 		String resourceLocation = "files/my.cnf";
> 		String content = ParseUtils.getStringContent(new File(resourceLocation), new TikaConfig());
> 		System.out.println(content);
> 	}
> {code}
> OR
> {code}
> 	public void testTikaParserUtils() throws Exception {
> 		String resourceLocation = "files/my.cnf";
> 		String content = ParseUtils.getStringContent(new File(resourceLocation), TikaConfig.getDefaultConfig());
> 		System.out.println(content);
> 	}
> {code}
>  
> but I get null pointer exception, because "parser" is null
> {code:title=ParseUtils.java|borderStyle=solid}
> public static String getStringContent(
>             InputStream stream, TikaConfig config, String mimeType)
>             throws TikaException, IOException {
>         try {
>             Parser parser = config.getParser(MediaType.parse(mimeType));
>             ContentHandler handler = new BodyContentHandler();
>             parser.parse(stream, handler, new Metadata());
>             return handler.toString();
>         } catch (SAXException e) {
>             throw new TikaException("Unexpected SAX error", e);
>         }
>     }}
> {code} 
> {color:red} 
> java.lang.NullPointerException
> 	at org.apache.tika.utils.ParseUtils.getStringContent(ParseUtils.java:112)
> 	at org.apache.tika.utils.ParseUtils.getStringContent(ParseUtils.java:171)
> 	at org.apache.tika.utils.ParseUtils.getStringContent(ParseUtils.java:189)
> 	at cz.instance.transl.tests.TikaTest.testTikaParserUtils(TikaTest.java:53)
> 	at org.apache.maven.surefire.testng.TestNGExecutor.run(TestNGExecutor.java:73)
> 	at org.apache.maven.surefire.testng.TestNGXmlTestSuite.execute(TestNGXmlTestSuite.java:95)
> 	at org.apache.maven.surefire.testng.TestNGProvider.invoke(TestNGProvider.java:101)
> 	at org.apache.maven.surefire.booter.ProviderFactory$ClassLoaderProxy.invoke(ProviderFactory.java:101)
> 	at $Proxy0.invoke(Unknown Source)
> 	at org.apache.maven.surefire.booter.SurefireStarter.invokeProvider(SurefireStarter.java:139)
> 	at org.apache.maven.surefire.booter.SurefireStarter.runSuitesInProcess(SurefireStarter.java:82)
> 	at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:81)
> ... Removed 24 stack frames
> {color}

-- 
This message is automatically generated by JIRA.
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Mime
View raw message