Search code examples
javasentry

io.sentry.SentryClientFactory - Error creating valid DSN from: 'https://public:private@host:port/1'


I am new to Sentry followed this

and this

and followed the same steps and the code I have an sbt project in which I created sentry.properties file its contents are

dsn=https://public:private@host:port/1

and placed it under src/main/resources when the code runs (the same code given the link above ) following exception is thrown'

18:19:26.745 [run-main-1] DEBUG io.sentry.config.Lookup - Found dsn=https://public:private@host:port/1 in sentry.properties.
18:19:26.754 [run-main-1] ERROR io.sentry.SentryClientFactory - Error creating valid DSN from: 'https://public:private@host:port/1'.
io.sentry.dsn.InvalidDsnException: Invalid DSN, the following properties aren't set '[host, public key]'
    at io.sentry.dsn.Dsn.validate(Dsn.java:209) ~[sentry-1.7.16.jar:na]
    at io.sentry.dsn.Dsn.<init>(Dsn.java:66) ~[sentry-1.7.16.jar:na]
    at io.sentry.dsn.Dsn.<init>(Dsn.java:41) ~[sentry-1.7.16.jar:na]
    at io.sentry.SentryClientFactory.resolveDsn(SentryClientFactory.java:73) [sentry-1.7.16.jar:na]
    at io.sentry.SentryClientFactory.sentryClient(SentryClientFactory.java:42) [sentry-1.7.16.jar:na]
    at io.sentry.Sentry.init(Sentry.java:81) [sentry-1.7.16.jar:na]
    at io.sentry.Sentry.init(Sentry.java:44) [sentry-1.7.16.jar:na]
    at sentry.SentryDemo$.main(SentryDemo.scala:16) [classes/:na]
    at sentry.SentryDemo.main(SentryDemo.scala) [classes/:na]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_181]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_181]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_181]
    at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_181]
    at sbt.Run.invokeMain(Run.scala:67) [run-0.13.16.jar:0.13.16]
    at sbt.Run.run0(Run.scala:61) [run-0.13.16.jar:0.13.16]
    at sbt.Run.sbt$Run$$execute$1(Run.scala:51) [run-0.13.16.jar:0.13.16]
    at sbt.Run$$anonfun$run$1.apply$mcV$sp(Run.scala:55) [run-0.13.16.jar:0.13.16]
    at sbt.Run$$anonfun$run$1.apply(Run.scala:55) [run-0.13.16.jar:0.13.16]
    at sbt.Run$$anonfun$run$1.apply(Run.scala:55) [run-0.13.16.jar:0.13.16]
    at sbt.Logger$$anon$4.apply(Logger.scala:84) [logging-0.13.16.jar:0.13.16]
    at sbt.TrapExit$App.run(TrapExit.scala:248) [run-0.13.16.jar:0.13.16]
    at java.lang.Thread.run(Thread.java:748) [na:1.8.0_181]
[error] (run-main-1) io.sentry.dsn.InvalidDsnException: Invalid DSN, the following properties aren't set '[host, public key]'
io.sentry.dsn.InvalidDsnException: Invalid DSN, the following properties aren't set '[host, public key]'
    at io.sentry.dsn.Dsn.validate(Dsn.java:209)
    at io.sentry.dsn.Dsn.<init>(Dsn.java:66)
    at io.sentry.dsn.Dsn.<init>(Dsn.java:41)
    at io.sentry.SentryClientFactory.resolveDsn(SentryClientFactory.java:73)
    at io.sentry.SentryClientFactory.sentryClient(SentryClientFactory.java:42)
    at io.sentry.Sentry.init(Sentry.java:81)
    at io.sentry.Sentry.init(Sentry.java:44)
    at sentry.SentryDemo$.main(SentryDemo.scala:16)
    at sentry.SentryDemo.main(SentryDemo.scala)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)

Is there anything I need to add in place of dsnin the properties file ? i am using sentry in my project which is not a web based project


Solution

  • The DSN tells the Sentry SDK which instance of sentry to hit (for example sentry.io) and which project within Sentry the events belong to.

    You need to get the DSN from Sentry and add to your project. In Sentry, in the project settings page, you'll see: Client keys (DSN):

    Sentry Client keys menu

    You'll then see the DSN like so:

    Example DSN

    Copy this (the button on the right), and paste on your sentry.properties replacing the placeholder: https://public:private@host:port/1