Quantcast

mavenized grails project

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

mavenized grails project

Liping Xu
Recently, I have developed a Grails web application that uses spring-security-core plugin for access control.  I did not have any problem with installing the plugin using grails install-plugin command, but have trouble to make it work in a mavenized grails application.
 
The following are what I have done:
 

(1)    Installed apache-maven-2.2.1 and set it to classpath

 

(2)    Created a mavenized new grails project by running:

mvn archetype:generate -DarchetypeGroupId=org.grails -DarchetypeArtifactId=grails-maven-archetype -DarchetypeVersion=1.3.7 -DgroupId=myProject  -DartifactId=myApp

 

(3)    Changed JDK from 1.5 to 1.6 in pom.xml

 

(4)    Added version 2.3.2 to maven-compiler-plugin in pom.xml to get rid of an error  from running “mvn initialize”

 

(5)    Run “mvn initialize”

 

(6)    Run “mvn grails:install-plugin -DpluginName=spring-security-core -DpluginVersion=1.1.2”

 

(7)    Run “mvn compile”

 
Everything before step (7) was successful.  But step (7) threw out 100 compilation errors and they seem like related to this plugin.  The following is a snapshot of the error message: 
 
Running pre-compiled script
Environment set to development
  [groovyc] Compiling 39 source files to /path/to/myApp/target/plugin-classes
  [groovyc] org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
  [groovyc] Compile error during compilation with javac.
  [groovyc] /path/to/myApp/plugins/spring-security-core-1.1.2/src/java/grails/plugins/springsecurity/ByteArrayPasswordEncoder.java:5: package org.springframework.security.authentication.encoding does not exist
  [groovyc] import org.springframework.security.authentication.encoding.PasswordEncoder;
  [groovyc]                                                            ^
  [groovyc] /path/to/myApp/plugins/spring-security-core-1.1.2/src/java/grails/plugins/springsecurity/ByteArrayPasswordEncoder.java:7: cannot find symbol
  [groovyc] symbol: class PasswordEncoder
  [groovyc] public class ByteArrayPasswordEncoder implements PasswordEncoder {
  [groovyc]                                                  ^
  [groovyc] /path/to/myApp/plugins/spring-security-core-1.1.2/src/java/grails/plugins/springsecurity/DigestAuthPasswordEncoder.java:21: package org.springframework.security.authentication.encoding does not exist
  [groovyc] import org.springframework.security.authentication.encoding.PasswordEncoder;
  [groovyc]                                                            ^
  [groovyc] /path/to/myApp/plugins/spring-security-core-1.1.2/src/java/grails/plugins/springsecurity/DigestAuthPasswordEncoder.java:22: package org.springframework.security.core.codec does not exist
  [groovyc] import org.springframework.security.core.codec.Hex;
 
.
.
 
  [groovyc] /path/to/myApp/plugins/spring-security-core-1.1.2/src/java/org/codehaus/groovy/grails/plugins/springsecurity/ChannelFilterInvocationSecurityMetadataSourceFactoryBean.java:39: cannot find symbol
  [groovyc] symbol  : class UrlMatcher
  [groovyc] location: class org.codehaus.groovy.grails.plugins.springsecurity.ChannelFilterInvocationSecurityMetadataSourceFactoryBean
  [groovyc]     private UrlMatcher _urlMatcher;
  [groovyc]             ^
  [groovyc] Note: /path/to/myApp/plugins/spring-security-core-1.1.2/src/java/org/codehaus/groovy/grails/plugins/springsecurity/GrailsWebInvocationPrivilegeEvaluator.java uses or overrides a deprecated API.
  [groovyc] Note: Recompile with -Xlint:deprecation for details.
  [groovyc] 100 errors
  [groovyc]
  [groovyc]
  [groovyc] 1 error
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Unable to start Grails
Embedded error: java.lang.reflect.InvocationTargetException
startup failed:
Compile error during compilation with javac.
/path/to/myApp/plugins/spring-security-core-1.1.2/src/java/grails/plugins/springsecurity/ByteArrayPasswordEncoder.java:5: package org.springframework.security.authentication.encoding does not exist
import org.springframework.security.authentication.encoding.PasswordEncoder;
                                                           ^
/path/to/cawsTool/plugins/spring-security-core-1.1.2/src/java/grails/plugins/springsecurity/ByteArrayPasswordEncoder.java:7: cannot find symbol
symbol: class PasswordEncoder
.
.
 
I intended to copy my existing grails project over to the mavenized new project after step (7), but because of the compilation errors, I can not proceed any further.
 
Here are my questions:
 
(1) To use spring-security-core plugin, we need to run s2-quickstart to initialize the plugin and create some domain classes, such as User, Role, etc, do we need to the same in a mavenized grails project?  If yes, how to run it?  I tried to run mvn grails:exec -Dcommand="S2Quickstart" -Dparameter="cawstool User Role", but got the same errors as running "mvn compile" in step (7).
 
(2) When a plugin gets installed, will its dependencies gets installed as well?  if so, why the compiler kept complaining about imported package not exsiting?
 
Does anyone have experience in making the plugin work?  If yes, can you please share it with me?
 
Thanks,
 
Lisa
 
 
 
 
 
 
 
 

 

 

 


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: mavenized grails project

jpearlin
The problem is that Maven does not know anything about the Grails Spring Security plugin or its dependencies, unless you "Mavenize" the plugin as well.  This is one of the core issues with the Grails Maven plugin.  Because Maven must set the classpath that is passed to the Grails scripts that are executed from within the plugin, Maven must know about all dependencies that need to be on the classpath.  We have gotten around this by creating a POM file for the plugin (including all dependencies that otherwise would be in the plugin ZIP file or referenced in the Dependencies.groovy file in the plugin) and installing the plugin as a Maven artifact in our Maven repository (you will probably want to use the packaging type of "grails-plugin").  Once you do that (and include the new plugin dependency as a dependency in your main application's POM file), the Grails Maven plugin should do the right thing and add all of the Grails plugin's dependencies to the classpath and thus help compilation pass.

--Jonathan

On Fri, Jun 3, 2011 at 11:55 AM, Liping xu <[hidden email]> wrote:
Recently, I have developed a Grails web application that uses spring-security-core plugin for access control.  I did not have any problem with installing the plugin using grails install-plugin command, but have trouble to make it work in a mavenized grails application.
 
The following are what I have done:
 

(1)    Installed apache-maven-2.2.1 and set it to classpath

 

(2)    Created a mavenized new grails project by running:

mvn archetype:generate -DarchetypeGroupId=org.grails -DarchetypeArtifactId=grails-maven-archetype -DarchetypeVersion=1.3.7 -DgroupId=myProject  -DartifactId=myApp

 

(3)    Changed JDK from 1.5 to 1.6 in pom.xml

 

(4)    Added version 2.3.2 to maven-compiler-plugin in pom.xml to get rid of an error  from running “mvn initialize”

 

(5)    Run “mvn initialize”

 

(6)    Run “mvn grails:install-plugin -DpluginName=spring-security-core -DpluginVersion=1.1.2”

 

(7)    Run “mvn compile”

 
Everything before step (7) was successful.  But step (7) threw out 100 compilation errors and they seem like related to this plugin.  The following is a snapshot of the error message: 
 
Running pre-compiled script
Environment set to development
  [groovyc] Compiling 39 source files to /path/to/myApp/target/plugin-classes
  [groovyc] org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
  [groovyc] Compile error during compilation with javac.
  [groovyc] /path/to/myApp/plugins/spring-security-core-1.1.2/src/java/grails/plugins/springsecurity/ByteArrayPasswordEncoder.java:5: package org.springframework.security.authentication.encoding does not exist
  [groovyc] import org.springframework.security.authentication.encoding.PasswordEncoder;
  [groovyc]                                                            ^
  [groovyc] /path/to/myApp/plugins/spring-security-core-1.1.2/src/java/grails/plugins/springsecurity/ByteArrayPasswordEncoder.java:7: cannot find symbol
  [groovyc] symbol: class PasswordEncoder
  [groovyc] public class ByteArrayPasswordEncoder implements PasswordEncoder {
  [groovyc]                                                  ^
  [groovyc] /path/to/myApp/plugins/spring-security-core-1.1.2/src/java/grails/plugins/springsecurity/DigestAuthPasswordEncoder.java:21: package org.springframework.security.authentication.encoding does not exist
  [groovyc] import org.springframework.security.authentication.encoding.PasswordEncoder;
  [groovyc]                                                            ^
  [groovyc] /path/to/myApp/plugins/spring-security-core-1.1.2/src/java/grails/plugins/springsecurity/DigestAuthPasswordEncoder.java:22: package org.springframework.security.core.codec does not exist
  [groovyc] import org.springframework.security.core.codec.Hex;
 
.
.
 
  [groovyc] /path/to/myApp/plugins/spring-security-core-1.1.2/src/java/org/codehaus/groovy/grails/plugins/springsecurity/ChannelFilterInvocationSecurityMetadataSourceFactoryBean.java:39: cannot find symbol
  [groovyc] symbol  : class UrlMatcher
  [groovyc] location: class org.codehaus.groovy.grails.plugins.springsecurity.ChannelFilterInvocationSecurityMetadataSourceFactoryBean
  [groovyc]     private UrlMatcher _urlMatcher;
  [groovyc]             ^
  [groovyc] Note: /path/to/myApp/plugins/spring-security-core-1.1.2/src/java/org/codehaus/groovy/grails/plugins/springsecurity/GrailsWebInvocationPrivilegeEvaluator.java uses or overrides a deprecated API.
  [groovyc] Note: Recompile with -Xlint:deprecation for details.
  [groovyc] 100 errors
  [groovyc]
  [groovyc]
  [groovyc] 1 error
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Unable to start Grails
Embedded error: java.lang.reflect.InvocationTargetException
startup failed:
Compile error during compilation with javac.
/path/to/myApp/plugins/spring-security-core-1.1.2/src/java/grails/plugins/springsecurity/ByteArrayPasswordEncoder.java:5: package org.springframework.security.authentication.encoding does not exist
import org.springframework.security.authentication.encoding.PasswordEncoder;
                                                           ^
/path/to/cawsTool/plugins/spring-security-core-1.1.2/src/java/grails/plugins/springsecurity/ByteArrayPasswordEncoder.java:7: cannot find symbol
symbol: class PasswordEncoder
.
.
 
I intended to copy my existing grails project over to the mavenized new project after step (7), but because of the compilation errors, I can not proceed any further.
 
Here are my questions:
 
(1) To use spring-security-core plugin, we need to run s2-quickstart to initialize the plugin and create some domain classes, such as User, Role, etc, do we need to the same in a mavenized grails project?  If yes, how to run it?  I tried to run mvn grails:exec -Dcommand="S2Quickstart" -Dparameter="cawstool User Role", but got the same errors as running "mvn compile" in step (7).
 
(2) When a plugin gets installed, will its dependencies gets installed as well?  if so, why the compiler kept complaining about imported package not exsiting?
 
Does anyone have experience in making the plugin work?  If yes, can you please share it with me?
 
Thanks,
 
Lisa
 
 
 
 
 
 
 
 

 

 

 



Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: mavenized grails project

Liping Xu
Thank you very much for your response. 
 
I have just done what you suggested as a work-around solution and now the compilation errors associated with spring-security-core plugin are all gone.  Thank you for your kindly help.
 
But, I am getting a different compilation error that is related to dependecy of org.codehaus.groovy.modules.http-builder,
 
Embedded error: java.lang.reflect.InvocationTargetException
loader constraint violation: when resolving overridden method "org.apache.xerces.jaxp.SAXParserImpl.getParser()Lorg/xml/sax/Parser;" the class loader (instance of org/codehaus/groovy/grails/cli/support/GrailsRootLoader) of the current class, org/apache/xerces/jaxp/SAXParserImpl, and its superclass loader (instance of <bootloader>), have different Class objects for the type org/xml/sax/Parser used in the signature
 
I have the following in pom.xml:
 
    <dependency>
       <groupId>org.codehaus.groovy.modules.http-builder</groupId>
       <artifactId>http-builder</artifactId>
       <version>0.5.1</version>
    </dependency>

 
Do you have experience on how to resolve it?
 
Thanks,
 
Lisa


From: Jonathan Pearlin <[hidden email]>
To: [hidden email]
Sent: Mon, June 6, 2011 8:18:13 AM
Subject: Re: [grails-user] mavenized grails project

The problem is that Maven does not know anything about the Grails Spring Security plugin or its dependencies, unless you "Mavenize" the plugin as well.  This is one of the core issues with the Grails Maven plugin.  Because Maven must set the classpath that is passed to the Grails scripts that are executed from within the plugin, Maven must know about all dependencies that need to be on the classpath.  We have gotten around this by creating a POM file for the plugin (including all dependencies that otherwise would be in the plugin ZIP file or referenced in the Dependencies.groovy file in the plugin) and installing the plugin as a Maven artifact in our Maven repository (you will probably want to use the packaging type of "grails-plugin").  Once you do that (and include the new plugin dependency as a dependency in your main application's POM file), the Grails Maven plugin should do the right thing and add all of the Grails plugin's dependencies to the classpath and thus help compilation pass.

--Jonathan

On Fri, Jun 3, 2011 at 11:55 AM, Liping xu <[hidden email]> wrote:
Recently, I have developed a Grails web application that uses spring-security-core plugin for access control.  I did not have any problem with installing the plugin using grails install-plugin command, but have trouble to make it work in a mavenized grails application.
 
The following are what I have done:
 

(1)    Installed apache-maven-2.2.1 and set it to classpath

 

(2)    Created a mavenized new grails project by running:

mvn archetype:generate -DarchetypeGroupId=org.grails -DarchetypeArtifactId=grails-maven-archetype -DarchetypeVersion=1.3.7 -DgroupId=myProject  -DartifactId=myApp

 

(3)    Changed JDK from 1.5 to 1.6 in pom.xml

 

(4)    Added version 2.3.2 to maven-compiler-plugin in pom.xml to get rid of an error  from running “mvn initialize”

 

(5)    Run “mvn initialize”

 

(6)    Run “mvn grails:install-plugin -DpluginName=spring-security-core -DpluginVersion=1.1.2”

 

(7)    Run “mvn compile”

 
Everything before step (7) was successful.  But step (7) threw out 100 compilation errors and they seem like related to this plugin.  The following is a snapshot of the error message: 
 
Running pre-compiled script
Environment set to development
  [groovyc] Compiling 39 source files to /path/to/myApp/target/plugin-classes
  [groovyc] org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
  [groovyc] Compile error during compilation with javac.
  [groovyc] /path/to/myApp/plugins/spring-security-core-1.1.2/src/java/grails/plugins/springsecurity/ByteArrayPasswordEncoder.java:5: package org.springframework.security.authentication.encoding does not exist
  [groovyc] import org.springframework.security.authentication.encoding.PasswordEncoder;
  [groovyc]                                                            ^
  [groovyc] /path/to/myApp/plugins/spring-security-core-1.1.2/src/java/grails/plugins/springsecurity/ByteArrayPasswordEncoder.java:7: cannot find symbol
  [groovyc] symbol: class PasswordEncoder
  [groovyc] public class ByteArrayPasswordEncoder implements PasswordEncoder {
  [groovyc]                                                  ^
  [groovyc] /path/to/myApp/plugins/spring-security-core-1.1.2/src/java/grails/plugins/springsecurity/DigestAuthPasswordEncoder.java:21: package org.springframework.security.authentication.encoding does not exist
  [groovyc] import org.springframework.security.authentication.encoding.PasswordEncoder;
  [groovyc]                                                            ^
  [groovyc] /path/to/myApp/plugins/spring-security-core-1.1.2/src/java/grails/plugins/springsecurity/DigestAuthPasswordEncoder.java:22: package org.springframework.security.core.codec does not exist
  [groovyc] import org.springframework.security.core.codec.Hex;
 
.
.
 
  [groovyc] /path/to/myApp/plugins/spring-security-core-1.1.2/src/java/org/codehaus/groovy/grails/plugins/springsecurity/ChannelFilterInvocationSecurityMetadataSourceFactoryBean.java:39: cannot find symbol
  [groovyc] symbol  : class UrlMatcher
  [groovyc] location: class org.codehaus.groovy.grails.plugins.springsecurity.ChannelFilterInvocationSecurityMetadataSourceFactoryBean
  [groovyc]     private UrlMatcher _urlMatcher;
  [groovyc]             ^
  [groovyc] Note: /path/to/myApp/plugins/spring-security-core-1.1.2/src/java/org/codehaus/groovy/grails/plugins/springsecurity/GrailsWebInvocationPrivilegeEvaluator.java uses or overrides a deprecated API.
  [groovyc] Note: Recompile with -Xlint:deprecation for details.
  [groovyc] 100 errors
  [groovyc]
  [groovyc]
  [groovyc] 1 error
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Unable to start Grails
Embedded error: java.lang.reflect.InvocationTargetException
startup failed:
Compile error during compilation with javac.
/path/to/myApp/plugins/spring-security-core-1.1.2/src/java/grails/plugins/springsecurity/ByteArrayPasswordEncoder.java:5: package org.springframework.security.authentication.encoding does not exist
import org.springframework.security.authentication.encoding.PasswordEncoder;
                                                           ^
/path/to/cawsTool/plugins/spring-security-core-1.1.2/src/java/grails/plugins/springsecurity/ByteArrayPasswordEncoder.java:7: cannot find symbol
symbol: class PasswordEncoder
.
.
 
I intended to copy my existing grails project over to the mavenized new project after step (7), but because of the compilation errors, I can not proceed any further.
 
Here are my questions:
 
(1) To use spring-security-core plugin, we need to run s2-quickstart to initialize the plugin and create some domain classes, such as User, Role, etc, do we need to the same in a mavenized grails project?  If yes, how to run it?  I tried to run mvn grails:exec -Dcommand="S2Quickstart" -Dparameter="cawstool User Role", but got the same errors as running "mvn compile" in step (7).
 
(2) When a plugin gets installed, will its dependencies gets installed as well?  if so, why the compiler kept complaining about imported package not exsiting?
 
Does anyone have experience in making the plugin work?  If yes, can you please share it with me?
 
Thanks,
 
Lisa
 
 
 
 
 
 
 
 

 

 

 



Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: mavenized grails project

pledbrook
> I have the following in pom.xml:
>
>     <dependency>
>        <groupId>org.codehaus.groovy.modules.http-builder</groupId>
>        <artifactId>http-builder</artifactId>
>        <version>0.5.1</version>
>     </dependency>
>
> Do you have experience on how to resolve it?

You'll want to exclude the "commons-logging", "xml-apis" and "groovy"
transitive dependencies, as the Release plugin does here:

    https://github.com/grails-plugins/grails-release/blob/master/grails-app/conf/BuildConfig.groovy#L28

Sorry, don't have a POM example for that.

Peter

--
Peter Ledbrook
Grails Advocate
SpringSource - A Division of VMware

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: mavenized grails project

Liping Xu
Thank you for your prompt response.  I will definitely give it a try tomorrow.
 
Lisa


From: Peter Ledbrook <[hidden email]>
To: [hidden email]
Sent: Mon, June 6, 2011 5:25:55 PM
Subject: Re: [grails-user] mavenized grails project

> I have the following in pom.xml:
>
>     <dependency>
>        <groupId>org.codehaus.groovy.modules.http-builder</groupId>
>        <artifactId>http-builder</artifactId>
>        <version>0.5.1</version>
>     </dependency>
>
> Do you have experience on how to resolve it?

You'll want to exclude the "commons-logging", "xml-apis" and "groovy"
transitive dependencies, as the Release plugin does here:

    https://github.com/grails-plugins/grails-release/blob/master/grails-app/conf/BuildConfig.groovy#L28

Sorry, don't have a POM example for that.

Peter

--
Peter Ledbrook
Grails Advocate
SpringSource - A Division of VMware

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: mavenized grails project

rlovtangen
In reply to this post by pledbrook
POM example:

                <dependency>
                        <groupId>org.codehaus.groovy.modules.http-builder</groupId>
                        <artifactId>http-builder</artifactId>
                        <version>0.5.1</version>
                        <exclusions>
                                <exclusion>
                                        <groupId>org.codehaus.groovy</groupId>
                                        <artifactId>groovy</artifactId>
                                </exclusion>
                                <exclusion>
                                        <groupId>xml-apis</groupId>
                                        <artifactId>xml-apis</artifactId>
                                </exclusion>
                        </exclusions>
                </dependency>


On Jun 6, 2011, at 11:25 PM, Peter Ledbrook wrote:

>> I have the following in pom.xml:
>>
>>     <dependency>
>>        <groupId>org.codehaus.groovy.modules.http-builder</groupId>
>>        <artifactId>http-builder</artifactId>
>>        <version>0.5.1</version>
>>     </dependency>
>>
>> Do you have experience on how to resolve it?
>
> You'll want to exclude the "commons-logging", "xml-apis" and "groovy"
> transitive dependencies, as the Release plugin does here:
>
>    https://github.com/grails-plugins/grails-release/blob/master/grails-app/conf/BuildConfig.groovy#L28
>
> Sorry, don't have a POM example for that.
>
> Peter
>
> --
> Peter Ledbrook
> Grails Advocate
> SpringSource - A Division of VMware
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>    http://xircles.codehaus.org/manage_email
>
>
>


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Loading...