He desarrollado una aplicación de inicio de la primavera independiente que sirve un servicio de descanso, he empaquetado como jar
y funciona correctamente. Con el fin de liberarlo en el servidor de producción (Websphere), tengo que convertirla en una war
.
He actualizado mi pom.xml
añadiendo estas líneas:
<properties>
<maven.compiler.target>1.7</maven.compiler.target>
<maven.compiler.source>1.7</maven.compiler.source>
</properties>
<packaging>war</packaging>
<build>
<finalName>${artifactId}</finalName>
</build>
Entonces, puse en marcha maven clean package
y consigo el war
. Así, publicarla en un servidor Tomcat bien funciona, pero en libertad me sale el error:
Error 404: SRVE0190E: File not found /
También he modificado mi punto de entrada como la siguiente:
@SpringBootApplication
@PropertySource("classpath:alerts.properties")
public class WebApplication extends SpringBootServletInitializer
{
// public static void main(String[] args) {
// SpringApplication.run(WebApplication.class, args);
// }
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(WebApplication.class);
}
}
Sin éxito, así que ... ¿cómo puedo ejecutar una guerra de arranque primavera en un servidor de la Libertad?
ACTUALIZAR
Como @Anjum Fatima sugirió, También he añadido las características deserver.xml
<feature>jsp-2.3</feature>
<feature>springBoot-2.0</feature>
<feature>servlet-3.1</feature>
Antes, en ese archivo También he añadido:
<library>
<file id="alerts.properties" name="${shared.resource.dir}/alerts.properties"/>
</library>
<webApplication id="alerts" location="alerts.war" name="alerts">
Y en wlp18\usr\shared\resources
He copiado el archivo de propiedades.
Pero todavía tengo el mismo error.
El alert.properties
archivo:
spring.datasource.url=jdbc:h2:file:~/alertsdb;DB_CLOSE_ON_EXIT=FALSE;AUTO_RECONNECT=TRUE
spring.datasource.username=admin
spring.datasource.password=mypassword
spring.datasource.driver-class-name=org.h2.Driver
spring.jpa.show-sql=true
spring.jpa.hibernate.ddl-auto=update
spring.h2.console.enabled=true
spring.h2.console.settings.web-allow-others=true
spring.mvc.view.prefix: /
spring.mvc.view.suffix: .jsp
spring.messages.basename=validation
ACTUALIZACIÓN 2
El servidor es casi comenzó, pero no puede encontrar algunos archivos como com.ibm.ws.kernel.boot.nls_1.0.22.jar
, en lib de la carpeta de la Libertad está el archivo com.ibm.ws.kernel.boot_1.0.22.jar
(y sin .nls
) Aquí está la salida de la consola, lo que me estoy perdiendo?
2020-03-18 13:44:38.950 INFO 34004 --- [ecutor-thread-4] it.mycompany.alerts.WebApplication : Started WebApplication in 10.915 seconds (JVM running for 24.544)
[WARNING ] The XML schema [web-jsptaglibrary_2_1.xsd] could not be found. This is very likely to break XML validation if XML validation is enabled.
[WARNING ] The XML schema [javaee_5.xsd] could not be found. This is very likely to break XML validation if XML validation is enabled.
[WARNING ] The XML schema [jsp_2_1.xsd] could not be found. This is very likely to break XML validation if XML validation is enabled.
[WARNING ] The XML schema [javaee_web_services_1_2.xsd] could not be found. This is very likely to break XML validation if XML validation is enabled.
[WARNING ] The XML schema [javaee_web_services_client_1_2.xsd] could not be found. This is very likely to break XML validation if XML validation is enabled.
[WARNING ] The XML schema [web-app_3_0.xsd] could not be found. This is very likely to break XML validation if XML validation is enabled.
[WARNING ] The XML schema [web-fragment_3_0.xsd] could not be found. This is very likely to break XML validation if XML validation is enabled.
[WARNING ] The XML schema [web-common_3_0.xsd] could not be found. This is very likely to break XML validation if XML validation is enabled.
[WARNING ] The XML schema [javaee_6.xsd] could not be found. This is very likely to break XML validation if XML validation is enabled.
[WARNING ] The XML schema [jsp_2_2.xsd] could not be found. This is very likely to break XML validation if XML validation is enabled.
[WARNING ] The XML schema [javaee_web_services_1_3.xsd] could not be found. This is very likely to break XML validation if XML validation is enabled.
[WARNING ] The XML schema [javaee_web_services_client_1_3.xsd] could not be found. This is very likely to break XML validation if XML validation is enabled.
[WARNING ] The XML schema [web-app_3_1.xsd] could not be found. This is very likely to break XML validation if XML validation is enabled.
[WARNING ] The XML schema [web-fragment_3_1.xsd] could not be found. This is very likely to break XML validation if XML validation is enabled.
[WARNING ] The XML schema [web-common_3_1.xsd] could not be found. This is very likely to break XML validation if XML validation is enabled.
[WARNING ] The XML schema [javaee_7.xsd] could not be found. This is very likely to break XML validation if XML validation is enabled.
[WARNING ] The XML schema [javaee_web_services_1_4.xsd] could not be found. This is very likely to break XML validation if XML validation is enabled.
[WARNING ] The XML schema [javaee_web_services_client_1_4.xsd] could not be found. This is very likely to break XML validation if XML validation is enabled.
[WARNING ] The XML schema [web-app_4_0.xsd] could not be found. This is very likely to break XML validation if XML validation is enabled.
[WARNING ] The XML schema [web-fragment_4_0.xsd] could not be found. This is very likely to break XML validation if XML validation is enabled.
[WARNING ] The XML schema [web-common_4_0.xsd] could not be found. This is very likely to break XML validation if XML validation is enabled.
[WARNING ] The XML schema [javaee_8.xsd] could not be found. This is very likely to break XML validation if XML validation is enabled.
[WARNING ] Failed to scan [file:/C:/lang/appserver/wlp/wlp18/lib/com.ibm.ws.kernel.boot.nls_1.0.22.jar] from classloader hierarchy
C:\lang\appserver\wlp\wlp18\lib\com.ibm.ws.kernel.boot.nls_1.0.22.jar (File not found)
Gracias
Por último funciona, empecé con un nuevo proyecto. Aquí la pom.xml
(con liberty-maven-plugin
):
<?xml version="1.0" encoding="UTF-8"?>
<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>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.2.5.RELEASE</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<groupId>it.mycompany</groupId>
<artifactId>alerts</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.source>1.8</maven.compiler.source>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.ibm.mq</groupId>
<artifactId>com.ibm.mq.allclient</artifactId>
<version>9.1.4.0</version>
</dependency>
</dependencies>
<packaging>war</packaging>
<build>
<finalName>${artifactId}</finalName>
<plugins>
<plugin>
<groupId>io.openliberty.tools</groupId>
<artifactId>liberty-maven-plugin</artifactId>
<version>3.2</version>
<configuration>
<appsDirectory>apps</appsDirectory>
<mainClass>${start-class}</mainClass>
</configuration>
</plugin>
</plugins>
</build>
</project>
La clase de punto de entrada:
@SpringBootApplication
@PropertySource("classpath:alerts.properties")
public class WebApplication extends SpringBootServletInitializer {
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(WebApplication.class);
}
}
He creado la guerra con mvn clean install
continuación he copiado desde el directorio de destino para wlp/servers/myserver/apps
(no dropins
)
Finalmente me puse el server.xml
como el siguiente:
<server description="Tester">
<featureManager>
<feature>servlet-4.0</feature>
<feature>localConnector-1.0</feature>
<feature>jsp-2.3</feature>
<feature>springBoot-2.0</feature>
</featureManager>
<httpEndpoint host="*" httpPort="9080" httpsPort="9443"
id="defaultHttpEndpoint" />
<library>
<file id="alerts.properties"
name="${shared.resource.dir}/alerts.properties" />
</library>
<webApplication id="alerts" location="alerts.war"
name="alerts" contextRoot="/" />
</server>
La libertad Server inicia bien, funciona la aplicación, el único problema es que responde a localhost:9080/login
y no a localhost:9080/alerts/login
. Sin embargo se logra el objetivo de la pregunta, he creado un archivo de la guerra y se ejecuta en un servidor de la libertad.
Gracias a todos y en especial gracias a @ScottKurz y @Anjum Fátima.