I'm trying to debug a Spring Boot microservice using Intellij's remote debugging feature. I have followed the correct steps to connect to the Cloud Service (like enabling ssh) where the service is deployed, and have set up the correct Intellij configuration under "Remote JVM Debug".
The method I'm trying to debug is a Spring Boot RequestMapping (GET) controller method. I added in my breakpoints in this method, but as soon as I hit the debug button and visit the associated path (same as the RequestMapping's path value) in the UI in the browser, the breakpoints don't seem to work as the method execution never steps. Instead, the red breakpoint dots are somehow replaced with green checkmarks, like below -
What does this indicate? Any idea as to why the debugging doesn't work? Even print statements in the method aren't displayed in the console.
Related
I am experimenting with different instrumentation libraries but primarily spring-cloud-sleuth and open-telemetry ( OT) are the ones I liked the most. Spring-cloud-sleuth is simple but it will not work for a non-spring ( Jax-RS)project , so I diverted my attention to open telemetry.
I am able to export the metrics using OT, but there is just too much data which I do not need. Spring sleuth gave the perfect solution wherein it just traces the call across microservices and links all the spans with one traceId.
My question is - How to configure OT to get an output similar to spring-sleuth? I tried various configuration and few worked but still the information is huge.
My configuration
-Dotel.traces.exporter=zipkin -Dotel.instrumentation.[jdbc].enabled=false -Dotel.instrumentation.[methods].enabled=false -Dotel.instrumentation.[jdbc-datasource].enabled=false
However, this still gives me method calls and other data. Also, one big pain is am not able to SHUT DOWN metrics data.
gets error like below
ERROR io.opentelemetry.exporter.internal.grpc.OkHttpGrpcExporter - Failed to export metrics. The request could not be executed. Full error message: Failed to connect to localhost/0:0:0:0:0:0:0:1:4317
Anyhelp will be appreciated -
There are 2 ways to configure the open telemetry agent(otel).
Environment variable
Java system property
you can either set
export OTEL_METRICS_EXPORTER=none
or
java -Dotel.metrics.exporter=none app.jar
Reference
https://github.com/open-telemetry/opentelemetry-java/blob/main/sdk-extensions/autoconfigure/README.md
I'm new to spring MVC 4 and I have a problem- Each time I start a new project there is something wrong with the configuration which results in a 404 when I try to work with my controllers.
I there a way to see some logs which will make things more clear as to what I did wrong? I work with tomcat and I looked into his "logs" folder and there was nothing there...
I suggest you to use remote debugging from your Eclipse IDE, or debug the application from within the IDE. then you can debug the code line by line and see what is going wrong.
For Spring application development Spring Tool Suit has more support for developing Spring Applications.
EDIT:
You can also configure your Log level in Tomcat Environment. See this article for more information to change your configuration of logging accordingly (Run on DEBUG mode)
I am trying to debug a java web application. I have configured tomcat in eclipse, added my application to tomcat and started the tomcat in debugging mode.
Now, when the user performs any action on the web page, the request hits the server, goes through some java/tomcat classes and finally reaches our application code.
If I know which of the application classes/methods will be executed, I can set a breakpoint and start debugging from there. But if I don't know which code will be executed, how can I set breakpoint?
Basically I am trying to figure out which application class/method is executed when user performs an action on the page.
I know I can set a breakpoint in the Servlet doGet/doPost method. But we are using struts and we have many more general servlets also. So it is difficult to set breakpoint in all of them.
Please help.
Check your Tomcat logs (or console). You should see which part of code is executed when you are doing something on your web page then set breakpoints. When you finally catch the program somewhere try to find a better place according to stacktrace in your debugger.
Look in your struts-config.xml file and find the action that matches your URL. Most Struts implementations use the *.do pattern to match Struts actions. The path part of the URL without the .do will match an action configuration in your struts-config.xml file. Find the action class that is called and put your breakpoint in the execute() method.
Platform I am using:
Fedora 20;
mariadb-5.5.34-2.fc20.x86_64;
Eclipse Kepler Service Release from www.eclipse.org
I am implementing example
See here
and I am trying to manage to work the login interface.
Actually I am configuring TomEE to use JAAS auth technology.
Since I am having some troubles, I would like to solve them with the help of Eclipse debugging mode. To do that, I:
setted breakpoint at line number 79 of LoginController.java;
started TomEE in debug mode;
executed login.xhtml in debug mode too;
My problem is that I see nothing in debug mode: no variables, etc.
How is it possible? I have been using debugging mode for a long time, but it is my first time in web development.
Project archive
Click here for a larger Screenshot
The webpage bean has not been istantiated for an unknown reason. I opened a new question to fix it.
Bean not instantiated
I'm working on a project in Java using the spring framework, hibernate and tomcat.
Background:
I have a form page which takes data, validates, processes it and ultimately persists the data using hibernate. In processing the data I do some special command (model)
manipulation prior to persisting using hibernate.
Problem:
For some reason my onSubmit method is being called twice, the first time through things
are processed properly. However the second time through they are not; and the incorrect
information is being persisted.
I've also noticed that on other pages which are simply pulling information from the data
base and displaying on screen; Double requests are happening there too.
Is there something misconfigured, am I not using spring properly..any help on this would
be great!
Additional Information:
The app is still being developed. In testing the app I'm running into this problem. I'm using the app as I would expect it to be used (single clicks,valid data,etc...)
If you are testing in IE, make note that in some versions of IE it sometimes submits two requests. What browsers are you testing the app in?
There is the javascript issue, if an on click handler is associated with submit button and calls submit() and does not return false to cancel the event bubble.
Could be as simple as users clicking on a link twice, re-submitting a form while the server is still processing the first request, or hitting refresh on a POST-ed page.
Are you doing anything on the server side to account for duplicate requests such as these from your users?
This is a very common problem faced by someone who is starting off. And not very sure about the application eco-system.
To deploy a spring app, we build the war file.
Then we put it inside 'webapps' folder of tomcat.
Then we run the tomcat instance using terminal (I am presuming a linux system).
Now, we set up env in that terminal.
The problem arises when we set up our environment for the spring application where there can be more than one war files to be deployed.
Then we must cater to the fact that the env must be exclusive to a specific war file.
To achieve this, what we can do is create exclusive env files for every war. (e.g. war_1.sh,war_2.sh,.....,war_n.sh) and so on.
Now we can source that particular env file for which we have to deploy its corresponding war. This way we can segregate the multiple wars (applications) and their environment.