How to find which method is called when going to route? - spring

I am getting too many redirects error I and want to find in which method this happens. The url I am going is
https://localhost:8443/OpenELIS-Global/
I tried searching codebase for OpenELIS-Global but I could not find something related with routes.
Also searched for #GetMapping - also nothing with OpenELIS-Global.
How do I find which method is called when going to that route?
In symfony can simply use
php bin/console debug:router
It is unbelievable if there is no similar command for spring.
Update
Base on the answer: spring version 5, as I understand MVC because there are controller files, log framework - I see there is log4j-1.2.8.jar
Update
The application I am working on looks like is forked from https://github.com/I-TECH-UW/OpenELIS-Global-2 . Just last commit being used is from 2021 if I remember well.
Update
Based on Jordi answer I added logging configs. It shows for most routes but for one route - https://localhost:8443/OpenELIS-Global/ which was giving problems (ketp redirecting to itself) and I did not know where to debug it - it still does not show:
When going to https://localhost:8443/OpenELIS-Global url, there are redirects
as you can see there were 3 requess but only login and home routes shown in log:
openelisglobal-webapp | 26 Apr 2022 17:31:55 -- TRACE -- Mapped to org.openelisglobal.login.controller.LoginPageController#showLoginPage(HttpServletRequest, Principal)
openelisglobal-webapp | 26 Apr 2022 17:31:55 -- TRACE -- Mapped to org.openelisglobal.login.controller.LoginPageController#showLoginPage(HttpServletRequest, Principal)
openelisglobal-webapp | 26 Apr 2022 17:31:55 -- TRACE -- Mapped to org.openelisglobal.home.controller.HomeController#showPanelManagement(HttpServletRequest)
openelisglobal-webapp | 26 Apr 2022 17:31:55 -- TRACE -- Mapped to org.openelisglobal.home.controller.HomeController#showPanelManagement(HttpServletRequest)
With another guy I discussed - it was somehow complicated done - the root route compressed in .war file.
src/main/resources/log4j2.properties:
loggers=rolling,routes
logger.routes.name=org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping
logger.routes.level = trace
logger.routes.appenderRefs = file, console
logger.routes.appenderRef.file.ref = RollingFile
logger.routes.appenderRef.console.ref = STDOUT
Update
Added
logging.level.org.springframework.web=debug
to src/main/resources/application.properties
from Antoniossss answer.
Intellij shows that it is unused property.
And it shows logs from Jordi config as I understand
openelisglobal-webapp | 26 Apr 2022 21:56:15 -- TRACE -- Mapped to org.openelisglobal.login.controller.LoginPageController#showLoginPage(HttpServletRequest, Principal)
openelisglobal-webapp | 26 Apr 2022 21:56:15 -- TRACE -- Mapped to org.openelisglobal.login.controller.LoginPageController#showLoginPage(HttpServletRequest, Principal)
openelisglobal-webapp | 26 Apr 2022 21:56:15 -- TRACE -- Mapped to org.openelisglobal.login.controller.LoginPageController#showLoginPage(HttpServletRequest, Principal)
openelisglobal-webapp | 26 Apr 2022 21:56:15 -- TRACE -- Mapped to org.openelisglobal.login.controller.LoginPageController#showLoginPage(HttpServletRequest, Principal)
openelisglobal-webapp | 26 Apr 2022 21:56:15 -- TRACE -- Mapped to org.openelisglobal.login.controller.LoginPageController#showLoginPage(HttpServletRequest, Principal)
openelisglobal-webapp | 26 Apr 2022 21:56:15 -- TRACE -- Mapped to org.openelisglobal.login.controller.LoginPageController#showLoginPage(HttpServletRequest, Principal)

By one hand, there is some additional information that could be useful in order to provide a more concrete answer: Spring Version (5 ?), assuming Spring MVC, and also the log framework that you are using.
By other hand, there are mainly two approaches to analyse routes further than what you can deduce directly looking into your code:
Activate a log level detailed enough that shows information on the URL mappings.
Debug the application in your IDE with the help of Spring source code; going to some specific Spring MVC classes and methods. As your url refers to localhost, I assume you will be able to do that.
Both approaches are detailed here: How to debug Spring MVC url mapping?
It is an old post with some recent updates in which two most voted answers provide details on the commented approaches.
Added info
According to the additional info provided, it seems clear you are using log4j2. It is a mavenized project, the maven pom.xml config file contains a log4j2 specific version config (2.17.1). Also, in src/main/resources you can find a log4j2.properties config file.
You can configure there a specific logger, similar to the following config (it has not been tested):
loggers=rolling,routes
logger.routes.name=org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping
logger.routes.level = trace
logger.routes.appenderRefs = file, console
logger.routes.appenderRef.file.ref = RollingFile
logger.routes.appenderRef.console.ref = STDOUT
You can add also a more generic one for org.springframework.web to debug level.
This will probably help, as stated in the referenced post.

I would simply turn on loggin with (application.properties)
logging.level.org.springframework.web=debug
this will disclose some information about existing mappiongs and which handler methods are picked upt to serve incoming requests as well as used response handlers.

Related

How to investigate JNI errors that only appear in Visual Studio debugger

I am working on a .NET application that is required to use a third-party library (a .NET eBMS/AS4 client); that third-party library is itself a JNI wrapper around a Java library. When I call the library, an exception is occurring within the Java library, but whoever implemented the wrapper did not do a good job of it, because any information that the Java exception contained (e.g. error codes, specific error messages) is not added to the .NET exception that gets passed back up to my application, all I get is the most generic of error messages. As you can imagine, this makes supporting the application in production a difficult proposition.
However, if I run the same code on my developer PC from within Visual Studio, then if I watch the Output window, the debugger writes a lot of information from the Java library - I can see it initialising itself, loading all of its modules, then executing, and finally I can see my Java exception occurring, and the actual error is right there in the Output window.
Jul 25, 2018 8:46:42 AM com.ibm.b2b.as4.client.internal.MessageBatcherImpl logEventAudit
INFO: Event Details: App Context Component:[COMMS]; App Context Service Inst:[AS4]; Trans Id:[ebb64ae1-762d-4175-9ca3-61c0b7d74f48]; Stage:[PROCESSING_IN_PROGRESS]; Event Date Time:[25/07/2018 8:46:42 AM]; Event Action:[SENDING_REQUEST]; Event Status:[SUCCESS]; Event Data:[Mime Packing and sending request]; Is Processing:[false]; Is Final:[false]; Exchange Profile Id:[BatchBulkAsyncPull-EVTE-9ea3427a-ed94-474c-8785-460d2dc28a61]; Storage Ref:[Content-Type:[multipart/related]; Storage Blob Id:[000000020028418e00617564697400000000000000000000aa1c854f9817c08d00000164ddec3291]; ]; Role:[REQUEST]; Exchange Group Id:[e88e4628-13fc-411f-ab83-2a297dccb186]; External Reference:[Destination IP=[test2.ato.sbr.gov.au]];
Jul 25, 2018 8:46:42 AM com.ibm.b2b.as4.client.internal.MessageBatcherImpl logEventAudit
INFO: Event Details: App Context Component:[COMMS]; App Context Service Inst:[AS4]; Trans Id:[ebb64ae1-762d-4175-9ca3-61c0b7d74f48]; Stage:[PROCESSING_IN_PROGRESS]; Event Date Time:[25/07/2018 8:46:42 AM]; Event Action:[UNPACKAGING]; Event Status:[SUCCESS]; Event Data:[Unpacking Mime Message]; Is Processing:[false]; Is Final:[false]; Exchange Profile Id:[BatchBulkAsyncPull-EVTE-9ea3427a-ed94-474c-8785-460d2dc28a61]; Storage Ref:[Content-Type:[multipart/related]; Storage Blob Id:[000000020028dcb9006175646974000000000000000000007ca39a2ac13a687b00000164ddec3571]; ]; Role:[REQUEST]; Exchange Group Id:[e88e4628-13fc-411f-ab83-2a297dccb186]; External Reference:[Destination IP=[test2.ato.sbr.gov.au]];
Exception in thread "main" EBMS ERRORS : 1 - [ error Code : EBMS:0006, Severity : WARNING, Description : There is no message available for pulling from this MPC at this moment., Error Details : EmptyMsgPartitionChannelException: Pulling message from pull destination failed., RefToMessageInError : A1528423965023.21c28b02-2092-4faf-a394-96a1264f7e6e#1528423965023, Origin : EBMS, Category : Communication, Short description : EmptyMessagePartitionChannel].
at com.ibm.b2b.as4.client.internal.ResponseImpl.workWithError(ResponseImpl.java:214)
at com.ibm.b2b.as4.client.internal.ResponseImpl.<init>(ResponseImpl.java:89)
at com.ibm.b2b.as4.client.internal.RequestImpl.createResponse(RequestImpl.java:341)
at com.ibm.b2b.as4.client.internal.RequestImpl.createResponse(RequestImpl.java:317)
at com.ibm.b2b.as4.client.internal.RequestImpl.sendBDO(RequestImpl.java:249)
at com.ibm.b2b.as4.client.internal.RequestImpl.send(RequestImpl.java:226)
Exception thrown: 'IBM_AS4Client.AS4ClientEbMSException' in AS4Client_x64.dll
So my question is: how can I get to that information that the debugger can see, but the .NET runtime is not aware of? Some of it looks like logging output, but it's not being written to any logs on the file system that I can find.
UPDATE
The third-party code seems to make some use of log4cxx (at least, it comes with a log4cxx.properties and a log4cxx_x64.dll, but the log4cxx.properties seems to be pure log4j); anyway, I tweaked it to show DEBUG level instead of the default INFO level it was showing before, and now I can see some of the output, but only DEBUG level, not INFO or higher. The INFO entries in the sample below are in a different layout to that used by the DEBUG entries, so I suspect they are not being written by log4j.
Further digging (hey, I'm a .NET guy, not a Java guy, so I have no idea what this stuff does until I prod it with a pointed stick) yields a logging.properties file, which together with the logging sample above, suggests that the INFO: stuff is being written by java.utils.logging, so some more investigation there would be merited.

Error using sonar-activedirectory 1.0 in SonarQube 6.0

After upgrading to SonarQube 6.0 we cannot use the SSO login plugin anymore. This is our SonarQube.log in TRACE mode:
DEBUG web[o.s.s.u.NewUserNotifier] User created: xxxx#xxxx. Notifying NewUserHandler handlers...
TRACE web[sql] time=0ms | sql=select u.login,u.name,u.email,u.active,u.scm_accounts,u.created_at,u.updated_at from users u where u.updated_at>? | params=1470426045520
TRACE web[es] ES refresh request on indices 'users' | time=94ms
**ERROR web[rails] cannot load Java class org.sonar.server.user.RubyUserSession**
DEBUG web[http] GET /active_directory/validate | time=2703ms
The plugin configuration is very simple (just one line):
sonar.security.realm=ACTIVE_DIRECTORY
Is there a way to solve this problem by adding other configuration settings and how can I tell if this error is in the SonarQube or SSO code?
Thanks. I wrote the linked google group note. Sadly it looks like SSO as it worked isn't going to be supported even if the plugin is updated. Users will still have to click a link.
https://github.com/SonarQubeCommunity/sonar-activedirectory/issues/9
Use the BaseIdentityProvider API (https://github.com/SonarSource/sonarqube/blob/master/sonar-plugin-api/src/main/java/org/sonar/api/server/authentication/BaseIdentityProvider.java) -> It will allow SSO by creating a link in the login page
It seems that the authentication interface is changed in SonarQube 6.0 in order to phasing out some old software components. So it cannot be solved by changing the SonarQube configuration; the SSO plugin must be updated. A ticket can be found on SonarQubeCommunity/sonar-activedirectory GitHub and in the SonarQube Google group.

Play Framework Date Parse Error

So i am having this issue with the play framework session dropping Play Session Dropping during payment tracking
I recently checked my logs and notices this stack trace coming up frequently
[debug] application - An invalidate date was received: Sat, 03 Oct 2015 23:08:37 UTC
java.lang.IllegalArgumentException: Invalid format: "Sat, 03 Oct 2015 23:08:37 UTC" is malformed at " UTC"
at org.joda.time.format.DateTimeFormatter.parseDateTime(DateTimeFormatter.java:873) ~[joda-time.joda-time-2.3.jar:2.3]
at controllers.AssetInfo$.parseDate(Assets.scala:106) ~[com.typesafe.play.play_2.11-2.3.8.jar:1.0-SNAPSHOT]
at controllers.AssetsBuilder$$anonfun$controllers$AssetsBuilder$$maybeNotModified$3.apply(Assets.scala:326) [com.typesafe.play.play_2.11-2.3.8.jar:1.0-SNAPSHOT]
at controllers.AssetsBuilder$$anonfun$controllers$AssetsBuilder$$maybeNotModified$3.apply(Assets.scala:325) [com.typesafe.play.play_2.11-2.3.8.jar:1.0-SNAPSHOT]
at scala.Option.flatMap(Option.scala:170) [org.scala-lang.scala-library-2.11.1.jar:na]
I looked at this post on github (https://github.com/playframework/playframework/issues/3569) which is similar and says fixed but not sure if my version has the fix. I am using version 2.3.8.
Could this be causing my request to not have my session since it can not even parse the request?
Also do I need to update my version to fix this issue ?

oauthd not asking me to set a user/pass on first use

I'm trying to figure out the oauthd system ( https://oauth.io/docs/oauthd) , so I can do social media authentication on my own server, rather than using theirs (which seems to go offline a fair bit for me)
Anyway, I've installed it, run init to create the instance, and then start, as per the below output:
oauthd start
Initializing plugins engine
Loading admin-auth
Loading slashme
Loading request
Loading front
oauthd start server
oauthd listening at http://:::6284 for https://example.com:6284
Server is ready (load time: 1.85s) Wed, 11 Mar 2015 17:20:24 GMT
Now, as per the document - I should go to:
http://example.com:6284/admin
...and its MEANT to ask you to setup a user/password, which will be the admin logins. Unfortunately, it doesn't do this. I just get sent to:
http://example.com:6284/login ... where it asks me to login with an email/password, both of which I don't have yet:
Can anyone explain what step I'm missing? I've love to get this going - as I'm not a fan of having to use 3rd party systems (i.e oauth.io), as you are at their mercy when it goes offline.
Logging in for the first time actually creates your admin user with the entered credentials. So for example if you enter 'admin#yourmail.com' as the e-mail and 'letmepassplease' as the password, you'll be able to log in with these credentials in the future.
I can see why it's not clear, and we will probably improve this later. In the meantime you can create an issue about this on the Github repo.
Hope this helps :)

twitter4j api to post image to twitter,

I use twitter4j api to post image to twitter, initially my project worked without any exception but after further development it became unresponsive. Below is the error log form eclipse logcat.
com.android.org.bouncycastle.jce.exception.ExtCertPathValidatorException: Could not validate certificate:
current time: Fri May 10 12:37:38 IST 2013, expiration time: Fri May 10 05:29:59 IST 2013
TwitterException{exceptionCode=[f69e96cd-138ff489 f69e96cd-138ff438 f69e96cd-138ff438 f69e96cd-138ff438 f69e96cd-138ff438], statusCode=-1, retryAfter=0, rateLimitStatus=null, version=2.1.6}
This happened since last night and I cant figure out whether this is due to twitter server error or not.
Somehow it seems the Certs are linked to your current date/time and any modification made there will cause this exception. Even I'm hunting for a perfect answer/resolution to this issue.

Resources