Guice Burned By GoDaddy

I've been working on a little app to display optimized train schedule information online in Java. I'm writing it more to play with new libraries, etc. than because I really want the functionality, but that's irrelevant to the story...

As I mentioned in my previous post 'Juiced about Guice', I wanted to play with Guice and see how it worked 'in the real world'. So, I used it to help configure my application.

I deployed it on GoDaddy and hoped it would 'just work'. Unfortunately it was not to be. After a long debugging cycle (see footnote), I finally tracked it down to this error:

java.security.AccessControlException: access denied (java.lang.RuntimePermission accessDeclaredMembers)
java.security.AccessControlCont
ext.checkPermission(AccessControlContext.java:264)
java.security.AccessController
.checkPermission(AccessController.java:427)
java.lang.SecurityManager
.checkPermission(SecurityManager.java:532)
java.lang.SecurityManager
.checkMemberAccess(SecurityManager.java:1662)
java.lang.Class.checkMemberAcce
ss(Class.java:2125)
java.lang.Class.getDeclaredMeth
ods(Class.java:1762)
sun.reflect.annotation.Annotati
onType.(AnnotationType.java:81)
sun.reflect.annotation.Annotati
onType.getInstance(AnnotationType.java:64)
sun.reflect.annotation.Annotati
onParser.parseAnnotation(AnnotationParser.java:202)
sun.reflect.annotation.Annotati
onParser.parseAnnotations2(AnnotationParser.java:69)
sun.reflect.annotation.Annotati
onParser.parseAnnotations(AnnotationParser.java:52)
java.lang.Class.initAnnotations
IfNecessary(Class.java:3031)
java.lang.Class.getAnnotation(Class.java:2989)
java.lang.Class.isAnnotationPre
sent(Class.java:3001)
com.google.inject.Scopes
.isScopeAnnotation(Scopes.java:106)
com.google.inject.BinderImpl
.bindScope(BinderImpl.java:150)
com.google.inject.BinderImpl.(BinderImpl.java:111)
com.google.inject.Guice
.createInjector(Guice.java:75)
com.google.inject.Guice
.createInjector(Guice.java:53)
com.google.inject.Guice
.createInjector(Guice.java:43)
org.apache.jsp.test_jsp.
_jspService(test_jsp.java:62)

Apparently, GoDaddy doesn't allow reflection. This pretty much disqualifies Guice from working. So, it looks like I'll have to rewrite it without Guice.

I just recently consolidated all my hosting on GoDaddy from my own managed box because I didn't want the hassle. GoDaddy supports Rails and Java, so I figured I was covered for all eventualities.

However, now that my Rails fascination is waning, maybe I should look for a better pure Java hosting environment. Suggestions welcome. :)

Footnote:
GoDaddy only allows you to reload/restart your web application nightly when they do a global restart of Tomcat. So, each debugging cycle takes 24 hours (or more since I don't bother with it every day). You can get SOME stuff done by throwing up new JSP files intra day, but this cycle can be VERY frustrating and is totally unacceptable for any 'real' application needs.

3 comments:

  1. I'll bet reflection works, but accessing non-public members does not. Maybe we'll support a "safe mode" in the future.

    ReplyDelete
  2. I came up with a quick test jsp:

    <%
    Class clazz = Class.forName("com.ericdaugherty.trainschedule.ajax.TrainData");

    Method[] methods = clazz.getDeclaredMethods();
    for( Method method : methods )
    {
    %>
    <%= method.getName()%><br/>
    <%
    }
    %>


    This still throws the same exception:


    java.security.AccessControlException: access denied (java.lang.RuntimePermission accessDeclaredMembers)
    java.security.AccessControlContext.checkPermission(AccessControlContext.java:264)
    java.security.AccessController.checkPermission(AccessController.java:427)
    java.lang.SecurityManager.checkPermission(SecurityManager.java:532)
    java.lang.SecurityManager.checkMemberAccess(SecurityManager.java:1662)
    java.lang.Class.checkMemberAccess(Class.java:2125)
    java.lang.Class.getDeclaredMethods(Class.java:1762)
    org.apache.jsp.test_jsp._jspService(test_jsp.java:51)


    So I'm pretty sure it is just a blanket restriction on ALL reflection unless I'm missing something...

    ReplyDelete
  3. Ok, so now I find out that the XML library (simple.xml) I was going to use also uses reflection and is blocked by the security manager.

    I give up writing stuff to run on GoDaddy.

    ReplyDelete