Issue
Presently, I have an ejb
project and a web service project. The problem is that my webservice project cannot access EJBs from my library project:
{"WFLYCTL0080: Failed services" => {"jboss.deployment.unit.\"myapp-ws.war\".POST_MODULE" => "WFLYSRV0153: Failed to process phase POST_MODULE of deployment \"myapp-ws.war\"
Caused by: java.lang.RuntimeException: WFLYSRV0177: Error getting reflective information for class org.ws.MyAppWSImpl with ClassLoader ModuleClassLoader for Module \"deployment.myapp-ws.war\" from Service Module Loader
Caused by: java.lang.NoClassDefFoundError: Lorg/myapp/MyAppStatelessLocal;
Caused by: java.lang.ClassNotFoundException: org.myappp.InfossStatelessLocal from [Module \"deployment.myapp-ws.war\" from Service Module Loader]"}}
As far as I can tell the dependencies are setup properly in the pom.xml
files. Here is my root pom.xml:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.myapp</groupId>
<artifactId>myapp-app</artifactId>
<packaging>pom</packaging>
<version>0.1.0</version>
<modules>
<module>myapp-ejb</module>
<module>myapp-web</module>
<module>myapp-ear</module>
<module>myapp-ws</module>
</modules>
<properties>
<root.dir>${project.basedir}</root.dir>
<jboss.home.name>JBOSS_HOME</jboss.home.name>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.source>1.8</maven.compiler.source>
<version.server.bom>18.0.1.Final</version.server.bom>
<version.wildfly.maven.plugin>2.0.0.Final</version.wildfly.maven.plugin>
<version.jaxws-tools-maven-plugin>1.2.3.Final</version.jaxws-tools-maven-plugin>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.wildfly.bom</groupId>
<artifactId>wildfly-jakartaee8-with-tools</artifactId>
<version>${version.server.bom}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>myapp-ejb</artifactId>
<version>${project.version}</version>
<type>ejb</type>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>myapp-web</artifactId>
<version>${project.version}</version>
<type>war</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>myapp-ws</artifactId>
<version>${project.version}</version>
<type>war</type>
<scope>compile</scope>
</dependency>
</dependencies>
</dependencyManagement>
...
</project>
Here my my ear
pom.xml:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.myapp</groupId>
<artifactId>myapp-ear</artifactId>
<packaging>ear</packaging>
<version>0.1.0</version>
<name>myapp-ear</name>
<parent>
<groupId>org.myapp</groupId>
<artifactId>myapp-app</artifactId>
<version>0.1.0</version>
</parent>
<description>This project packages myapp-ejb and myapp-web in an EAR; this is the EAR POM file</description>
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>myapp-ejb</artifactId>
<type>ejb</type>
<version>0.1.0</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>myapp-web</artifactId>
<version>0.1.0</version>
<type>war</type>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>myapp-ws</artifactId>
<type>war</type>
</dependency>
</dependencies>
...
</project>
Here is my web service pom.xml
:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.myapp</groupId>
<artifactId>myapp-ws</artifactId>
<packaging>war</packaging>
<version>0.1.0</version>
<name>myapp-ws Maven Soap WS</name>
<parent>
<groupId>org.myapp</groupId>
<artifactId>myapp-app</artifactId>
<version>0.1.0</version>
</parent>
<dependencies>
...
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>myapp-ejb</artifactId>
<type>ejb</type>
<scope>provided</scope>
</dependency>
....
</project>
The ear
project deploys without a problem but the webservice deployment fails. Basically, I am trying to follow this guide:
https://docs.wildfly.org/18/Getting_Started_Developing_Applications_Guide.html
https://github.com/wildfly/quickstart/blob/10.x/guide/HelloworldQuickstart.asciidoc
https://developers.redhat.com/quickstarts/eap/helloworld-ws#
Does anyone have any suggestions? TIA
UPDATE:
Here is my MyAppWSImpl.java
:
package myapp.ws;
import javax.ejb.EJB;
import javax.jws.WebMethod;
import javax.jws.WebService;
import myapp.lab.MyAppStatelessLocal;
@WebService(endpointInterface = "myapp.ws.MyAppWS")
public class MyAppWSImpl implements MyAppWS {
@EJB
MyAppStatelessLocal masl;
@WebMethod()
public String predict(int value) {
return masl.getPrediction(value);
}
}
Here is my web.xml
. HTH.
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" id="WebApp_ID" version="3.1">
<display-name>myapp-ws</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>myappws</servlet-name>
<servlet-class>myapp.ws.MyAppWSImpl</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>myappws</servlet-name>
<url-pattern>/myappws</url-pattern>
</servlet-mapping>
</web-app>
Solution
Please note that I finally figured out that I needed to use this URL:
http://localhost:8080/myapp-ws/myappws?wsdl
Instead of this value:
http://localhost:8080/myapp-ws/MyAppWSImpl?wsdl
Answered By - user8128167
Answer Checked By - Pedro (JavaFixing Volunteer)