1

As my title already explains, i would like to know how to combine these technologies?

I already tried the combination JEE6-Maven-Glassfish-EJB-JSF2-Hibernate-PrettyFaces, but the problem is that the glassfish mojarra implementation can not be replaced by a newer version through pom.xml and the included mojarra version can not work with prettyfaces. Anyways on a real system i would replace the internal jars to get this to work.

Now i am trying the combination JEE6-Maven-Tomcat-EJB-JSF2-Hibernate-Prettyfaces but somehow EJB does not work properly. I know that Apache does not ship a jsf implementation with Tomcat so i added the dependency in the pom for the newest mojarra implementation.

There is also a strange behaviour with tomcat, i try to deploy a webapp on context path "/" and with firefox i get the tomcat startpage loading localhost:8080 and with chrome i get my application view. What could be the problem?

Here you can see my pom.xml:

<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.pkg</groupId>
<artifactId>App</artifactId>
<version>1.0</version>
<packaging>war</packaging>

<name>App</name>

<properties>
    <endorsed.dir>${project.build.directory}/endorsed</endorsed.dir>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <netbeans.hint.deploy.server>Tomcat70</netbeans.hint.deploy.server>
</properties>

<repositories>
    <repository>
        <id>JBoss</id>
        <name>JBoss Repsitory</name>
        <layout>default</layout>
        <url>http://repository.jboss.org/maven2</url>
    </repository>

    <repository>
        <id>jboss-snapshot</id>
        <url>http://snapshots.jboss.org/maven2</url>
        <releases>
        </releases>
        <snapshots>
        </snapshots>
    </repository>

    <repository>
        <url>http://download.java.net/maven/2/</url>
        <id>hibernate-support</id>
        <layout>default</layout>
        <name>Repository for library Library[hibernate-support]</name>
    </repository>
</repositories>

<dependencies>
    <dependency>
        <groupId>log4j</groupId>
        <artifactId>log4j</artifactId>
        <version>1.2.15</version>
        <exclusions>
            <exclusion>
                <groupId>javax.mail</groupId>
                <artifactId>mail</artifactId>
            </exclusion>
            <exclusion>
                <groupId>javax.jms</groupId>
                <artifactId>jms</artifactId>
            </exclusion>
            <exclusion>
                <groupId>com.sun.jdmk</groupId>
                <artifactId>jmxtools</artifactId>
            </exclusion>
            <exclusion>
                <groupId>com.sun.jmx</groupId>
                <artifactId>jmxri</artifactId>
            </exclusion>
        </exclusions>
    </dependency>

    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-core</artifactId>
        <version>3.3.2.GA</version>
    </dependency>

    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-annotations</artifactId>
        <version>3.4.0.GA</version>
    </dependency>

    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-commons-annotations</artifactId>
        <version>3.3.0.ga</version>
    </dependency>

    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-entitymanager</artifactId>
        <version>3.3.2.GA</version>
    </dependency>

    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate</artifactId>
        <version>3.2.5.ga</version>
    </dependency>

    <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
        <version>5.0.5</version>
    </dependency>

    <dependency>
        <groupId>com.ocpsoft</groupId>
        <artifactId>prettyfaces-jsf2</artifactId>
        <version>3.2.0</version>
    </dependency>

    <dependency>
        <groupId>javax.sql</groupId>
        <artifactId>jdbc-stdext</artifactId>
        <version>2.0</version>
    </dependency>

    <dependency>
        <groupId>javax.transaction</groupId>
        <artifactId>jta</artifactId>
        <version>1.0.1B</version>
    </dependency>
    <dependency>
        <groupId>com.sun.faces</groupId>
        <artifactId>jsf-api</artifactId>
        <version>2.1.1-b04</version>
    </dependency>
    <dependency>
        <groupId>com.sun.faces</groupId>
        <artifactId>jsf-impl</artifactId>
        <version>2.1.1-b04</version>
    </dependency>
    <dependency>
        <groupId>javax</groupId>
        <artifactId>javaee-web-api</artifactId>
        <version>6.0</version>
        <scope>provided</scope>
    </dependency>

    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.8.1</version>
        <scope>test</scope>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>2.3.2</version>
            <configuration>
                <source>1.6</source>
                <target>1.6</target>
                <compilerArguments>
                    <endorseddirs>${endorsed.dir}</endorseddirs>
                </compilerArguments>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-war-plugin</artifactId>
            <version>2.1</version>
            <configuration>
                <failOnMissingWebXml>false</failOnMissingWebXml>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-dependency-plugin</artifactId>
            <version>2.1</version>
            <executions>
                <execution>
                    <phase>validate</phase>
                    <goals>
                        <goal>copy</goal>
                    </goals>
                    <configuration>
                        <outputDirectory>${endorsed.dir}</outputDirectory>
                        <silent>true</silent>
                        <artifactItems>
                            <artifactItem>
                                <groupId>javax</groupId>
                                <artifactId>javaee-endorsed-api</artifactId>
                                <version>6.0</version>
                                <type>jar</type>
                            </artifactItem>
                        </artifactItems>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
    <finalName>App</finalName>
</build>

Christian Beikov
  • 15,141
  • 2
  • 32
  • 58

2 Answers2

4

Why not just upgrade the GlassFish Mojarra JARs?

  • Download new Mojarra http://javaserverfaces.java.net/download.html
  • Shutdown GlassFish 3
  • Replace the Mojarra files jsf-impl.jar and jsf-api.jar in the glassfishv3/glassfish/modules directory with the new Mojarra files jsf-impl.jar and jsf-api.jar.
  • Delete everything in the glassfish/domains/domain1/osgi-cache directory
  • Start GlassFish
  • Verify that the string new Mojarra 2.x.x appears in the GlassFish log file when JSF applications are started

http://forums.netbeans.org/post-97832.html#97832

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
Lincoln
  • 3,151
  • 17
  • 22
0

That is strange that you would get two different web applications from the same context like that on different browsers. I would suspect at this point that one or more of the browsers are returning cached pages somehow. Did you try clearing your browser caches in both browsers and try again?

With Glassfish, I replaced the Mojarra jar files that come bundled with the version of Mojarra that I need. This is the correct thing to do.

Can you elaborate your problems with JEE6 however? Glassfish 3.1 is supposed to be JEE6 compliant so what exactly "isn't working" for you?

maple_shaft
  • 10,435
  • 6
  • 46
  • 74
  • With Tomcat 7 the injection of EJBs is not working, i am annotating a field with @EJB but the object gets not injected. I did not try to just replace the libraries in glassfish but it would be helpful to know how to get my application to run within tomcat. the problem with two different outputs on the same context was a cache problem. – Christian Beikov May 20 '11 at 11:44
  • 2
    Tomcat is a servlet container and NOT an EJB container. There do exist extensions to Tomcat however that can provide JEE support. See the OpenEJB project. http://openejb.apache.org/ – maple_shaft May 20 '11 at 12:21
  • Thank you! Probably Glassfish or Jboss AS will then be my choice. – Christian Beikov May 20 '11 at 13:34