Hi all,
I'm writing a tiny wrapper around apache UIMA but I'm facing some
classloading issues. Before I start explaining I should point out that
UIMA makes heavy use of the .class member of classes. It is practically
everywhere (a small java code snippet follows for demonstration of what
I mean):
AnalysisEngine goldTagger =
AnalysisEngineFactory.createPrimitive(*GoldTagger.class*,
typeSystem);
Ok let's start...I tried to create a minimal example with proxying
java.awt.Point but the only tool that I have to check whether a class is
present on the classpath is this code:
(try (Class/forName "somePackage.someClass")
(catch ClassNotFoundException cnf "NOT FOUND!"))
which in my made up minimal example returns the class object just fine
(as does for my proper example following which makes things confusing).
That is why I'm not posting the short example...OK here we go:
;first of all we need a component of our own that is alien to uima
(def regex-tokenizer artefacts/reg-tok) ;a regex-based tokenizer
;then I need to make it uima-compatible - this means extending a class
and overriding 'process(JCas jc)'
(def uima-friendly
(uima-compatible regex-tokenizer squeeze-jcas)) ;everything up to
here works just fine.
;the definitions for 'uima-compatible' & 'squeeze-jcas' follow for the
sake of completeness (feel free to skip them)
(defn uima-compatible [component jcas-input-extractor]
(proxy [org.uimafit.component.JCasAnnotator_ImplBase][]
(process [^JCas jc]
(let [xs (jcas-input-extractor jc)]
(component xs))))) ;;assuming component is a fn for now
(defn squeeze-jcas [^JCas jcas & classes]
(for [c classes
x (JCasUtil/select jcas c)]
x))
;the final step is to produce the actual analysis engine(s) from the
uima components (the proxied versions as they are the ones that are
uima-friendly).
;this is where the classloading problems begin which is very frustrating
as this is the very last step! Using the following fn:
(defn ufit-produce
"Produce UIMA components from your objects without writing any XML
descriptors, via uima-fit."
[& os]
(map #(AnalysisEngineFactory/createPrimitive (class %) *type-system*
(to-array [])) os))
I am doing (ufit-produce uima-friendly) and I get :
*ClassNotFoundException
hotel_nlp.externals.uima.proxy$org.uimafit.component.JCasAnnotator_ImplBase$0
**
**java.net.URLClassLoader$1.run (URLClassLoader.java:366) *
However the class is definitely there since I am able to do thie
following no problem:
*(try (Class/forName
"hotel_nlp.externals.uima.proxy$org.uimafit.component.JCasAnnotator_ImplBase$0")
**
** (catch ClassNotFoundException cnf "NOT FOUND!"))**
**
**
=>hotel_nlp.externals.uima.proxy$org.uimafit.component.JCasAnnotator_ImplBase$0*
What on earthis happening? How am I able to get the class Object back
but the ClassLoader couldn't? This is very weird isn't it?
any insights would be great! :)
Jim
--
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to the Google Groups "Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.