Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Aug 09 22:57

    magnolia-k on master

    removes broken link to riak per… Merge pull request #219 from sv… (compare)

  • Aug 09 22:57
    magnolia-k closed #219
  • Aug 09 11:55
    sv3ndk opened #219
  • Aug 09 04:42
    scala-steward-bot opened #1401
  • Aug 09 04:37

    magnolia-k on main

    avoid `reflectiveCalls` (#1400) (compare)

  • Aug 09 04:37
    magnolia-k closed #1400
  • Aug 09 04:36

    magnolia-k on main

    update to jetty 11 (#1399) (compare)

  • Aug 09 04:36
    magnolia-k closed #1399
  • Aug 07 00:03
    xuwei-k opened #1400
  • Aug 06 23:48
    xuwei-k opened #1399
  • Aug 05 01:31

    magnolia-k on main

    Update metrics-servlet, metrics… (compare)

  • Aug 05 01:31
    magnolia-k closed #1398
  • Aug 04 21:59
    scala-steward-bot opened #1398
  • Jul 31 10:11

    magnolia-k on main

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

  • Jul 31 10:11
    magnolia-k closed #1397
  • Jul 31 10:11

    magnolia-k on main

    Update scalatest-featurespec, .… (compare)

  • Jul 31 10:11
    magnolia-k closed #1396
  • Jul 30 19:05
    scala-steward-bot opened #1397
  • Jul 30 18:01
    scala-steward-bot opened #1396
  • Jul 29 10:26

    magnolia-k on main

    Update scala-collection-compat … (compare)

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!

1 reply
Daniel de Oliveira Mantovani
@mantovani
It's possible to generate Scalatra code from a swagger json ?
I know is possible to generate the swagger json from a Scalatra app.(it's clear on the documentation)
7 replies
vamsi
@vktmm_twitter
Hi,
is there any schedular we can incorporate into scalatra to execute periodically?
1 reply