Spring Social
  1. Spring Social
  2. SOCIAL-73

Spring Social should be usable on Google AppEngine

    Details

    • Type: Improvement Improvement
    • Status: Open
    • Priority: Minor Minor
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None

      Description

      As the developer of a social application, I want Spring Social to avoid using classes or libraries that are not on Google AppEngine's whitelist, so that I can deploy my social application in Google AppEngine.

      1. AppEngineConnectionRepository.java
        14 kB
        Geoff Chandler
      2. AppEngineUsersConnectionRepository.java
        3 kB
        Geoff Chandler
      3. AppEngineUsersConnectionRepositoryTest.java
        24 kB
        Geoff Chandler

        Activity

        Hide
        Craig Walls added a comment -

        A specific problem to address with regard to GAE-friendliness is to deal with the use of CommonsClientHttpRequestFactory, as the Commons implementation violates GAE's thread rules.

        Show
        Craig Walls added a comment - A specific problem to address with regard to GAE-friendliness is to deal with the use of CommonsClientHttpRequestFactory, as the Commons implementation violates GAE's thread rules.
        Hide
        Kieran Simpson added a comment -

        For some of the work I've been doing integrating with FB I've been able to substitute the CommonsClientHttpRequestFactory with a SimpleClientHttpRequestFactory as the response codes aren't 302 (most of them are 200). This works on GAE.

        Show
        Kieran Simpson added a comment - For some of the work I've been doing integrating with FB I've been able to substitute the CommonsClientHttpRequestFactory with a SimpleClientHttpRequestFactory as the response codes aren't 302 (most of them are 200). This works on GAE.
        Hide
        Dragan Vidovic added a comment -

        @Kieran Simpson, could you explain what you did in little more details?

        Show
        Dragan Vidovic added a comment - @Kieran Simpson, could you explain what you did in little more details?
        Hide
        Craig Walls added a comment -

        FWIW, I've had success deploying the Spring Social Showcase sample on GAE and it worked with minimal change. (If I recall, I only needed to add an appropriate appengine-web.xml to the project.)

        But one reason it worked so well is that the showcase uses an embedded in-memory H2 database. This means that Spring Social never had to deal with persisting to GAE's bigtable, but it also meant that any data stored in the DB would not survive an app restart.

        To do this right, we'd need an implementation of UsersConnectionRepository that could persist connections to bigtable. Some have suggested that a JPA-based implementation would be appropriate for this job. While I believe it could be done that way, I also think it might be simpler to have an implementation that natively persists to bigtable.

        In either event, the persistence of connections is the one major outstanding issue in making this work in GAE.

        Show
        Craig Walls added a comment - FWIW, I've had success deploying the Spring Social Showcase sample on GAE and it worked with minimal change. (If I recall, I only needed to add an appropriate appengine-web.xml to the project.) But one reason it worked so well is that the showcase uses an embedded in-memory H2 database. This means that Spring Social never had to deal with persisting to GAE's bigtable, but it also meant that any data stored in the DB would not survive an app restart. To do this right, we'd need an implementation of UsersConnectionRepository that could persist connections to bigtable. Some have suggested that a JPA-based implementation would be appropriate for this job. While I believe it could be done that way, I also think it might be simpler to have an implementation that natively persists to bigtable. In either event, the persistence of connections is the one major outstanding issue in making this work in GAE.
        Hide
        Kieran Simpson added a comment -

        @Dragan Vidovic

        Please note that these changes were against 1.0.0.M1, and may not be applicable depending on what version you're using.

        I created a class called FacebookTemplateExtentions which extends FacebookTemplate and supplements the constructor with additional logic. Since the restOperations (of type RestTemplate) attribute is private to the parent class, I used reflection to get access. A nasty hack to be sure! From there it was a matter of changing the ClientHttpRequestFactory so that GAE wouldn't throw a fit.

        restTemplate.setRequestFactory(new SimpleClientHttpRequestFactory());
        

        Hope that helps.

        Show
        Kieran Simpson added a comment - @Dragan Vidovic Please note that these changes were against 1.0.0.M1, and may not be applicable depending on what version you're using. I created a class called FacebookTemplateExtentions which extends FacebookTemplate and supplements the constructor with additional logic. Since the restOperations (of type RestTemplate ) attribute is private to the parent class, I used reflection to get access. A nasty hack to be sure! From there it was a matter of changing the ClientHttpRequestFactory so that GAE wouldn't throw a fit. restTemplate.setRequestFactory( new SimpleClientHttpRequestFactory()); Hope that helps.
        Hide
        Dragan Vidovic added a comment -

        @Craig Walls My problem is that i get these exceptions:
        java.lang.NoClassDefFoundError: Could not initialize class org.apache.http.conn.ssl.SSLSocketFactory
        java.lang.NoClassDefFoundError: javax.net.ssl.HttpsURLConnection is a restricted class. Please see the Google App Engine developer's guide for more details.
        If I understood correctly it is because they are trying to make a socket connection witch is forbidden by GAE.
        @Kieran Simpson Thanks. I'll check it out, I need to see if I can use reflection.

        Show
        Dragan Vidovic added a comment - @Craig Walls My problem is that i get these exceptions: java.lang.NoClassDefFoundError: Could not initialize class org.apache.http.conn.ssl.SSLSocketFactory java.lang.NoClassDefFoundError: javax.net.ssl.HttpsURLConnection is a restricted class. Please see the Google App Engine developer's guide for more details. If I understood correctly it is because they are trying to make a socket connection witch is forbidden by GAE. @Kieran Simpson Thanks. I'll check it out, I need to see if I can use reflection.
        Hide
        Geoff Chandler added a comment -

        I think the best approach here is to create an adapter that uses the google URLFetchService instead of an http client.

        I was able to make a BigTable implementation UsersConnectionRepository in a couple hours and would be happy to share it with anyone that wants it. It is easy to wire into the regular spring config without getting into the guts of the framework. I'm really hoping the same sort of thing can be done with the RestTemplate.

        Show
        Geoff Chandler added a comment - I think the best approach here is to create an adapter that uses the google URLFetchService instead of an http client. I was able to make a BigTable implementation UsersConnectionRepository in a couple hours and would be happy to share it with anyone that wants it. It is easy to wire into the regular spring config without getting into the guts of the framework. I'm really hoping the same sort of thing can be done with the RestTemplate.
        Hide
        Geoff Chandler added a comment -

        These files allow connection persistence with BigTable.

        Show
        Geoff Chandler added a comment - These files allow connection persistence with BigTable.
        Hide
        cometta added a comment -

        i get this error Caused by: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.social.facebook.connect.FacebookConnectionFactory]: Constructor threw exception; nested exception is java.lang.NoClassDefFoundError: javax.net.ssl.HttpsURLConnection is a restricted class. Please see the Google App Engine developer's guide for more details.

        @Geoff Chandler, how do you solve this problem?

        Show
        cometta added a comment - i get this error Caused by: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.social.facebook.connect.FacebookConnectionFactory] : Constructor threw exception; nested exception is java.lang.NoClassDefFoundError: javax.net.ssl.HttpsURLConnection is a restricted class. Please see the Google App Engine developer's guide for more details. @Geoff Chandler, how do you solve this problem?

          People

          • Assignee:
            Unassigned
            Reporter:
            Craig Walls
          • Votes:
            16 Vote for this issue
            Watchers:
            15 Start watching this issue

            Dates

            • Created:
              Updated: