Myfaces, Facelets, Tomahawk и Maven, развернутые в Tomcat 7, терпят неудачу

У меня большие проблемы с запуском томагавка. Некоторое время назад я использовал архетип myfaces hellworld20 для создания нового проекта. Теперь я хотел расширить его с помощью томагавка. Новый 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>

Как только я закомментирую все зависимости, связанные с томагавком, сервер развернется правильно, хотя кажется, что теги, связанные с томагавком, не работают.

Если я не прокомментирую это, я получаю сообщение об ошибке, подобное этому:

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. Но я не нашел решения, поэтому и спрашиваю здесь. Может быть, это тривиально и, вероятно, даже очевидно, но я не могу найти ответ, почему это не работает.


person saenridanra    schedule 03.07.2012    source источник
comment
Итак, я поиграл еще довольно много часов... Я пытался использовать tomahawk-sandbox12 в качестве зависимости от maven, и это работает, единственное, что теперь, это то, что он не отображает теги.   -  person saenridanra    schedule 04.07.2012


Ответы (1)


Я не думаю, что это может сработать. Вы не можете использовать томагавк-песочницу 1.1.6 с томагавком20 1.1.13, потому что томагавк-песочница предназначена только для JSF 1.1/1.2. Кроме того, вам не нужны com.sun.facelets, потому что реализация JSF, в данном случае реализация JSF 2.0/2.1 (в данном случае MyFaces Core), имеет фаслеты уже внутри своих банок. Не используйте com.google.code.tomahawk, поддержка фейслетов была добавлена ​​в томагавк уже давно. Попробуйте сначала добавить только tomahawk20 1.1.13, то есть просто добавьте его как зависимость, а затем вы можете попробовать добавить песочницу, но обратите внимание, что песочница никогда не выпускается, поэтому вам нужно собрать ее вручную из исходного кода или взять из репозиторий снимков.

person lu4242    schedule 06.07.2012
comment
Спасибо за ответ, но я сдался. Возможно, решение, которое вы предлагаете, сработает, это должен решить кто-то другой. Я перешла на праймфейсы и очень рада, что сделала это. Он отлично работает с myfaces, и результаты действительно хорошие. Все равно спасибо! - person saenridanra; 06.07.2012