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)

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
somatoko
@somatoko

Hi guys! I have some warnings during development.
To reproduce:

  • Basic project setup with sbt new scalatra/scalatra.g8 and all defaults;
  • Add JettyLauncher.scala as described in Standalone deployment + adjust build.sbt.

Now when I run in sbt ~Jetty/start console logs ≈ 1100 lines of warnings with similar content as:

WARN:oeja.AnnotationParser:qtp1427810650-12: javax.servlet.AsyncEvent scanned from multiple locations: jar:file:///Users/emris/scala/sanga/target/webapp/WEB-INF/lib/javax.servlet-api-3.1.0.jar!/javax/servlet/AsyncEvent.class, jar:file:///Users/emris/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/eclipse/jetty/jetty-runner/9.4.29.v20200521/jetty-runner-9.4.29.v20200521.jar!/javax/servlet/AsyncEvent.class

Do I miss some configuration option to fix these conflicts?

Eric Anderson
@Nexus6
I can reproduce this, though most of the warning messages refer to the org.eclipse.jetty.xml package. I'm using Jetty 10.0.6 but "Jetty / start" is, as in your case, pulling in a ton of Jetty 9.x jars from the Coursier cache. Starting the app with the sbt "run" command works fine which is why I hadn't noticed this before. Deleting the cache doesn't help - the next time I start sbt it pulls down a ton of old jars again and "start" yields the same list of warnings.
Eric Anderson
@Nexus6
My project directory is polluted from experimentation with Idea and VSCode/metals (finally decided on Idea) and I think that metals has mucked things up with its insistence on installing bloop. When I nuke the Coursier cache and restart sbt, a lot of what gets pulled down again are libs for scala 2.12 whereas my project is "scalaVersion := "2.13.6". I have not studied the architecture of sbt (yeah, I really should) but since "sbt run" is happy and "sbt Jetty/start" isn't, I suspect the difference (and problem) is related to where - what jvm instance - the app is being run, and the differing classpaths of each. Have you been playing with Metals in your project by any chance?
1 reply
Naoki Takezoe
@takezoe
Sounds like the issue is related to xsbt-web-plugin that provides ~jetty/start functionality. How does it work if you run sbt ~jetty/start in a fresh Scalatra project created by sbt new scalatra/scalatra.g8?
4 replies
Nils Kilden-Pedersen
@nilskp
Just upgraded to 2.8.2 and find out that Scalate has been deprecated. Can someone point to some of the background for this? Sad to say that I'm disappointed in this, as it means I'll be stuck at some point. Twirl doesn't really seem like a workable alternative for those of us with Jade/Pug codebases.
Naoki Takezoe
@takezoe
@nilskp Scalate heavily depends on Scala compiler internally and it doesn't seem to be going to support Scala 3 (scalate/scalate#253). Deprecating Scalate is preparation for supporting Scala 3 in Scalatra.
2 replies
Naveen
@dexter2305
Hello, I am learning scalatra. I am familiar with cake pattern. I have implemented repository using the cake pattern. But I am running into 1. design issues about mixing RepositoryComponent into ScalatraServlet. 2. How is the cake pattern applicable to scalatra servlets? Any references will help.
3 replies
Sean Sabour
@seansabour
Hi we're facing a very strange issue when trying to enable CORS, when the header "Access-Control-Request-Method: POST" is set it is not matching our options route to augment the response header for allow-access-control-origin. This header is automatically added by most browser and when trying via postman/curl without this header it is matching our route. Any idea what i'm missing?
1 reply
Jonas Natten
@jnatten
We've been using enumeratum for enums (mostly because they allow exhaustive pattern matching checks), is there a way to get scalatra-swagger to work with them?
I see there is some work here with macros, but the @ApiModel from scalatra doesn't have the same fields as the one from io.swagger so i can't find a way to get this to work
Naoki Takezoe
@takezoe
Yeah, Twirl doesn't support Scala3 yet.
Naoki Takezoe
@takezoe
Just adding sbt plugin to your project and enabling it should be enough as described in https://github.com/playframework/twirl. You can put template files under src/main/twirl. Template files will be compiled to Scala methods so you can simply call them from your Scala code.
Naoki Takezoe
@takezoe
Ah, it might be possible to compile Twirl template in Scala2 project and use compiled templates from Scala3 project as a library.
Twirl compiler depends on Scala2 compiler so sbt plugin wouldn't work in Scala3 project anyway.
By the way, why did you ask about Twirl here in a gitter room for Scalatra? I'm just curious...
Paul-Folbrecht
@Paul-Folbrecht
Oh boy. I had several gitter tabs open and posted in the wrong one. Apologies! I will delete.
Naoki Takezoe
@takezoe
No worries! You didn't need to delete your messages :-)
bcoromina
@bcoromina
Hi, I set a Content-Type header like "text/cvs;charset=utf-8" but looks Scalatra is trying to guess the charset and for whatever reason the header reaches the client like "text/cvs;charset=GB18030". How can I indicate Scalatra to resopect the charset in the header? (scalatra 2.8.2)
Naoki Takezoe
@takezoe
@bcoromina Could you show your actual code that sets Content-Type?
bcoromina
@bcoromina
val contentTypeHeader: GenericHeader = HttpHeader.ContentType("text/cvs;charset=utf-8")
ActionResult(HttpStatus.SC_OK, file.content, contentTypeHeader.toMap)
I think when Scalatra renders the ActionResult something is out of control
bcoromina
@bcoromina
I've seen the ContentTypeTest.scala but it doesn't include the rendering of the response
Naoki Takezoe
@takezoe
@bcoromina You can set Content-Type by contentType = "text/cvs;charset=utf-8" inside your action.
bcoromina
@bcoromina
@takezoe sorry, what do you mean by 'inside your action'? indide the case class ActionResult?
Naoki Takezoe
@takezoe
@bcoromina like this:
get("/hoge") {
  contentType = "text/cvs;charset=utf-8"
  Ok(file.content)
}