• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

whitelabel 404 error in microservice

 
Ranch Hand
Posts: 948
2
  • Number of slices to send:
    Optional 'thank-you' note:
I am getting below error while aces below micro service from the browser or postman as attached. I see H2 database getting inserterted with data successfully.  Please advise

I am able to start the spring boot servers and also be able to see the data inserted into the H2 Database.

ACCOUNTS AND CUSTOMER H2

http://localhost:8081/h2-console/login.do?jsessionid=4cfecd0415af0b7a7fb18fb59dda08e2 works fine
CARDS H2

http://localhost:9010/h2-console/ works fine
Loans h2

http://localhost:8099/h2-console  works fine
When I access URLs in the browser I get errors like 404 whitelabel errors. Even postman also giving similar errors not sure of any issues with paths, URLs, mappings.

http://localhost:8081/api/v1/accounts/1
Above gives white label 404 as attached


http://localhost:9010/api/v1/cards/1
Above gives white label 404 as attached

http://localhost:8099/api/v1/loans/1  
Above gives white label 404 as attached


Code is as below


h2-console-coming.JPG
postman_404_bank_app_hw.JPG
whitelable-404.JPG
Staff note (Ron McLeod) :

srk: I removed a large amount of blank lines from your code which was making it unreadable.

 
Saloon Keeper
Posts: 15608
366
  • Number of slices to send:
    Optional 'thank-you' note:
Well, which endpoint is http://localhost:8081/api/v1/accounts/1 supposed to reach? The mappings in your AccountController class don't match.

Furthermore, even if they did match, the accountService.fetchAccountDetails(customerId) call would fail because accountService is not auto-wired.
 
sai rama krishna
Ranch Hand
Posts: 948
2
  • Number of slices to send:
    Optional 'thank-you' note:
With below url got 500 error. Please advise

http://localhost:8081/api/v1/accounts/fetch/1
Whitelabel Error Page
This application has no explicit mapping for /error, so you are seeing this as a fallback.

Mon Apr 22 22:07:19 EDT 2024
There was an unexpected error (type=Internal Server Error, status=500).
 
Stephan van Hulst
Saloon Keeper
Posts: 15608
366
  • Number of slices to send:
    Optional 'thank-you' note:
There's nothing we can do with that error message.

You need to either look in the server logs, use a debugger to step through your code, or provide a custom error page.
 
sai rama krishna
Ranch Hand
Posts: 948
2
  • Number of slices to send:
    Optional 'thank-you' note:
How to effectively debug these type of intricate errors involving multiple layers like controller, service, repository, configurations and database etc. ?
Please advise
 
Saloon Keeper
Posts: 7597
177
  • Number of slices to send:
    Optional 'thank-you' note:
They all run in the same JVM, right? So a debugger would work well, as Stephan said.
 
sai rama krishna
Ranch Hand
Posts: 948
2
  • Number of slices to send:
    Optional 'thank-you' note:
Yea, Currently running in my local windows laptop. How to debug paths like below which are given in annotations
api/v1/accounts/fetch/1

I gave wrong path earlier
api/v1/accounts/1

I keep get these type of errors with paths

Multiple hops like browser to app controller and then to database harder to debug I feel especially in enterprise applications
 
Tim Moores
Saloon Keeper
Posts: 7597
177
  • Number of slices to send:
    Optional 'thank-you' note:
A debugger can set breakpoints in the code, not at particular URLs. So it doesn't matter how code is accessed, only that it does get executed.
 
sai rama krishna
Ranch Hand
Posts: 948
2
  • Number of slices to send:
    Optional 'thank-you' note:
Lot of times I am getting access errors. I think i need to put more attention on paths

In log i see below type of error for that 500 error



I do not see this.accountService in below class though



I just uncommented autowired as below


Now I see error like below data error


I do see that data
data-mangodb.JPG
 
Stephan van Hulst
Saloon Keeper
Posts: 15608
366
  • Number of slices to send:
    Optional 'thank-you' note:
How is Spring JPA to know that a field named customerId is mapped to a column named customer_id?

Use the @Column annotation to map the field to the correct column.
 
sai rama krishna
Ranch Hand
Posts: 948
2
  • Number of slices to send:
    Optional 'thank-you' note:
Ah got it. Thank you. Let me try once i am able to get to that personal laptop today.
 
sai rama krishna
Ranch Hand
Posts: 948
2
  • Number of slices to send:
    Optional 'thank-you' note:
If distributed in multiple JVMs how to debug these type of issues. What are best practices in naming conventions, debugging, avoiding, finding root causes of these type of issues which i have pattern of making similar ones again and again
 
Stephan van Hulst
Saloon Keeper
Posts: 15608
366
  • Number of slices to send:
    Optional 'thank-you' note:
When debugging a client and server application simultaneously, I typically just open two separate instances of my IDE and attach each one to a different JVM process.

There are two important pieces of advice I can give you: First, learn how to read log files and stack traces. Second, learn how the debugger works by stepping through your application and experimenting with the call stack and watched variables.

For naming conventions, have your code reviewed by experienced programmers, such as the fine members of the CodeRanch.

Other than that, a lot of expertise really comes from making the same mistakes over and over until you learn not to make them anymore.
 
sai rama krishna
Ranch Hand
Posts: 948
2
  • Number of slices to send:
    Optional 'thank-you' note:
Thank you.

When I am trying to start intellij standard free edition server on my laptop now I am getting below error. Trying to resolve this.
Error: Could not find or load main class com.je.JeHwAccountApplication
Caused by: java.lang.ClassNotFoundException: com.je.JeHwAccountApplication

After doing maven install now this server issue resolved and started


I added @column customer_id

still getting below error


Whitelabel Error Page
This application has no explicit mapping for /error, so you are seeing this as a fallback.

Wed Apr 24 21:35:39 EDT 2024
There was an unexpected error (type=Internal Server Error, status=500).





2024-04-24T21:35:39.518-04:00  INFO 19076 --- [JE-HW-Account] [nio-8081-exec-1] com.je.controllers.AccountController     : acct controler ->fetchAccountDetails1
2024-04-24T21:35:39.737-04:00 ERROR 19076 --- [JE-HW-Account] [nio-8081-exec-1] o.a.c.c.C.[.[.[/].[dispatcherServlet]    : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed: java.lang.RuntimeException: account not there in db] with root cause

java.lang.RuntimeException: account not there in db
at com.je.service.AccountService.lambda$0(AccountService.java:19) ~[classes/:na]
at java.base/java.util.Optional.orElseThrow(Optional.java:403) ~[na:na]
at com.je.service.AccountService.fetchAccountDetails(AccountService.java:19) ~[classes/:na]
at com.je.controllers.AccountController.fetchAccountDetails(AccountController.java:31) ~[classes/:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) ~[na:na]
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
at java.base/java.lang.reflect.Method.invoke(Method.java:568) ~[na:na]
at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:255) ~[spring-web-6.1.5.jar:6.1.5]
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:188) ~[spring-web-6.1.5.jar:6.1.5]
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:118) ~[spring-webmvc-6.1.5.jar:6.1.5]
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:925) ~[spring-webmvc-6.1.5.jar:6.1.5]
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:830) ~[spring-webmvc-6.1.5.jar:6.1.5]
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87) ~[spring-webmvc-6.1.5.jar:6.1.5]
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1089) ~[spring-webmvc-6.1.5.jar:6.1.5]
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:979) ~[spring-webmvc-6.1.5.jar:6.1.5]
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1014) ~[spring-webmvc-6.1.5.jar:6.1.5]
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:903) ~[spring-webmvc-6.1.5.jar:6.1.5]
at jakarta.servlet.http.HttpServlet.service(HttpServlet.java:564) ~[tomcat-embed-core-10.1.19.jar:6.0]
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:885) ~[spring-webmvc-6.1.5.jar:6.1.5]
at jakarta.servlet.http.HttpServlet.service(HttpServlet.java:658) ~[tomcat-embed-core-10.1.19.jar:6.0]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:205) ~[tomcat-embed-core-10.1.19.jar:10.1.19]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:149) ~[tomcat-embed-core-10.1.19.jar:10.1.19]
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51) ~[tomcat-embed-websocket-10.1.19.jar:10.1.19]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:174) ~[tomcat-embed-core-10.1.19.jar:10.1.19]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:149) ~[tomcat-embed-core-10.1.19.jar:10.1.19]
at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100) ~[spring-web-6.1.5.jar:6.1.5]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:116) ~[spring-web-6.1.5.jar:6.1.5]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:174) ~[tomcat-embed-core-10.1.19.jar:10.1.19]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:149) ~[tomcat-embed-core-10.1.19.jar:10.1.19]
at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93) ~[spring-web-6.1.5.jar:6.1.5]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:116) ~[spring-web-6.1.5.jar:6.1.5]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:174) ~[tomcat-embed-core-10.1.19.jar:10.1.19]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:149) ~[tomcat-embed-core-10.1.19.jar:10.1.19]
at org.springframework.web.filter.ServerHttpObservationFilter.doFilterInternal(ServerHttpObservationFilter.java:109) ~[spring-web-6.1.5.jar:6.1.5]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:116) ~[spring-web-6.1.5.jar:6.1.5]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:174) ~[tomcat-embed-core-10.1.19.jar:10.1.19]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:149) ~[tomcat-embed-core-10.1.19.jar:10.1.19]
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201) ~[spring-web-6.1.5.jar:6.1.5]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:116) ~[spring-web-6.1.5.jar:6.1.5]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:174) ~[tomcat-embed-core-10.1.19.jar:10.1.19]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:149) ~[tomcat-embed-core-10.1.19.jar:10.1.19]
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:167) ~[tomcat-embed-core-10.1.19.jar:10.1.19]
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:90) ~[tomcat-embed-core-10.1.19.jar:10.1.19]
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:482) ~[tomcat-embed-core-10.1.19.jar:10.1.19]
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:115) ~[tomcat-embed-core-10.1.19.jar:10.1.19]
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:93) ~[tomcat-embed-core-10.1.19.jar:10.1.19]
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74) ~[tomcat-embed-core-10.1.19.jar:10.1.19]
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:344) ~[tomcat-embed-core-10.1.19.jar:10.1.19]
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:391) ~[tomcat-embed-core-10.1.19.jar:10.1.19]
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:63) ~[tomcat-embed-core-10.1.19.jar:10.1.19]
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:896) ~[tomcat-embed-core-10.1.19.jar:10.1.19]
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1744) ~[tomcat-embed-core-10.1.19.jar:10.1.19]
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:52) ~[tomcat-embed-core-10.1.19.jar:10.1.19]
at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191) ~[tomcat-embed-core-10.1.19.jar:10.1.19]
at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659) ~[tomcat-embed-core-10.1.19.jar:10.1.19]
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:63) ~[tomcat-embed-core-10.1.19.jar:10.1.19]
at java.base/java.lang.Thread.run(Thread.java:833) ~[na:na]

I put debug break point in controller class then service class then repository class.

I tried to start application in debug mode but I do not see that option

I put log statement in Controller and SErvice which are prinitng 1 as well as below. But in repository layer failing. How to print the query the is being executed?



Please advise


ACCOUNT-NOT-IN-DB.JPG
debug-mode.JPG
customerid1.JPG
 
sai rama krishna
Ranch Hand
Posts: 948
2
  • Number of slices to send:
    Optional 'thank-you' note:
I printed the SQL as below by including below line application.properties file
spring.jpa.show-sql=true

Also in boot debugger view I am able to start server in debug mode as well
Looks like query expecting account_number not customer Id. Please advise





Loans worked as attached





loansworks.jpg
loans_working.JPG
loans-db.JPG
 
sai rama krishna
Ranch Hand
Posts: 948
2
  • Number of slices to send:
    Optional 'thank-you' note:
Also cards worked as below, attached.  Both cards and loans working does not have service layer. Accounts not working has service layer not sure any issue with that



cards_works.jpg
cardssworks.JPG
cards_db.JPG
 
sai rama krishna
Ranch Hand
Posts: 948
2
  • Number of slices to send:
    Optional 'thank-you' note:
I will try to  remember not to edit posts. Mostly I am editing to correct typos and attach forgotten images. I updated my code as below by removing customerId variable reference and adding accountNumber variable as reference as dealing with accounts here. Below is the query generated by intellij idea when i put hibernate query as true in configuration


select a1_0.account_number,a1_0.account_type,a1_0.branch_address,a1_0.create_dt,a1_0.customer_id from account a1_0 where a1_0.account_number=1

I get below same error no records found in database as below



When I try to execute same query in h2o console there also i get results found even though there is record with account number 1 as attached when I use below query

SELECT * FROM ACCOUNT

My complete updated code of this accounts micro service as below. Please advise


select-star-accounts-works-fine..JPG
same-query-from-h2o-console-yields-no-results.JPG
query-generated-in-idea.JPG
 
sai rama krishna
Ranch Hand
Posts: 948
2
  • Number of slices to send:
    Optional 'thank-you' note:
Thank you all for your help, guidance. It finally worked when I give account number value (instead of customerId) in the query as that is primary key. Latest working code, working screenshots attached




accounts_working_from_browser.JPG
accounts_working.JPG
 
Marshal
Posts: 79394
377
  • Number of slices to send:
    Optional 'thank-you' note:

sai rama krishna wrote:I will try to  remember not to edit posts. Mostly I am editing to correct typos and attach forgotten images. . . .

That is not too bad; it doesn't usually cause confusion later.
 
sai rama krishna
Ranch Hand
Posts: 948
2
  • Number of slices to send:
    Optional 'thank-you' note:
I agree. Thank you.
reply
    Bookmark Topic Watch Topic
  • New Topic
vceplus-200-125    | boson-200-125    | training-cissp    | actualtests-cissp    | techexams-cissp    | gratisexams-300-075    | pearsonitcertification-210-260    | examsboost-210-260    | examsforall-210-260    | dumps4free-210-260    | reddit-210-260    | cisexams-352-001    | itexamfox-352-001    | passguaranteed-352-001    | passeasily-352-001    | freeccnastudyguide-200-120    | gocertify-200-120    | passcerty-200-120    | certifyguide-70-980    | dumpscollection-70-980    | examcollection-70-534    | cbtnuggets-210-065    | examfiles-400-051    | passitdump-400-051    | pearsonitcertification-70-462    | anderseide-70-347    | thomas-70-533    | research-1V0-605    | topix-102-400    | certdepot-EX200    | pearsonit-640-916    | itproguru-70-533    | reddit-100-105    | channel9-70-346    | anderseide-70-346    | theiia-IIA-CIA-PART3    | certificationHP-hp0-s41    | pearsonitcertification-640-916    | anderMicrosoft-70-534    | cathMicrosoft-70-462    | examcollection-cca-500    | techexams-gcih    | mslearn-70-346    | measureup-70-486    | pass4sure-hp0-s41    | iiba-640-916    | itsecurity-sscp    | cbtnuggets-300-320    | blogged-70-486    | pass4sure-IIA-CIA-PART1    | cbtnuggets-100-101    | developerhandbook-70-486    | lpicisco-101    | mylearn-1V0-605    | tomsitpro-cism    | gnosis-101    | channel9Mic-70-534    | ipass-IIA-CIA-PART1    | forcerts-70-417    | tests-sy0-401    | ipasstheciaexam-IIA-CIA-PART3    | mostcisco-300-135    | buildazure-70-533    | cloudera-cca-500    | pdf4cert-2v0-621    | f5cisco-101    | gocertify-1z0-062    | quora-640-916    | micrcosoft-70-480    | brain2pass-70-417    | examcompass-sy0-401    | global-EX200    | iassc-ICGB    | vceplus-300-115    | quizlet-810-403    | cbtnuggets-70-697    | educationOracle-1Z0-434    | channel9-70-534    | officialcerts-400-051    | examsboost-IIA-CIA-PART1    | networktut-300-135    | teststarter-300-206    | pluralsight-70-486    | coding-70-486    | freeccna-100-101    | digitaltut-300-101    | iiba-CBAP    | virtuallymikebrown-640-916    | isaca-cism    | whizlabs-pmp    | techexams-70-980    | ciscopress-300-115    | techtarget-cism    | pearsonitcertification-300-070    | testking-2v0-621    | isacaNew-cism    | simplilearn-pmi-rmp    | simplilearn-pmp    | educationOracle-1z0-809    | education-1z0-809    | teachertube-1Z0-434    | villanovau-CBAP    | quora-300-206    | certifyguide-300-208    | cbtnuggets-100-105    | flydumps-70-417    | gratisexams-1V0-605    | ituonline-1z0-062    | techexams-cas-002    | simplilearn-70-534    | pluralsight-70-697    | theiia-IIA-CIA-PART1    | itexamtips-400-051    | pearsonitcertification-EX200    | pluralsight-70-480    | learn-hp0-s42    | giac-gpen    | mindhub-102-400    | coursesmsu-CBAP    | examsforall-2v0-621    | developerhandbook-70-487    | root-EX200    | coderanch-1z0-809    | getfreedumps-1z0-062    | comptia-cas-002    | quora-1z0-809    | boson-300-135    | killtest-2v0-621    | learncia-IIA-CIA-PART3    | computer-gcih    | universitycloudera-cca-500    | itexamrun-70-410    | certificationHPv2-hp0-s41    | certskills-100-105    | skipitnow-70-417    | gocertify-sy0-401    | prep4sure-70-417    | simplilearn-cisa    |
http://www.pmsas.pr.gov.br/wp-content/    | http://www.pmsas.pr.gov.br/wp-content/    |