Я закончил на этой странице, удивляясь тому же. Вот что я делаю (что мне не нравится, но, кажется, работает отлично):
HttpContext context = HttpContext.Current;
if (context == null)
{
HttpRequest request = new HttpRequest(string.Empty, "http://tempuri.org", string.Empty);
HttpResponse response = new HttpResponse(new StreamWriter(new MemoryStream()));
context = new HttpContext(request, response);
HttpContext.Current = context;
}
this.cache = context.Cache;
First of all, package is a reserved keyword, so you can't use it as a a package name.
Second of all, you can't do that in Groovy, since the dot notation is used for classes, not for scripts, so you need a compiled class file to use it.
Still, you can replace the groovy command with java + classpath:
java -cp /usr/share/java/groovy/embeddable/groovy-all-1.6.3.jar:. my.some.MyClass
You can add an alias to it 'g_java' for instance to make it less verbose.