30

I've created a Maven project. This is the structure:

-parent
    -core
    -web

but when I try to deploy with the command mvn tomcat7:deploy, I get the following error:

No plugin found for prefix 'tomcat7' in the current project and in the plugin groups [org.apache.maven.plugins, org.codehaus.mojo]

I put this configuration in the pom.xml (of the web project):

<build>
    <finalName>MavenWeb</finalName>
    <plugins>
        <plugin>
            <groupId>org.apache.tomcat.maven</groupId>
            <artifactId>tomcat7-maven-plugin</artifactId>
            <version>2.0</version>
        </plugin>
    </plugins>
</build>
3
  • 6
    You are probably executing this command NOT from your web project. Jun 19, 2014 at 20:09
  • @Aleksandr thank you for your answer, you were right. Now I am trying to solve another problem "Cannot invoke Tomcat manager: Connection to 127.0.0.1:8080 refused: Connection refused" I am trying to reach the solution. Jun 19, 2014 at 20:53
  • Version concretization in <i>tomcat7-maven-plugin</i> pom.xml helped me. There was <version>${tomcat7-maven-plugin.version}</version>. I changed it to <version>2.2</version> and all worked! May 24, 2019 at 18:22

6 Answers 6

23

Plugins goals can be called using their 'FQN': groupId:artifactId:version:goal or, if applicable, shorter commands (many variants available). Using only the short name of a plugin (in your tomcat7:deploy, tomcat7 is the short name, deploy being the goal/mojo) is applicable if:

1) the groupId of the plugin is contained in the known plugin groups of Maven. org.apache.maven.plugins being in the list by default.

OR

the pom.xml of the project you're invoking the Maven command on declares the plugin

2) the artifactId is [short-name]-maven-plugin or maven-[short-name]-plugin (maven-[short-name]-plugin being 'reserved' for plugins provided by Maven project.

That explains why mvn compiler:compile can work out of the box on any project, but not tomcat7:deploy

In your case, the second condition is true, so you just have to declare the plugin on the project you're launching the command on, or add this to your user settings.xml file:

<pluginGroups>
  <pluginGroup>org.apache.tomcat.maven</pluginGroup>
</pluginGroups>

See here for more info

5
  • 1
    There is no need to change settings.xml file if plugin is defined in pom. Jun 19, 2014 at 20:12
  • You're right, I'm editing the answer to include this
    – Tome
    Jun 20, 2014 at 7:08
  • What does "you just have to declare the plugin on the project you're launching the command on" mean for the pom.xml? How do I do this exactly?
    – Daniel S.
    Apr 30, 2015 at 8:50
  • That means that if the plugin you want to invoke from the command line, using the short notation (not the FQN) is already defined in the pom.xml of the module you're invoking the command from, the <pluginGroups> is not needed.
    – Tome
    Apr 30, 2015 at 8:59
  • I would like to add that the settings.xml file is inside the apache-maven-X.X.X\conf\ folder, because It wasn't easy to find it, being a begginer myself and that info could be useful for someone else (even though after all I get it working with the maven-plugin-dependency tip ;) )
    – visconttig
    Jul 18, 2021 at 17:17
5

The reason why you get that error is because you simply have not installed the Tomcat7 plugin. Here's what you can do (I tested this on my test project and it works):

  1. Add tomcat7 plugin dependency in your pom.xml file just like you have done.
  2. Run either mvn installor mvn package to install that tomcat7 plugin
  3. Now you should be able to run mvn tomcat7:deploy

I tested this solution with mvn tomcat7:run and it works like a charm :)

4

It means tomcat7 plugin not found . Add this to your pom.xml.

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.tomcat.maven</groupId>
            <artifactId>tomcat7-maven-plugin</artifactId>
            <version>2.3-SNAPSHOT</version>
        </plugin>
    </plugins>
</build>
1

The error happens to have the plugin inside <reporting>, it should be located in <build>

Before:

<reporting>
<plugins>
    <plugin>
    <groupId>org.apache.tomcat.maven</groupId>
    <artifactId>tomcat7-maven-plugin</artifactId>
    <version>2.2</version>
    <configuration>
    <port>8080</port>
    <path>/</path>
    </configuration>
    </plugin>
</plugins>
</reporting>

After:

<build>
<plugins>
    <plugin>
    <groupId>org.apache.tomcat.maven</groupId>
    <artifactId>tomcat7-maven-plugin</artifactId>
    <version>2.2</version>
    <configuration>
    <port>8080</port>
    <path>/</path>
    </configuration>
    </plugin>
</plugins>
</build>
1

After I checked my pom.xml file, I made sure all my dependencies were selected in the build order under the JAVA Build Path JAVA BUILD PATH

1
  • In general you may want to add a little more detail on how your answer solves the original issue
    – camba1
    Jul 8, 2019 at 17:50
0

I got the same error from using the file based idp.xml and formatting it!!! Don't format it, use curl, or chrome and save the file from https://idp.ssocircle.com/idp-meta.xml directly to spring-security-saml-1.0.2.RELEASE\sample\src\main\resources\metadata\idm.xml

Then in SecurityContext.cml

 <bean id="metadata" class="org.springframework.security.saml.metadata.CachingMetadataManager">
    <constructor-arg>
        <list>
            <!-- Example of classpath metadata with Extended Metadata -->
            <bean class="org.springframework.security.saml.metadata.ExtendedMetadataDelegate">
                <constructor-arg>
                    <bean class="org.opensaml.saml2.metadata.provider.ResourceBackedMetadataProvider">
                        <constructor-arg>
                            <bean class="java.util.Timer"/>
                        </constructor-arg>
                        <constructor-arg>
                            <bean class="org.opensaml.util.resource.ClasspathResource">
                                <constructor-arg value="/metadata/idp.xml"/>
                            </bean>
                        </constructor-arg>
                        <property name="parserPool" ref="parserPool"/>
                    </bean>
                </constructor-arg>
                <constructor-arg>
                    <bean class="org.springframework.security.saml.metadata.ExtendedMetadata">
                    </bean>
                </constructor-arg>
            </bean>

</bean>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.