java.lang.NoClassDefFoundError for org/apache/http/config/Lookup

#1

I’m trying to do some test code to work with the Exchange Web Service so we can ditch cfexchange and migrate from ACF to Lucee. I’ve installed ews-java-api-2.0.jar in Lucee (and restarted). I can instantiate the service fine:
<cfobject type="Java" class="microsoft.exchange.webservices.data.core.ExchangeService" name="service">

When I call service.init() It fails with the error:
Lucee 5.2.8.50-RC Error (java.lang.NoClassDefFoundError)
Message org/apache/http/config/Lookup

Which makes me think it is a dependency error. When I add
httpclient-4.4.1.jar and httpcore-4.4.1.jar and restart Lucee, I still get the error (Plus, I’m pretty sure Lucee already has these built in). Just to be thorough, I added all the dependencies listed here and all THEIR dependencies: https://mvnrepository.com/artifact/com.microsoft.ews-java-api/ews-java-api/2.0. Still get the same error. I’m not sure what else to try.

I’m running version Lucee 5.2.8.50-RC on Windows Server 2012 and I am using IIS 8.5.

#2

Could it be that the ews-java-api.jar was compiled with Java 6 and Lucee is using Java 8? If so what would be a good path foward to resolve the issue or what other alternatives are there for making calls to a web service like EWS from java/Lucee?

#3

not sure what you mean with “installed”, but assuming you did simply copy the jar to the lib folder.
If that is the case forget “Plus, I’m pretty sure Lucee already has these built in”, Lucee loads the jars as OSGi bundles, that means only the lucee core itself sees this jars and not a class that is loaded in a classic way.
That gives you the option to add the jars in any version you likes, but you need to add the jars you need.
In many cases an exception like this is a cascade, so the stacktrace shows “caused by …”, please post the complete stacktrace.

And yes you can of course also load the jars as OSGi bundles.

1 Like
#4

as a sidenote, the lucee core does not use this jars, only the Lucene extension does, so in other words only jars loaded by this extension to see that jars

#5

Pretty cool that that is the way it works. I may be a little out of my depth. OSGi looks interesting. I added all the dependencies back, ran it again. Slightly different error for org/apache/http/conn/HttpClientConnectionManager.

stacktrace.txt (4.9 KB)

#6

intressting, i will try to reproduce asap, can you link the jars you are using? best as a jars.zip

#7

I had to break it up. Java.zip are the dependencies. In desperation I also added those files dependencies (Java2.zip), unsure if that is necessary.
java.zip (1.8 MB)
java2.zip (1.8 MB)

#8

I think I am making progress. Previously I dumped the jars in lucee\tomcat\webapps\ROOT\WEB-INF\lucee\lib. Now I have made a separate folder, added an application.cfc and I am specifying a load path:
<cfset this.javasettings={LoadPaths = ["D:/ewsjars"], loadCFMLClassPath = true}>

I can now call service.init() and cfdump the service to inspect it. I’ve got new unrelated errors to deal with, but I am on my way!

I’m not clear how this is different than putting them in the lib folder. You’ve set me on the path on trying to figure out how to make this into an OSGi bundle when I get it working.

#9

FYI the http libs already exists as OSGi libs

https://search.maven.org/#search|gav|1|g%3A"org.lucee"%20AND%20a%3A"httpcomponents-httpclient"

https://search.maven.org/#search|gav|1|g%3A"org.lucee"%20AND%20a%3A"httpcomponents-httpmime"

https://search.maven.org/#search|gav|1|g%3A"org.lucee"%20AND%20a%3A"httpcomponents-httpcore"

#10

also for sure joda, commons-codec, log4j exist as OSGi libs

#11

I’ve just got some learning to do. The EWS jar is also in the maven repository:
https://search.maven.org/#artifactdetails|com.microsoft.ews-java-api|ews-java-api|2.0|jar

But I guess it is just a jar, not a bundle, based on the information here:

By looking at the manifest for the links you posted I can tell they are OSGi bundles. Without looking at the manifest file it does not seem obvious that they are bundles.

#12

parts are OSGI, parts are not. i have an application that creates a maven project that can convert a regular jar hosted on maven to a OSGi jar, then also hosted on maven.

#13

here an example of a generated project

#14

NIfty. I may pursue a similar approach. Thanks for all the help!

#15

I was able to create a bundle in Eclipse (MARS) using some examples I found and I have everything working in Lucee.

  • File > New > Project-> Plug-in from existing JARs.
  • Project name: OSGI_EWS
  • Under ‘jars to include in this plugin’ I added all the jars using add external button
  • Target OSGI framework->Standard
  • Finish
  • On the runtime tab for manifest.mf I only export the microsoft.exchange packages
  • File Export->Plugin development->Deployable plugins and fragments, choose destination
  • grabbed jar file from plugins subfolder
  • Put in lucee\tomcat\lucee-server\bundles
  • restarted lucee
  • It shows in lucee admin in info->Bundle (jar) as not loaded

I’m able to create the service using:
service=createobject(“java”,“microsoft.exchange.webservices.data.core.ExchangeService”,“OSGI_EWS”,“1.0.0”);

I’m not certain adding ALL the jars in the plugin was the right way to go about it, but I couldn’t get it to work otherwise.

1 Like
#16

We have Lucee 4.5.5 using the EWS API – on Lucee 5 however, I’m running into similar issues described above. The jars are loaded - its just some of the microsoft.exchange.webservices.data classes seem unavailable?

I’ve tried to bundle as a plugin - but as of yet to no avail. Seems odd that we’d need to do this though.

Did anyone discover more about this per chance?

#17

i always use https://mvnrepository.com/ see all the dependencies, have in mind that the jars bundled also can have dependencies, so you need to follow down the rabbit hole.
In addition all classes you are using need to be imported in the manifest or at least have a “require-bundle”
https://github.com/lucee/extension-hibernate/blob/master/source/java/src/META-INF/MANIFEST.MF#L4

a bundle only see bundles it imports statically or dynamically