2
votes

I got a short question, for a while I'm trying to get my application building with maven and running into small hickups.

To get started I updated it from:

Grails 1.3.7 -> 2.0 -> 2.1 -> 2.3.8

using the standard BuildConfig.groovy, which works fine and my app behaves as it should.

Now after executing:

grails create-pom mycompany

and adjusting the pom to reflect the reality a bit more, I keep running into the following error:

[context.ContextLoader] [ERROR] [16:00:24] [Context initialization failed] org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'pluginManager' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: Lgrails/plugin/searchable/SearchableService; at org.eclipse.jetty.server.handler.ContextHandler.startContext(ContextHandler.java:733) at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:233) at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1214) at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:676) at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:455) at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:59) at org.eclipse.jetty.server.handler.HandlerWrapper.doStart(HandlerWrapper.java:90) at org.eclipse.jetty.server.Server.doStart(Server.java:261) at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:59) at org.grails.jetty.JettyServer.startServer(JettyServer.groovy:134) at org.grails.jetty.JettyServer.start(JettyServer.groovy:99) at _GrailsRun$_run_closure1.doCall(_GrailsRun.groovy:60) at RunApp$_run_closure1.doCall(RunApp.groovy:33) at org.grails.launcher.GrailsLauncher.launch(GrailsLauncher.java:144) at org.grails.maven.plugin.tools.ForkedGrailsRuntime.main(ForkedGrailsRuntime.java:168) Caused by: java.lang.NoClassDefFoundError: Lgrails/plugin/searchable/SearchableService; at java.lang.Class.privateGetDeclaredFields(Class.java:2348) at java.lang.Class.getDeclaredField(Class.java:1916) ... 15 more Caused by: java.lang.ClassNotFoundException: grails.plugin.searchable.SearchableService at org.grails.launcher.RootLoader.findClass(RootLoader.java:147) at java.lang.ClassLoader.loadClass(ClassLoader.java:306) at org.grails.launcher.RootLoader.loadClass(RootLoader.java:119) at java.lang.ClassLoader.loadClass(ClassLoader.java:247) ... 17 more

Configuration of my pom:

build section:

<build>
    <pluginManagement/>

    <plugins>
        <!-- Disables the Maven surefire plugin for Grails applications, as we have our own test runner -->
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <configuration>
                <skip>true</skip>
            </configuration>
            <executions>
                <execution>
                    <id>surefire-it</id>
                    <phase>integration-test</phase>
                    <goals>
                        <goal>test</goal>
                    </goals>
                    <configuration>
                        <skip>false</skip>
                    </configuration>
                </execution>
            </executions>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-clean-plugin</artifactId>
            <version>2.4.1</version>
            <configuration>
                <filesets>
                    <fileset>
                        <directory>plugins</directory>
                        <includes>
                            <include>**/*</include>
                        </includes>
                        <followSymlinks>false</followSymlinks>
                    </fileset>
                </filesets>
            </configuration>
        </plugin>

        <plugin>
            <groupId>org.grails</groupId>
            <artifactId>grails-maven-plugin</artifactId>
            <version>${grails.version}</version>
            <configuration>
                <!-- Whether for Fork a JVM to run Grails commands -->
                <fork>true</fork>
            </configuration>
            <extensions>true</extensions>

        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.1</version>
            <configuration>
                <source>1.6</source>
                <target>1.6</target>
            </configuration>
        </plugin>


    </plugins>
</build>    

dependency section:

<dependencies>

.....

    <dependency>
        <groupId>org.grails.plugins</groupId>
        <artifactId>searchable</artifactId>
        <version>0.6.9</version>
        <type>zip</type>
        <scope>compile</scope>
    </dependency>

....    

</dependencies>

and executing mvn clean install shows the successful installation of the searchable plugin.

Loading Grails 2.3.8 |Configuring classpath |Running pre-compiled script . |Environment set to development ...... |Installing zip tinyurl-0.1.zip... ... |Installed plugin tinyurl-0.1 ............. |Installing zip executor-0.3.zip... ... |Installed plugin executor-0.3 ............. |Installing zip searchable-0.6.9.zip... ... |Installed plugin searchable-0.6.9

Thanks for installing the Grails Searchable Plugin!

Documentation is available at ...

Help is available from [email protected]

Issues and improvements should be raised at...

If you are upgrading from a previous release, please see ...

|Installing zip jquery-datatables-1.7.5.zip... ...

|Installed plugin jquery-datatables-1.7.5

............. |Installing zip jetty-2.0.3.zip... ...

|Installed plugin jetty-2.0.3 .............

I would really appreciate some help with this and thanks in advance!

2

2 Answers

0
votes

This is the relevant line in your stacktrace:

java.lang.ClassNotFoundException: grails.plugin.searchable.SearchableService

Do you have the following in your BuildConfig.groovy?

compile ":searchable:0.6.9"

(As per http://grails.org/plugin/searchable)

0
votes

Ok the resolution for this issues turned out to be updating the maven grails plugin to 2.4.3 and everything builds now.

       <plugin>
            <groupId>org.grails</groupId>
            <artifactId>grails-maven-plugin</artifactId>
            <version>2.4.3</version>
            <configuration>
                <!-- Whether for Fork a JVM to run Grails commands -->
                <fork>true</fork>
                <grailsVersion>${grails.version}</grailsVersion>
            </configuration>
            <extensions>true</extensions>

        </plugin>

thanks for provided help