Posts Tagged ‘Jetty’
Jetty / Timeout scanning annotations
Case
My application consists in a WAR I deploy on Tomcat or Jetty during the development phase. I execute Eclipse Jetty either in standalone, or via Maven Jetty plugin – most of the time.
On updating and deploying the application on my laptop (which is not my primary development machine), I get the following error with Maven:
[java]java.lang.Exception: Timeout scanning annotations[/java]
Unlike, with a standalone instance of Jetty, the WAR is successfully deployed.
Complete stacktrace
[java]2014-09-08 22:28:50.669:INFO:oeja.AnnotationConfiguration:main: Scanned 1 container path jars, 87 WEB-INF/lib jars, 1 WEB-INF/classes dirs in 65922ms for context o.e.j.m.p.JettyWebAppContext@13bb109{/,[file:/D:/JLALOU/development/forfait-XXX-XXX/XXX-web/src/main/webapp/, jar:file:/C:/Users/jlalou/.m2/repository/org/primefaces/extensions/primefaces-extensions/2.0.0/primefaces-extensions-2.0.0.jar!/META-INF/resources/, jar:file:/C:/Users/jlalou/.m2/repository/org/primefaces/themes/bootstrap/1.0.10/bootstrap-1.0.10.jar!/META-INF/resources/, jar:file:/C:/Users/jlalou/.m2/repository/org/primefaces/primefaces/5.0/primefaces-5.0.jar!/META-INF/resources/, jar:file:/C:/Users/jlalou/.m2/repository/com/sun/faces/jsf-impl/2.2.6/jsf-impl-2.2.6.jar!/META-INF/resources/],STARTING}{file:/D:/JLALOU/development/forfait-XXX-XXX/XXX-web/src/main/webapp/}
2014-09-08 22:28:50.670:WARN:oejw.WebAppContext:main: Failed startup of context o.e.j.m.p.JettyWebAppContext@13bb109{/,[file:/D:/JLALOU/development/forfait-XXX-XXX/XXX-web/src/main/webapp/, jar:file:/C:/Users/jlalou/.m2/repository/org/primefaces/extensions/primefaces-extensions/2.0.0/primefaces-extensions-2.0.0.jar!/META-INF/resources/, jar:file:/C:/Users/jlalou/.m2/repository/org/primefaces/themes/bootstrap/1.0.10/bootstrap-1.0.10.jar!/META-INF/resources/, jar:file:/C:/Users/jlalou/.m2/repository/org/primefaces/primefaces/5.0/primefaces-5.0.jar!/META-INF/resources/, jar:file:/C:/Users/jlalou/.m2/repository/com/sun/faces/jsf-impl/2.2.6/jsf-impl-2.2.6.jar!/META-INF/resources/],STARTING}{file:/D:/JLALOU/development/forfait-XXX-XXX/XXX-web/src/main/webapp/}
java.lang.Exception: Timeout scanning annotations
at org.eclipse.jetty.annotations.AnnotationConfiguration.scanForAnnotations(AnnotationConfiguration.java:571)
at org.eclipse.jetty.annotations.AnnotationConfiguration.configure(AnnotationConfiguration.java:441)
at org.eclipse.jetty.webapp.WebAppContext.configure(WebAppContext.java:466)
at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1342)
at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:745)
at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:492)
at org.eclipse.jetty.maven.plugin.JettyWebAppContext.doStart(JettyWebAppContext.java:282)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:117)
at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:99)
at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:60)
at org.eclipse.jetty.server.handler.ContextHandlerCollection.doStart(ContextHandlerCollection.java:154)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:117)
at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:99)
at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:60)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:117)
at org.eclipse.jetty.server.Server.start(Server.java:358)
at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:99)
at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:60)
at org.eclipse.jetty.server.Server.doStart(Server.java:325)
at org.eclipse.jetty.maven.plugin.JettyServer.doStart(JettyServer.java:68)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
at org.eclipse.jetty.maven.plugin.AbstractJettyMojo.startJetty(AbstractJettyMojo.java:564)
at org.eclipse.jetty.maven.plugin.AbstractJettyMojo.execute(AbstractJettyMojo.java:360)
at org.eclipse.jetty.maven.plugin.JettyRunMojo.execute(JettyRunMojo.java:168)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:133)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
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:108)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:76)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:116)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:361)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:155)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:584)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:213)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:157)
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:606)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)[/java]
Explanation
Since the release of 9.1 branch, Jetty server limits the scan time for annotations at 60 seconds, by default.
The exception is raised here: source
[java]boolean timeout = !latch.await(getMaxScanWait(context), TimeUnit.SECONDS);
if (LOG.isDebugEnabled())
{
for (ParserTask p:_parserTasks)
LOG.debug("Scanned {} in {}ms", p.getResource(), TimeUnit.MILLISECONDS.convert(p.getStatistic().getElapsed(), TimeUnit.NANOSECONDS));
LOG.debug("Scanned {} container path jars, {} WEB-INF/lib jars, {} WEB-INF/classes dirs in {}ms for context {}",
_containerPathStats.getTotal(), _webInfLibStats.getTotal(), _webInfClassesStats.getTotal(),
(TimeUnit.MILLISECONDS.convert(System.nanoTime()-start, TimeUnit.NANOSECONDS)),
context);
}
if (timeout)
me.add(new Exception("Timeout scanning annotations"));[/java]
Fix
As a quick fix, on launching Maven, add the option -Dorg.eclipse.jetty.annotations.maxWait=120
(set a higher value if needed):
[java]mvn jetty:run -Dorg.eclipse.jetty.annotations.maxWait=120[/java]
You can also set this property directly in jetty-*.xml
configuration files, for webapp or even for a complete server.
(long tweet) Could not find backup for factory javax.faces.context.FacesContextFactory.
Case
On deploying a JSF 2.2 / Primefaces 5 application on Jetty 9, I got the following error:
[java]java.lang.IllegalStateException: Could not find backup for factory javax.faces.context.FacesContextFactory.[/java]
The issue seems linked to Jetty, since I could not reproduce the issue on Tomcat 8.
Quickfix
In the web.xml
, add the following block:
[xml] <listener>
<listener-class>com.sun.faces.config.ConfigureListener</listener-class>
</listener>[/xml]
MultiException[java.lang.RuntimeException: Error scanning file]
Case
I run a project with JSF 2 / PrimeFaces 5 (BTW: it rocks!) / Spring 4 / Jetty 9 / Java 8:
[java]MultiException java.lang.RuntimeException: Error scanning file SummerBean.class, java.lang.RuntimeException: Error scanning entry …/SummerService.class from jar file:/…/spring-tier-1.0-SNAPSHOT.jar, java.lang.RuntimeException: Error scanning entry …/SummerServiceImpl.class from jar file:/…/spring-tier-1.0-SNAPSHOT.jar
at org.eclipse.jetty.annotations.AnnotationConfiguration.scanForAnnotations(AnnotationConfiguration.java:530)[/java]
Explanation
The error occurs because of a conflict on the JARs of ASM.
Fix
You have to override Jetty’s dependencies to ASM.
In Maven’s POM, amend Jetty plugin to force ASM versions:
[xml]<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>${jetty.version}</version>
<dependencies>
<dependency>
<groupId>org.ow2.asm</groupId>
<artifactId>asm</artifactId>
<version>5.0.2</version>
</dependency>
<dependency>
<groupId>org.ow2.asm</groupId>
<artifactId>asm-commons</artifactId>
<version>5.0.2</version>
</dependency>
</dependencies>
<!– … –>
</plugin>
[/xml]
Then it should work 😉
(long tweet) Jetty / Unified Expression Language / NoSuchMethodError: javax.el.ELResolver.invoke
Case
On deploying a JSF project on Jetty (via Maven plugin), when I display the XHtml page I get an error, which starts with:
[java]java.lang.NoSuchMethodError: javax.el.ELResolver.invoke(Ljavax/el/ELContext;Ljava/lang/Object;Ljava/lang/Object;[Ljava/lang/Class;[Ljava/lang/Object;)Ljava/lang/Object;
at com.sun.el.parser.AstValue.getValue(AstValue.java:111)
at com.sun.el.parser.AstValue.getValue(AstValue.java:163)
at com.sun.el.ValueExpressionImpl.getValue(ValueExpressionIm[/java]
Quick fix
I fixed the issue by removing the dependencies to Unified Expression Language (EL API), either direct or induced:
[xml]
<dependency>
<groupId>org.glassfish.web</groupId>
<artifactId>el-impl</artifactId>
<version>2.2</version>
</dependency>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-web-api</artifactId>
<version>6.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.sun.el</groupId>
<artifactId>el-ri</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>javax.el</groupId>
<artifactId>el-api</artifactId>
<version>2.2</version>
</dependency>
<dependency>
<groupId>com.sun.el</groupId>
<artifactId>el-ri</artifactId>
<version>1.0</version>
</dependency>[/xml]
Actually, some JARs that had to be depended on have been included within Tomcat and Jetty, that’s why some conflict of JARs happen to be. What prevented me to fix quickly the issue was that Tomcat and Jetty seem not to embed the same version on EL
Maven / Jetty 7 / java.lang.NoClassDefFoundError: javax/servlet/ServletRequestListener
Case
My project is deployed via Maven on a Jetty 6 server. I have to upgrade the server to Jetty 7.
(BTW: notice that the plugin maven-jetty-plugin
was renamed as jetty-maven-plugi
n)
I get this error:
[java]java.lang.NoClassDefFoundError: javax/servlet/ServletRequestListener[/java]
Quick Fix
In Jetty plugin, add a dependency to servlet-api, eg:
[xml] <plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>7.4.4.v20110707</version>
<dependencies>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.4</version>
</dependency>
</dependencies>[/xml]
Maven / Jetty / Cause: Class name which was explicitly given in configuration using ‘implementation’ attribute: ‘org.mortbay.jetty.bio.SocketConnector’ cannot be loaded
Case
My project is deployed via Maven on a Jetty 6 server. I have to upgrade the server to Jetty 7.
(BTW: notice that the plugin maven-jetty-plugin
was renamed as jetty-maven-plugi
n)
I get this error:
[java] Cause: Class name which was explicitly given in configuration using ‘implementation’ attribute: ‘org.mortbay.jetty.bio.SocketConnector’ cannot be loaded[/java]
Quick fix
org.mortbay.jetty.bio.SocketConnector
was removed from Jetty with the release 7. To fix the issue, use a more recent implementation. For instance, replace this block:
[xml]<connector implementation="org.mortbay.jetty.bio.SocketConnector">[/xml]
with that one:
[xml]<connector implementation="org.eclipse.jetty.server.nio.SelectChannelConnector">[/xml]
Maven / Jetty / Cannot override read-only parameter: contextPath in goal
Case
My project is deployed via Maven on a Jetty 6 server. I have to upgrade the server to Jetty 7.
(BTW: notice that the plugin maven-jetty-plugin
was renamed as jetty-maven-plugi
n)
I get this error:
[java] Error configuring: org.mortbay.jetty:jetty-maven-plugin. Reason: ERROR: Cannot override read-only parameter: contextPath in goal: jetty:run-exploded[/java]
Quick fix
Insert a tag <webAppConfig>
between <configuration>
and <contextPath>
. In other terms, replace this block:
[xml]<configuration>
<contextPath>/I/love/USA</contextPath>
</configuration>[/xml]
with that one:
[xml]<configuration>
<webAppConfig>
<contextPath>/I/love/USA</contextPath>
</webAppConfig>
</configuration>[/xml]
Maven / Jetty / java.lang.ClassNotFoundException: org.apache.axis2.transport.http.AxisAdminServlet
Case
I have a WAR containing Axis2-built on webservices. I must deploy it under Jetty 6. The version of Axis2 is 1.5.X.
I get this exception:
[java]java.lang.ClassNotFoundException: org.apache.axis2.transport.http.AxisAdminServlet[/java]
I assume the same case may occur with Tomcat.
Explanation
The class AxisAdminServlet
was removed from Axis2 between the releases 1.4 and 1.5.
Quick fix
Add the following dependency in Maven’s Jetty plugin:
[xml]<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>maven-jetty-plugin</artifactId>
<version>6.1.26</version>
<dependencies>
<dependency>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2-kernel</artifactId>
<version>1.4.1</version>
</dependency>
</dependencies>
(…)[/xml]
GWT in noserver mode with Tomcat or WebLogic
Abstract
You would like to work on the client side of your GWT application, without building and deploying the Jetty server. Or, in the same way, you need test some server features available in WebLogic but not in Jetty, such as the EJB.
GWT 2.0 documentation, at the segment How do I use my own server in hosted mode instead of GWT’s built-in Jetty instance? is not precise at all on the 3rd step: it simply states:
“change the URL at the end of the argument list to match the URL you recorded in step #1.”
Process
- Let’s assume your WAR is deployed on
http://distantMachine:8080/myApplication
. The servlet container may be Tomcat or WebLogic, it does not matter - In Eclipse, go in “
Run Configuration...
“. Duplicate your current and classic GWT application configuration. - Go in
Server
, uncheck “Run built-in server
“. - In
Arguments
tab, write the following line:
[java]-noserver -remoteUI "${gwt_remote_ui_server_port}:${unique_id}" -logLevel INFO -war C:\eclipse\workspace\myApplication\src\main\webapp\lalou.jonathan.web.gwt.MyApplication -startupUrl http://distantMachine:8080/myApplication lalou.jonathan.web.gwt.MyApplication[/java] - Run
- The application is available at the following address:
[html]http://distantMachine:8080/muyApplication/?gwt.codesvr=127.0.0.1:9997[/html]