I am working on Grails 2.3.11 and am using MongoDb plugin mongodb:3.0.3.
My code looks like this:
def home() {
List abcs = ABC.list()
println abcs.unique { it.parent }
}
The code breaks while accessing unique closure.
The exception says:
ERROR errors.GrailsExceptionResolver- UnsupportedOperationException occurred when processing request: [GET] /MongoAppInEcomEnv/product/home
Stacktrace follows:
Message: null
Line | Method
->> 148 | add in java.util.AbstractList
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 108 | add in ''
| 342 | addAll . in java.util.AbstractCollection
| 120 | $tt__home in com.test.aitm.ProductController$$EPCH6LtA
| 198 | doFilter in grails.plugin.cache.web.filter.PageFragmentCachingFilter
| 63 | doFilter in grails.plugin.cache.web.filter.AbstractFilter
| 1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
| 615 | run in java.util.concurrent.ThreadPoolExecutor$Worker
^ 744 | run . . . in java.lang.Thread
Looks like the list is empty.
Also you could try
abcs.parent.unique()
Related
I newbie in powershell. I have two different CSV files, that I am looking to merge together into one using a primary key field from each file.
An example would be:
CSV 1:
ID - TB - Number
01:01 - SB - 24
12:04 - DV - 63
CSV 2:
ID - UR1 - UR2
01:01 - soft - install soft
12:04 - soft - uninstall soft
Desired Output
ID - TB - Number - UR1 - UR2
01:01 - SB - 24 - soft - install soft
12:04 - DV - 63 - soft - uninstall soft
Indeed to CSV is not properly formatted, did an ugly fixe (first two lines), after that you can do it as bellow
$csv1 = (gc C:\tmp\csv1.ps1 -raw) -replace ' - ',',' | ConvertFrom-Csv
$csv2 = (gc C:\tmp\csv2.ps1 -raw) -replace ' - ',',' | ConvertFrom-Csv
$columns1 = ($csv1 | Get-Member -MemberType NoteProperty).Name
$csv1 | % {
$row1 = $_
$row2 = $csv2 | ? {$_.ID -eq $row1.ID}
$row2 | Get-Member -MemberType NoteProperty | % {
if($_.Name -notin $columns1) {
$row1 | Add-Member $_.Name $row2.$($_.Name)
}
}
}
$csv1
mail {
host = "smtp.1und1.de"
port = 465
username = "pt8100853-1"
password = "xxxxxxxx"
props = ["mail.smtp.auth":"true",
"mail.smtp.socketFactory.port":"465",
"mail.smtp.socketFactory.class":"javax.net.ssl.SSLSocketFactory",
"mail.smtp.socketFactory.fallback":"false"]
}
is the contents of config groovy. My controller contains
sendMail {
to "gaby#strotmann.org"
subject "Hello Fred"
body 'How are you?'
}
After activating sendMail I get:
Error 2015-02-25 21:19:25,883 [http-bio-8080-exec-8] ERROR errors.GrailsExceptionResolver - MailSendException occurred when processing request: [GET] /Partner/kommunikation/eMail
Failed messages: com.sun.mail.smtp.SMTPSendFailedException: 501 Syntax error in parameters or arguments
;
nested exception is:
com.sun.mail.smtp.SMTPSenderFailedException: 501 Syntax error in parameters or arguments
. Stacktrace follows:
Message: Failed messages: com.sun.mail.smtp.SMTPSendFailedException: 501 Syntax error in parameters or arguments
;
nested exception is:
com.sun.mail.smtp.SMTPSenderFailedException: 501 Syntax error in parameters or arguments
Line | Method
->> 131 | sendMessage in grails.plugin.mail.MailMessageBuilder
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 55 | sendMail in grails.plugin.mail.MailService
| 59 | sendMail . in ''
| 165 | doCall in MailGrailsPlugin$_configureSendMail_closure6
| 37 | eMail . . . in org.strotmann.partner.KommunikationController
| 198 | doFilter in grails.plugin.cache.web.filter.PageFragmentCachingFilter
| 63 | doFilter . in grails.plugin.cache.web.filter.AbstractFilter
| 1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
| 615 | run . . . . in java.util.concurrent.ThreadPoolExecutor$Worker
^ 745 | run in java.lang.Thread
I'm somewhat confused to get a syntax error, as I copied the original code directly from the plugin documentation.
How can I escape that problem?
I am using the spring security facebook plugin to implement login in my grails application. I am using the 0.14.5 version of spring security facebook plugin. It was working fine until couple of months ago, now I cannot login to my application. I get the following error:
2014-12-12 16:52:50,197 [http-bio-8080-exec-1] ERROR [/testApp].[default] - Servlet.service() for servlet [default] in context with path [/testApp] threw exception [Filter execution threw an exception] with root cause
Message: org.codehaus.jackson.JsonNode
Line | Method
->> 175 | findClass in org.codehaus.groovy.tools.RootLoader
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 423 | loadClass in java.lang.ClassLoader
| 147 | loadClass . . . . . . . . in org.codehaus.groovy.tools.RootLoader
| 356 | loadClass in java.lang.ClassLoader
| 2451 | privateGetDeclaredMethods in java.lang.Class
| 1810 | getDeclaredMethods in ''
| 46 | getLocked . . . . . . . . in org.codehaus.groovy.util.LazyReference
| 33 | get in ''
| 59 | create . . . . . . . . . in testApp.user.FacebookAuthService
| 118 | create in com.the6hours.grails.springsecurity.facebook.DefaultFacebookAuthDao
| 67 | authenticate . . . . . . in com.the6hours.grails.springsecurity.facebook.FacebookAuthProvider
| 40 | attemptAuthentication in com.the6hours.grails.springsecurity.facebook.FacebookAuthRedirectFilter
| 1145 | runWorker . . . . . . . . in java.util.concurrent.ThreadPoolExecutor
| 615 | run in java.util.concurrent.ThreadPoolExecutor$Worker
^ 722 | run . . . . . . . . . . . in java.lang.Thread
I tried to upgrade the plugin but that did not help. During debuggin I found that I was getting access token from facebook and the error was occurring in following line
Facebook facebook = new FacebookTemplate(token.accessToken.accessToken)
recently, I am working in a grails project and intend to use mongodb as our nosql database, besides mysql.
I added mongodb plugin, do a test with a domain and it work well (show/edit/save...):
compile ':mongodb:3.0.1'
and try another method using gmongo plugin, which is useful in case I want to use mongodb low level API (or using mapReduce for example)
runtime "org.mongodb:mongo-java-driver:2.11.3"
compile "org.mongodb:mongo-java-driver:2.11.3"
runtime "com.gmongo:gmongo:1.3"
try to test with a simple query find(), it works well too
Now I want to combine 2 method and here is the error:
| Error 2014-05-13 17:52:07,197 [localhost-startStop-1] ERROR plugins.DefaultGrailsPluginManager - Error configuring dynamic methods for plugin [mongodb:3.0.1]: com/mongodb/AggregationOptions
Message: com/mongodb/AggregationOptions
Line | Method
->> 2531 | privateGetDeclaredMethods in java.lang.Class
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 1855 | getDeclaredMethods in ''
| 46 | getLocked . . . . . . . . in org.codehaus.groovy.util.LazyReference
| 33 | get in ''
| 98 | createGormStaticApi . . . in org.grails.datastore.gorm.mongo.plugin.support.MongoMethodsConfigurer
| 65 | configure in org.grails.datastore.gorm.plugin.support.DynamicMethodsConfigurer
| 49 | configure . . . . . . . . in org.grails.datastore.gorm.mongo.plugin.support.MongoMethodsConfigurer
| 76 | doCall in MongodbGrailsPlugin$_closure2
| 262 | run . . . . . . . . . . . in java.util.concurrent.FutureTask
| 1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
| 615 | run . . . . . . . . . . . in java.util.concurrent.ThreadPoolExecutor$Worker
^ 745 | run in java.lang.Thread
Caused by ClassNotFoundException: com.mongodb.AggregationOptions
->> 366 | run in java.net.URLClassLoader$1
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 355 | run in ''
| 354 | findClass . . . . . . . . in java.net.URLClassLoader
| 425 | loadClass in java.lang.ClassLoader
| 2531 | privateGetDeclaredMethods in java.lang.Class
| 1855 | getDeclaredMethods in ''
| 46 | getLocked . . . . . . . . in org.codehaus.groovy.util.LazyReference
| 33 | get in ''
| 98 | createGormStaticApi . . . in org.grails.datastore.gorm.mongo.plugin.support.MongoMethodsConfigurer
| 65 | configure in org.grails.datastore.gorm.plugin.support.DynamicMethodsConfigurer
| 49 | configure . . . . . . . . in org.grails.datastore.gorm.mongo.plugin.support.MongoMethodsConfigurer
| 76 | doCall in MongodbGrailsPlugin$_closure2
| 262 | run . . . . . . . . . . . in java.util.concurrent.FutureTask
| 1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
| 615 | run . . . . . . . . . . . in java.util.concurrent.ThreadPoolExecutor$Worker
^ 745 | run in java.lang.Thread
I don't know how to fix it actually!
Mongodb Plugin is a wrapper over GMongo with the power of GORM features. You can definitely use GMongo or lower level API directly from the plugin instead of adding those dependencies explicitly.
Have a look at the build.gradle where they are included. Most likely the error is due to conflicting dependencies when both of them are used simultaneously.
I create a new grails app and do grails install-plugin rest. App builds. Now I add exactly the example from the plugin page: http://grails.org/plugin/rest into the bootstrap and have:
import l2http.*
class BootStrap {
def init = { servletContext ->
withHttp(uri: "http://www.google.com") {
def html = get(path : '/search', query : [q:'Groovy'])
assert html.HEAD.size() == 1
assert html.BODY.size() == 1
}
}
def destroy = {
}
}
This crashes with the following error:
| Loading Grails 2.0.0
| Configuring classpath.
| Environment set to development.....
| Packaging Grails application.....
| Compiling 1 source files.....
| Running Grails application
| Error 2012-03-26 11:41:07,823 [Thread-8] ERROR context.GrailsContextLoader - Error executing bootstraps: groovy.lang.MissingMethodException: No signature of method: grails.util.Environment.withHttp() is applicable for argument types: (java.util.LinkedHashMap, BootStrap$_closure1_closure3) values: [[uri:http://www.google.com], BootStrap$_closure1_closure3#299cc074]
Message: groovy.lang.MissingMethodException: No signature of method: grails.util.Environment.withHttp() is applicable for argument types: (java.util.LinkedHashMap, BootStrap$_closure1_closure3) values: [[uri:http://www.google.com], BootStrap$_closure1_closure3#299cc074]
Line | Method
->> 290 | evaluateEnvironmentSpecificBlock in grails.util.Environment
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 283 | executeForEnvironment in ''
| 259 | executeForCurrentEnvironment . . in ''
| 334 | innerRun in java.util.concurrent.FutureTask$Sync
| 166 | run . . . . . . . . . . . . . . in java.util.concurrent.FutureTask
| 1110 | runWorker in java.util.concurrent.ThreadPoolExecutor
| 603 | run . . . . . . . . . . . . . . in java.util.concurrent.ThreadPoolExecutor$Worker
^ 722 | run in java.lang.Thread
Caused by MissingMethodException: No signature of method: grails.util.Environment.withHttp() is applicable for argument types: (java.util.LinkedHashMap, BootStrap$_closure1_closure3) values: [[uri:http://www.google.com], BootStrap$_closure1_closure3#299cc074]
->> 345 | methodMissing in grails.util.Environment$EnvironmentBlockEvaluator
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 4 | doCall in BootStrap$_closure1
| 290 | evaluateEnvironmentSpecificBlock in grails.util.Environment
| 283 | executeForEnvironment in ''
| 259 | executeForCurrentEnvironment . . in ''
| 334 | innerRun in java.util.concurrent.FutureTask$Sync
| 166 | run . . . . . . . . . . . . . . in java.util.concurrent.FutureTask
| 1110 | runWorker in java.util.concurrent.ThreadPoolExecutor
| 603 | run . . . . . . . . . . . . . . in java.util.concurrent.ThreadPoolExecutor$Worker
^ 722 | run in java.lang.Thread
The withHttp or any method added by the rest-plugin is injected to the Controllers and Services not to the BootStrap class. Please try it within Services or Controllers.
Cheers.
Bernardo