0

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.

AdemC
  • 406
  • 6
  • 16
  • Glassfish, as a JavaEE application container, provides its own JSF implementation which you can change. Are you planning to have different versions on different servers and just change your war's mojarra version? – Aritz Oct 26 '13 at 10:37
  • That's right. I have a DAS and many standalone instances on the same machine. The reason for this is quite simple. Some of my Web-Apps are running on Mojarra 2.1.6 and are stable. But one of the Web-App is running with Primefaces and needs a newer version of Mojarra. But I dont't want to update the hole DAS and all the standalone instances. No time to test all the Web-Apps on every instance. Is it possible to bind a specific Version of `javax.faces.jar' to the Application over `pom.xml'. – AdemC Oct 28 '13 at 09:35
  • OK, but what I want to know is, are you running a single instance of glassfish for all the applications or are there different ones? I mean, each glassfish instance could only contain one specific implementation. – Aritz Oct 28 '13 at 09:41
  • Thats also right. One instance has only one application. Some instances have more than one if they are not critical. The reason for this constellation is, I can restart instances without interrupting other applications. – AdemC Oct 28 '13 at 09:44

1 Answers1

1

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

Community
  • 1
  • 1
Aritz
  • 30,971
  • 16
  • 136
  • 217