Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Sep 18 11:21
    magnolia-k closed #1278
  • Sep 18 11:20

    magnolia-k on main

    Update junit-4-13 to 3.2.10.0 (… (compare)

  • Sep 18 11:20
    magnolia-k closed #1284
  • Sep 18 11:20

    magnolia-k on main

    Update scalatest-featurespec, .… (compare)

  • Sep 18 11:20
    magnolia-k closed #1283
  • Sep 17 18:56
    scala-steward-bot opened #1284
  • Sep 17 18:56
    scala-steward-bot opened #1283
  • Sep 17 08:26

    magnolia-k on main

    Update scala3-library to 3.1.0-… (compare)

  • Sep 17 08:26
    magnolia-k closed #1282
  • Sep 16 11:49
    scala-steward-bot opened #1282
  • Sep 15 14:03

    magnolia-k on main

    Update scala-library to 2.12.15… (compare)

  • Sep 15 14:03
    magnolia-k closed #1281
  • Sep 14 20:54
    scala-steward-bot opened #1281
  • Sep 10 09:55

    magnolia-k on main

    Update logback-classic to 1.2.6… (compare)

  • Sep 10 09:55
    magnolia-k closed #1280
  • Sep 10 09:54

    magnolia-k on main

    Update specs2-core, specs2-matc… (compare)

  • Sep 10 09:54
    magnolia-k closed #1279
  • Sep 09 22:50
    scala-steward-bot opened #1280
  • Sep 09 11:48
    scala-steward-bot opened #1279
  • Sep 08 21:50
    scala-steward-bot opened #1278
Carlos Eduardo
@carlosedp
Hi all
Is it possible to use scalatra-metrics to generate Prometheus metrics?
I'm pretty new into scalatra and looking at the possibilities
Naoki Takezoe
@takezoe
@carlosedp Though I'm not familiar with Prometheus, scalatra-metrics is based on DropWizard's metrics library and integrating with Prometheus seems easy according to this article: https://www.robustperception.io/exposing-dropwizard-metrics-to-prometheus
Carlos Eduardo
@carlosedp
Nice, thanks @takezoe :)
Carlos Eduardo
@carlosedp
Hi all, I've solved the usage of Prometheus for metrics...
Another question... is there a way to access the jetty server from the ScalatraBootstrap class?
so I can add a statistics handler to it...
I need to do something like
    // Configure StatisticsHandler.
    val stats = new StatisticsHandler()
    stats.setHandler(server.getHandler())
    server.setHandler(stats)
    // Register collector.
    new JettyStatisticsCollector(stats).register()
Naoki Takezoe
@takezoe
@carlosedp I think we cannot access Jetty from ScalatraBootstrap because it's independent from servlet container implementation. You may need to write your own bootstrap class like this: https://github.com/gitbucket/gitbucket/blob/master/src/main/java/JettyLauncher.java
Carlos Eduardo
@carlosedp
humm.. got it...
override the whole bootstrap
that's too much work... hehe
Naoki Takezoe
@takezoe
@carlosedp Haha. By the way, how would you run your Scalatra based application? Create war file and deploy on Jetty?
Carlos Eduardo
@carlosedp
I still don't know.. .heheeh
:) evaluating the framework right now
Naoki Takezoe
@takezoe
Oh, I see.
Carlos Eduardo
@carlosedp
like... trying to understand if I can use the tools the framework gives .. for example for logging, metrics and etc... or if I need to override and do it myself...
like the Prometheus case, I can use the framework integrations .. so makes life easier
Naoki Takezoe
@takezoe
Yeah, experimenting before using it hardly makes sense.
Carlos Eduardo
@carlosedp
yep, once committed it's hard to change
Naoki Takezoe
@takezoe
Since Scalatra is a traditional Java servlet based web framework, it's designed to run on Servlet containers such as Jetty or Tomcat. Creating a war file and deploying it on Servlet container is the basic process. However, by writing a bootstrap class like I showed above, you can also build a standalone executable jar file.
Carlos Eduardo
@carlosedp
Yes, I was thinking about it... because the idea is to have it deployed on containers
can I build a native image with it?
Naoki Takezoe
@takezoe
Ah, hmm. I have never tried that with Scalatra.
Carlos Eduardo
@carlosedp
for people interested into looking at
I've pushed a Scalatra demo project with Prometheus metrics
sheeper
@sheeper:matrix.org
[m]
Hello everyone. I am new to scalatra. Is the version 2.8.0 stable and only about updating the dependencies. Should I start with 2.8.0 or go with 2.7.+?
Thanks for your reply 🙂
Naoki Takezoe
@takezoe
@sheeper:matrix.org Scalatra 2.8.0 itself is stable but if you use it with Twirl, you may face a dependency issue. The problem is already fixed in the latest master of Twirl so we are holding the release announcement of Scalatra 2.8.0 off until the next release of Twirl.
sheeper
@sheeper:matrix.org
[m]
Ah, okay. Will use it as a server backend, so no need for twirl. I removed the dependencies already.
Does anything speak against using it as a backend for an angular application?
Btw. scalatra feels nice for now! Thanks for the great work. Way simpler than Play when starting from scratch.
sheeper
@sheeper:matrix.org
[m]

Hello together. I am currently struggling with a strange error in IntelliJ.
I want to write some basic tests and created:

class ServletTests extends ScalatraFlatSpec {
  addServlet(classOf[Servlet], "/*")

  "The Servlet" should "return status 200 when invoking GET /" in {
    get("/") {
      status should equal(200)
    }
  }
}

But IntelliJ showing me:

Class 'ServletTests' must either be declared abstract or implement abstract member 'header: Any' in 'org.scalatra.test.Client'

I can ignore the error and run the tests without an issue but I would like to get rid of this problem.

Naoki Takezoe
@takezoe
@sheeper:matrix.org Did you create your project by sbt new scalatra/scalatra.g8?
Naoki Takezoe
@takezoe
and is that test case possible to compile and run on the console using sbt command?
If you can compile and run that test case using sbt command, it's IntelliJ specific issue. Otherwise, there is something needs to be fixed in your project.
Probably, I may need to see your build.sbt or entire your project that can reproduce the issue.
sheeper
@sheeper:matrix.org
[m]
Hi, yes. It seems to be IntelliJ related. When I run sbt new scalatra/scalatra.g8 with all default properties, I end up with the same error ☹️.
Naoki Takezoe
@takezoe
I see. I will try the project created by sbt new with IntelliJ, then.
sheeper
@sheeper:matrix.org
[m]

I can ignore it, becuase the code compiles and the tests run fine but intelliJ will prompt me, that there is an issue in the code everytime I commit changes ...

Perhaps an issue with the IntelliJ scala Plugin.

Naoki Takezoe
@takezoe

Perhaps an issue with the IntelliJ scala Plugin.

Yeah, that could be...

Screen Shot 2021-08-11 at 0.22.36.png
Naoki Takezoe
@takezoe
Found this one: https://youtrack.jetbrains.com/issue/SCL-16381, though I don't know if this is the same case.
2 replies
sheeper
@sheeper:matrix.org
[m]
@takezoe: this issue disappeared as I switched to scalatra version 2.7.0.
Had a similar issue, when I started to use the scalatra-json library. Hope this helps.
1 reply
sheeper
@sheeper:matrix.org
[m]

Sorry. Last update for today. I am a bit confused.
I use the dependencies like the following now:

libraryDependencies ++= Seq(
    "org.scalatra" %% "scalatra" % "2.7.0",
    "org.scalatra" %% "scalatra-scalatest" % "2.6.0" % "test",
    "org.scalatra" %% "scalatra-json" % "2.7.0",
    "org.json4s" %% "json4s-jackson" % "3.5.2",
    "ch.qos.logback" % "logback-classic" % "1.2.5" % "runtime",
    "org.eclipse.jetty" % "jetty-webapp" % "9.4.43.v20210629" % "container",
    "javax.servlet" % "javax.servlet-api" % "3.1.0" % "provided",
  )

Now I have no more problems reported by intelliJ. Hope this helps someone to get you scalatra app running without intelliJ issues ;-)

vtbaladev
@vtbaladev
Hello. I am new to scalatra. Does anyone know HTTPS strictTransportSecurity redirect in scalatra steps using ScalatraFilter or other means? Appreciate your help.
sheeper
@sheeper:matrix.org
[m]
Hey. I am new to scalatra as well but I think a simple filter with an after method should do it right? In the after you can set the HSTS header to the response.
Naoki Takezoe
@takezoe
before might be better since the response might have been already flushed when after is called. Or it might be better to use a servlet filter if your app has multiple controllers.
vtbaladev
@vtbaladev
Appreciated. Thanks. I will try this.
vamsi
@vktmm_twitter
Hi, I am new to Scalatra,wondering is there any web service client/api does scalatra offers to make external rest api calls?
3 replies
sheeper
@sheeper:matrix.org
[m]

Hello together. I have a question regarding scalatra and SSO.

What I want to do
When someone fetches data from my scalatra backend, he has to be authenticated. As authentication mechanism I have to use SAML SSO with Azure as IdP.
So, when someone is not authenticated, he has to enter his credentials at the IdPs page and will be redirected to the requested data endpoint.

In addition to that, an authenticated user must have roles, which do not come from the IdP. So I want each new user persisted in the database with a default role and then assign roles to them later.

What I currently have
I use pac4j for the SAML SSO login, which works just fine. For the session handling I use buji-pac4j (Apache Shiro Integration) which receives the Profile Data from Pac4J and puts in into the session store.

But for me it's now unclear how to handle the roles of the users. Can I somehow persist the profiles to a database and read them from there again, when permissions have to be checked?
Is there any example project out there, where I can see how this can be done?

Thanks for your help!