0

I've built an application in Spring, and would like to get it running in wildfly. It is NOT a webapp, so the packaging is jar.

Upon startup, jboss reports that it has loaded it:

14:50:42,899 INFO  [org.jboss.weld.deployer] (MSC service thread 1-2) WFLYWELD0003: Processing weld deployment APPLICATION_cnp.jar
14:50:42,949 INFO  [org.jboss.weld.deployer] (MSC service thread 1-2) WFLYWELD0006: Starting Services for CDI deployment: cnp.ear
14:50:43,031 INFO  [org.jboss.weld.Version] (MSC service thread 1-2) WELD-000900: 2.2.16 (SP1)
14:50:43,066 INFO  [org.jboss.weld.deployer] (MSC service thread 1-3) WFLYWELD0009: Starting weld service for deployment cnp.ear
14:50:45,517 INFO  [org.jboss.as.server] (Controller Boot Thread) WFLYSRV0010: Deployed "cnp.ear" (runtime-name : "cnp.ear")

The entry point for the application is this class:

//@Configuration
//@ComponentScan
//@EnableAutoConfiguration
//3 above added as per https://stackoverflow.com/questions/35786401/
@SpringBootApplication
//3 below added to try and get java EE to bootstrap the app
//@Startup
//@Singleton
//@ApplicationScoped
public class CNPApplication {

private static final Logger log = LoggerFactory.getLogger(CNPApplication.class);

public static void main(String[] args) throws Exception {
    SpringApplication.run(CNPApplication.class);
}

public CNPApplication() {
    System.out.println("CNPApplication instantiated");
}

@PostConstruct
public void bootstrap() {
    System.out.println("CNPApplication bootstrap");
    SpringApplication.run(CNPApplication.class);

}

}

My pom file looks like this:

<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.mycompany</groupId>
<artifactId>APPLICATION_cnp</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>

<name>APPLICATION_cnp</name>
<description>Courtesy Notification Processor</description>

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.4.1.RELEASE</version>
    <relativePath/> 
</parent>

<properties>
    <java.version>1.8</java.version>
    <maven.compiler.target>1.8</maven.compiler.target>
    <maven.compiler.source>1.8</maven.compiler.source>
</properties>

<dependencies>
   <dependency>
        <groupId>javax</groupId>
        <artifactId>javaee-api</artifactId>
        <version>7.0</version>
        <scope>compile</scope>
    </dependency>
</dependencies>

I've deployed it as part of an EAR. The wildfly admin console shows a deployment called cnp.ear, with a nested deployment APPLICATION_cnp.jar.

The System.out.println calls in the CNPApplication class are not being called. I've tried all the annotations at the top of the class, and I've tried adding a beans.xml. With the beans.xml added, I get a stack trace at startup: Unable to resolve a bean for 'javax.persistence.EntityManager' - This link suggested that I resolve this by removing the beans.xml because it causes JAVA EE CDI to conflict with spring.

How do I actually get the thing to run?

Community
  • 1
  • 1
mdarwin
  • 1,684
  • 7
  • 28
  • 72
  • See https://spring.io/blog/2014/03/07/deploying-spring-boot-applications – mh-dev Oct 13 '16 at 14:25
  • I've seen that documentation. It appears only to be applicable for web applications, since it tells me to change the packaging to war. But this is not a web application. – mdarwin Oct 13 '16 at 14:26
  • Its a while since I used EE Servers, but back then they only understand wars. They even don't care about the main method. As you could see in the linked blog entry. – mh-dev Oct 13 '16 at 14:29

0 Answers0