在Tomcat 7中部署的Myfaces,Facelets,Tomahawk和Maven失败了

时间:2012-07-03 01:33:23

标签: maven facelets myfaces tomahawk

让tomahawk跑步我遇到了很多麻烦。我刚才用myfaces hellworld20原型来创建一个新项目。现在我想用tomahawk扩展它。新的pom.xml看起来像这样:

<properties>
    <jsf-myfaces.version>2.1.8</jsf-myfaces.version>
</properties>
<build>
    <pluginManagement>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <version>2.2</version>
            </plugin>
        </plugins>
    </pluginManagement>
    <!-- To use the plugin goals in your POM or parent POM -->
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-war-plugin</artifactId>
        </plugin>
    </plugins>
</build>

<!-- Project dependencies -->
<dependencies>
    <dependency>
        <groupId>${project.groupId}</groupId>
        <artifactId>commons</artifactId>
        <version>${project.version}</version>
    </dependency>

    <dependency>
        <groupId>${project.groupId}</groupId>
        <artifactId>configuration</artifactId>
        <version>${project.version}</version>
    </dependency>

    <dependency>
        <groupId>${project.groupId}</groupId>
        <artifactId>application</artifactId>
        <version>${project.version}</version>
    </dependency>

    <dependency>
        <groupId>org.apache.geronimo.specs</groupId>
        <artifactId>geronimo-servlet_2.5_spec</artifactId>
        <version>1.2</version>
        <scope>provided</scope>
    </dependency>

    <dependency>
        <groupId>org.apache.geronimo.specs</groupId>
        <artifactId>geronimo-el_2.2_spec</artifactId>
        <version>1.0.2</version>
        <scope>provided</scope>
    </dependency>

    <dependency>
        <groupId>org.apache.geronimo.specs</groupId>
        <artifactId>geronimo-annotation_1.0_spec</artifactId>
        <version>1.1.1</version>
        <scope>provided</scope>
    </dependency>

    <dependency>
        <groupId>org.apache.myfaces.core</groupId>
        <artifactId>myfaces-api</artifactId>
        <version>${jsf-myfaces.version}</version>
        <scope>compile</scope>
    </dependency>

    <dependency>
        <groupId>org.apache.myfaces.core</groupId>
        <artifactId>myfaces-impl</artifactId>
        <version>${jsf-myfaces.version}</version>
        <scope>compile</scope>
    </dependency>

    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>jstl</artifactId>
        <version>1.2</version>
        <scope>runtime</scope>
    </dependency>

    <dependency>
        <groupId>org.apache.myfaces.tomahawk</groupId>
        <artifactId>tomahawk20</artifactId>
        <version>1.1.13</version>
        <scope>compile</scope>
    </dependency>

    <dependency>
        <groupId>org.apache.myfaces.tomahawk</groupId>
        <artifactId>tomahawk-sandbox</artifactId>
        <version>1.1.6</version>
        <scope>compile</scope>
    </dependency>

    <dependency>
        <groupId>com.google.code.tomahawk</groupId>
        <artifactId>tomahawk-facelets</artifactId>
        <version>1.1.6.3</version>
        <exclusions>
            <exclusion>
                <groupId>com.sun.facelets</groupId>
                <artifactId>jsf-facelets</artifactId>
            </exclusion>
            <exclusion>
                <groupId>javax.servlet</groupId>
                <artifactId>jstl</artifactId>
            </exclusion>
            <exclusion>
                <groupId>org.apache.myfaces.tomahawk</groupId>
                <artifactId>tomahawk</artifactId>
            </exclusion>
            <exclusion>
                <groupId>org.apache.myfaces.tomahawk</groupId>
                <artifactId>tomahawk-sandbox</artifactId>
            </exclusion>
        </exclusions>
    </dependency>

    <dependency>
        <groupId>com.sun.facelets</groupId>
        <artifactId>jsf-facelets</artifactId>
        <version>1.1.13</version>
    </dependency>

</dependencies>

<profiles>
    <profile>
        <id>bundle-myfaces</id>
        <activation>
            <property>
                <name>jsf</name>
                <value>myfaces</value>
            </property>
        </activation>
        <!-- Include MyFaces jars into the war -->
        <dependencies>
            <dependency>
                <groupId>org.apache.myfaces.core</groupId>
                <artifactId>myfaces-api</artifactId>
                <version>${jsf-myfaces.version}</version>
                <scope>compile</scope>
            </dependency>
            <dependency>
                <groupId>org.apache.myfaces.core</groupId>
                <artifactId>myfaces-impl</artifactId>
                <version>${jsf-myfaces.version}</version>
                <scope>runtime</scope>
            </dependency>
        </dependencies>
    </profile>

    <profile>
        <id>maven-tomcat7</id>
        <activation>
            <property>
                <name>container</name>
                <value>tomcat7</value>
            </property>
        </activation>
        <build>
            <plugins>
                <plugin>
                    <groupId>org.apache.tomcat.maven</groupId>
                    <artifactId>tomcat7-maven-plugin</artifactId>
                    <version>2.0</version>
                </plugin>
                <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>aspectj-maven-plugin</artifactId>
                    <version>1.3</version>
                    <executions>
                        <execution>
                            <goals>
                                <goal>compile</goal><!-- to weave all your main classes -->
                                <goal>test-compile</goal><!-- to weave all your test classes -->
                            </goals>
                        </execution>
                    </executions>
                    <configuration>
                        <aspectLibraries>
                            <aspectLibrary>
                                <groupId>${project.groupId}</groupId>
                                <artifactId>configuration</artifactId>
                            </aspectLibrary>
                        </aspectLibraries>
                        <sources>
                            <source>
                                <basedir>src/main/java</basedir>
                                <includes>
                                    <include>**/*.aj</include>
                                </includes>
                            </source>
                        </sources>
                        <source>1.5</source>
                        <target>1.5</target>
                        <encoding>utf-8</encoding>
                        <complianceLevel>1.5</complianceLevel>
                        <verbose>true</verbose>
                        <showWeaveInfo>true</showWeaveInfo>
                    </configuration>
                </plugin>
            </plugins>

            <pluginManagement>
                <plugins>
                    <!--This plugin's configuration is used to store Eclipse m2e settings 
                        only. It has no influence on the Maven build itself. -->
                    <plugin>
                        <groupId>org.eclipse.m2e</groupId>
                        <artifactId>lifecycle-mapping</artifactId>
                        <version>1.0.0</version>
                        <configuration>
                            <lifecycleMappingMetadata>
                                <pluginExecutions>
                                    <pluginExecution>
                                        <pluginExecutionFilter>
                                            <groupId>org.codehaus.mojo</groupId>
                                            <artifactId>
                                                aspectj-maven-plugin
                                            </artifactId>
                                            <versionRange>
                                                [1.3,)
                                            </versionRange>
                                            <goals>
                                                <goal>compile</goal>
                                                <goal>test-compile</goal>
                                            </goals>
                                        </pluginExecutionFilter>
                                        <action>
                                            <ignore></ignore>
                                        </action>
                                    </pluginExecution>
                                </pluginExecutions>
                            </lifecycleMappingMetadata>
                        </configuration>
                    </plugin>
                </plugins>
            </pluginManagement>
        </build>
        <dependencies>
            <dependency>
                <groupId>org.apache.myfaces.core</groupId>
                <artifactId>myfaces-api</artifactId>
                <version>${jsf-myfaces.version}</version>
                <scope>compile</scope>
            </dependency>
            <dependency>
                <groupId>org.apache.myfaces.core</groupId>
                <artifactId>myfaces-impl</artifactId>
                <version>${jsf-myfaces.version}</version>
                <scope>runtime</scope>
            </dependency>
        </dependencies>
    </profile>

</profiles>
<repositories>
    <repository>
        <releases>
            <enabled>true</enabled>
            <updatePolicy>always</updatePolicy>
            <checksumPolicy>warn</checksumPolicy>
        </releases>
        <snapshots>
            <enabled>false</enabled>
            <updatePolicy>never</updatePolicy>
            <checksumPolicy>fail</checksumPolicy>
        </snapshots>
        <id>Tomahawk-Facelets</id>
        <name>Tomahawk-Facelets releases</name>
        <url>http://tomahawk-facelets.googlecode.com/svn/maven2/repository</url>
        <layout>default</layout>
    </repository>
</repositories>

一旦我评论所有与战斧相关的依赖关系,服务器就会正确部署,尽管似乎tomhawk相关标签不起作用。

如果我没有发表评论,我会收到如下错误消息:

Jul 03, 2012 3:07:00 AM org.apache.catalina.startup.Embedded start
Information: Starting tomcat server
Jul 03, 2012 3:07:00 AM org.apache.catalina.core.StandardEngine start
Information: Starting Servlet Engine: Apache Tomcat/6.0.29
Jul 03, 2012 3:07:01 AM org.apache.myfaces.config.DefaultFacesConfigurationProvider getStandardFacesConfig
Information: Reading standard config META-INF/standard-faces-config.xml
Jul 03, 2012 3:07:01 AM org.apache.myfaces.config.DefaultFacesConfigurationProvider getWebAppFacesConfig
Information: Reading config /WEB-INF/faces-config.xml
Jul 03, 2012 3:07:02 AM org.apache.myfaces.config.DefaultFacesConfigurationProvider getClassloaderFacesConfig
Information: Reading config : jar:file:/E:/Users/Andreas/Dropbox/Studium/4.Semester/Software-Projekt/Marx1/trunk/deliverable3/parent/webui/target/webui-0.0.1/WEB-INF/lib/jsf-facelets-1.1.13.jar!/META-INF/faces-config.xml
Jul 03, 2012 3:07:02 AM org.apache.myfaces.webapp.AbstractFacesInitializer initFaces
Schwerwiegend: An error occured while initializing MyFaces: java.lang.NullPointerException
javax.faces.FacesException: java.lang.NullPointerException
    at org.apache.myfaces.config.DefaultFacesConfigurationProvider.getClassloaderFacesConfig(DefaultFacesConfigurationProvider.java:279)
    at org.apache.myfaces.config.DefaultFacesConfigurationMerger.getFacesConfigData(DefaultFacesConfigurationMerger.java:101)
    at org.apache.myfaces.config.FacesConfigurator.configure(FacesConfigurator.java:416)
    at org.apache.myfaces.webapp.AbstractFacesInitializer.buildConfiguration(AbstractFacesInitializer.java:338)
    at org.apache.myfaces.webapp.Jsp21FacesInitializer.initContainerIntegration(Jsp21FacesInitializer.java:73)
    at org.apache.myfaces.webapp.AbstractFacesInitializer.initFaces(AbstractFacesInitializer.java:140)
    at org.apache.myfaces.webapp.StartupServletContextListener.contextInitialized(StartupServletContextListener.java:119)
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4135)
    at org.apache.catalina.core.StandardContext.start(StandardContext.java:4630)
    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
    at org.apache.catalina.core.StandardHost.start(StandardHost.java:785)
    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
    at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:445)
    at org.apache.catalina.startup.Embedded.start(Embedded.java:825)
    at org.codehaus.mojo.tomcat.AbstractRunMojo.startContainer(AbstractRunMojo.java:558)
    at org.codehaus.mojo.tomcat.AbstractRunMojo.execute(AbstractRunMojo.java:255)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:107)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:319)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:534)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:601)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
Caused by: java.lang.NullPointerException
    at com.bluecast.xml.Piccolo.addAttributeDefinition(Piccolo.java:1167)
    at com.bluecast.xml.Piccolo.yyparse(Piccolo.java:1699)
    at com.bluecast.xml.Piccolo.parse(Piccolo.java:702)
    at org.apache.commons.digester.Digester.parse(Digester.java:1745)
    at org.apache.myfaces.config.impl.digester.DigesterFacesConfigUnmarshallerImpl.getFacesConfig(DigesterFacesConfigUnmarshallerImpl.java:309)
    at org.apache.myfaces.config.impl.digester.DigesterFacesConfigUnmarshallerImpl.getFacesConfig(DigesterFacesConfigUnmarshallerImpl.java:36)
    at org.apache.myfaces.config.DefaultFacesConfigurationProvider.getClassloaderFacesConfig(DefaultFacesConfigurationProvider.java:265)
    ... 36 more
Jul 03, 2012 3:07:02 AM org.apache.catalina.core.ApplicationContext log
Schwerwiegend: StandardWrapper.Throwable
java.lang.IllegalStateException: No Factories configured for this Application. This happens if the faces-initialization does not work at all - make sure that you properly include all configuration settings necessary for a basic faces application and that all the necessary libs are included. Also check the logging output of your web application and your container for any exceptions!
If you did that and find nothing, the mistake might be due to the fact that you use some special web-containers which do not support registering context-listeners via TLD files and a context listener is not setup in your web.xml.
A typical config looks like this;
<listener>
  <listener-class>org.apache.myfaces.webapp.StartupServletContextListener</listener-class>
</listener>

我一直在寻找几个小时,现在正在访问与标签tomhawk,maven,facelets相关的大量页面。但我似乎没有找到解决方案,这就是我在这里问的原因。也许它是微不足道的,甚至可能是显而易见的,但我找不到为什么这不起作用的答案。

1 个答案:

答案 0 :(得分:0)

我不认为这可行。你不能使用tomahawk-sandbox 1.1.6与tomahawk20 1.1.13,因为tomahawk-sandbox仅适用于JSF 1.1 / 1.2。此外,您不需要com.sun.facelets,因为JSF实现,在这种情况下JSF 2.0 / 2.1实现(在本例中为MyFaces Core)已经在其jar中包含facelets。不要使用com.google.code.tomahawk,很久以前就已将facelets支持添加到tomahawk中。首先尝试添加tomahawk20 1.1.13,它只是将其添加为依赖项,然后您可以尝试添加沙箱,但注意沙箱永远不会发布,因此您需要从源代码手动构建它或从snapshot repo获取它