NPE when used with Play #23

Closed
baank opened this Issue Sep 1, 2012 · 3 comments

Comments

Projects
None yet
2 participants
@baank

baank commented Sep 1, 2012

Play for some reason removes all the appenders on startup. This causes a NPE as worker has not been initialized:

Exception in thread "main" java.lang.NullPointerException
    at net.kencochrane.sentry.SentryQueue.shutdown(SentryQueue.java:35)
    at net.kencochrane.sentry.SentryAppender.close(SentryAppender.java:91)
    at org.apache.log4j.helpers.AppenderAttachableImpl.removeAllAppenders(AppenderAttachableImpl.java:141)
    at org.apache.log4j.Category.removeAllAppenders(Category.java:891)
    at org.apache.log4j.PropertyConfigurator.parseCategory(PropertyConfigurator.java:726)
    at org.apache.log4j.PropertyConfigurator.configureRootCategory(PropertyConfigurator.java:615)
    at org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.java:502)
    at org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.java:547)
    at org.apache.log4j.PropertyConfigurator.configure(PropertyConfigurator.java:415)
    at play.Logger.init(Logger.java:79)
    at play.Play.init(Play.java:206)
    at play.server.Server.main(Server.java:159)
@roam

This comment has been minimized.

Show comment Hide comment
@roam

roam Sep 1, 2012

Contributor

With the 1.0 snapshot version logging to Sentry seems to work ok in Play 1.2.5. A jar including all dependencies is available here: https://github.com/downloads/kencochrane/raven-java/raven-log4j-1.0-SNAPSHOT-jar-with-dependencies.jar

Drop that jar into your lib folder and update your log4j.properties:

log4j.appender.sentry=net.kencochrane.raven.log4j.SentryAppender
log4j.appender.sentry.sentryDsn=YOUR_SENTRY_DSN

An updated readme for this version is available. Let us know how it goes!

Contributor

roam commented Sep 1, 2012

With the 1.0 snapshot version logging to Sentry seems to work ok in Play 1.2.5. A jar including all dependencies is available here: https://github.com/downloads/kencochrane/raven-java/raven-log4j-1.0-SNAPSHOT-jar-with-dependencies.jar

Drop that jar into your lib folder and update your log4j.properties:

log4j.appender.sentry=net.kencochrane.raven.log4j.SentryAppender
log4j.appender.sentry.sentryDsn=YOUR_SENTRY_DSN

An updated readme for this version is available. Let us know how it goes!

@baank

This comment has been minimized.

Show comment Hide comment
@baank

baank Sep 2, 2012

You seem to be using the trunk version of Commons-Codec.

The current shipping version (1.6) has no Base64.encodeBase64String method. Hence it is complaining during runtime.

baank commented Sep 2, 2012

You seem to be using the trunk version of Commons-Codec.

The current shipping version (1.6) has no Base64.encodeBase64String method. Hence it is complaining during runtime.

@roam

This comment has been minimized.

Show comment Hide comment
@roam

roam Sep 2, 2012

Contributor

No, 1.6 does contain that method, but Play provides version 1.4. I'll try to backport this code, but for now you should probably force Play to use commons codec 1.6.

Your dependencies might look a little like this (Raven needs commons-lang, commons-codec and json-simple):

require:
    - play 1.2.5
    - commons-lang 2.5:
        force: true
    - commons-codec 1.6:
        force: true
    - com.googlecode.json-simple -> json-simple 1.1

Now you could also use the jars without included dependencies: raven and raven-log4j. Resolve the dependencies with play dependencies, then drop those two jars in the lib folder.

Contributor

roam commented Sep 2, 2012

No, 1.6 does contain that method, but Play provides version 1.4. I'll try to backport this code, but for now you should probably force Play to use commons codec 1.6.

Your dependencies might look a little like this (Raven needs commons-lang, commons-codec and json-simple):

require:
    - play 1.2.5
    - commons-lang 2.5:
        force: true
    - commons-codec 1.6:
        force: true
    - com.googlecode.json-simple -> json-simple 1.1

Now you could also use the jars without included dependencies: raven and raven-log4j. Resolve the dependencies with play dependencies, then drop those two jars in the lib folder.

@roam roam closed this Jan 20, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment