Having a really strange issue in a Grails service. I have a service thats setup like this:
package com.mydomain
import java.net.URLEncoder
import java.rmi.server.UID
import java.security.*
class EmailConfirmationService {
def sendConfirmation(Person person) {}
}
And I'm calling it from a controller with emailConfirmationService.sendConfirmation(person)
When I startup the Grails app, it throws the following error:
MissingMethodException occurred when processing request: [POST] /api/people/
No signature of method: mydomain.api.EmailConfirmationService.sendConfirmation() is applicable for argument types: (com.mydomain.Person) values: [name#mydomain.com]
All I have to do is save the EmailConfirmationService file, the watcher picks it up and recompiles, then it works great and never again throws that error.
Until I restart, then it errors until I save that file again.
I've tried the following but nothing has worked yet:
clean build
changed function name
made sure person instance existed
Any ideas?
Your service states another package (com.mydomain) than the one in the error message (mydomain.api). Please make sure, that the packages match and that the file is located in grails-app/services/com/mydomain/EmailConfirmationService.groovy (unless all of this is due to some obfuscation you did for SO)
Related
Resetting CleanURL Prestashop Module has lead to HTTP ERROR.
Parse error: syntax error, unexpected ''supplier_rule''
(T_CONSTANT_ENCAPSED_STRING), expecting function (T_FUNCTION) in
/home/mbawithf/public_html/mbawithfun.cu.cc/override/classes/Dispatcher.php
on line 4
Now I can not even access backend. I just tried to deleting module from FTP... still didn't work. Any solution?
Delete the Dispatcher file in override folder, or comment the function that includes that line.
Don't forget to delete the cache/class_index.php so Prestashop recreates that file.
PrestaShop tries to manually copy class methods to \override\classes* files, and sometimes the lines miss-match or the line break are wrong, and the end result is incorrectly copied lines which cause syntax errors. That happens both on installation and uninstallation. Basically, you then have to manually fix/remove syntax errors from overridden class files.
What you need is to log on to FTP server and edit this files - fix syntax error.
EDIT:
If you had uninstalled the module, then you should replace the contents of this file with:
class Dispatcher extends DispatcherCore
{
}
Please check that the are no public function ... because if there is, it means that other modules may have inserted their functions here. If there isn't any, then it's safe to reset the file with the code above.
I got above error message when I try to use specflow.exe to generate specflow Step Definition Report, the command I used is:
specflow.exe stepdefinitionreport ..\\..\\..\MyProject\MyProject.csproj"
Any ideas and suggestions, Thank you!
I had this issue when I was using StepDefinition instead of Given-When-Then in my step definitions. By switching back to Given-When-Then it started working.
Instead of using the [StepDefinition(#"...")] use a [Given(#"...")] for example:
[Given("I take a screenshot")]
[When("I take a screenshot")]
[Then("I take a screenshot")]
public void takeScreenshot()
{
screenShots.Add(((ITakesScreenshot)driver).GetScreenshot());
}
I am having this issue while using findbyid to get a unique url for a page on my shared hosting. The problem I have is that I keep getting the following error while trying to access the unique page via the Id number of the item on shared hosting(i dont get this issue on localhost):
Error: The action item is not defined in controller ProductsController
Error: Create ProductsController::item() in file: app/Controller/ProductsController.php.
However item is defined in the productscontroller:
public function item($id = null) {
if (!$id) {
throw new NotFoundException(__('product not found'));
}
$items = $this->Product->findById($id);
if (!$items) {
throw new NotFoundException(__('Invalid post'));
}
$this->set('item', $items);
}
you can see the problem at this url: http://entourmag.com/hava/products/item/39
it works on localhost via wamp so I am not sure what the problem is.
Thanks in advance
Well I figured out the issue. The problem was with the files uploaded; the files uploaded were incomplete or missing, when I check the ProductsController.php file I realised that most of the code was missing. Reuploading solved the problem.
For others with problematic internet connection take note of this while coding.
Error: A Database connection using "Mysql" was missing or unable to connect.
The database server returned this error: SQLSTATE[HY000] [1045] Access denied for user 'root'#'localhost' (using password: NO)
Notice: If you want to customize this error message, create app/View/Errors/missing_connection.ctp
I think you have not created/configured your database.php in app/Config
I am using cakephp 3.8 and I figure out one possible cause of this kind of messages.
In my case, I am expecting the __construct method is responsible for creating the base class.
And the solution is to use initialize method, like so:
function initialize() {
parent::initialize();
}
In conclusion, we should more carefully read the documentation, it clearly stated here and please take time to do the 20 min cms tutorial
Running the application with grails run-app works fine but after deploying in Tomcat 7 I get following error.
groovy.lang.MissingMethodException:
No signature of method: static com.digithurst.hdspro.web.Responder.respond()
is applicable for argument types: (ResourceListCmd, QueryCmd, groovy.util.ConfigObject)
values: [ResourceListCmd#5c380e, ...]
Possible solutions: respond(HttpResource, java.lang.Object, java.lang.String)
As already said, this works outside of Tomcat. The way the method is called is exactly as it is implemented. The ResourceListCmd implements the interface HttpResource which makes it a perfect fit. This error also occurs if the first parameter is null.
groovy.lang.MissingMethodException:
No signature of method: static com.digithurst.hdspro.web.Responder.respond()
is applicable for argument types: (null, QueryCmd, groovy.util.ConfigObject)
values: [null, ...]
Possible solutions: respond(HttpResource, java.lang.Object, java.lang.String)
More on the environment:
Windows 7 64 Bit
Java 7 U45 x86
Grails 2.3.4
Tomcat 7.0.47
I have already cleaned the .grails and .m2 folders in the user directory and performed a grails clean berfore creating the war file.
[Edit after answer of H3rnst]
Controller:
def index() {
try {
ResourceListCmd configs = configService.search()
respond Responder.respond(configs, new QueryCmd(level: 'list'),
grailsApplication.config.grails.serverURL)
}
catch (Exception e) {
render status: INTERNAL_SERVER_ERROR
}
}
ResourceListCmd:
interface HttpResource {
...
}
abstract class AbstractHttpResource implements HttpResource {
...
}
class ResourceListCmd extends AbstractHttpResource {
...
}
Responder:
class Responder {
static def respond(HttpResource resource, def query, String serverURL) {
...
}
}
Your war (or tomcat server classpath) contain a duplicate or wrong version of jar that contains the class com.digithurst.hdspro.web.Responder. (The version of the class you are using developing an launching with run-app is different from the one tomcat load running your war)
You could try to unpack the war end verify the version of the problematic jar and/or use a tool like jarscan to scan for duplicate classes.
You could even try to use the command dependecy-report and search for duplicate injection of the same lib. Probably two different plugins your are using are incorporating to differente versions of the same lib causing the problem.
marko's suggestion doing run-war actually gave the final clue to solving this thing. It wasn't a problem with Tomcat but rather the environment the app was running in. run-app as well as run-war both use the "development" environment by default and therefore it worked. Only in "production" it did not, which is what is used when deployed to Tomcat.
The actual culprit was part of the configuration and the error message was right, although unexpected. I'm calling the Responder.respond() method with grailsApplication.config.grails.serverURL. The serverURL was only set in "development" mode but not in "production". That's why Groovy/Java complained about the method signature:
(ResourceListCmd, QueryCmd, groovy.util.ConfigObject) vs (HttpResource, java.lang.Object, java.lang.String)
The clue is the last parameter, the first two are correct. However, I would've expected null as the value instead of a completely different type.
I need some help, I am trying to make an controller using Google Analytics API, but using:
statsController.groovy
/**************************************************************/
import com.google.gdata.client.analytics.AnalyticsService
class StatsController {
def myService
def stats(){
myService = new AnalyticsService("example-App");
}
}
/************************************************************/
error Message:
ClassNotFoundException occurred when processing request: [...]
com.google.common.collect.Maps
I ve tryed adding to the buildpath the "gdata.analytics*.jar", "google-collect-1.0.jar", "guava.jar" and "jsr305.jar" but without results, the error always says that i described or NotDefClassError ocurred when processing request: [...] com.google.gdata.client.analytics.AnalyticsService.
I need to solve.
The handling of JARs is kept pretty easy in grails. If you don't use stuff like maven you can just copy your JARs into the lib folder in the root directory of your grails application.
Try to put them there and see if it solves the problem.
Further: what IDE do you use? IntelliJ for instance recognize JARs within the lib folder instantly. So you should see the effects in your IDE already.