Jetty

Jetty plugin beta12 can no longer run plexus-based servlets

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Won't Fix
  • Affects Version/s: 6.0.0beta12, 6.0.0beta14, 6.0.0beta15
  • Fix Version/s: None
  • Component/s: Maven
  • Labels:
    None
  • Number of attachments :
    1

Description

I've not yet investigated what changed, but it works when I use beta11. An example is MRM:
http://svn.apache.org/repos/asf/maven/repository-manager/trunk (run mvn install at the root, then jetty6:run in the webapp)

Caused by: java.lang.ClassCastException: org.apache.maven.plugin.MavenPluginDiscoverer
at org.codehaus.plexus.component.discovery.DefaultComponentDiscovererManager.initialize(DefaultComponentDiscovererManager.java:89)
at org.codehaus.plexus.DefaultPlexusContainer.initializeCoreComponents(DefaultPlexusContainer.java:1252)
at org.codehaus.plexus.DefaultPlexusContainer.initialize(DefaultPlexusContainer.java:640)
at org.codehaus.plexus.embed.Embedder.start(Embedder.java:216)
at org.codehaus.plexus.servlet.ServletContextUtils.createContainer(ServletContextUtils.java:172)
at org.codehaus.plexus.servlet.PlexusServletContextListener.contextInitialized(PlexusServletContextListener.java:65)
at org.mortbay.jetty.handler.ContextHandler.startContext(ContextHandler.java:368)
at org.mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.java:970)
at org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:341)
at org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:368)
at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:37)
at org.mortbay.jetty.handler.HandlerCollection.doStart(HandlerCollection.java:133)
at org.mortbay.jetty.Server.doStart(Server.java:256)
at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:37)
at org.mortbay.jetty.plugin.Jetty6PluginServer.start(Jetty6PluginServer.java:116)
at org.mortbay.jetty.plugin.AbstractJettyMojo.startJetty(AbstractJettyMojo.java:398)
... 21 more

Activity

Hide
Brett Porter added a comment -

patch to workaround the problem.

the fix is to set the priority back to java2 instead of child-first. This also requires that all the jetty classes be in the same classloader, so I've removed the manual jsp creation and switched that for a profile (it has the same effect on the jsp side - might need to check the logging jars used).

there might be a more complete solution to this instead of using the java2 style, but I believe when only run inside Maven this is not a bad thing anyway.

Show
Brett Porter added a comment - patch to workaround the problem. the fix is to set the priority back to java2 instead of child-first. This also requires that all the jetty classes be in the same classloader, so I've removed the manual jsp creation and switched that for a profile (it has the same effect on the jsp side - might need to check the logging jars used). there might be a more complete solution to this instead of using the java2 style, but I believe when only run inside Maven this is not a bad thing anyway.
Hide
Brett Porter added a comment -

I've discovered what the real problem is with this. It's nothing to do with classloading order, but rather that the default contextloader's findresources will look all the way back up to the maven core libraries. When instantiating our plexus container this results in loading some descriptors from there that it can't (and shouldn't) instantiate.

I'm now investigating the best solution to this (whether it be in jetty or plexus)

Show
Brett Porter added a comment - I've discovered what the real problem is with this. It's nothing to do with classloading order, but rather that the default contextloader's findresources will look all the way back up to the maven core libraries. When instantiating our plexus container this results in loading some descriptors from there that it can't (and shouldn't) instantiate. I'm now investigating the best solution to this (whether it be in jetty or plexus)
Hide
Jan Bartel added a comment -

Not sure if this would help but Jetty has the ability to "hide" classes from a webapp. This is done on a package level basis. The default setting for this is:
{"org.mortbay.", "-org.mortbay.naming.","-org.mortbay.util.", "org.slf4j."} meaning that everything in org.mortbay is hidden from the webapp EXCEPT org.mortbay.util and org.mortbay.naming. and org.slf4j classes are hidden too. Potentially we could hide the maven core libraries too for the plugin?

Show
Jan Bartel added a comment - Not sure if this would help but Jetty has the ability to "hide" classes from a webapp. This is done on a package level basis. The default setting for this is: {"org.mortbay.", "-org.mortbay.naming.","-org.mortbay.util.", "org.slf4j."} meaning that everything in org.mortbay is hidden from the webapp EXCEPT org.mortbay.util and org.mortbay.naming. and org.slf4j classes are hidden too. Potentially we could hide the maven core libraries too for the plugin?
Hide
Brett Porter added a comment -

that's not what I needed. I don't think this is anything Jetty should have to fix - it's either the Maven plugin API or an improvement to Plexus itself.

I've put a workaround into the webapp that works for me, so you can close this won't fix.

Show
Brett Porter added a comment - that's not what I needed. I don't think this is anything Jetty should have to fix - it's either the Maven plugin API or an improvement to Plexus itself. I've put a workaround into the webapp that works for me, so you can close this won't fix.
Hide
Jan Bartel added a comment -

That's what I like to hear - less work for me to do!

Show
Jan Bartel added a comment - That's what I like to hear - less work for me to do!
Hide
Juan F. Codagnone added a comment -

brett, what is your work arround? im running into the same problem.

Show
Juan F. Codagnone added a comment - brett, what is your work arround? im running into the same problem.
Hide
Brett Porter added a comment -

Juan, use plexus-xwork-integration 1.0-alpha-2-SNAPSHOT from the trunk of plexus.

Basically, I am filtering out requests for plexus.xml in a custom classloader so it doesn't find Maven's. We use application.xml instead for initialising the container. The same thing might need to be done in plexus-servlet if that is where you are using it from.

Ideally, the jetty plugin would be able to isolate itself from the parent classloader, but this is working for now.

Show
Brett Porter added a comment - Juan, use plexus-xwork-integration 1.0-alpha-2-SNAPSHOT from the trunk of plexus. Basically, I am filtering out requests for plexus.xml in a custom classloader so it doesn't find Maven's. We use application.xml instead for initialising the container. The same thing might need to be done in plexus-servlet if that is where you are using it from. Ideally, the jetty plugin would be able to isolate itself from the parent classloader, but this is working for now.

People

Vote (0)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved: