The project compiles in IntelliJ, Tomcat says java.lang.NoClassDefFoundError: my / package / name / blah

My project compiles in IntelliJ, it is a simple spring -mvc written in scala.

I get this error when I run it using tomcat:

java.lang.NoClassDefFoundError: org/example/houses/SomeClassNameHere

The above is not the exact name of my library.

My controller looks like this:

package com.example.scalacms.web.controllers

import org.springframework.stereotype.Controller
import org.springframework.web.bind.annotation.{ResponseBody, RequestMapping}
import org.example.house

@Controller
class HomeController {
  var houses: Houses = _


  @RequestMapping(Array("/"))
  @ResponseBody
  def index: String = {
    "hello, world!"
  }

}

I am confused because it compiles in IntelliJ, it raises all my classes in intellisense, etc.

Maybe tomcat doesn't have a library in my classpath? I use an exploded artifact.

I do not see the class path anywhere in the output windows, so I cannot confirm.

Update

So, I looked in /out/artifacts/myapp_web_war_exploded/WEB-INF/lib, and I do not see the jar file there. Why is the bank not included in the deployment? What should I do to enable it in intellij?

+4
3

WAR Maven, , provided pom, WAR.

, , pom WAR, mvn dependency:tree , .

, , , IDE. :

  • .
  • .
  • IDE
  • maven, IDEA , poms
  • Maven, Maven Projects ( ) Reimport Maven
  • F4/Libraries ,
+5

intellij, eclipse, maven, , maven .

: Maven WEB-INF/lib

+1

​​ ...

IntelliJ /lib /src- , , LIB , ; , LIB.

, IntelliJ JAR. Tomcat , Tomcat /WEB -INF/lib,...

, :

1) LIB (, "/lib" ) /src/lib, /web/WEB -INF

2) /JAR, .

( , LIB ):

3) FILE →

4) Select Libraries in the menu on the left

5) If you do not see any existing libraries, then everything is ready, click OK

6) If you see libs there, then:

7) Click on each LIB with the middle list, and then delete those that cannot be located,

8) Re-add them from the new location

9) Repeat (7) to all other LIBs.

10) OK

RE-compile, your project should now deploy to Tomcat and work fine.

Relations Hyder

0
source

Source: https://habr.com/ru/post/1530855/


All Articles