# The Ninja Web framework

**URL:** <https://discuss.kotlinlang.org/t/the-ninja-web-framework/689>\
**Category:** Uncategorized\
**Created:** [November 24, 2013, 8:59am UTC](https://discuss.kotlinlang.org/t/the-ninja-web-framework/689 "2013-11-24T08:59:32Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rayz](https://avatars.discourse-cdn.com/v4/letter/r/f05b48/32.png) [@Rayz](https://discuss.kotlinlang.org/u/Rayz)\
**Post date:** [November 24, 2013, 8:59am UTC](https://discuss.kotlinlang.org/t/the-ninja-web-framework/689/1 "2013-11-24T08:59:32Z")

</div>

Hello there :-)

The Ninja framework is a fairly lightweight stack modelled loosely on the Play! framework. It’s dead easy to learn, open-source, scaleable and supports just about every other feature you’d expect to ensure full buzzword compliance.

[http://www.ninjaframework.org](http://www.ninjaframework.org)

I had a go at converting the framework examples from Java. Turned out to be pretty straightforward:

[https://github.com/MuppetGate/NinjaTest.git](https://github.com/MuppetGate/NinjaTest.git)

Though again, the need to support nullable types in the framework made a few bits of the code a little cumbersome.

Anyway, if you’re on the lookout for a web framework that’s pretty much production-ready and is a good fit for Kotlin, then the Ninja Web framework is worth a look. With any luck, the folk at Jetbrains could work with the Ninja folk to make the framework a little more Kotlin-friendly.

Message was edited by: Rayz  
  
Fixed duff links.

---

<div class="post-metadata">

**Author:** ![Rayz](https://avatars.discourse-cdn.com/v4/letter/r/f05b48/32.png) [@Rayz](https://discuss.kotlinlang.org/u/Rayz)\
**Post date:** [November 24, 2013, 9:01am UTC](https://discuss.kotlinlang.org/t/the-ninja-web-framework/689/2 "2013-11-24T09:01:14Z")

</div>

P.S.

I am not affliated with either company.

🙂

Just thought I’d mention that.

---

<div class="post-metadata">

**Author:** ![cedricbeust](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/cedricbeust/32/1429_2.png) [@cedricbeust](https://discuss.kotlinlang.org/u/cedricbeust)\
**Post date:** [November 24, 2013, 5:14pm UTC](https://discuss.kotlinlang.org/t/the-ninja-web-framework/689/3 "2013-11-24T17:14:21Z")

</div>

I don't see any Kotlin code anywhere, do you have a direct link?

Also, your links have weird linkedin redirects in them.

---

<div class="post-metadata">

**Author:** ![Rayz](https://avatars.discourse-cdn.com/v4/letter/r/f05b48/32.png) [@Rayz](https://discuss.kotlinlang.org/u/Rayz)\
**Post date:** [November 24, 2013, 9:08pm UTC](https://discuss.kotlinlang.org/t/the-ninja-web-framework/689/4 "2013-11-24T21:08:59Z")

</div>

Doh!

:8}

Thanks for that. I’ve fixed the links now.

---

<div class="post-metadata">

**Author:** ![cedricbeust](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/cedricbeust/32/1429_2.png) [@cedricbeust](https://discuss.kotlinlang.org/u/cedricbeust)\
**Post date:** [November 24, 2013, 10:12pm UTC](https://discuss.kotlinlang.org/t/the-ninja-web-framework/689/5 "2013-11-24T22:12:58Z")

</div>

Thanks, but I'm still not seeing any Kotlin anywhere (NinjaTest only has src/main/java).

---

<div class="post-metadata">

**Author:** ![Rayz](https://avatars.discourse-cdn.com/v4/letter/r/f05b48/32.png) [@Rayz](https://discuss.kotlinlang.org/u/Rayz)\
**Post date:** [November 24, 2013, 10:19pm UTC](https://discuss.kotlinlang.org/t/the-ninja-web-framework/689/6 "2013-11-24T22:19:19Z")

</div>

Yes, I didn't change the name of folder. The Kotlin files are inside there.

---

<div class="post-metadata">

**Author:** ![jonjanisch](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/jonjanisch/32/1578_2.png) [@jonjanisch](https://discuss.kotlinlang.org/u/jonjanisch)\
**Post date:** [December 2, 2013, 5:42am UTC](https://discuss.kotlinlang.org/t/the-ninja-web-framework/689/7 "2013-12-02T05:42:08Z")

</div>

I've been experimenting with Kotlin/Ninja as well.&nbsp;&nbsp;Injecting services into controllers was a bit cumbersome at first when I tried field level injection.&nbsp;&nbsp;Initially, I believe I was doing something like this (which is similar to your InjectionExampleController):

&nbsp;&nbsp;Inject  
 &nbsp;&nbsp;var greetingService : GreetingService? = null

This of course gives you a nullable GreetingService which is rather annoying as you have to either add nullchecks everywhere or use the !! operator.&nbsp;&nbsp;I find using constructor injection is much better:

public class HelloController [Inject] ( val greetingService : GreetingService) {

… since you get a non-null reference that doesn’t propagate throughout your code.

---

<div class="post-metadata">

**Author:** ![Rayz](https://avatars.discourse-cdn.com/v4/letter/r/f05b48/32.png) [@Rayz](https://discuss.kotlinlang.org/u/Rayz)\
**Post date:** [December 2, 2013, 11:21pm UTC](https://discuss.kotlinlang.org/t/the-ninja-web-framework/689/8 "2013-12-02T23:21:29Z")

</div>

Ah! Thanks for that! I think I'd got something similar in the upload controller while experimenting with the injection:

```kotlin

```

But it's not anywhere near as tidy.
