0

I am working on a Java EE project with

  1. jdk 1.8
  2. wildfly 10.1.0 final
  3. intellij idea 2016.3

The project has a web application module and an ejb module, and the structure is as follows: project structure

And the two modules have already been deployed successfully enter image description here

But when I tried to call the session bean, the ejb project went wrong and threw an error

Caused by: java.lang.NoClassDefFoundError: org/json/JSONArray

I use JSON in class DAOHelperImpl in the ejb module, and I've already add the dependency. I tried to put the jar in various packages such as /ejb/lib or /web/web/lib, but none of them are working.

What's wrong?

Arjan Tijms
  • 37,782
  • 12
  • 108
  • 140
Stone
  • 43
  • 1
  • 8

2 Answers2

0

Move the jars libraries from /web/web/lib into

/web/web/WEB-INF/lib

By Convention the general folder for auto included jars is:
web-project-name/webContent/WEB-INF/lib

Read more here: https://blogs.oracle.com/alexismp/entry/web_inf_lib_jar_meta

I am not aware how IntelliJ handles Java EE projects.
In Eclipse the EAR and WAR are in separate projects and can be assigned to each other.

Arjan Tijms
  • 37,782
  • 12
  • 108
  • 140
code_angel
  • 1,537
  • 1
  • 11
  • 21
0

I think this error is raised due to my bad understanding of how this web application together with the ejb module works: I deploy the web module and the ejb module separately, and it seems that wildfly can only link to the lib of the web module. The solution is to deploy only the web application to the server and add the ejb module to the web application.

Stone
  • 43
  • 1
  • 8