# Packaging spring-boot app w/deps can't find main class when running from java -jar

**URL:** <https://discuss.kotlinlang.org/t/packaging-spring-boot-app-w-deps-cant-find-main-class-when-running-from-java-jar/4408>\
**Category:** Support\
**Created:** [August 31, 2017, 11:49am UTC](https://discuss.kotlinlang.org/t/packaging-spring-boot-app-w-deps-cant-find-main-class-when-running-from-java-jar/4408 "2017-08-31T11:49:55Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mhahla](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/mhahla/32/3787_2.png) [@mhahla](https://discuss.kotlinlang.org/u/mhahla)\
**Post date:** [August 31, 2017, 11:49am UTC](https://discuss.kotlinlang.org/t/packaging-spring-boot-app-w-deps-cant-find-main-class-when-running-from-java-jar/4408/1 "2017-08-31T11:49:55Z")

</div>

I’m building my first kotlin spring-boot app w/jpa and a few controllers. It works fine when running within Intellij ultimate, but I need a working self-contained jar. I’m hitting a roadblock here when trying to run the self-contained jar.

First, I added the plugin in my pom.xml exactly as instructed in the url below.  
instructions I’m following: [https://kotlinlang.org/docs/reference/using-maven.html](https://kotlinlang.org/docs/reference/using-maven.html)

After running mvn install or mvn package. My resulting target/my-api-0.0.1-SNAPSHOT-jar-with-dependencies.jar is 68M

Within the .jar class files exist as expected  
BOOT-INF/classes/com/myproject/

- MyApplication$init$1.class
- MyApplication.class
- MyApplicationKt.class

And in META-INF/MANIFEST.mf the main class matches what I set for main.class in my pom.xml

**Here’s the error I get when running the jar**

**java -jar target/my-api-0.0.1-SNAPSHOT-jar-with-dependencies.jar**

**Error: Could not find or load main class com.myproject.MyApplicationKt (or without Kt depending on how I set main.class in my pom)**

Heres what I’ve tried so far to get this self-contained jar working:

1. in pom.xml tried both  
\<main.class\>com.myproject.MyApplicationKt\</main.class\> &&\<main.class\>com.myproject.MyApplication\</main.class\>

2. in pom.xml (same as before) tried both  
\<main.class\>com.myproject.MyApplicationKt\</main.class\> &&  
\<main.class\>com.myproject.MyApplication\</main.class\>

but instead w/ a companion object inside MyApplication. i.e.

```
class MyApplication : WebMvcConfigurerAdapter() { 
   companion object {
@JvmStatic fun main(args: Array<String>) {
    SpringApplication.run(Application::class.java, *args)
       }
}

```

}

**Lastly:**

- kotlin: 1.1.4
- spring boot: 1.5.6.RELEASE
- maven: 3.3.9

---

<div class="post-metadata">

**Author:** ![vbezhenar](https://avatars.discourse-cdn.com/v4/letter/v/35a633/32.png) [@vbezhenar](https://discuss.kotlinlang.org/u/vbezhenar)\
**Post date:** [August 31, 2017, 12:23pm UTC](https://discuss.kotlinlang.org/t/packaging-spring-boot-app-w-deps-cant-find-main-class-when-running-from-java-jar/4408/2 "2017-08-31T12:23:34Z")

</div>

If you extract files from your jar file, it should contain `/com/myproject/MyApplicationKt.class` file. I’m not sure what is `BOOT-INF/classes` prefix, it’s certainly not a correct jar-file. If you mean `WEB-INF/classes`, it means that you built a `war` file, not `jar` file. `war`-files are meant to be deployed into application servers, like Tomcat, they are not runnable `jar` files.

---

<div class="post-metadata">

**Author:** ![mhahla](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/mhahla/32/3787_2.png) [@mhahla](https://discuss.kotlinlang.org/u/mhahla)\
**Post date:** [August 31, 2017, 3:22pm UTC](https://discuss.kotlinlang.org/t/packaging-spring-boot-app-w-deps-cant-find-main-class-when-running-from-java-jar/4408/3 "2017-08-31T15:22:45Z")

</div>

Alright cool, so we’re onto something then.

So maybe it’s the spring-boot plugin moving the class files into this folder. Does anyone know how to get the sprint-boot maven plugin and kotlin maven plugins to harmonize in this scenario?

---

<div class="post-metadata">

**Author:** ![taylor.patton](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/taylor.patton/32/6734_2.png) [@taylor.patton](https://discuss.kotlinlang.org/u/taylor.patton)\
**Post date:** [September 3, 2019, 8:56pm UTC](https://discuss.kotlinlang.org/t/packaging-spring-boot-app-w-deps-cant-find-main-class-when-running-from-java-jar/4408/4 "2019-09-03T20:56:31Z")

</div>

hi @mhahla, were you able to resolve your issue? I’m seeing the same thing
