Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Maven Plugin - the option to set extraClasspath in the plugin configuration isn't working #7970

Closed
miriambron opened this issue May 10, 2022 · 4 comments · Fixed by #8268
Closed
Assignees
Labels
Bug For general bugs on Jetty side

Comments

@miriambron
Copy link

miriambron commented May 10, 2022

Jetty version : 10.0.8

Java version/vendor :jdk-11.0.12

OS type/version : Windows 10

Description
In version 10.0.8 , the class org.eclipse.jetty.webapp.WebAppContext is no more POJO class,
since there is an overloading to the setter setExtraClasspath :

   public void setExtraClasspath(String extraClasspath) throws IOException
    {
        setExtraClasspath(Resource.fromList(extraClasspath, false, this::newResource));
    }

    public void setExtraClasspath(List<Resource> extraClasspath)
    {
        _extraClasspath = extraClasspath;
    }

so that , the maven plugin can't set this value , since the sisu-plexus is taking the 1st setter by reflection , assuming there is only one
This bug is not consistent , because if the classloader will find the 1st overload as the 1st setter, it will work ,
but if the 2nd overload will be the 1st setter , so the sisu-plexus won't be able to construct List from the string input

How to reproduce?

  1. Create a jetty maven project,
  2. in your pom.xml, add build proflie for jetty for example :
        <profile>
            <id>jetty</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.eclipse.jetty</groupId>
                        <artifactId>jetty-maven-plugin</artifactId>
                        <configuration>
                            <webApp>
                                <extraClasspath>/path/to/classpath</extraClasspath>
                            </webApp>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
  1. run your maven build with this profile, since this bug is not consistent , you may need to try to build several times in order to get the error -
[ERROR] Failed to execute goal org.eclipse.jetty:jetty-maven-plugin:10.0.8:run (default-cli) on project test-jetty: Unable to parse configuration of mojo org.eclipse.jetty:jetty-maven-plugin:10.0.8:run for parameter #: Cannot create instance of class org.eclipse.jetty.util.resource.Resource: InstantiationException -> [Help 1]


@miriambron miriambron added the Bug For general bugs on Jetty side label May 10, 2022
@miriambron miriambron changed the title Maven Plugin - Can't set WebApp extraClasspath in the plugin configuration Maven Plugin - the option to set extraClasspath in the plugin configuration isn't working May 10, 2022
olamy added a commit that referenced this issue Jul 7, 2022
@joakime
Copy link
Contributor

joakime commented Jul 7, 2022

Opened PR #8268

@rinnnn
Copy link

rinnnn commented May 1, 2024

I just tried to migrate today from version 10.0.16 of jetty-maven-plugin to version 12.0.8 of jejetty-ee10-maven-plugin (which uses jetty-12.0.8), and reproduced this issue in the Jetty 12... Was the fix done in v10 migrated to v12 properly?

Everything as written in this issue - it sometimes picks up the String constructor and works, while the other times it picks the List constructor and fails with "Cannot create instance of class org.eclipse.jetty.util.resource.Resource".

@olamy
Copy link
Member

olamy commented May 1, 2024

@rinnnn it should be almost the same code.
please open a new issue (if possible with a reproducer) as commenting on a closed issue will be lost.

@rinnnn
Copy link

rinnnn commented May 1, 2024

Opened #11732

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug For general bugs on Jetty side
Projects
None yet
4 participants