0

I have seen this question asked around before and Can't seem to find a solid solution to it. As of now, Google App Engine does not support subclasses of java.util.logging.Logger. I have some code in a java endpoint that is using the Base CRM API (info here: https://github.com/basecrm/basecrm-java) to input contacts into my CRM. This works as expected when using it in a locahost environment for testing, but onc edeployed it does not like the logging that the Base API is doing. Here is the error I am getting from GAE:

java.lang.SecurityException: Google App Engine does not support subclasses of java.util.logging.Logger: com/getbase/http/jersey/HttpClient$Slf4jAdapter
    at com.google.appengine.runtime.Request.process-bbdc1f6d27729bc9(Request.java)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:375)
    at com.getbase.http.jersey.HttpClient.<init>(HttpClient.java:31)
    at com.getbase.Client.<init>(Client.java:34)
    at com.nicholas.leadsbackend.LeadsServlet.sendToBase(LeadsServlet.java:90)
    at com.nicholas.leadsbackend.LeadsServlet.doPost(LeadsServlet.java:61)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1166)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
    at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:388)
    at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
    at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
    at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
    at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:418)
    at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
    at org.mortbay.jetty.Server.handle(Server.java:326)
    at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
    at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:923)
    at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
    at com.google.tracing.TraceContext$TraceContextRunnable.runInContext(TraceContext.java:453)
    at com.google.tracing.TraceContext$TraceContextRunnable$1.run(TraceContext.java:460)
    at com.google.tracing.CurrentContext.runInContext(CurrentContext.java:293)
    at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContextNoUnref(TraceContext.java:319)
    at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContext(TraceContext.java:311)
    at com.google.tracing.TraceContext$TraceContextRunnable.run(TraceContext.java:457)
    at java.lang.Thread.run(Thread.java:745)

Here is the code in my endpoint that sends to base:

Client client = new Client(new Configuration.Builder()
                    .accessToken(BASECRM_ACCESS_TOKEN)
                    .verbose()
                    .build());

            Contact contact = new Contact();
            contact.setName(name);
            contact.setPhone(phone);
            contact.setEmail(email);
            contact.setDescription("Make/Model/Year: " + make + "\n" +
                    "Type of Ad: " + adType);
            client.contacts().create(contact);

The API code is very simple code, and is not the issue here. My issue is that the CRM API needs this dependency compile group: 'org.slf4j', name: 'slf4j-simple', version: '1.7.21' to work properly or it throws errors.

Please let me know if there is any way to fix this for GAE. I am looking towards other options than GAE as other options might not have strict Logging rules. I understand that this is also a special case scenario since it's an additional API causing me the issue, but any insight will be very helpful. Thanks in advance!

Nicholas Pesa
  • 1,906
  • 2
  • 22
  • 37

1 Answers1

0

I understand this is a very specific issue and I am working with Base developer support to find a workaround for the SFL4j logging. So I have scrubbed the Base Java API to find only one class creates a subclass of the sfj4j Adapter. This is an update to their API, not sure when they incorporated this update so I decided to use an older API then the one they have listed on the documentation.

Here is the one library base provides to use: compile "com.getbase:basecrm-java:1.4.5"

Which has this class:

public static class Slf4jAdapter extends java.util.logging.Logger {
        private final Logger logger;

        public Slf4jAdapter(Logger logger) {
            super("jersey", null);
            this.logger = logger;
        }

        @Override
        public void info(String msg) {
            logger.info(msg);
        }
    }

That is the subclass of the java.util Logger.

I ended up using this library: compile "com.getbase:basecrm-java:1.0.0"

Which is before they started using the sfl4j logging. This made it so Google App Engine did not reject my request and everything is working now.

I am not sure which version they started using sfl4j but am going to find out so I can use the latest getbase build without sfl4j.

I will edit this answer after I find out if there is a workaround to sfl4j logging or to display the latest build without it. I hope this can be helpful to anyone else.

Nicholas Pesa
  • 1,906
  • 2
  • 22
  • 37