I am able to debug my application by remote debug in intellij. But how to debug the method like
list in below example.
Student.createCriteria().list {
'in'('Id', params.id)
}
I want to debug the list method to get the query which is getting fired but debug point don't go there.
You can debug GORM code pretty much like you debug all JVM classes. You can step-into the GORM code. If you don't want to step into the GORM code but instead want to put the breakpoint in the GORM code directly, it is impossible to say for sure where you should put a breakpoint because I don't know which GORM implementation you are using and which version of that implementation. If you are using GORM for Hibernate version 7.0.3.RELEASE, then you may want to put a breakpoint at https://github.com/grails/gorm-hibernate5/blob/df05ec7e99a6b12718dfc814a7cbe4073b09a881/grails-datastore-gorm-hibernate5/src/main/groovy/org/grails/orm/hibernate/query/AbstractHibernateCriteriaBuilder.java#L1570.
I hope that helps.
Related
The problem only occurs when I am trying to debug a test via the IntelliJ debugger. It does not happen when I just simply run the test.
CustomerChoiceRepository is a normal Spring Boot JPA repository which here is being mocked with #Mock.
When this line executes in the debugger I get the following error in the watch section of the variables:
The entire error message is:
Method threw 'org.mockito.exceptions.misusing.UnfinishedStubbingException' exception. Cannot evaluate com.item.repository.jpa.CustomerChoiceRepository$MockitoMock$1318657964.toString()
Again this is only is detected in the IntelliJ debugger, as a result the test fails only when I am debugging it.
So my question is: what is happening here?
Is this a bug ? Is this something that I fail to understand because I do not know the internals of Mockito particularly well ?
Your IntelliJ is calling toString on the mock during stubbing, which causes the exception.
Check your debugger settings
By default, IntelliJ calls toString on objects in debugger window, but only on objects that override that method. This behaviour is customizable, currently in Preferences -> Build Tools -> Debugger -> Data Views -> Java -> Enable 'toString' object view, but the settings mey differ between IDE versions.
See:
Is it possible to tell IntelliJ IDEA to automatically invoke toString() on the objects inspected in watches, variables, tool tip windows?
Don't call methods on mocked object during stubbing
See:
How do Mockito matchers work?
How does mockito when() invocation work?
This query is regarding performance logging.I am using Log4net for logging.
I want to log the time execution for particular method.
I have came across Interceptors for logging using Unity Container but its all about Interface and virtual method.
In my C# .Net project we have not use interfaces but abstract classes and other normal classes.
Is there a way I can use interceptors for logging execution of methods of any normal class?
I am not looking for paid option.
Thanks,
Suraj
I found a open source library to get method time execution.
Its methodtimer Fody nuget Package.
More information here : https://github.com/Fody/MethodTimer
When you add this nuget, FodyWeavers.xml file gets added to project.
Inside this file, you need to add MethodTimer tag inside the weaver tag
Hope this information found helpful to the viewers.
Thanks,
Suraj
I am writing a spring-batch application, based on an example I found. When I run it in Eclipse, it produces some annoying INFO logs from deep inside the framework. I'd like to suppress that, so only my System.out statements show - for clarity.
I figured the logging is from the inherited commons-logging1.1.1.jar, that's in my classpath, because when I take out that reference I get errors about Logger.
Question1: Which framework is used for logging in my sample application and how can I change the default INFO to WARN?
Question2: will adopting Log4j just override this default behavior?
I've create two property files under /resources: commons-logging.properties, with this: org.apache.commons.logging.Log=org.apache.commons.logging.impl.SimpleLog, and simplelog.properties, with this: org.apache.commons.logging.simplelog.defaultlog=warn It worked. Thanks - –
I am working on a well undocumented project and I was wondering if is it possible to get the controller used for a certain url or view?
Without knowing more information, one of the easiest ways is to turn on DEBUG logging for the Spring servlet. For example if you are using log4j:
log4j.logger.org.springframework.web.servlet=DEBUG
After you turn that on, you'll see log entries anytime a page is hit like this:
Mapping [/some/path] to HandlerExecutionChain with handler [com.myapp.controller.MyController#4cda661a]
Anyway, there are various ways to do this, including scanning the code for the view name or path. Another approach would be to create a interceptor that logs some additional information for every request.
You could try Spring Tool Suite (comes either standalone or as an add-on for Eclipse). It's essentially Eclipse with extra Spring-specific features, one of them is what you're looking for:
Is it possible to log the low-level transactionid (I'm debugging something and this would be helpful to have in the log)?
The method to get that value is http://download.oracle.com/javase/6/docs/api/javax/transaction/xa/Xid.html#getGlobalTransactionId%28%29 but am not sure how to get the appropriate implementation (the javadoc points to an interface).
I've tried enabling TRACE logging for org.hibernate but no luck.
Thanks for any ideas.
EDIT: forgot to mention: running inside JBoss 5.1