0

Groovy ships various third party libraries. The servlet-api (v2.4) is an example for groovy (v 2.0.1):

groovy:000> javax.servlet.http.HttpServlet.protectionDomain.codeSource
===> (file:/usr/lib/groovy/2.0.1/lib/servlet-api-2.4.jar <no signer certificates>)
groovy:000> 

Assuming I want a more recent version: What is the suggested approach to accomplish that?

Cœur
  • 37,241
  • 25
  • 195
  • 267
Andreas Steffan
  • 6,039
  • 2
  • 23
  • 25

2 Answers2

1

I just ran into this problem when I was using a Groovy script to run an embedded instance of Jetty 9.1.x. After a lot of class loading contortions the only thing that worked was to specify the JAR on the command line using -cp option:

groovysh -cp javax.servlet-api-3.1.0.jar

This places the URL of the JAR in front of the included servlet-api so that it's checked first. Doesn't seem like there's another way around it for now:

groovy:000> javax.servlet.http.HttpServlet.protectionDomain.codeSource
===> (file:/<current directory>/javax.servlet-api-3.1.0.jar <no signer certificates>)
Phuong LeCong
  • 1,834
  • 16
  • 19
0

I removed the old from groovy/lib/ and added the one i wanted in /home/will/.groovy/lib/ I think you could also add directly to the original lib dir

Will
  • 14,348
  • 1
  • 42
  • 44
  • I have to say I hate the answer. :) Unfortunately there seems to be no straight forward programmatical solution to get this kind of jar "out of the way". – Andreas Steffan Sep 18 '12 at 05:00
  • Hahaha! Aw! It probably has a better way around, i don't know a lot about groovy classpath's. You could try printing it's classpath to see if you can get something: `println System.properties` – Will Sep 18 '12 at 10:12
  • Been there, done that. Did neither find a way to remove resources from the classloader, nor did I find a "ready-to-use" classloader looking locally first (to avoid resources being resolved by the parent cl). – Andreas Steffan Sep 18 '12 at 14:13