You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@uima.apache.org by Erik Fäßler <er...@uni-jena.de> on 2012/07/26 18:17:58 UTC

PEAR Classpath issues

Hi all,

I know this question has been asked a few times in the past years but I didn't really come to a definite answer or a solution to the problem. The issue is to use a PEAR packaged simple AE in a pipeline without setting the classpath manually. On the contrary, my primary goal is to make use of the PEAR isolation feature introduced in UIMA 2.2. 

I created a very small example. My AE is a simple (non-aggregate) AE without dependencies on any resources. It does only rely on the commons-lang3 library. The process method is this:
public void process(JCas aJCas) throws AnalysisEngineProcessException {
		String[] mow = {"eins", "zwei", "drei"};
		System.out.println("wow: " + StringUtils.join(mow, " -- "));
	}

My humble goal is to make a PEAR of this AE, to install it and let it run successfully using the Cas Visual Debugger. I created an AE descriptor and placed it in the "desc" directory. I copied the dependency JARs into the "lib" directory (using the Maven dependency plugin).
I created the PEAR package manually by using the Eclipse PEAR plugin, not the Maven plugin. I left the automatically created install.xml untouched:

<?xml version="1.0" encoding="UTF-8"?>
<COMPONENT_INSTALLATION_DESCRIPTOR>
	<OS>
		<NAME>Linux</NAME>
	</OS>
	<TOOLKITS>
		<JDK_VERSION>1.6.0</JDK_VERSION>
	</TOOLKITS>
	<UIMA_FRAMEWORK>
	</UIMA_FRAMEWORK>
	<SUBMITTED_COMPONENT>
		<ID>peartest</ID>
		<NAME></NAME>
		<DESC>$main_root/desc/aeDescriptor.xml</DESC>
		<DEPLOYMENT>standard</DEPLOYMENT>
	</SUBMITTED_COMPONENT>
	<INSTALLATION>
		<PROCESS>
			<ACTION>set_env_variable</ACTION>
			<PARAMETERS>
				<COMMENTS></COMMENTS>
				<VAR_VALUE>$main_root/target/classes;</VAR_VALUE>
				<VAR_NAME>CLASSPATH</VAR_NAME>
			</PARAMETERS>
		</PROCESS>
	</INSTALLATION>
</COMPONENT_INSTALLATION_DESCRIPTOR>

I did intentionally not include my libraries in the classpath here, because the documentation says,
"The buildComponentClasspath method of the PackageBrowser class builds a classpath string from what it finds in the CLASSPATH specification here, plus adds a classpath entry for all Jars in the lib directory. Because of this, there is no need to specify Class Path entries for Jars in the lib directory."

I created the PEAR package and then used the runPearPackage.sh script to install it, which went fine. Then I hit the button to test the AE with CVD and got this exception:
26.07.12 18:00:13 - 10: org.apache.uima.tools.cvd.MainFrame.handleException(529): SCHWERWIEGEND: org/apache/commons/lang/StringUtils
java.lang.NoClassDefFoundError: org/apache/commons/lang/StringUtils
	at de.julielab.peartest.PearTestAE.process(PearTestAE.java:38)
	at org.apache.uima.analysis_component.JCasAnnotator_ImplBase.process(JCasAnnotator_ImplBase.java:48)
	at org.apache.uima.analysis_engine.impl.PrimitiveAnalysisEngine_impl.callAnalysisComponentProcess(PrimitiveAnalysisEngine_impl.java:377)
	at org.apache.uima.analysis_engine.impl.PrimitiveAnalysisEngine_impl.processAndOutputNewCASes(PrimitiveAnalysisEngine_impl.java:295)
	at org.apache.uima.analysis_engine.impl.PearAnalysisEngineWrapper.processAndOutputNewCASes(PearAnalysisEngineWrapper.java:339)
	at org.apache.uima.analysis_engine.impl.AnalysisEngineImplBase.process(AnalysisEngineImplBase.java:267)
	at org.apache.uima.tools.cvd.MainFrame.internalRunAE(MainFrame.java:1506)
	at org.apache.uima.tools.cvd.MainFrame.runAE(MainFrame.java:430)
	at org.apache.uima.tools.pear.install.InstallPear$2.run(InstallPear.java:448)
	at java.lang.Thread.run(Thread.java:680)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.lang.StringUtils
	at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
	at org.apache.uima.internal.util.UIMAClassLoader.loadClass(UIMAClassLoader.java:151)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
	... 10 more

When I - for a test - add the path for the used library manually to the install.xml (which then reads: "$main_root/lib/commons-lang-2.4.jar;"), the CVD runs smoothly without exception. I.e. the library is there and working.

Have I done something completely wrong? Shouldn't the CVD - and later then, the runCPE.sh script - automatically add the libraries in the lib/ directory of a PEAR automatically to create an isolated PEAR runtime?

And one fall-back-question: In case I would just add all my libraries manually into the install.xml, would I still get the PEAR isolation?

Thanks for your time,

	Erik

Re: PEAR Classpath issues

Posted by Thilo Goetz <tw...@gmx.de>.
Hi Erik,

On 27/07/12 10:51, Erik Fäßler wrote:
> Hi Thilo!
> 
> Thanks for your answer! Some comments and further questions below:
> 
> Am 27.07.2012 um 08:24 schrieb Thilo Goetz:
> 
>>> I did intentionally not include my libraries in the classpath here, because the documentation says,
>>> "The buildComponentClasspath method of the PackageBrowser class builds a classpath string from what it finds in the CLASSPATH specification here, plus adds a classpath entry for all Jars in the lib directory. Because of this, there is no need to specify Class Path entries for Jars in the lib directory."
>>
>> If the documentation still says that, I think it's outdated.  I'm pretty
>> sure we changed this defaulty behavior at some point.
> 
> *cough* It doesn't. I am very sorry - I must have confused documentation versions while being in the full action of research for information. The new version just says, Eclipse classpath entries would be included.
> 
>>>
>>> And one fall-back-question: In case I would just add all my libraries manually into the install.xml, would I still get the PEAR isolation?
>>
>> I think the answer to that is "yes", but I'm not sure I really
>> understand your question.
>>
> 
> My ultimate goal is to run two components in one pipeline where the two components use incompatible versions of the same library. The ability to do so was called "PEAR isolation" in older versions of the UIMA documentation.

yes, that should work just fine.

> 
> I will try this out now, after I just got the classpath entries managed using the Maven PEAR packaging plugin.
> 
> Thx a lot for your help,
> 
> 	Erik
> 


Re: PEAR Classpath issues

Posted by Erik Fäßler <er...@uni-jena.de>.
Hi Thilo!

Thanks for your answer! Some comments and further questions below:

Am 27.07.2012 um 08:24 schrieb Thilo Goetz:

>> I did intentionally not include my libraries in the classpath here, because the documentation says,
>> "The buildComponentClasspath method of the PackageBrowser class builds a classpath string from what it finds in the CLASSPATH specification here, plus adds a classpath entry for all Jars in the lib directory. Because of this, there is no need to specify Class Path entries for Jars in the lib directory."
> 
> If the documentation still says that, I think it's outdated.  I'm pretty
> sure we changed this defaulty behavior at some point.

*cough* It doesn't. I am very sorry - I must have confused documentation versions while being in the full action of research for information. The new version just says, Eclipse classpath entries would be included.

>> 
>> And one fall-back-question: In case I would just add all my libraries manually into the install.xml, would I still get the PEAR isolation?
> 
> I think the answer to that is "yes", but I'm not sure I really
> understand your question.
> 

My ultimate goal is to run two components in one pipeline where the two components use incompatible versions of the same library. The ability to do so was called "PEAR isolation" in older versions of the UIMA documentation.

I will try this out now, after I just got the classpath entries managed using the Maven PEAR packaging plugin.

Thx a lot for your help,

	Erik


Re: PEAR Classpath issues

Posted by Thilo Goetz <tw...@gmx.de>.
On 26/07/12 18:17, Erik Fäßler wrote:
> Hi all,
> 
> I know this question has been asked a few times in the past years but I didn't really come to a definite answer or a solution to the problem. The issue is to use a PEAR packaged simple AE in a pipeline without setting the classpath manually. On the contrary, my primary goal is to make use of the PEAR isolation feature introduced in UIMA 2.2. 
> 
> I created a very small example. My AE is a simple (non-aggregate) AE without dependencies on any resources. It does only rely on the commons-lang3 library. The process method is this:
> public void process(JCas aJCas) throws AnalysisEngineProcessException {
> 		String[] mow = {"eins", "zwei", "drei"};
> 		System.out.println("wow: " + StringUtils.join(mow, " -- "));
> 	}
> 
> My humble goal is to make a PEAR of this AE, to install it and let it run successfully using the Cas Visual Debugger. I created an AE descriptor and placed it in the "desc" directory. I copied the dependency JARs into the "lib" directory (using the Maven dependency plugin).
> I created the PEAR package manually by using the Eclipse PEAR plugin, not the Maven plugin. I left the automatically created install.xml untouched:
> 
> <?xml version="1.0" encoding="UTF-8"?>
> <COMPONENT_INSTALLATION_DESCRIPTOR>
> 	<OS>
> 		<NAME>Linux</NAME>
> 	</OS>
> 	<TOOLKITS>
> 		<JDK_VERSION>1.6.0</JDK_VERSION>
> 	</TOOLKITS>
> 	<UIMA_FRAMEWORK>
> 	</UIMA_FRAMEWORK>
> 	<SUBMITTED_COMPONENT>
> 		<ID>peartest</ID>
> 		<NAME></NAME>
> 		<DESC>$main_root/desc/aeDescriptor.xml</DESC>
> 		<DEPLOYMENT>standard</DEPLOYMENT>
> 	</SUBMITTED_COMPONENT>
> 	<INSTALLATION>
> 		<PROCESS>
> 			<ACTION>set_env_variable</ACTION>
> 			<PARAMETERS>
> 				<COMMENTS></COMMENTS>
> 				<VAR_VALUE>$main_root/target/classes;</VAR_VALUE>
> 				<VAR_NAME>CLASSPATH</VAR_NAME>
> 			</PARAMETERS>
> 		</PROCESS>
> 	</INSTALLATION>
> </COMPONENT_INSTALLATION_DESCRIPTOR>
> 
> I did intentionally not include my libraries in the classpath here, because the documentation says,
> "The buildComponentClasspath method of the PackageBrowser class builds a classpath string from what it finds in the CLASSPATH specification here, plus adds a classpath entry for all Jars in the lib directory. Because of this, there is no need to specify Class Path entries for Jars in the lib directory."

If the documentation still says that, I think it's outdated.  I'm pretty
sure we changed this defaulty behavior at some point.

> 
> I created the PEAR package and then used the runPearPackage.sh script to install it, which went fine. Then I hit the button to test the AE with CVD and got this exception:
> 26.07.12 18:00:13 - 10: org.apache.uima.tools.cvd.MainFrame.handleException(529): SCHWERWIEGEND: org/apache/commons/lang/StringUtils
> java.lang.NoClassDefFoundError: org/apache/commons/lang/StringUtils
> 	at de.julielab.peartest.PearTestAE.process(PearTestAE.java:38)
> 	at org.apache.uima.analysis_component.JCasAnnotator_ImplBase.process(JCasAnnotator_ImplBase.java:48)
> 	at org.apache.uima.analysis_engine.impl.PrimitiveAnalysisEngine_impl.callAnalysisComponentProcess(PrimitiveAnalysisEngine_impl.java:377)
> 	at org.apache.uima.analysis_engine.impl.PrimitiveAnalysisEngine_impl.processAndOutputNewCASes(PrimitiveAnalysisEngine_impl.java:295)
> 	at org.apache.uima.analysis_engine.impl.PearAnalysisEngineWrapper.processAndOutputNewCASes(PearAnalysisEngineWrapper.java:339)
> 	at org.apache.uima.analysis_engine.impl.AnalysisEngineImplBase.process(AnalysisEngineImplBase.java:267)
> 	at org.apache.uima.tools.cvd.MainFrame.internalRunAE(MainFrame.java:1506)
> 	at org.apache.uima.tools.cvd.MainFrame.runAE(MainFrame.java:430)
> 	at org.apache.uima.tools.pear.install.InstallPear$2.run(InstallPear.java:448)
> 	at java.lang.Thread.run(Thread.java:680)
> Caused by: java.lang.ClassNotFoundException: org.apache.commons.lang.StringUtils
> 	at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
> 	at java.security.AccessController.doPrivileged(Native Method)
> 	at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
> 	at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
> 	at org.apache.uima.internal.util.UIMAClassLoader.loadClass(UIMAClassLoader.java:151)
> 	at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
> 	... 10 more
> 
> When I - for a test - add the path for the used library manually to the install.xml (which then reads: "$main_root/lib/commons-lang-2.4.jar;"), the CVD runs smoothly without exception. I.e. the library is there and working.

Good, then everything is as expected.

> 
> Have I done something completely wrong? Shouldn't the CVD - and later then, the runCPE.sh script - automatically add the libraries in the lib/ directory of a PEAR automatically to create an isolated PEAR runtime?
> 
> And one fall-back-question: In case I would just add all my libraries manually into the install.xml, would I still get the PEAR isolation?

I think the answer to that is "yes", but I'm not sure I really
understand your question.

--Thilo

> 
> Thanks for your time,
> 
> 	Erik
>