Migrating AppEngine application to Java 11 runtime - [http://java.sun.com/jsp/jstl/core] cannot be resolved - maven

So I have an AppEngine application that I'm working on migrating to the Java 11 runtime, and am using the appengine-simple-jetty-main artifact, as outlined in https://cloud.google.com/appengine/docs/standard/java-gen2/war-packaging, to replace the built-in Jetty server of the old Java 8 runtime.
Now if I use mvn jetty:run to bring up my application locally, everything works fine. But when I try to run the appengine-simple-jetty-main wrapper via mvn exec:java -Dexec.args="<my application directory>/target/<application>.war", I hit an issue.
The server starts up fine, and executes various ServletContextListeners that use outside dependencies declared in my pom.xml. I'm also able to navigate to static HTML. When I try to navigate to a JSP Servlet, however, I'm getting the error
HTTP ERROR 500 org.apache.jasper.JasperException: The absolute uri: [http://java.sun.com/jsp/jstl/core] cannot be resolved in either web.xml or the jar files deployed with this application
And likewise, I get this same error when I actually deploy to AppEngine.
As mentioned before, this works just fine when I bypass appengine-simple-jetty-main wrapper using mvn jetty:run, and my pom.xml includes the dependency
<dependency>
<groupId>jakarta.servlet.jsp.jstl</groupId>
<artifactId>jakarta.servlet.jsp.jstl-api</artifactId>
<version>2.0.0</version>
</dependency>
My build section looks like
<build>
<plugins>
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>11.0.11</version>
</plugin>
<plugin>
<groupId>com.google.cloud.tools</groupId>
<artifactId>appengine-maven-plugin</artifactId>
<version>2.4.3</version>
<configuration>
<deploy.projectId>contra-program</deploy.projectId>
<deploy.version>GCLOUD_CONFIG</deploy.version>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>3.1.1</version>
<executions>
<execution>
<id>copy</id>
<phase>prepare-package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/appengine-staging</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
So I'm a bit flummoxed. Other maven dependencies seem to be getting brought in just fine. It's only the JSTL library that's having issues (so far, at least), and even then, only when I use the appengine-simple-jetty-main wrapper.
The nearest existing question I could find was cannot load JSTL taglib within embedded Jetty server, but I haven't had luck with the provided solutions (though I'm more than happy to admit the possibility that I'm just not applying one or more of them correctly).
Any pointers would be greatly appreciated :-)

Related

Spring Boot Admin - How to show app version (build-info) in wallboard?

I see on the web some images refferred to Spring Boot Admin showing the app version in the wallboard page.
I'm using latest version of SBA, currently 2.1.6 and i can't see the versions in the wallboard.
I see something like this.
Reading the documentation it seems that a maven plugin is needed:
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>build-info</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
I added it in the pom.xml of a micro-service and I restarted all docker swarms stacks (including SBA) but no changes.
I did some search but I can't find any reference.
The 'spring-boot-maven-plugin' is required to generate the build-info in
/target/classes/META-INF/build-info.properties
Spring Boot Admin picks up the build info including the application version from this file. Please check if this file is generated.
You need to execute the maven plugin first or just run
mvn clean install
For Spring Boot applications
The easiest way 😄 to show the version, is to use the build-info goal from the spring-boot-maven-plugin, which generates the META-INF/build-info.properties.
1) Change/add the plugin in the pom.xml as below👇
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>build-info</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
2) Delete 🚮 your target folder and do a mvn clean install🧹
3) Restart your app and check the version is there 👏
I did so and it worked.
Src.➡Show Version in Application List
Dirty fix
If the previous solution does not work...
You can read the properties from the META-INF (in the jar) and concatenate it to the app name (here: myApp-service).
1) Do the previous step 👆 (add goal in maven plugin)
2) Add in the properties:
spring.config.import=classpath:META-INF/build-info.properties
spring.application.name=myApp-service ${build.version}
3) Check the result (image below 📸 )
Src.➡spring-boot-maven-plugin build-info.properties

Swagger CodeGen Dependency Issues

I'm trying to get a project up and running with Swagger codegen Maven plugin. I have the following plugin in my pom.xml.
<build>
<plugins>
<plugin>
<groupId>io.swagger</groupId>
<artifactId>swagger-codegen-maven-plugin</artifactId>
<version>3.0.0-rc1</version>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<inputSpec>${project.basedir}/src/main/resources/openapi.yaml</inputSpec>
<language>spring</language>
<configOptions>
<sourceFolder>src/gen/java/main</sourceFolder>
</configOptions>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
When I run mvn clean compile, I get a bunch of dependency errors. For example, fasterxml and threeten. I'm surprised that the dependencies wouldn't be automatically configured and that everything would work out of the box. Am I doing something wrong or do you really need to manually add the dependencies to pom.xml?
UPDATE
While digging through the code, I noticed there is a generated pom.xml (target/generated-sources/swagger with my config above) that seems to have the dependencies I need. Googling led to an issue thread concerning my problem. Looks like this is potentially a known issue.
The dependency copying worked when I used <language>jaxrs-resteasy</language> but I'm still working on other use cases (the spring I originally had and also jaxrs-jersey).

Is it possible to get the maven install plugin to deploy the ejb client jar?

After years of working with Spring, I'm working on a Java EE 7 application with EJB 3.2 and Maven. One thing I would like is to deploy the EJB Jars separately from the web application so I can develop independently. Including the EJB Jars in the WAR causes the app server to redefine the EJBs in the context of the WAR, which I don't want to happen.
The prescribed method is to have maven create a client jar with this directive:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ejb-plugin</artifactId>
<version>2.5.1</version>
<configuration>
<ejbVersion>3.2</ejbVersion>
<generateClient>true</generateClient>
<clientExcludes>
<clientExclude>**/*Impl.class</clientExclude>
</clientExcludes>
</configuration>
</plugin>
I'm excluding any Impls from the Client JAR.
The issue I'm having is that maven isn't installing the client jar during the install phase.
I can install it manually by doing this:
mvn install:install-file -Dfile=foo-1.0-client.jar -DgroupId=com.awesome -DartifactId=foo -Dversion=1.0 -Dpackaging=jar -Dclassifier=client
I fiddled around a lot and came up with this
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ejb-plugin</artifactId>
<version>2.5.1</version>
<configuration>
<ejbVersion>3.2</ejbVersion>
<generateClient>true</generateClient>
<clientExcludes>
<clientExclude>**/*Impl.class</clientExclude>
</clientExcludes>
</configuration>
<executions>
<execution>
<id>package</id>
<phase>package</phase>
<goals>
<goal>ejb</goal>
</goals>
</execution>
<execution>
<id>install</id>
<phase>install</phase>
</execution>
</executions>
</plugin>
</plugins>
However, this isn't proper. This installs the client as a new artifact, not as the same artifact with classifier client. When you include the client in another application, you are supposed to use ejb-client. This looks in your folder that contains the normal artifact, foo-1.0.jar, and looks for something with classifier client.
<dependency>
<groupId>com.awesome</groupId>
<artifactId>foo</artifactId>
<version>${com.awesome.version}</version>
<type>ejb-client</type>
</dependency>
Stumped here, any ideas?

Maven GPG Plugin 1.4 works fine, but 1.5 does not work

I am currently trying to sign my packaged jars etc. with the maven GPG Plugin (http://maven.apache.org/plugins/maven-gpg-plugin/sign-mojo.html).
I found on several sites (for example here: https://docs.sonatype.org/display/Repository/How+To+Generate+PGP+Signatures+With+Maven ) the hint, that one could do this with the following code in once pom.xml:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
Unfortunately, if I do this, and run maven package gpg:sign, it stops when trying to sign. If I add <version>1.4</version> (like in Maven GPG plugin not signing sources and javadoc jars), it works fine. Normally, it uses version 1.5, and if I specify that it should use this version, it does not work. Does anyone know what the reason of this behavoir is, and how I need to configure the maven-gpg plugin to run correctly with version 1.5?

Deploy a web-application on Websphere 8.5 using maven 3

I´m trying to make a Maven Project from an existing web application using JSF. The Project
should be deployed on Web Sphere 8.5.
Since i'm new to Web Sphere, don´t know how to build the "ear" Module, in order to be deployable on Web Sphere 8.5.
Does anyone know, where i can find further Information about deploying a web application on Web Sphere 8.5 using Maven 3.0.3?
Thanking you in anticipation,
Mosen
I've never worked with WebSphere Application Server 8.5; but in the days I was playing with IBM WAS 6.1 the WAS6 Maven plugin worked pretty well (it seems it works with WAS7 too). Here's a POM fragment from the plugin site that allows automatic EAR deployment:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>was6-maven-plugin</artifactId>
<version>1.2</version>
<executions>
<execution>
<id>integration-test</id>
<phase>integration-test</phase>
<goals>
<goal>installApp</goal>
</goals>
</execution>
</executions>
<configuration>
<wasHome>${was61home}</wasHome>
<host>deploymentmanager.your.domain</host>
<username>admin</username>
<password>adminpassword</password>
<targetCluster>nameOfCluster</targetCluster>
<profileName>Dmgr01</profileName>
<conntype>SOAP</conntype>
<port>8879</port>
<verbose>true</verbose>
<updateExisting>false</updateExisting>
</configuration>
</plugin>
That plugin is for deployment and other administrative task, for EAR generation you can use the Maven EAR Plugin as described in 20InchMovement answer.
Hope this could helps:
<plugin>
<groupId>com.orctom.mojo</groupId>
<artifactId>was-maven-plugin</artifactId>
<version>1.0.8</version>
<executions>
<execution>
<id>deploy</id>
<phase>install</phase>
<goals>
<goal>deploy</goal>
</goals>
<configuration>
<wasHome>${env.WAS_HOME}</wasHome>
<applicationName>${project.build.finalName}</applicationName>
<host>${local or remote address}</host>
<server>server01</server>
<node>node01</node>
<virtualHost>default_host</virtualHost>
<verbose>true</verbose>
</configuration>
</execution>
</executions>
</plugin>
From https://github.com/orctom/was-maven-plugin
in order to package an *.ear, you don't need Websphere.
This can be accomplished with maven itself.
pom.xml:
<project>
...
<artifactId>YourApp</
<packaging>ear</packaging>
...
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ear-plugin</artifactId>
<configuration>
<modules>
<jarModule>
<groupId>${project.parent.groupId}</groupId>
<artifactId>configurationApp</artifactId>
</jarModule>
<ejbModule>
<groupId>${project.parent.groupId}</groupId>
<artifactId>AnEjbModule</artifactId>
</ejbModule>
</modules>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
...
</project>
Then you add your dependencies.
On command line go to your project and run mvn package.
Because of the package defined in you pom.xml, the ear will be created and can be found in the YourApp/target directory.
On the websphere admin console you can simply install the ear.
After login, goto:
Applications->Websphere enterprise applications and install a new application.
Select your YourApp.ear and go for easiness through the fast path to install the app.
The port to check is probably
yourServerName:9080/YourApp.
Good luck.
See http://code.google.com/p/websphere-maven-plugin/
Websphere Maven Plugin provides goals to:
deploy ear on websphere 7
start application
stop application
uninstall
require websphere application client.

Resources