Different Mojarra versions for standalone instances in GlassFish 3 - maven

How can I deploy a web-app (war) on different GlassFish standalone instances, while using different Mojarra versions on every instance.
We are planning to update the used Mojarra version from 2.1.6 used default by GF 3.1.2.2 to Mojarra 2.1.24. In our JSF Applications we are using PrimeFaces from version 2.2 to 3.5. Before we go in production with our application, after Mojarra update, we want to test it on a standalone GlassFish instance within the same Node.
How can we accomplish, that the app deployed on this standalone instance is using different Mojarra version then available on the domain administration server. The project is build with maven.
<dependency>
<groupId>org.glassfish</groupId>
<artifactId>javax.faces</artifactId>
<version>2.1.24</version>
<scope>runtime</scope>
</dependency>
Tried scope of the dependency with compile, provided and runtime. While deploying
[#|2013-10-25T13:11:25.122+0200|INFO|glassfish3.1.2|javax.enterprise.resource.webcontainer.jsf.config|_ThreadID=150;_ThreadName=Thread-2;|Mojarra 2.1.6 (SNAPSHOT 20111206) für Kontext '/TestApp'
Even putting javax.jaces.jar in instance-root/lib/applibs and setting --libraries option while deploying dowsn't work.
Thanks for any ideas.

Well, what you can do is using Maven profiles to include conditional dependencies. Glassfish contains jsf API and implementation out of the box. So what you need for your project is to specify what API you want to code against, marking it as provided as you don't need to deploy them:
<profiles>
<profile>
<id>old-glassfish</id>
<dependencies>
<dependency>
<groupId>javax.faces</groupId>
<artifactId>jsf-api</artifactId>
<version>2.0</version>
<scope>provided</scope>
</dependency>
</dependencies>
</profile>
<profile>
<id>new-glassfish</id>
<dependencies>
<dependency>
<groupId>javax.faces</groupId>
<artifactId>jsf-api</artifactId>
<version>2.1</version>
<scope>provided</scope>
</dependency>
</dependencies>
</profile>
</profiles>
I don't do Glassfish, but also you should change the provided JSF libraries to stablish the one you're interested in. There are some threads here at SO which explain what you have to do to update them.
Otherways, you could also use your own JSF implementation for each application, configuring the server properly not to use its bundled libraries.
See also:
How to update Mojarra version in GlassFish

Related

change default web server on spring-boot 2.4.4

I'm working with Spring Boot 2.4.4 and I would change the default web server Tomcat to undertow orJHetty but I find it very difficult using both Gradle or Maven.
An old documentation exposes how do it but I'm sure all is changed because now tomcat, undertow and jetty configuration is embedded in the core library:
https://docs.spring.io/spring-boot/docs/2.1.9.RELEASE/reference/html/howto-embedded-web-servers.html
How do it in the 2.4.4 version?
There are no changes between the versions. This is well described right at the Spring Boot 2.4.4 Reference guide, right in 3.1. Use Another Web Server section. Basically, the change consists of two steps:
Exclude embedded Tomcat server dependency from the spring-boot-starter-web artifact:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<!-- Exclude the Tomcat dependency -->
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
</dependency>
Include your embedded server as a separate dependency instead:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jetty</artifactId>
</dependency>
Just don't forget to notice the following quote from the reference guide in the very same section which might or might not be relevant to you:
The version of the Servlet API has been overridden as, unlike Tomcat 9 and Undertow 2.0, Jetty 9.4 does not support Servlet 4.0.
follow three steps to change the default web server, change configuration in pom.xml.
1.exclude the default web server.
2.Include the necessary web server.
3.Maven update.
For example,
Instead of this
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</dependency>
Add this one
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jetty</artifactId>
</dependency>
for the necessary server add the appropriate web server dependency.

Add features Websphere Liberty profile to the application

Am migrating an application from websphere to websphere liberty and have to migrate JSf bean validation components. How to add the WLP features to the web project using Maven .I have added
<dependency>
<groupId>net.wasdev.maven.tools.targets</groupId>
<artifactId>liberty-target</artifactId>
<version>RELEASE</version>
<type>pom</type>
<scope>provided</scope>
</dependency>
but that doesn't get me the JSF and bean validation related classes .
I'd recommend following the example in the Open Liberty guide:
https://openliberty.io/guides/getting-started.html
The basic approach involves:
Using aggregate dependencies for compile:
<dependency>
<groupId>jakarta.platform</groupId>
<artifactId>jakarta.jakartaee-api</artifactId>
<version>8.0.0</version>
<scope>provided</scope>
</dependency>
Using the server.xml to do fine-grained feature enablement, only activating the features you're using, so for the features you mentioned, you might have:
<server description="Sample Liberty server">
<featureManager>
<feature>beanValidation-2.0</feature>
<feature>jsf-2.3</feature>
<feature>cdi-2.0</feature>
<!-- .... -->
</featureManager>
Also note, though it's not directly related to your question, you might as well be sure to use the 3.x version of the liberty-maven-plugin, with "dev mode" and a lot of other useful function:
<plugin>
<groupId>io.openliberty.tools</groupId>
<artifactId>liberty-maven-plugin</artifactId>
<version>3.2</version>
</plugin>

Standard way of adding JSLT 1.2.1 in a Maven Project?

What is the standard pom for adding the 1.2.1 JSTL taglib in a maven project. Any recommendations as to when/if can this be scoped as provided ? Any server peculiarities (interested in Jboss 7, Glassfish 4 and/or Tomcat 7)
EDIT: Added:
<dependency>
<groupId>org.glassfish.web</groupId>
<artifactId>javax.servlet.jsp.jstl</artifactId>
<version>1.2.1</version>
<scope>provided</scope>
</dependency>
This adds:
Notice it transitively adds the 1.2 api.
I am using provided as I am using Jboss which should provide it: Basic question complicated solution - Tomcat to JBoss. Still this is the 1.2 api apparently
$ find . -name *jstl*.jar
./modules/javax/servlet/jstl/api/main/jboss-jstl-api_1.2_spec-1.0.2.Final.jar
(contains implementation also). So would the correct way be to add the jstl jars to the pom (not in provided scope) and mark the servlet-api (I'm on 3 anyway) as provided somehow ?
Ended up using :
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
<scope>provided</scope>
</dependency>
<!-- Add the jstl-api dependency explicitly - otherwise jstl-api 1.2 is added -->
<dependency>
<groupId>javax.servlet.jsp.jstl</groupId>
<artifactId>javax.servlet.jsp.jstl-api</artifactId>
<version>1.2.1</version>
</dependency>
<dependency>
<groupId>org.glassfish.web</groupId>
<artifactId>javax.servlet.jsp.jstl</artifactId>
<version>1.2.1</version>
<exclusions>
<!-- jstl-api was adding selvlet-api 2.5 and jsp-api-->
<exclusion>
<artifactId>jstl-api</artifactId>
<groupId>javax.servlet.jsp.jstl</groupId>
</exclusion>
</exclusions>
</dependency>
Not sure if I should add the jstl-api dependency - please comment (I would accept a more authoritative answer actually). Result:
See:
Autocomplete with JSP, JSTL 1.2.1 and Servlet 3.0 in Tomcat 7 with Eclipse Kepler
Fix maven JSTL 1.2.1 dependency so maven-war-plugin doesn't package JARs that offend Tomcat 7
JBoss 7.1 - Migration to JSF 2.2 - includes how to upgrate your jstl to 1.2.1
For 1.2:
Running JSTL 1.2 on Tomcat 7 using Maven

Jetty plugin only maven dependency

I'm developing CXF web services with JDK 7 + Eclipse Juno + Maven 3 and deploying on a WebSphere 7 Application Server.
I've spent hours to fiund the right configuration of dependencies (a complex mix of runtime, system, compile and provided scopes) that the WAS accepts without conflicts, but with this configuration my jetty plug in does not work anymore.
How can I specify a classpath specific only for the Jetty plugin (hopefully a maven configuration)?
AFAIK, the only way to make the jetty plugin working properly regarding all those dependency issues is to specify all dependencies that are <provided> in your webapp as direct dependencies of the jetty plugin (and unfortunately, this brings kind of redundancy):
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>9.0.0.v20130308</version>
...
<dependencies>
<!-- put here all your dependencies with scope provided in your webapp -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>3.0</version>
</dependency>
...
</dependencies>
</plugin>

JBoss AS 7 maven dependency for standalone client

We have a standalone desktop client that connects to a JBoss server. For version 6 of JBoss the maven dependency used by the desktop client project was
<dependency>
<groupId>org.jboss.jbossas</groupId>
<artifactId>jboss-as-client</artifactId>
</dependency>
For JBoss 7.1.1 no such dependency exists. What is the correct maven dependency that should be used when developing a standalone desktop client?
If you directly connect to EJB you need the EJB client libs.In earlier versions of JBoss AS7 there were a bunch of individual dependencies required. Starting (AFAIK) from 7.1.1-Final a BOM (bill of materials) is available:
<dependencies>
<dependency>
<groupId>org.jboss.as</groupId>
<artifactId>jboss-as-ejb-client-bom</artifactId>
<version>7.1.1.Final</version>
<type>pom</type>
</dependency>
</dependencies>
You will find here detailed information on JNDI lookups and invoking methods.
I'm not too familiar with the JBoss AS 6 client, but for the JBoss AS 7 one you would need the following.
<dependencies>
<dependency>
<groupId>org.jboss.as</groupId>
<artifactId>jboss-as-controller-client</artifactId>
<version>${as.version}</version>
</dependency>
</dependencies>
You'll be using the org.jboss.as.controller.client.ModelControllerClient for standalone or org.jboss.as.controller.client.helpers.domain.DomainClient for domain mode.

Resources