Google App Engine compatibility

68 views
Skip to first unread message

Pierre Lavignotte

unread,
Nov 22, 2009, 3:57:09 PM11/22/09
to Induction Framework
Hi,

I've spent a few hours reading the documentation and playing with a
sample app.
I have some questions and remarks :

1. I've found that Induction is not compatible with GAE.
At application startup, it raises the following exception :
Caused by: java.lang.SecurityException: Google Apphosting only
supports custom ClassLoaders that derive from ClassLoader or
URLClassLoader, not SecureClassLoader.
at com.google.appengine.runtime.Request.process-8c1ecd7c458b31b7
(Request.java)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
at com.acciente.induction.dispatcher.HttpDispatcher.init
(HttpDispatcher.java:124)
at org.mortbay.jetty.servlet.ServletHolder.initServlet
(ServletHolder.java:433)

Is the classloader configurable ?


2. I've wrote the following interceptor :

public class AuthentInterceptor implements RequestInterceptor {

public Redirect postResolution(ControllerResolver.Resolution
resolution) {

System.out.println("AuthentInterceptor.postResolution()");
System.out.println("ClassName = " + resolution.getClassName());
System.out.println("MethodName = " + resolution.getMethodName());

return null;
}
}
When I call an URL that is matched by a Controller, it runs ok.
But I call an URL (or redirect to) an URL that is matched by a View, I
get the following error :

22 nov. 2009 21:45:36 com.acciente.induction.dispatcher.HttpDispatcher
logAndRespond
GRAVE: dispatch-error: interceptor-exec-request-interceptor-parameter-
provider: error resolving value for type: class
com.acciente.induction.resolver.ControllerResolver$Resolution
com.acciente.commons.reflect.ParameterProviderException: request-
interceptor-parameter-provider: error resolving value for type: class
com.acciente.induction.resolver.ControllerResolver$Resolution
at
com.acciente.induction.dispatcher.interceptor.RequestInterceptorParameterProviderFactory
$RequestInterceptorParameterProvider.getParameter
(RequestInterceptorParameterProviderFactory.java:147)

Did I make something wrong ?
Is there a way to make an interceptor match a URL pattern ?

3. To make the demoapp sample to work, I had to modify the induction-
demoapp.xml file and add "/demoapp" in the url-format patterns of the
redirect mapping :

<redirect-mapping>
<class-to-url-map>
<class-packages>demoapp</class-packages>
<class-pattern>(?:.*\.)?(\w+)Controller</class-pattern>
<url-format>/demoapp/$Name.action</url-format>
<url-format-alt>/demoapp/$Name.$Method.action</url-format-
alt>
</class-to-url-map>
<class-to-url-map>
<class-packages>demoapp</class-packages>
<class-pattern>(?:.*\.)?(\w+)View</class-pattern>
<url-format>/demoapp/$Name</url-format>
</class-to-url-map>
</redirect-mapping>

Without that, redirect where not hitting the app.
Why this behaviour ? If I want to change my web app context, I'll have
to update the conf (ok, that's only 2 lines).

4. Why no writing a XSD for the induction-xxx.xml file and get IDE
auto-completion ?


Thank you for the job done!
Pierre

Adinath

unread,
Nov 23, 2009, 1:35:00 AM11/23/09
to induction...@googlegroups.com
On Sun, Nov 22, 2009 at 1:57 PM, Pierre Lavignotte <pierre.l...@gmail.com> wrote:
Hi,

I've spent a few hours reading the documentation and playing with a
sample app.
I have some questions and remarks :

1. I've found that Induction is not compatible with GAE.
At application startup, it raises the following exception :
Caused by: java.lang.SecurityException: Google Apphosting only
supports custom ClassLoaders that derive from ClassLoader or
URLClassLoader, not SecureClassLoader.
       at com.google.appengine.runtime.Request.process-8c1ecd7c458b31b7
(Request.java)
       at java.lang.ClassLoader.loadClass(Unknown Source)
       at java.lang.ClassLoader.loadClassInternal(Unknown Source)
       at com.acciente.induction.dispatcher.HttpDispatcher.init
(HttpDispatcher.java:124)
       at org.mortbay.jetty.servlet.ServletHolder.initServlet
(ServletHolder.java:433)

Ouch!! This is good to know..hmmm
 
Is the classloader configurable ?

Well...here is the deal. When you deploy to GAE if you are putting everything in a .war file, then in the Induction config you can ommit the <java-class-path> and Induction will use the classloader of the GAE servlet engine.

That said I could Induction classloader could easily have extended ClassLoader instead of SecureClassLoader, in fact I think it would be nice if I let you choose it that would not be difficult as I think about. OK I will do it after the current 2 features I am working on.


2. I've wrote the following interceptor :

public class AuthentInterceptor implements RequestInterceptor {

       public Redirect postResolution(ControllerResolver.Resolution
resolution) {

               System.out.println("AuthentInterceptor.postResolution()");
               System.out.println("ClassName = " + resolution.getClassName());
               System.out.println("MethodName = " + resolution.getMethodName());

               return null;
       }
}
When I call an URL that is matched by a Controller, it runs ok.
But I call an URL (or redirect to) an URL that is matched by a View, I
get the following error :

22 nov. 2009 21:45:36 com.acciente.induction.dispatcher.HttpDispatcher
logAndRespond
GRAVE: dispatch-error: interceptor-exec-request-interceptor-parameter-
provider: error resolving value for type: class
com.acciente.induction.resolver.ControllerResolver$Resolution
com.acciente.commons.reflect.ParameterProviderException: request-
interceptor-parameter-provider: error resolving value for type: class
com.acciente.induction.resolver.ControllerResolver$Resolution
       at
com.acciente.induction.dispatcher.interceptor.RequestInterceptorParameterProviderFactory
$RequestInterceptorParameterProvider.getParameter
(RequestInterceptorParameterProviderFactory.java:147)

Did I make something wrong ?

You interceptor is correct..you are hitting an bug that I fixed in rev 219...I have to investigate why it did not make it into v1.3.0b. I am going to upload a new 1.3.1b distribution in the next few hours.

Is there a way to make an interceptor match a URL pattern ?

No, but you can check the classname of the controller resolution.
 

3. To make the demoapp sample to work, I had to modify the induction-
demoapp.xml file and add "/demoapp" in the url-format patterns of the
redirect mapping :

   <redirect-mapping>
       <class-to-url-map>
           <class-packages>demoapp</class-packages>
           <class-pattern>(?:.*\.)?(\w+)Controller</class-pattern>
           <url-format>/demoapp/$Name.action</url-format>
           <url-format-alt>/demoapp/$Name.$Method.action</url-format-
alt>
       </class-to-url-map>
       <class-to-url-map>
           <class-packages>demoapp</class-packages>
           <class-pattern>(?:.*\.)?(\w+)View</class-pattern>
           <url-format>/demoapp/$Name</url-format>
       </class-to-url-map>
   </redirect-mapping>

Without that, redirect where not hitting the app.
Why this behaviour ?

Sorry, in my config with IntelliJ IDEA the /demoapp is passed is not visible from inside the servlet container. The change you made for your environment is correct.
 
If I want to change my web app context, I'll have
to update the conf (ok, that's only 2 lines).

4. Why no writing a XSD for the induction-xxx.xml file and get IDE
auto-completion ?

Good point..its on my todo list now if only I had more time..

Overall I am quite impressed with how familiar you have become with framework in such a short time.

Thank you for the job done!

Appreciated.

Regards,
Adi

--
Acciente, LLC
Systems Architecture and Software Design

www.acciente.com
www.inductionframework.org

Adi

unread,
Nov 23, 2009, 2:23:44 AM11/23/09
to Induction Framework
Pierre,

You should see v1.3.1b available for download at
http://www.inductionframework.org/downloads.html

Adi

Pierre Lavignotte

unread,
Nov 23, 2009, 2:46:13 AM11/23/09
to induction...@googlegroups.com
Thank you for the update, I'll give it a try.

About the redirect mapping, I've found that I just had the remove the "/" :

<redirect-mapping>
       <class-to-url-map>
           <class-packages>demoapp</class-packages>
           <class-pattern>(?:.*\.)?(\w+)Controller</class-pattern>
           <url-format>$Name.action</url-format>
           <url-format-alt>$Name.$Method.action</url-format-alt>
 ...


>> Overall I am quite impressed with how familiar you have become with framework in such a short time.
Thank you, but as I said in my other message, that's because it's clear, simple, and full Java.




Cordialement,
Pierre Lavignotte
Ingénieur Conception & Développement
http://pierre.lavignotte.googlepages.com



--

You received this message because you are subscribed to the Google Groups "Induction Framework" group.
To post to this group, send email to induction...@googlegroups.com.
To unsubscribe from this group, send email to induction-frame...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/induction-framework?hl=.



Adinath

unread,
Nov 23, 2009, 11:54:30 AM11/23/09
to induction...@googlegroups.com
On Mon, Nov 23, 2009 at 12:46 AM, Pierre Lavignotte <pierre.l...@gmail.com> wrote:
Thank you for the update, I'll give it a try.

About the redirect mapping, I've found that I just had the remove the "/" :

<redirect-mapping>
       <class-to-url-map>
           <class-packages>demoapp</class-packages>
           <class-pattern>(?:.*\.)?(\w+)Controller</class-pattern>
           <url-format>$Name.action</url-format>
           <url-format-alt>$Name.$Method.action</url-format-alt>
 ...

Just FYI, if you need Induction to put your domain name in the redirect you can use the directive:

<url-base>an_optional_base_url_for_redirects</url-base>

It is a child of of <redirect-mapping>

If specified the "base url" is prepended to every redirect after applying the ur-format/url-format-alt directive.

Adi

Pierre Lavignotte

unread,
Nov 23, 2009, 5:20:43 PM11/23/09
to induction...@googlegroups.com
The 1.3.1 version fixed the Interceptor issue, thank you.

Another (last ?) question :
Say a view have to display a list of :
<A href="myView?id=X>link X</A>

How do I generate the URL that points to the class MyView in Java ?

Thanks,
Pierre




Cordialement,
Pierre Lavignotte
Ingénieur Conception & Développement
http://pierre.lavignotte.googlepages.com


--

Adinath

unread,
Nov 23, 2009, 10:42:18 PM11/23/09
to induction...@googlegroups.com
Pierre,

On Mon, Nov 23, 2009 at 3:20 PM, Pierre Lavignotte <pierre.l...@gmail.com> wrote:
The 1.3.1 version fixed the Interceptor issue, thank you.

Another (last ?) question :
Say a view have to display a list of :
<A href="myView?id=X>link X</A>

How do I generate the URL that points to the class MyView in Java ?

Are you looking for a feature in Induction that would return a URL given a view class name?

If so that is a great question..and is something I recently realized is missing..and would be very useful. Currently there is not a way to do this but the internals already exist to accomplish this..another feature request?

Adi

Pierre Lavignotte

unread,
Nov 24, 2009, 2:19:29 AM11/24/09
to induction...@googlegroups.com
Adi,

Sure it's really missing since your framework tends to avoid the use of strings.

Maybe a URL Resoler could be included in the params available from a View, Controller or Interceptor ?


Pierre


Cordialement,
Pierre Lavignotte
Ingénieur Conception & Développement
http://pierre.lavignotte.googlepages.com


--

You received this message because you are subscribed to the Google Groups "Induction Framework" group.
To post to this group, send email to induction...@googlegroups.com.
To unsubscribe from this group, send email to induction-frame...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/induction-framework?hl=en.

Adinath

unread,
Nov 24, 2009, 3:20:50 AM11/24/09
to induction...@googlegroups.com

Pierre,

On Tue, Nov 24, 2009 at 12:19 AM, Pierre Lavignotte <pierre.l...@gmail.com> wrote:
Adi,

Sure it's really missing since your framework tends to avoid the use of strings.

Yes, I agree.
 
Maybe a URL Resoler could be included in the params available from a View, Controller or Interceptor ?

Yes, something along that line is what I had in mind, it will basically use same the redirect rules that the redirect resolver uses. I have added it to the list of features to complete by the end of this month.

Thanks for all your useful feedback.

Regards,
Adi

Adinath

unread,
Feb 23, 2010, 6:15:42 PM2/23/10
to induction...@googlegroups.com
Pierre,

I have not forgotten the URL Resolver feature request you made last Nov. It's a very important feature, I just got side tracked, it's next on my list.

Regards,
Adi

Pierre Lavignotte

unread,
Jan 19, 2012, 6:11:53 PM1/19/12
to induction...@googlegroups.com
Hi there,

Two years later....... I just gave a try at using the URLResolver to generate string URLs from Java code.
Here's what I tried :

public class DataController implements Controller {

public void page1(Response response, URLResolver resolver) throws IOException {
response.setContentType( "text/plain" );
   response.out().println( "Hello World, using a simple println()<br/>"
    + "<a href="
    + resolver.resolve(DataController.class, "page2")
    + ">Switch !</a>");
}
public void page2(Response response, URLResolver resolver) throws IOException {
response.setContentType( "text/plain" );
   response.out().println( "Hello World, using a simple println()<br/>"
    + "<a href="
    + resolver.resolve(DataController.class, "page1")
    + ">Switch !</a>");
}
}

So page1 should display an hyperlink to page2 and so the other way.
Unfortunatly, I get a NullPointerException.

Something to configure ?
I'm still on version 1.5.1b.

Thank you,
Pierre

GRAVE: | Context: dispatch-controller-request > during controller execution| Message: null | Cause: class java.lang.NullPointerException
java.lang.NullPointerException
at com.acciente.induction.dispatcher.resolver.RedirectResolverExecutor.resolveRedirect(RedirectResolverExecutor.java:82)
at com.acciente.induction.dispatcher.resolver.URLResolver.resolve(URLResolver.java:80)
at com.data.controllers.DataController.page1(DataController.java:18)

Adinath Raveendra Raj

unread,
Jan 20, 2012, 12:43:17 PM1/20/12
to induction...@googlegroups.com
Hi Pierre,

It's great to hear from you. Sorry I did not get to this yesterday.

So the good news is that the URL resolver functionality is something we use very heavily, but we typically use it in the views; so my first hunch was maybe I forgot to support it in controllers, so I tested with the demo app this morning and it is supported very nicely in controllers too. So I looked at the code where you get the NullPtrEx in RedirectResolverExecutor.java:82 and I noticed it looks like this:
 
      if ( ! ( oReturnValue instanceof String ) )
      {
         throw new IllegalArgumentException( "Redirect resolver: resolveRequest(...) did not return a string, returned type was: "
                                             + oReturnValue.getClass() );
      }

Where the oReturnValue is from the active redirect resolver. Of course the way that code is wrritten if the return value is null you will get a NullPtrEx, instead of the IllegalArgumentException. So it seems like somehow your redirect resolver is returning null. So I am assuming that you are using the built-in ShortURL resolvers, so I look at the ShortURLRedirectResolver to see why it would return null.

One reason the ShortURLRedirectResolver resolver returns null is if it cannot resolve the redirect, and one reason for this would be missing the redirect mappings config section in the induction config.xml

Here is what a the redirect mapping section in the induction config.xml in the demoapp looks like:

<config>

    .... other stuff you have .....


    <redirect-mapping>
        <class-to-url-map>
            <class-packages>demoapp</class-packages>
            <class-pattern>(?:.*\.)?(\w+)Controller</class-pattern>
            <url-format>/$Name.action</url-format>
            <url-format-alt>/$Name.$Method.action</url-format-alt>
        </class-to-url-map>
        <class-to-url-map>
            <class-packages>demoapp</class-packages>
            <class-pattern>(?:.*\.)?(\w+)View</class-pattern>
            <url-format>/$Name</url-format>
        </class-to-url-map>

        <url-base>http://localhost:8080</url-base>
    </redirect-mapping>

    .... other stuff you have .....

</config>

In the above, $Name resolves the "short name" of the class, the short name of the class is whatever is returned by the first match group when the <class-pattern> regex is applied to a class name. For example, for <class-pattern>(?:.*\.)?(\w+)Controller</class-pattern> (from the snippet above) the only matching group in the regex is (\w+), so if your class name is com.data.controllers.DataController then the shortname would be Data. Induction also lower cases short names (since they are hashed) so it would actually be data.

$Method is whatever you passed for the method name when you called the URLResolver's resolve() method.

Basically they work in kinda reverse of the controller and view mappings. If you are wondering why Induction does not try to automatically reverse the controller/view mapping...on reason is because this gives you more complete control over the redirects.

Please let me know if this helps.

Thanks,
Adi
Adinath Raveendra Raj
President/CEO

Acciente, LLC
Systems Architecture and Software Design

www.acciente.com
www.inductionframework.org

480.626.0248 (office)
480.250.0170 (mobile)

Adinath Raveendra Raj

unread,
Jan 20, 2012, 12:51:55 PM1/20/12
to induction...@googlegroups.com
Pierre,

In case you do have redirect mappings defined, you would currently get that NullPtr if you resolve request does match any of the rules you specified.

Adi

Pierre Lavignotte

unread,
Jan 20, 2012, 5:56:08 PM1/20/12
to induction...@googlegroups.com
Adi,

My bad, I was missing the <redirect-mapping> section in the xml config file...

It's working perfectly now.

Thank you,
Pierre

Adinath Raveendra Raj

unread,
Jan 20, 2012, 7:57:18 PM1/20/12
to induction...@googlegroups.com
Great to hear! Thanks for the update.

Adi
Reply all
Reply to author
Forward
0 new messages