Overriding libraries shipped with groovy in groovsh?
-
30-06-2021 - |
Вопрос
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?
Решение
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>)
Другие советы
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