diff --git a/jetty-annotations/src/main/java/org/eclipse/jetty/annotations/AnnotationParser.java b/jetty-annotations/src/main/java/org/eclipse/jetty/annotations/AnnotationParser.java index 366df415328..002877546f7 100644 --- a/jetty-annotations/src/main/java/org/eclipse/jetty/annotations/AnnotationParser.java +++ b/jetty-annotations/src/main/java/org/eclipse/jetty/annotations/AnnotationParser.java @@ -692,15 +692,10 @@ public class AnnotationParser parseDir(handlers, res, resolver); else { +System.err.println("TRYING TO SCAN "+res); //we've already verified the directories, so just verify the class file name - boolean valid = true; File file = res.getFile(); - if (file == null) - LOG.warn("Unable to validate class file name for {}", res); - else - valid = isValidClassFileName(file.getName()); - - if (valid) + if (isValidClassFileName((file==null?null:file.getName()))) { try { @@ -711,12 +706,16 @@ public class AnnotationParser if (LOG.isDebugEnabled()) {LOG.debug("Scanning class {}", r);}; scanClass(handlers, dir, r.getInputStream()); } - } + } catch (Exception ex) { me.add(new RuntimeException("Error scanning file "+files[f],ex)); } } + else + { + if (LOG.isDebugEnabled()) LOG.debug("Skipping scan on invalid file {}", res); + } } } diff --git a/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/JettyWebAppContext.java b/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/JettyWebAppContext.java index 64b777c77f6..5e31a6233ab 100644 --- a/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/JettyWebAppContext.java +++ b/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/JettyWebAppContext.java @@ -29,6 +29,7 @@ import java.util.Map; import java.util.Set; import java.util.TreeSet; +import org.eclipse.jetty.annotations.AnnotationConfiguration; import org.eclipse.jetty.plus.webapp.EnvConfiguration; import org.eclipse.jetty.plus.webapp.PlusConfiguration; import org.eclipse.jetty.servlet.FilterHolder; @@ -111,7 +112,7 @@ public class JettyWebAppContext extends WebAppContext new FragmentConfiguration(), _envConfig = new EnvConfiguration(), new PlusConfiguration(), - new MavenAnnotationConfiguration(), + new AnnotationConfiguration(), new JettyWebXmlConfiguration() }); // Turn off copyWebInf option as it is not applicable for plugin. diff --git a/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/MavenAnnotationConfiguration.java b/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/MavenAnnotationConfiguration.java deleted file mode 100644 index 0f55c0620b2..00000000000 --- a/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/MavenAnnotationConfiguration.java +++ /dev/null @@ -1,90 +0,0 @@ -// -// ======================================================================== -// Copyright (c) 1995-2013 Mort Bay Consulting Pty. Ltd. -// ------------------------------------------------------------------------ -// All rights reserved. This program and the accompanying materials -// are made available under the terms of the Eclipse Public License v1.0 -// and Apache License v2.0 which accompanies this distribution. -// -// The Eclipse Public License is available at -// http://www.eclipse.org/legal/epl-v10.html -// -// The Apache License v2.0 is available at -// http://www.opensource.org/licenses/apache2.0.php -// -// You may elect to redistribute this code under either of these licenses. -// ======================================================================== -// - -package org.eclipse.jetty.maven.plugin; - -import java.io.File; -import java.util.HashSet; -import java.util.Set; - -import org.eclipse.jetty.annotations.AnnotationConfiguration; -import org.eclipse.jetty.annotations.AnnotationParser; -import org.eclipse.jetty.annotations.AnnotationParser.Handler; -import org.eclipse.jetty.util.log.Log; -import org.eclipse.jetty.util.log.Logger; -import org.eclipse.jetty.util.resource.Resource; -import org.eclipse.jetty.webapp.MetaData; -import org.eclipse.jetty.webapp.WebAppContext; - -public class MavenAnnotationConfiguration extends AnnotationConfiguration -{ - private static final Logger LOG = Log.getLogger(MavenAnnotationConfiguration.class); - - /* ------------------------------------------------------------ */ - @Override - public void parseWebInfClasses(final WebAppContext context, final AnnotationParser parser) throws Exception - { - JettyWebAppContext jwac = (JettyWebAppContext)context; - if (jwac.getClassPathFiles() == null || jwac.getClassPathFiles().size() == 0) - super.parseWebInfClasses (context, parser); - else - { - LOG.debug("Scanning classes "); - //Look for directories on the classpath and process each one of those - - MetaData metaData = context.getMetaData(); - if (metaData == null) - throw new IllegalStateException ("No metadata"); - - Set handlers = new HashSet(); - handlers.addAll(_discoverableAnnotationHandlers); - if (_classInheritanceHandler != null) - handlers.add(_classInheritanceHandler); - handlers.addAll(_containerInitializerAnnotationHandlers); - - - for (File f:jwac.getClassPathFiles()) - { - //scan the equivalent of the WEB-INF/classes directory that has been synthesised by the plugin - if (f.isDirectory() && f.exists()) - { - doParse(handlers, context, parser, Resource.newResource(f.toURI())); - } - } - - //if an actual WEB-INF/classes directory also exists (eg because of overlayed wars) then scan that - //too - if (context.getWebInf() != null && context.getWebInf().exists()) - { - Resource classesDir = context.getWebInf().addPath("classes/"); - if (classesDir.exists()) - { - doParse(handlers, context, parser, classesDir); - } - } - } - } - - - public void doParse (final Set handlers, final WebAppContext context, final AnnotationParser parser, Resource resource) - throws Exception - { - if (_parserTasks != null) - _parserTasks.add(new ParserTask(parser, handlers, resource, _webAppClassNameResolver)); - } -} diff --git a/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/MavenWebInfConfiguration.java b/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/MavenWebInfConfiguration.java index eb0b1676837..680f8ba93a2 100644 --- a/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/MavenWebInfConfiguration.java +++ b/jetty-maven-plugin/src/main/java/org/eclipse/jetty/maven/plugin/MavenWebInfConfiguration.java @@ -238,6 +238,46 @@ public class MavenWebInfConfiguration extends WebInfConfiguration } + + + + /** + * Add in the classes dirs from test/classes and target/classes + * @see org.eclipse.jetty.webapp.WebInfConfiguration#findClassDirs(org.eclipse.jetty.webapp.WebAppContext) + */ + @Override + protected List findClassDirs(WebAppContext context) throws Exception + { + List list = new ArrayList(); + + JettyWebAppContext jwac = (JettyWebAppContext)context; + if (jwac.getClassPathFiles() != null) + { + for (File f: jwac.getClassPathFiles()) + { + if (f.exists() && f.isDirectory()) + { + try + { + list.add(Resource.newResource(f.toURI())); + } + catch (Exception e) + { + LOG.warn("Bad url ", e); + } + } + } + } + + List classesDirs = super.findClassDirs(context); + if (classesDirs != null) + list.addAll(classesDirs); + return list; + } + + + + protected Resource unpackOverlay (WebAppContext context, Overlay overlay) throws IOException diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/Request.java b/jetty-server/src/main/java/org/eclipse/jetty/server/Request.java index fe8025eb994..caa320cfda0 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/Request.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/Request.java @@ -1546,6 +1546,9 @@ public class Request implements HttpServletRequest /* ------------------------------------------------------------ */ protected void recycle() { + if (_context != null) + throw new IllegalStateException("Request in context!"); + if (_inputState == __READER) { try @@ -1561,6 +1564,7 @@ public class Request implements HttpServletRequest } } + _dispatcherType=null; setAuthentication(Authentication.NOT_CHECKED); getHttpChannelState().recycle(); if (_async!=null) @@ -1568,8 +1572,6 @@ public class Request implements HttpServletRequest _async=null; _asyncSupported = true; _handled = false; - if (_context != null) - throw new IllegalStateException("Request in context!"); if (_attributes != null) _attributes.clearAttributes(); _characterEncoding = null; @@ -1578,7 +1580,9 @@ public class Request implements HttpServletRequest _cookies.reset(); _cookiesExtracted = false; _context = null; + _newContext=false; _serverName = null; + _httpMethod=null; _httpMethodString = null; _pathInfo = null; _port = 0; @@ -1587,6 +1591,7 @@ public class Request implements HttpServletRequest _queryString = null; _requestedSessionId = null; _requestedSessionIdFromCookie = false; + _secure=false; _session = null; _sessionManager = null; _requestURI = null;