Search code examples
javaeclipsewildfly-swarm

Java wildfly swarm on Eclipse


Good day Java and Wildfly Swarm Gurus,

I have a question. I have built a microservice project in Eclipse using Wildfly Swarm and EJB. The project is named TestProject and will build a TestProject.war.

When I run in the Terminal, using the command "mvn wildfly-swarm:run" it runs properly and will somewhat build the right war file. Below is a snippet when it runs:

2017-09-12 12:03:34,884 INFO  [org.xnio.nio] (MSC service thread 1-7) XNIO NIO Implementation Version 3.4.0.Final
2017-09-12 12:03:34,971 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-7) WFLYUT0012: Started server default-server.
2017-09-12 12:03:35,056 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-1) WFLYUT0006: Undertow HTTP listener default listening on [0:0:0:0:0:0:0:0]:8080
2017-09-12 12:03:35,176 INFO  [org.jboss.as] (Controller Boot Thread) WFLYSRV0025: WildFly Swarm 2017.3.3 (WildFly Core 2.2.1.CR1) started in 1140ms - Started 132 of 143 services (25 services are lazy, passive or on-demand)
2017-09-12 12:03:36,380 INFO  [org.wildfly.swarm.runtime.deployer] (main) deploying TestProject.war
2017-09-12 12:03:36,398 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-1) WFLYSRV0027: Starting deployment of "TestProject.war" (runtime-name: "TestProject.war")
2017-09-12 12:03:37,779 WARN  [org.jboss.as.dependency.private] (MSC service thread 1-2) WFLYSRV0018: Deployment "deployment.TestProject.war" is using a private module ("org.jboss.jts:main") which may be changed or removed in future versions without notice.
2017-09-12 12:03:38,114 INFO  [org.jboss.as.ejb3.deployment] (MSC service thread 1-1) WFLYEJB0473: JNDI bindings for session bean named 'ProductRestBean' in deployment unit 'deployment "TestProject.war"' are as follows:

    java:global/TestProject/ProductRestBean!com.mycompany.ejb.ProductRestBeanInterface
    java:app/TestProject/ProductRestBean!com.mycompany.ejb.ProductRestBeanInterface
    java:module/ProductRestBean!com.mycompany.ejb.ProductRestBeanInterface
    java:global/TestProject/ProductRestBean
    java:app/TestProject/ProductRestBean
    java:module/ProductRestBean

When I run in in Eclipse IDE it will still run, but the war it created is different and is causing the bean loading and look up later, unable to load. Below is a snippet on how it runs (problematic) in Eclipse:

[0m[0m2017-09-12 12:36:46,741 INFO  [org.xnio.nio] (MSC service thread 1-6) XNIO NIO Implementation Version 3.4.0.Final
[0m[0m2017-09-12 12:36:46,795 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-6) WFLYUT0012: Started server default-server.
[0m[0m2017-09-12 12:36:46,871 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-7) WFLYUT0006: Undertow HTTP listener default listening on [0:0:0:0:0:0:0:0]:8080
[0m[0m2017-09-12 12:36:46,997 INFO  [org.jboss.as] (Controller Boot Thread) WFLYSRV0025: WildFly Swarm 2017.3.3 (WildFly Core 2.2.1.CR1) started in 1197ms - Started 132 of 143 services (25 services are lazy, passive or on-demand)
[0m[0m2017-09-12 12:36:48,232 INFO  [org.wildfly.swarm.runtime.deployer] (main) deploying 507ac020-cc98-4956-9c88-418869842dcf.war
[0m[0m2017-09-12 12:36:48,252 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-4) WFLYSRV0027: Starting deployment of "507ac020-cc98-4956-9c88-418869842dcf.war" (runtime-name: "507ac020-cc98-4956-9c88-418869842dcf.war")
[0m[33m2017-09-12 12:36:49,676 WARN  [org.jboss.as.dependency.private] (MSC service thread 1-8) WFLYSRV0018: Deployment "deployment.507ac020-cc98-4956-9c88-418869842dcf.war" is using a private module ("org.jboss.jts:main") which may be changed or removed in future versions without notice.
[0m[0m2017-09-12 12:36:49,966 INFO  [org.jboss.as.ejb3.deployment] (MSC service thread 1-3) WFLYEJB0473: JNDI bindings for session bean named 'ProductRestBean' in deployment unit 'deployment "507ac020-cc98-4956-9c88-418869842dcf.war"' are as follows:

    java:global/507ac020-cc98-4956-9c88-418869842dcf/ProductRestBean!com.mycompany.ejb.ProductRestBeanInterface
    java:app/507ac020-cc98-4956-9c88-418869842dcf/ProductRestBean!com.mycompany.ejb.ProductRestBeanInterface
    java:module/ProductRestBean!com.mycompany.ejb.ProductRestBeanInterface
    java:global/507ac020-cc98-4956-9c88-418869842dcf/ProductRestBean
    java:app/507ac020-cc98-4956-9c88-418869842dcf/ProductRestBean
    java:module/ProductRestBean

as we can observe, it creates the war file:

507ac020-cc98-4956-9c88-418869842dcf.war

instead of:

TestProject.war

I would be very delighted to have some insights on how to prevent Eclipse from creating the randomly named war file and use the intended war file name which is TestProject.war.

Thanks a lot! And have a great day =)!


Solution

  • The solution is to add these lines in to the projects-default.yml of your project.

    swarm:
      app:
        name: TestProject.war