I'm attempting to use the Spring Security OpenID plugin in grails. I used the supplied scripts to generate the various classes and I have the following in my Config.groovy:
grails.plugins.springsecurity.userLookup.userDomainClassName = 'net.example.manager.User'
grails.plugins.springsecurity.userLookup.authorityJoinClassName = 'net.example.manager.UserRole'
grails.plugins.springsecurity.authority.className = 'net.example.manager.Role'
grails.plugins.springsecurity.openid.domainClass = 'net.example.manager.OpenID'
When I run grails run-app I get the following error:
[main] ERROR context.GrailsContextLoader - Error executing bootstraps: Cannot invoke method newInstance() on null object
java.lang.NullPointerException: Cannot invoke method newInstance() on null object
at SpringSecurityOpenidGrailsPlugin$_closure2.doCall(SpringSecurityOpenidGrailsPlugin.groovy:140)
at org.grails.tomcat.TomcatServer.start(TomcatServer.groovy:212)
at grails.web.container.EmbeddableServer$start.call(Unknown Source)
at _GrailsRun_groovy$_run_closure5_closure12.doCall(_GrailsRun_groovy:158)
at _GrailsRun_groovy$_run_closure5_closure12.doCall(_GrailsRun_groovy)
at _GrailsSettings_groovy$_run_closure10.doCall(_GrailsSettings_groovy:280)
at _GrailsSettings_groovy$_run_closure10.call(_GrailsSettings_groovy)
at _GrailsRun_groovy$_run_closure5.doCall(_GrailsRun_groovy:149)
at _GrailsRun_groovy$_run_closure5.call(_GrailsRun_groovy)
at _GrailsRun_groovy.runInline(_GrailsRun_groovy:116)
at _GrailsRun_groovy.this$4$runInline(_GrailsRun_groovy)
at _GrailsRun_groovy$_run_closure1.doCall(_GrailsRun_groovy:59)
at RunApp$_run_closure1.doCall(RunApp.groovy:33)
at gant.Gant$_dispatch_closure5.doCall(Gant.groovy:381)
at gant.Gant$_dispatch_closure7.doCall(Gant.groovy:415)
at gant.Gant$_dispatch_closure7.doCall(Gant.groovy)
at gant.Gant.withBuildListeners(Gant.groovy:427)
at gant.Gant.this$2$withBuildListeners(Gant.groovy)
at gant.Gant$this$2$withBuildListeners.callCurrent(Unknown Source)
at gant.Gant.dispatch(Gant.groovy:415)
at gant.Gant.this$2$dispatch(Gant.groovy)
at gant.Gant.invokeMethod(Gant.groovy)
at gant.Gant.executeTargets(Gant.groovy:590)
at gant.Gant.executeTargets(Gant.groovy:589)
I tracked down the error to this area in the OpenID plugin's source (The error occurs in the last line):
String userClassName = conf.userLookup.userDomainClassName
def userClass = ctx.grailsApplication.getClassForName(userClassName)
String openIdsPropertyName = conf.openid.userLookup.openIdsPropertyName
if (openIdsPropertyName && !userClass.newInstance().hasProperty(openIdsPropertyName))
My domain class exists, but for some reason grails can't get the class and I have no idea why.
I had the same problem, though I had a much shorter error message. For whatever reason the call to 'conf.userLookup.userDomainClassName' returned the class name correctly, and it matches the class perfectly, but 'ctx.grailsApplication.getClassForName(userClassName)' returned null. For me this only happened when running locally. When I pushed to my remote branch and ran it there I had no problems.
I fixed this by avoiding the call to 'getForClassName'. I added the following line to my Config.groovy file:
grails.plugins.springsecurity.userLookup.userDomainClass = mypackage.User;
and made the following change in my SpringSecurityOpenidGrailsPlugin.groovy file:
// The old way this was done was breaking when run locally for some reason.
//String userClassName = conf.userLookup.userDomainClassName
//def userClass = ctx.grailsApplication.getClassForName(userClassName)
//
// So I replaced it with this:
Class userClass = conf.userLookup.userDomainClass;
Now it runs fine.
Related
I am having hard time to figure out why Grails fails to run a plugin I created. This is my environment:
Grails Version: 3.2.6
Groovy Version: 2.4.7
JVM Version: 1.8.0_91
And these are my steps:
I created the plugin with:
grails create-plugin bioprofile
I add the Spring Security core plugin, by adding this line to build.gradle:
compile 'org.grails.plugins:spring-security-core:3.1.1'
I ran the s2-quickstart command to set User, Role and UserRole:
grails s2-quickstart cscie56.ps5 User Role
I modified the User domain class to include some new fields
Created a few other domain classes
grails create-domain-class cscie56.ps5.BlogEntry
grails create-domain-class cscie56.ps5.Comment
I generated the controllers, etc...
grails generate-all BlogEntry
grails generate-all User
grails generate-all Role
grails generate-all UserRole
I added the following initialization in the BootStrap.groovy file:
package bioprofile
import cscie56.ps5.Role
import cscie56.ps5.User
import cscie56.ps5.UserRole
class BootStrap {
def init = { servletContext ->
environments {
development {
setupData()
setupUsersAndRoles()
println "Developement execution"
}
test {
setupData()
setupUsersAndRoles()
println "Test execution"
}
production {
// do nothing
println "Production execution"
}
}
}
def destroy = {
}
def setupUsersAndRoles() {
User admin = new User(username: 'admin', password: 'password')
admin.save(flush: true)
User user = new User(username: 'user', password: 'user')
user.save(flsuh:true)
Role adminRole = new Role(authority: Role.ROLE_ADMIN)
adminRole.save(flush:true)
Role userRole = new Role(authority: Role.ROLE_USER)
userRole.save(flush:true)
UserRole.create(admin, adminRole)
UserRole.create(admin, userRole)
UserRole.create(user, userRole)
}
def setupData() {
}
}
When I run the app with grails run-app I get this tedious error:
Running application...
objc[84720]: Class JavaLaunchHelper is implemented in both /Library/Java/JavaVirtualMachines/jdk1.8.0_91.jdk/Contents/Home/bin/java and /Library/Java/JavaVirtualMachines/jdk1.8.0_91.jdk/Contents/Home/jre/lib/libinstrument.dylib. One of the two will be used. Which one is undefined.
Configuring Spring Security Core ...
... finished configuring Spring Security Core
2017-04-06 06:20:06.032 ERROR --- [ main] o.s.boot.SpringApplication : Application startup failed
java.lang.IllegalStateException: Either class [cscie56.ps5.User] is not a domain class or GORM has not been initialized correctly or has already been shutdown. Ensure GORM is loaded and configured correctly before calling any methods on a GORM entity.
at org.grails.datastore.gorm.GormEnhancer.stateException(GormEnhancer.groovy:387)
at org.grails.datastore.gorm.GormEnhancer.findInstanceApi(GormEnhancer.groovy:273)
at org.grails.datastore.gorm.GormEnhancer.findInstanceApi(GormEnhancer.groovy:270)
at org.grails.datastore.gorm.GormEntity$Trait$Helper.currentGormInstanceApi(GormEntity.groovy:1326)
at org.grails.datastore.gorm.GormEntity$Trait$Helper.save(GormEntity.groovy:151)
at org.grails.datastore.gorm.GormEntity$Trait$Helper$save.call(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:133)
at cscie56.ps5.User.save(User.groovy)
at cscie56.ps5.User.save(User.groovy)
at org.grails.datastore.gorm.GormEntity$save.call(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125)
at bioprofile.BootStrap.setupUsersAndRoles(BootStrap.groovy:33)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1426)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:384)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1024)
at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.callCurrent(PogoMetaClassSite.java:69)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:52)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:154)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:158)
at bioprofile.BootStrap$_closure1$_closure3$_closure4.doCall(BootStrap.groovy:13)
at bioprofile.BootStrap$_closure1$_closure3$_closure4.doCall(BootStrap.groovy)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1426)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:294)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1024)
at groovy.lang.Closure.call(Closure.java:414)
at bioprofile.BootStrap$_closure1$_closure3$_closure4.call(BootStrap.groovy)
at groovy.lang.Closure.call(Closure.java:408)
at bioprofile.BootStrap$_closure1$_closure3$_closure4.call(BootStrap.groovy)
at grails.util.Environment$EnvironmentBlockEvaluator.execute(Environment.java:529)
at grails.util.Environment.executeForEnvironment(Environment.java:510)
at grails.util.Environment.executeForCurrentEnvironment(Environment.java:485)
at org.grails.web.servlet.boostrap.DefaultGrailsBootstrapClass.callInit(DefaultGrailsBootstrapClass.java:62)
at org.grails.web.servlet.context.GrailsConfigUtils.executeGrailsBootstraps(GrailsConfigUtils.java:65)
at org.grails.plugins.web.servlet.context.BootStrapClassRunner.onStartup(BootStrapClassRunner.groovy:53)
at grails.boot.config.GrailsApplicationPostProcessor.onApplicationEvent(GrailsApplicationPostProcessor.groovy:256)
at grails.boot.config.GrailsApplicationPostProcessor.onApplicationEvent(GrailsApplicationPostProcessor.groovy)
at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:167)
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139)
at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:383)
at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:337)
at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:882)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.finishRefresh(EmbeddedWebApplicationContext.java:144)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:545)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:762)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:372)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:316)
at grails.boot.GrailsApp.run(GrailsApp.groovy:83)
at grails.boot.GrailsApp.run(GrailsApp.groovy:388)
at grails.boot.GrailsApp.run(GrailsApp.groovy:375)
at grails.boot.GrailsApp$run.call(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:133)
at bioprofile.Application.main(Application.groovy:10)
I tried to run
grails clean
grails clean --refresh-dependencies
grails compile
but same result.
Anyone has encountered this issue or have an idea what the root cause is?
This is what worked for me, if someone else is going to have the same problem.
It seems like it was an hibernate dependencies issue. Not obvious, and most likely a subtle bug of whatever is generating the boilerplate stuff across the several files (never been a big fan of "I'll do it all for you" frameworks).
In my specific case (and this might be specific to my environment) by replacing the generated hibernate5 dependencies with hibernate4 in the build.gradle file, the error above went away. This is what I have now (removed the hibernate5 stuff):
classpath "org.grails.plugins:hibernate4:5.0.10"
compile "org.grails.plugins:hibernate4"
compile "org.hibernate:hibernate-core:4.3.10.Final"
compile "org.hibernate:hibernate-ehcache:4.3.10.Final"
The .withTransaction { hack did not seem to have any effect in solving this problem.
I'm getting the following error in my Grails app. Grails 1.3.7, Spring Security plugin 2.6 How to solve this? I can still run the app but this is realy bugging me.
Configuring Spring Security UI ...
2011-12-08 09:35:07,701 [main] ERROR plugins.DefaultGrailsPluginManager - Error configuring dynamic methods for plugin [springSecurityCore:1.2.6]: You must provide a configuration attribute
java.lang.IllegalArgumentException: You must provide a configuration attribute
at SpringSecurityCoreGrailsPlugin$_closure3.doCall(SpringSecurityCoreGrailsPlugin.groovy:538)
at org.grails.tomcat.TomcatServer.start(TomcatServer.groovy:212)
at grails.web.container.EmbeddableServer$start.call(Unknown Source)
at _GrailsRun_groovy$_run_closure5_closure12.doCall(_GrailsRun_groovy:158)
at _GrailsRun_groovy$_run_closure5_closure12.doCall(_GrailsRun_groovy)
at _GrailsSettings_groovy$_run_closure10.doCall(_GrailsSettings_groovy:280)
at _GrailsSettings_groovy$_run_closure10.call(_GrailsSettings_groovy)
at _GrailsRun_groovy$_run_closure5.doCall(_GrailsRun_groovy:149)
at _GrailsRun_groovy$_run_closure5.call(_GrailsRun_groovy)
at _GrailsRun_groovy.runInline(_GrailsRun_groovy:116)
at _GrailsRun_groovy.this$4$runInline(_GrailsRun_groovy)
at _GrailsRun_groovy$_run_closure1.doCall(_GrailsRun_groovy:59)
at _GrailsRun_groovy$_run_closure8_closure14.doCall(_GrailsRun_groovy:263)
at _GrailsRun_groovy$_run_closure8_closure14.doCall(_GrailsRun_groovy)
at _GrailsPackage_groovy$_run_closure8.doCall(_GrailsPackage_groovy:299)
at _GrailsPackage_groovy$_run_closure8.call(_GrailsPackage_groovy)
at _GrailsRun_groovy$_run_closure8.doCall(_GrailsRun_groovy:245)
at RunApp$_run_closure1.doCall(RunApp:35)
at gant.Gant$_dispatch_closure5.doCall(Gant.groovy:381)
at gant.Gant$_dispatch_closure7.doCall(Gant.groovy:415)
at gant.Gant$_dispatch_closure7.doCall(Gant.groovy)
at gant.Gant.withBuildListeners(Gant.groovy:427)
at gant.Gant.this$2$withBuildListeners(Gant.groovy)
at gant.Gant$this$2$withBuildListeners.callCurrent(Unknown Source)
at gant.Gant.dispatch(Gant.groovy:415)
at gant.Gant.this$2$dispatch(Gant.groovy)
at gant.Gant.invokeMethod(Gant.groovy)
at gant.Gant.executeTargets(Gant.groovy:590)
at gant.Gant.executeTargets(Gant.groovy:589)
Server running. Browse to http://localhost:8080/Test2
I'm on 1.2.4, but the plugin code in SpringSecurityCoreGrailsPlugin.groovy:538 is referencing the filterChain in your securityConfig (which should now be in your Config.groovy file - unlike the Acegi plugin). As suggested look in the plugin source code. You'll find it in: ~/.grails/1.3.7/projects/{yourproject}/plugins
This plugin is an awesome, if somewhat complicated beast - get the basics down with the tutorial: Spring Security Plugin Tutorial Then read the docs carefully, it will save you a ton of time.
I have just created a grails script to create database, but the code is in Java and I thought I could use that in grails script.
This is my script
import com.test.database.*
import com.test.constant.*
import org.neo4j.kernel.*
target(main: "The description of the script goes here!") {
db = DataRepository.getInstance(new EmbeddedGraphDatabase(
Constant.PROJECT_PATH + "/web-app/WEB-INF/resources/db"))
}
setDefaultTarget(main)
And my java classes are in src/java, but when I run the script I got this error
Error executing script DbCreate: No such property: DataRepository for class: DbCreate
No such property: DataRepository for class: DbCreate
at gant.Gant$_dispatch_closure5.doCall(Gant.groovy:387)
at gant.Gant$_dispatch_closure7.doCall(Gant.groovy:415)
at gant.Gant$_dispatch_closure7.doCall(Gant.groovy)
at gant.Gant.withBuildListeners(Gant.groovy:427)
at gant.Gant.this$2$withBuildListeners(Gant.groovy)
at gant.Gant$this$2$withBuildListeners.callCurrent(Unknown Source)
at gant.Gant.dispatch(Gant.groovy:415)
at gant.Gant.this$2$dispatch(Gant.groovy)
at gant.Gant.invokeMethod(Gant.groovy)
at gant.Gant.executeTargets(Gant.groovy:590)
at gant.Gant.executeTargets(Gant.groovy:589)
Caused by: groovy.lang.MissingPropertyException: No such property: DataRepository for class: DbCreate
at DbCreate$_run_closure1.doCall(DbCreate:11)
at gant.Gant$_dispatch_closure5.doCall(Gant.groovy:381)
My question would be could I call user-defined java classes in grails script?
You could load the class directly using the classLoader like this...
def dataRepo = classLoader.loadClass('path.to.DataRepository')
Or you could also use...
includeTargets << grailsScript('_GrailsBootstrap')
Which should load all you members.
If you're using 1.3.6 or greater you can use http://grails.org/doc/latest/ref/Command%20Line/run-script.html and if you're using an older version of Grails you can get the script from http://naleid.com/blog/2010/12/03/grails-run-script-updated-for-grails-1-3-5/
After installing export plugin i can not run grails application and get this
java.lang.LinkageError: loader constraint violation: loader (instance of <bootloader>) previously initiated loading for a different type with name "org/xml/sax/SAXParseException"
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2427)
at java.lang.Class.getDeclaredMethods(Class.java:1791)
at java.security.AccessController.doPrivileged(Native Method)
at org.codehaus.groovy.util.LazyReference.getLocked(LazyReference.java:46)
at org.codehaus.groovy.util.LazyReference.get(LazyReference.java:33)
at grails.util.PluginBuildSettings.getPluginInfos(PluginBuildSettings.groovy:123)
at grails.util.PluginBuildSettings.getPluginInfos(PluginBuildSettings.groovy)
at grails.util.PluginBuildSettings$getPluginInfos.callCurrent(Unknown Source)
at grails.util.PluginBuildSettings.getPluginInfo(PluginBuildSettings.groovy:167)
at grails.util.PluginBuildSettings$getPluginInfo.callCurrent(Unknown Source)
at grails.util.PluginBuildSettings.getPluginInfoForSource(PluginBuildSettings.groovy:208)
at org.codehaus.groovy.transform.ASTTransformationVisitor$3.call(ASTTransformationVisitor.java:302)
at org.codehaus.groovy.control.CompilationUnit.applyToSourceUnits(CompilationUnit.java:824)
at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:521)
at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:497)
at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:474)
at _GrailsEvents_groovy.run(_GrailsEvents_groovy:54)
at _GrailsEvents_groovy$run.call(Unknown Source)
at _GrailsClean_groovy$run.call(Unknown Source)
at _GrailsClean_groovy.run(_GrailsClean_groovy:29)
at _GrailsClean_groovy$run.call(Unknown Source)
at _GrailsPlugins_groovy$run.call(Unknown Source)
at _GrailsPlugins_groovy.run(_GrailsPlugins_groovy:32)
at _GrailsPlugins_groovy$run.call(Unknown Source)
at _GrailsRun_groovy$run.call(Unknown Source)
at _GrailsRun_groovy.run(_GrailsRun_groovy:31)
at _GrailsRun_groovy$run.call(Unknown Source)
at RunApp.run(RunApp.groovy:25)
at RunApp$run.call(Unknown Source)
at gant.Gant.prepareTargets(Gant.groovy:606)
Error loading event script from file [/home/natalia/.grails/1.3.7/projects/MEM1.1/plugins/tomcat-1.3.7/scripts/_Events.groovy] loader constraint violation: loader (instance of <bootloader>) previously initiated loading for a different type with name "org/xml/sax/SAXParseException"
Error executing script RunApp: loader constraint violation: loader (instance of <bootloader>) previously initiated loading for a different type with name "org/xml/sax/SAXParseException"
java.lang.LinkageError: loader constraint violation: loader (instance of <bootloader>) previously initiated loading for a different type with name "org/xml/sax/SAXParseException"
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2427)
at java.lang.Class.getDeclaredMethods(Class.java:1791)
at java.security.AccessController.doPrivileged(Native Method)
at org.codehaus.groovy.util.LazyReference.getLocked(LazyReference.java:46)
at org.codehaus.groovy.util.LazyReference.get(LazyReference.java:33)
at grails.util.PluginBuildSettings.getPluginInfos(PluginBuildSettings.groovy:123)
at grails.util.PluginBuildSettings.getPluginInfos(PluginBuildSettings.groovy)
at grails.util.PluginBuildSettings$getPluginInfos.callCurrent(Unknown Source)
at grails.util.PluginBuildSettings.getPluginInfoForName(PluginBuildSettings.groovy:180)
at grails.util.PluginBuildSettings$getPluginInfoForName.call(Unknown Source)
at _PluginDependencies_groovy$_run_closure1.doCall(_PluginDependencies_groovy:66)
at _PackagePlugins_groovy$_run_closure2.doCall(_PackagePlugins_groovy:69)
at _GrailsPackage_groovy$_run_closure2.doCall(_GrailsPackage_groovy:81)
at RunApp$_run_closure1.doCall(RunApp.groovy:28)
at gant.Gant$_dispatch_closure5.doCall(Gant.groovy:381)
at gant.Gant$_dispatch_closure7.doCall(Gant.groovy:415)
at gant.Gant$_dispatch_closure7.doCall(Gant.groovy)
at gant.Gant.withBuildListeners(Gant.groovy:427)
at gant.Gant.this$2$withBuildListeners(Gant.groovy)
at gant.Gant$this$2$withBuildListeners.callCurrent(Unknown Source)
at gant.Gant.dispatch(Gant.groovy:415)
at gant.Gant.this$2$dispatch(Gant.groovy)
at gant.Gant.invokeMethod(Gant.groovy)
at gant.Gant.executeTargets(Gant.groovy:590)
at gant.Gelpant.executeTargets(Gant.groovy:589)
Error executing script RunApp: loader constraint violation: loader (instance of <bootloader>) previously initiated loading for a different type with name "org/xml/sax/SAXParseException"
What is wrong? Please help...
Adding this in BuildConfig.groovy worked for me:
inherits("global") {
excludes "xml-apis"
}
Source: http://arrogantprogrammer.blogspot.com.ar/2010/07/grails-linkageerror-for.html
That seems to be the result of a classpath hell...
Two dependencies link the same jar with different versions
Check your dependencies, spot the guilty jar (which seems to be a Sax Parser) and remove this linkage in your BuildConfig.groovy
Cheers
Grooveek
SaxParseException is loaded by the JVM and I guess the plugin is loading an older version.
Just add the excludes parameter to the plugin
Run grails "dependency-report" to find out which jar is causing the problem.
I am using jdk1.6 and grails 1.3.4. I have set the JAVA_HOME,GRAILS_HOME and PATH variables following the instructions in the grails.org site. When I execute the create-app command I get the following error:
C:\grails\grails-1.3.4>grails create-app C:\Users\Documents\Grails\helloworld
Welcome to Grails 1.3.4 - http://grails.org/
Licensed under Apache Standard License 2.0
Grails home is set to: C:\grails\grails-1.3.4
Base Directory: C:\grails\grails-1.3.4
Resolving dependencies...
Dependencies resolved in 2102ms.
Running script C:\grails\grails-1.3.4\scripts\CreateApp_.groovy
Environment set to development
Error executing script CreateApp: java.lang.StringIndexOutOfBoundsException: Str
ing index out of range: 1
java.lang.StringIndexOutOfBoundsException: String index out of range: 1
at gant.Gant$_dispatch_closure5.doCall(Gant.groovy:391)
at gant.Gant$_dispatch_closure7.doCall(Gant.groovy:415)
at gant.Gant$_dispatch_closure7.doCall(Gant.groovy)
at gant.Gant.withBuildListeners(Gant.groovy:427)
at gant.Gant.this$2$withBuildListeners(Gant.groovy)
at gant.Gant$this$2$withBuildListeners.callCurrent(Unknown Source)
at gant.Gant.dispatch(Gant.groovy:415)
at gant.Gant.this$2$dispatch(Gant.groovy)
at gant.Gant.invokeMethod(Gant.groovy)
at gant.Gant.executeTargets(Gant.groovy:590)
at gant.Gant.executeTargets(Gant.groovy:589)
Caused by: java.lang.StringIndexOutOfBoundsException: String index out of range:
1
at java.lang.String.substring(String.java:1934)
at grails.util.GrailsNameUtils.getClassNameRepresentation(GrailsNameUtil
s.java:82)
at grails.util.GrailsNameUtils$getClassNameRepresentation.call(Unknown S
ource)
at _GrailsCreateProject_groovy$_run_closure4.doCall(_GrailsCreateProject
_groovy:135)
at _GrailsCreateProject_groovy$_run_closure1.doCall(_GrailsCreateProject
_groovy:36)
at gant.Gant$_dispatch_closure5.doCall(Gant.groovy:381)
... 10 more
--- Nested Exception ---
java.lang.StringIndexOutOfBoundsException: String index out of range: 1
at java.lang.String.substring(String.java:1934)
at grails.util.GrailsNameUtils.getClassNameRepresentation(GrailsNameUtil
s.java:82)
at grails.util.GrailsNameUtils$getClassNameRepresentation.call(Unknown S
ource)
at _GrailsCreateProject_groovy$_run_closure4.doCall(_GrailsCreateProject
_groovy:135)
at _GrailsCreateProject_groovy$_run_closure1.doCall(_GrailsCreateProject
_groovy:36)
at gant.Gant$_dispatch_closure5.doCall(Gant.groovy:381)
at gant.Gant$_dispatch_closure7.doCall(Gant.groovy:415)
at gant.Gant$_dispatch_closure7.doCall(Gant.groovy)
at gant.Gant.withBuildListeners(Gant.groovy:427)
at gant.Gant.this$2$withBuildListeners(Gant.groovy)
at gant.Gant$this$2$withBuildListeners.callCurrent(Unknown Source)
at gant.Gant.dispatch(Gant.groovy:415)
at gant.Gant.this$2$dispatch(Gant.groovy)
at gant.Gant.invokeMethod(Gant.groovy)
at gant.Gant.executeTargets(Gant.groovy:590)
at gant.Gant.executeTargets(Gant.groovy:589)
Error executing script CreateApp: java.lang.StringIndexOutOfBoundsException: Str
ing index out of range: 1
There is a StringIndexOutOfBoundsException. Can anyone help me resolve this?
Thanks
SJan
create-app: The starting point for Grails. This command creates a Grails application and requires the user to specify the application name. A subdirectory within the directory the command was executed from is then created based on the entered application name.
The correct way to execute this command:
Browse to your workspace directory using the command prompt
Type "grails create-app helloworld
A subdirectory "helloworld" will be created as your workspace directory