Quantcast
Channel: Mendix Forum Questions
Viewing all articles
Browse latest Browse all 82402

Tika Parser Exception

$
0
0

I have the following Java that tries to determine file type server side:

        // BEGIN USER CODE
    Core.getLogger(this.toString()).info("Starting...");
    String retval=new String("");
    InputStream is = Core.getFileDocumentContent(getContext(),obj_FileDocument.getMendixObject());;
    try {
        //File f = new File("data/tmp/a.jpg");
        ContentHandler contenthandler = new BodyContentHandler();
        Metadata metadata = new Metadata();
        //metadata.set(Metadata.RESOURCE_NAME_KEY, f.getName());
        try{
            Parser parser = new AutoDetectParser();
            ParseContext context=new ParseContext();
            parser.parse(is, contenthandler, metadata,context);
            /*
            Core.getLogger(this.toString()).info("Mime: " + metadata.get(Metadata.CONTENT_TYPE));
            Core.getLogger(this.toString()).info("Title: " + metadata.get(Metadata.TITLE));
            Core.getLogger(this.toString()).info("Author: " + metadata.get(Metadata.AUTHOR));
            Core.getLogger(this.toString()).info("content: " + contenthandler.toString());
            */
            retval=metadata.get(Metadata.CONTENT_TYPE);
        }catch (Exception e) {
            Core.getLogger(this.toString()).info("Mime type exception: "+e.toString());
        }
    }catch (Exception e) {
        Core.getLogger(this.toString()).info("Error in determining file type: "+e.toString());
    }finally{
        if (is != null) is.close();
    }
    Core.getLogger(this.toString()).info("Ending...");
    return retval;
    // END USER CODE

I get the following error when querying certain file types:

Uncaught fatal error from thread [MxRuntimeSystem-akka.actor.action-dispatcher-15] shutting down ActorSystem [MxRuntimeSystem]
java.lang.NoClassDefFoundError: javax/xml/namespace/QName
at org.apache.tika.detect.XmlRootExtractor$ExtractorHandler.startElement(XmlRootExtractor.java:79)
at org.apache.tika.sax.ContentHandlerDecorator.startElement(ContentHandlerDecorator.java:104)
at org.apache.crimson.parser.Parser2.maybeElement(Parser2.java:1488)
at org.apache.crimson.parser.Parser2.parseInternal(Parser2.java:500)
at org.apache.crimson.parser.Parser2.parse(Parser2.java:305)
at org.apache.crimson.parser.XMLReaderImpl.parse(XMLReaderImpl.java:442)
at javax.xml.parsers.SAXParser.parse(SAXParser.java:393)
at javax.xml.parsers.SAXParser.parse(SAXParser.java:191)
at org.apache.tika.detect.XmlRootExtractor.extractRootElement(XmlRootExtractor.java:63)
at org.apache.tika.mime.MimeTypes.getMimeType(MimeTypes.java:232)
at org.apache.tika.mime.MimeTypes.detect(MimeTypes.java:530)
at org.apache.tika.parser.AutoDetectParser.parse(AutoDetectParser.java:92)
at os.actions.ja_FileDocument2FileTypeStr_tika.executeAction(ja_FileDocument2FileTypeStr_tika.java:71)
at os.actions.ja_FileDocument2FileTypeStr_tika.executeAction(ja_FileDocument2FileTypeStr_tika.java:41)
at com.mendix.systemwideinterfaces.core.UserAction.execute(UserAction.java:49)
at com.mendix.core.actionmanagement.CoreAction.doCall(CoreAction.java:261)
at com.mendix.core.actionmanagement.CoreAction.call(CoreAction.java:249)
at com.mendix.core.actionmanagement.ActionManager$1.execute(ActionManager.java:192)
at com.mendix.util.classloading.Runner.doRunUsingClassLoaderOf(Runner.java:32)
at com.mendix.core.actionmanagement.ActionManager.executeSync(ActionManager.java:198)
at com.mendix.core.component.InternalCore.execute(InternalCore.java:229)
at com.mendix.modules.microflowengine.actions.actioncall.JavaAction.execute(JavaAction.scala:52)
at com.mendix.modules.microflowengine.microflow.impl.MicroflowObject.execute(MicroflowObject.java:44)
at com.mendix.modules.microflowengine.microflow.impl.MicroflowImpl.executeAfterBreakingIfNecessary(MicroflowImpl.java:192)
at com.mendix.modules.microflowengine.microflow.impl.MicroflowImpl.executeAction(MicroflowImpl.java:149)
at com.mendix.systemwideinterfaces.core.UserAction.execute(UserAction.java:49)
at com.mendix.core.actionmanagement.CoreAction.doCall(CoreAction.java:261)
at com.mendix.core.actionmanagement.CoreAction.call(CoreAction.java:249)
at com.mendix.core.actionmanagement.ActionManager$1.execute(ActionManager.java:192)
at com.mendix.util.classloading.Runner.doRunUsingClassLoaderOf(Runner.java:32)
at com.mendix.core.actionmanagement.ActionManager.executeSync(ActionManager.java:198)
at com.mendix.core.component.InternalCore.executeSync(InternalCore.java:206)
at com.mendix.modules.microflowengine.actions.SubMicroflowAction.execute(SubMicroflowAction.scala:37)
at com.mendix.modules.microflowengine.microflow.impl.MicroflowObject.execute(MicroflowObject.java:44)
at com.mendix.modules.microflowengine.microflow.impl.MicroflowImpl.executeAfterBreakingIfNecessary(MicroflowImpl.java:192)
at com.mendix.modules.microflowengine.microflow.impl.MicroflowImpl.executeAction(MicroflowImpl.java:149)
at com.mendix.systemwideinterfaces.core.UserAction.execute(UserAction.java:49)
at com.mendix.core.actionmanagement.CoreAction.doCall(CoreAction.java:261)
at com.mendix.core.actionmanagement.CoreAction.call(CoreAction.java:249)
at com.mendix.core.actionmanagement.ActionManager$1.execute(ActionManager.java:192)
at com.mendix.util.classloading.Runner.doRunUsingClassLoaderOf(Runner.java:32)
at com.mendix.core.actionmanagement.ActionManager.executeSync(ActionManager.java:198)
at com.mendix.core.component.InternalCore.execute(InternalCore.java:229)
at com.mendix.webui.actions.client.ExecuteAction.execute(ExecuteAction.java:135)
at com.mendix.webui.requesthandling.ClientRequestHandler$$anonfun$handleRequest$1.apply$mcV$sp(ClientRequestHandler.scala:300)
at com.mendix.webui.requesthandling.ClientRequestHandler$$anonfun$handleRequest$1.apply(ClientRequestHandler.scala:293)
at com.mendix.webui.requesthandling.ClientRequestHandler$$anonfun$handleRequest$1.apply(ClientRequestHandler.scala:293)
at com.mendix.core.session.Worker$$anonfun$receive$3$$anonfun$2$$anon$1.execute(ActionDispatching.scala:126)
at com.mendix.util.classloading.Runner.doRunUsingClassLoaderOf(Runner.java:32)
at com.mendix.core.session.Worker$$anonfun$receive$3$$anonfun$2.apply(ActionDispatching.scala:128)
at scala.util.Try$.apply(Try.scala:191)
at com.mendix.core.session.Worker$$anonfun$receive$3.applyOrElse(ActionDispatching.scala:122)
at akka.actor.Actor$class.aroundReceive(Actor.scala:465)
at com.mendix.core.session.Worker.aroundReceive(ActionDispatching.scala:119)
at akka.actor.ActorCell.receiveMessage(ActorCell.scala:516)
at akka.actor.ActorCell.invoke(ActorCell.scala:487)
at akka.dispatch.Mailbox.processMailbox(Mailbox.scala:238)
at akka.dispatch.Mailbox.run(Mailbox.scala:220)
at akka.dispatch.ForkJoinExecutorConfigurator$AkkaForkJoinTask.exec(AbstractDispatcher.scala:393)
at scala.concurrent.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260)
at scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339)
at scala.concurrent.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979)
at scala.concurrent.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107)

Caused by: java.lang.ClassNotFoundException: javax.xml.namespace.QName not found by project [104] at org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1532) at org.apache.felix.framework.BundleWiringImpl.access$400(BundleWiringImpl.java:75) at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:1955) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) at org.apache.tika.detect.XmlRootExtractor$ExtractorHandler.startElement(XmlRootExtractor.java:79) at org.apache.tika.sax.ContentHandlerDecorator.startElement(ContentHandlerDecorator.java:104) at org.apache.crimson.parser.Parser2.maybeElement(Parser2.java:1488) at org.apache.crimson.parser.Parser2.parseInternal(Parser2.java:500) at org.apache.crimson.parser.Parser2.parse(Parser2.java:305) at org.apache.crimson.parser.XMLReaderImpl.parse(XMLReaderImpl.java:442) at javax.xml.parsers.SAXParser.parse(SAXParser.java:393) at javax.xml.parsers.SAXParser.parse(SAXParser.java:191) at org.apache.tika.detect.XmlRootExtractor.extractRootElement(XmlRootExtractor.java:63) at org.apache.tika.mime.MimeTypes.getMimeType(MimeTypes.java:232) at org.apache.tika.mime.MimeTypes.detect(MimeTypes.java:530) at org.apache.tika.parser.AutoDetectParser.parse(AutoDetectParser.java:92) at os.actions.jaFileDocument2FileTypeStrtika.executeAction(jaFileDocument2FileTypeStrtika.java:71) at os.actions.jaFileDocument2FileTypeStrtika.executeAction(jaFileDocument2FileTypeStrtika.java:41) at com.mendix.systemwideinterfaces.core.UserAction.execute(UserAction.java:49) at com.mendix.core.actionmanagement.CoreAction.doCall(CoreAction.java:261) at com.mendix.core.actionmanagement.CoreAction.call(CoreAction.java:249) at com.mendix.core.actionmanagement.ActionManager$1.execute(ActionManager.java:192) at com.mendix.util.classloading.Runner.doRunUsingClassLoaderOf(Runner.java:32) at com.mendix.core.actionmanagement.ActionManager.executeSync(ActionManager.java:198) at com.mendix.core.component.InternalCore.execute(InternalCore.java:229) at com.mendix.modules.microflowengine.actions.actioncall.JavaAction.execute(JavaAction.scala:52) at com.mendix.modules.microflowengine.microflow.impl.MicroflowObject.execute(MicroflowObject.java:44) at com.mendix.modules.microflowengine.microflow.impl.MicroflowImpl.executeAfterBreakingIfNecessary(MicroflowImpl.java:192) at com.mendix.modules.microflowengine.microflow.impl.MicroflowImpl.executeAction(MicroflowImpl.java:149) at com.mendix.systemwideinterfaces.core.UserAction.execute(UserAction.java:49) at com.mendix.core.actionmanagement.CoreAction.doCall(CoreAction.java:261) at com.mendix.core.actionmanagement.CoreAction.call(CoreAction.java:249) at com.mendix.core.actionmanagement.ActionManager$1.execute(ActionManager.java:192) at com.mendix.util.classloading.Runner.doRunUsingClassLoaderOf(Runner.java:32) at com.mendix.core.actionmanagement.ActionManager.executeSync(ActionManager.java:198) at com.mendix.core.component.InternalCore.executeSync(InternalCore.java:206) at com.mendix.modules.microflowengine.actions.SubMicroflowAction.execute(SubMicroflowAction.scala:37) at com.mendix.modules.microflowengine.microflow.impl.MicroflowObject.execute(MicroflowObject.java:44) at com.mendix.modules.microflowengine.microflow.impl.MicroflowImpl.executeAfterBreakingIfNecessary(MicroflowImpl.java:192) at com.mendix.modules.microflowengine.microflow.impl.MicroflowImpl.executeAction(MicroflowImpl.java:149) at com.mendix.systemwideinterfaces.core.UserAction.execute(UserAction.java:49) at com.mendix.core.actionmanagement.CoreAction.doCall(CoreAction.java:261) at com.mendix.core.actionmanagement.CoreAction.call(CoreAction.java:249) at com.mendix.core.actionmanagement.ActionManager$1.execute(ActionManager.java:192) at com.mendix.util.classloading.Runner.doRunUsingClassLoaderOf(Runner.java:32) at com.mendix.core.actionmanagement.ActionManager.executeSync(ActionManager.java:198) at com.mendix.core.component.InternalCore.execute(InternalCore.java:229) at com.mendix.webui.actions.client.ExecuteAction.execute(ExecuteAction.java:135) at com.mendix.webui.requesthandling.ClientRequestHandler$$anonfun$handleRequest$1.apply$mcV$sp(ClientRequestHandler.scala:300) at com.mendix.webui.requesthandling.ClientRequestHandler$$anonfun$handleRequest$1.apply(ClientRequestHandler.scala:293) at com.mendix.webui.requesthandling.ClientRequestHandler$$anonfun$handleRequest$1.apply(ClientRequestHandler.scala:293) at com.mendix.core.session.Worker$$anonfun$receive$3$$anonfun$2$$anon$1.execute(ActionDispatching.scala:126) at com.mendix.util.classloading.Runner.doRunUsingClassLoaderOf(Runner.java:32) at com.mendix.core.session.Worker$$anonfun$receive$3$$anonfun$2.apply(ActionDispatching.scala:128) at scala.util.Try$.apply(Try.scala:191) at com.mendix.core.session.Worker$$anonfun$receive$3.applyOrElse(ActionDispatching.scala:122) at akka.actor.Actor$class.aroundReceive(Actor.scala:465) at com.mendix.core.session.Worker.aroundReceive(ActionDispatching.scala:119) at akka.actor.ActorCell.receiveMessage(ActorCell.scala:516) at akka.actor.ActorCell.invoke(ActorCell.scala:487) at akka.dispatch.Mailbox.processMailbox(Mailbox.scala:238) at akka.dispatch.Mailbox.run(Mailbox.scala:220) at akka.dispatch.ForkJoinExecutorConfigurator$AkkaForkJoinTask.exec(AbstractDispatcher.scala:393) at scala.concurrent.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260) at scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339) at scala.concurrent.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979) at scala.concurrent.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107)

How can I handle this fatality that it does not shut down mendix runtime? Alternatively what filetype detection library can I use.

Thankyou


Viewing all articles
Browse latest Browse all 82402

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>