Details
Description
Checking some archetypes for MyFaces Core project I notice the latest version of jetty does not work.
MyFaces has a listener entry in a .tld file, and that is not loaded or scanned anymore
I'll attach a example webapp for this one. Just type mvn clean -PjettyConfig jetty:run. With jetty 7.4.5.v20110725 works but if you change maven.jetty.plugin.version property inside the pom to 7.6.0.v20120127 it does not, throwing a ClassNotFoundException. Later, I added myfaces jars as dependencies for the plugin but the tlds are not scanned, so myfaces listener is not loaded and another exception occur (Factory not loaded). Later if I add:
<listener>
<listener-class>org.apache.myfaces.webapp.StartupServletContextListener</listener-class>
</listener>
Into web.xml the app works, but contextPath is not added.
-
Hide
- myfaces-helloworld20.zip
- 08/Feb/12 7:49 PM
- 11 kB
- Leonardo Uribe
-
- myfaces-helloworld20/pom.xml 6 kB
- myfaces-helloworld20/.../HelloWorldController.java 2 kB
- myfaces-helloworld20/.../helloWorld.xhtml 2 kB
- myfaces-helloworld20/src/.../index.html 0.9 kB
- myfaces-helloworld20/src/.../page2.xhtml 1 kB
- myfaces-helloworld20/src/.../css/style.css 1 kB
- myfaces-helloworld20/.../faces-config.xml 1 kB
- myfaces-helloworld20/src/.../WEB-INF/web.xml 6 kB
Activity
Hi
I tried this with jetty 7.6.1.v20120215 as described in the wiki:
<profile>
<!-- Plugin embedded jetty 7 container.
Just running use:
mvn clean -Dcontainer=jetty7 jetty:run
-->
<!-- For debugging use (attach debugger port 8000):
mvnDebug clean -Dcontainer=jetty7 jetty:run
-->
<id>jetty7Config</id>
<activation>
<property>
<name>container</name>
<value>jetty7</value>
</property>
</activation>
<build>
<plugins>
<plugin>
<!--This plugin allows to run the war using mvn jetty:run -->
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>7.6.1.v20120215</version>
<configuration>
<systemProperties>
<systemProperty>
<!-- use the ecj compiler -->
<name>org.apache.jasper.compiler.disablejsr199</name>
<value>true</value>
</systemProperty>
</systemProperties>
<contextXml>$
/src/conf/jetty/context.xml</contextXml>
<webApp>
<contextPath>/$
</webApp>
<scanIntervalSeconds>5</scanIntervalSeconds>
</configuration>
<dependencies>
<!-- Tld scanning only works when JSF is included
as container 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>runtime</scope>
</dependency>
<dependency>
<groupId>javax.el</groupId>
<artifactId>javax.el-api</artifactId>
<version>2.2.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.glassfish.web</groupId>
<artifactId>javax.el</artifactId>
<version>2.2.1</version>
<scope>provided</scope>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
</profile>
src/conf/jetty/context.xml
<Configure class="org.eclipse.jetty.webapp.WebAppContext">
<Call name="setAttribute">
<Arg>org.eclipse.jetty.server.webapp.ContainerIncludeJarPattern</Arg>
<Arg>./.*myfaces-impl-[^/]\.jar$|./.*jsp-api-[^/]\.jar$|./.*jsp-[^/]\.jar$|./.*taglibs[^/]\.jar$</Arg>
</Call>
</Configure>
Throws no factories configured for application (happens because the listener on myfaces tld does not load correctly).
But I tried this using jetty 8.1.1.v20120215:
<profile>
<!-- Plugin embedded jetty 8 container.
Just running use:
mvn clean jetty:run or mvn clean jetty:run
-->
<!-- For debugging use (attach debugger port 8000):
mvnDebug clean jetty:run or mvn clean jetty:run
-->
<id>jettyConfig</id>
<activation>
<property>
<name>!container</name>
</property>
</activation>
<build>
<plugins>
<plugin>
<!--This plugin allows to run the war using mvn jetty:run -->
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>${jetty.maven.plugin.version}</version>
<configuration>
<systemProperties>
<systemProperty>
<!-- optional to use the ecj compiler -->
<name>org.apache.jasper.compiler.disablejsr199</name>
<value>true</value>
</systemProperty>
</systemProperties>
<webApp>
<contextPath>/${artifactId}
</contextPath>
</webApp>
<scanIntervalSeconds>5</scanIntervalSeconds>
</configuration>
<dependencies>
<!-- Tld scanning only works when JSF is included
as container dependency. -->
<dependency>
<groupId>org.apache.myfaces.core</groupId>
<artifactId>myfaces-api</artifactId>
<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>
</plugin>
</plugins>
</build>
</profile>
It works.
Why it does not work with jetty-maven-plugin 7? no idea. In jetty 8 it works because MyFaces has a ServletInitializer that do what's necessary according to Servlet spec 3. Jetty 8 is enough for me. Thanks for your help. I'll keep an eye on this one if someday is fixed.
Hi Leonard,
Yes, you're right, 7.6.x does not work! That was my fault, I was overwriting the attribute org.eclipse.jetty.server.webapp.ContainerIncludeJarPattern in the startup of the plugin (attempting to make sure that all the jars that we distribute with jetty that have tlds get scanned - unfortunately I forgot about jsf!).
So now I have added in a pattern for the common jsf impls: myfaces and the jsf from sun, so from jetty-7.6.2 onwards you won't have to set any attributes or anything. Just ensure that the jsf jars are on the plugin classpath, not the webapp's classpath.
If you have other jars that need to be scanned, then you'll need to specify their pattern in a context xml file, but these will now be additive to the patterns defined inside the plugin startup. In other words, if you have a new dependency jar foo-123.jar that contains tlds that you want scanned, then you would put the following in your context xml file:
<Call name="setAttribute">
<Arg>org.eclipse.jetty.server.webapp.ContainerIncludeJarPattern</Arg>
<Arg>./.*foo-[^/]\.jar$</Arg>
</Call>
The plugin implementation will take care of adding in all the other standard patterns.
cheers
Jan
I also updated the wiki page here: http://wiki.eclipse.org/Jetty/Howto/Configure_JSP#Jetty_Maven_Plugin
Leonard,
The changes to the version of jsp that we use in jetty 7 require that you make a couple of changes if you want to use jsf. Its documented here:
http://wiki.eclipse.org/Jetty/Howto/Configure_JSP
Let me know if things are working after you define the context attribute as described above.
Jan