suraha
suraha

Reputation: 387

No plugin found for prefix 'jetty' in the current project and in the plugin groups

I run

mvn jetty:run

command and I am getting

--No plugin found for prefix 'jetty' in the current project and in the plugin groups [org.apache.maven.plugins, org.codehaus.mojo] available from the repositories [local (C:\work.m2\repository), error--

controller

package com.himtech.googlechart;
//imports are here

@Controller
@RequestMapping("/gcharts")
public class GglPieChart
{
    @RequestMapping(value = "/piechart", method = RequestMethod.GET)
    public String drawPieChart(ModelMap model)
    {
        Slice s1 = Slice.newSlice(15, Color.newColor("CACACA"), "Mac", "Mac");
        Slice s2 = Slice.newSlice(50, Color.newColor("DF7417"), "Window","Window");
        Slice s3 = Slice.newSlice(25, Color.newColor("951800"), "Linux","Linux");
        Slice s4 = Slice.newSlice(10, Color.newColor("01A1DB"), "Others","Others");

        PieChart pieChart = GCharts.newPieChart(s1, s2, s3, s4);
        pieChart.setTitle("Google Pie Chart", Color.BLACK, 15);
        pieChart.setSize(720, 360);
        pieChart.setThreeD(true);

        model.addAttribute("pieUrl", pieChart.toURLString());

        return "display";
    }
}

web.xml

<web-app id="WebApp_ID" version="2.5"
    xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee 
    http://java.sun.com/xml/ns/j2ee/web-app_2_5.xsd">

    <display-name>SpringMVC 3.2 + Google Chart</display-name>

    <servlet>
        <servlet-name>frontController</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <init-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>WEB-INF/applnConfig.xml</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>

    <servlet-mapping>
        <servlet-name>frontController</servlet-name>
        <url-pattern>/</url-pattern>
    </servlet-mapping>
</web-app>

applnConfig.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:mvc="http://www.springframework.org/schema/mvc" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="
        http://www.springframework.org/schema/beans     
        http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
        http://www.springframework.org/schema/context 
        http://www.springframework.org/schema/context/spring-context-3.2.xsd
        http://www.springframework.org/schema/mvc
        http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd">

    <context:component-scan base-package="com.himtech" />

    <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <property name="prefix">
            <value>/jsps/</value>
        </property>
        <property name="suffix">
            <value>.jsp</value>
        </property>
    </bean>
</beans>

pom.xml

<project>
    <modelVersion>4.0.0</modelVersion>
    <groupId>himtech</groupId>
    <artifactId>springmvc_googlechart</artifactId>
    <packaging>war</packaging>
    <version>1.0.0</version>
    <name>springmvc_googlechart Maven Webapp</name>

    <properties>
        <spring.version>3.2.1.RELEASE</spring.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-core</artifactId>
            <version>${spring.version}</version>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-web</artifactId>
            <version>${spring.version}</version>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc</artifactId>
            <version>${spring.version}</version>
        </dependency>

        <dependency>
            <groupId>com.googlecode.charts4j</groupId>
            <artifactId>charts4j</artifactId>
            <version>1.3</version>
        </dependency>

        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>servlet-api</artifactId>
            <version>2.5</version>
            <scope>provided</scope>
        </dependency>
    </dependencies>

    <build>
        <finalName>springmvc_googlechart</finalName>
    </build>
</project>

Upvotes: 0

Views: 2636

Answers (1)

A_Di-Matteo
A_Di-Matteo

Reputation: 27872

You are getting this error because the jetty plugin prefix is not recognized by default (as part of default plugins) nor configured in your settings.

Change the build section you mentioned as below (that is, add the Jenkins Maven Plugin to it):

<build>
    <finalName>springmvc_googlechart</finalName>
    <plugins>
        <plugin>
            <groupId>org.eclipse.jetty</groupId>
            <artifactId>jetty-maven-plugin</artifactId>
            <version>9.2.8.v20150217</version>
            <configuration>
                <scanIntervalSeconds>10</scanIntervalSeconds>
                <httpConnector>
                    <port>7777</port>
                </httpConnector>
            </configuration>
        </plugin>
    </plugins>
</build>

By defining the Jetty Maven Plugin as part of your POM, Maven will properly recognize the jetty prefix/alias from command line, hence executing the following will work:

mvn jetty:run

Note: in the configuration above, Jetty will run on port 7777 (hence, accessible from http://localhost:7777), you can change it as required. By default the application will be deployed under the server root (the URL previously mentioned). If you want to access it from http://localhost:7777/springmvc_googlechart, you can then add the following to the above configuration section:

<webApp>
    <contextPath>/${project.build.finalName}</contextPath>
</webApp>

Check the official plugin documentation for further configuration.

Upvotes: 2

Related Questions