Maven,JEE6,Tomcat 7 / Glassfish 3.1,EJB,JSF2,Hibernate / JPA和PrettyFaces [英] Maven, JEE6, Tomcat 7/Glassfish 3.1, EJB, JSF2, Hibernate/JPA and PrettyFaces

查看:118
本文介绍了Maven,JEE6,Tomcat 7 / Glassfish 3.1,EJB,JSF2,Hibernate / JPA和PrettyFaces的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的标题已经解释了,我想知道如何组合这些技术?



我已经尝试过JEE6-Maven-Glassfish-EJB-JSF2- Hibernate-PrettyFaces,但问题是,glassfish mojarra实现无法通过pom.xml替换为较新版本,并且包含的​​mojarra版本无法使用prettyfaces。无论如何,在真正的系统上,我将替换内部的jar来使其工作。



现在我正在尝试组合JEE6-Maven-Tomcat-EJB-JSF2-Hibernate-但是不知何故,EJB无法正常工作。我知道Apache不会在Tomcat中运行jsf实现,所以我添加了最新的mojarra实现的pom中的依赖关系。



tomcat还有一个奇怪的行为,我尝试在上下文路径/部署一个webapp,并使用firefox,我得到tomcat startpage加载localhost:8080和chrome我得到我的应用程序视图。可能是什么问题?



这里可以看到我的pom.xml:

 < project xmlns =http://maven.apache.org/POM/4.0.0xmlns: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>
< approvaled.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>库库的库[hibernate-support]< / name>
< / repository>
< / repositories>

<依赖关系>
<依赖关系>
< groupId> log4j< / groupId>
< artifactId> log4j< / artifactId>
< version> 1.2.15< / version>
<排除>
< exclude>
< groupId> javax.mail< / groupId>
< artifactId> mail< / artifactId>
< / exclusion>
< exclude>
< groupId> javax.jms< / groupId>
< artifactId> jms< / artifactId>
< / exclusion>
< exclude>
< groupId> com.sun.jdmk< / groupId>
< artifactId> jmxtools< / artifactId>
< / exclusion>
< exclude>
< groupId> com.sun.jmx< / groupId>
< artifactId> jmxri< / artifactId>
< / exclusion>
< / exclusions>
< / dependency>

<依赖关系>
< groupId> org.hibernate< / groupId>
< artifactId> hibernate-core< / artifactId>
< version> 3.3.2.GA< / version>
< / dependency>

<依赖关系>
< groupId> org.hibernate< / groupId>
< artifactId> hibernate-annotations< / artifactId>
< version> 3.4.0.GA< / version>
< / dependency>

<依赖关系>
< groupId> org.hibernate< / groupId>
< artifactId> hibernate-commons-annotations< / artifactId>
< version> 3.3.0.ga< / version>
< / dependency>

<依赖关系>
< groupId> org.hibernate< / groupId>
< artifactId> hibernate-entitymanager< / artifactId>
< version> 3.3.2.GA< / version>
< / dependency>

<依赖关系>
< groupId> org.hibernate< / groupId>
< artifactId> hibernate< / artifactId>
< version> 3.2.5.ga< / version>
< / dependency>

<依赖关系>
< groupId> mysql< / groupId>
< artifactId> mysql-connector-java< / artifactId>
< version> 5.0.5< / version>
< / dependency>

<依赖关系>
< groupId> com.ocpsoft< / groupId>
< artifactId> prettyfaces-jsf2< / artifactId>
< version> 3.2.0< / version>
< / dependency>

<依赖关系>
< groupId> javax.sql< / groupId>
< artifactId> jdbc-stdext< / artifactId>
< version> 2.0< / version>
< / dependency>

<依赖关系>
< groupId> javax.transaction< / groupId>
< artifactId> jta< / artifactId>
< version> 1.0.1B< / version>
< / dependency>
<依赖关系>
< groupId> com.sun.faces< / groupId>
< artifactId> jsf-api< / artifactId>
< version> 2.1.1-b04< / version>
< / dependency>
<依赖关系>
< groupId> com.sun.faces< / groupId>
< artifactId> jsf-impl< / artifactId>
< version> 2.1.1-b04< / version>
< / dependency>
<依赖关系>
< groupId> javax< / groupId>
< artifactId> javaee-web-api< / artifactId>
< version> 6.0< / version>
< scope>已提供< / scope>
< / 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>
< approvaleddirs> $ {approvaled.dir}< / approvaleddirs>
< / 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>
<执行>
< execution>
< phase> validate< / phase>
< goals>
< goal> copy< / goal>
< / goals>
< configuration>
< outputDirectory> $ {approvaled.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>

解决方案

为什么不升级GlassFish Mojarra JAR?




  • 下载新的Mojarra http://javaserverfaces.java.net/download.html

  • 关闭GlassFish 3

  • 使用新的Mojarra文件
    jsf-impl.jar和jsf-api替换
    glassfishv3 / glassfish / modules目录中的Mojarra文件jsf-impl.jar和jsf-api.jar .jar。

  • 删除glassfish / domains / domain1 / osgi-cache目录中的所有内容

  • 启动GlassFish

  • 验证当JSF应用程序启动时,新的Mojarra 2.xx字符串出现在GlassFish
    日志文件中



< a href =http://forums.netbeans.org/post-97832.html#97832 =nofollow> http://forums.netbeans.org/post-97832.html#97832


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>

解决方案

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

这篇关于Maven,JEE6,Tomcat 7 / Glassfish 3.1,EJB,JSF2,Hibernate / JPA和PrettyFaces的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆