1

I am done building the java spring boot app and now I am trying to deploy it to VPS. Everything works except once I access part of web app that is connected to the database I get this error

ERROR 7379 --- [nio-8080-exec-5] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Handler dispatch failed; nested exception is java.lang.ExceptionInInitializerError] with root cause

When I put connection url to database to be jdbc:mysql://"ip of server":3306/kuponi i get this error

and when I put connection url to database to be jdbc:mysql://localhost:3306/kuponi

1 Answers1

0

Try adding these dependencies to your pom.xml file

<dependency>
    <groupId>jakarta.xml.bind</groupId>
    <artifactId>jakarta.xml.bind-api</artifactId>
    <version>2.3.3</version>
</dependency>

<dependency>
    <groupId>com.sun.xml.bind</groupId>
    <artifactId>jaxb-ri</artifactId>
    <version>2.3.3</version>
</dependency>
  • 1
    didnt help much, now I get this error : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Handler dispatch failed; nested exception is java.lang.ExceptionInInitializerError] with root cause java.lang.ClassNotFoundException: com.sun.xml.bind.v2.ContextFactory at org.springframework.boot.web.embedded.tomcat.TomcatEmbeddedWebappClassLoader.loadClass(TomcatEmbeddedWebappClassLoader.java:72) ~[spring-boot-2.2.2.RELEASE.jar!/:2.2.2.RELEASE] – Danilo Congradac Oct 21 '21 at 20:55
  • yes, thanks, now i get diferent error, access denied for user 'root'@'localhost' – Danilo Congradac Oct 21 '21 at 21:27
  • yea, i made it work, now I am getting this error.... Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Handler dispatch failed; nested exception is java.lang.ExceptionInInitializerError] with root cause java.net.ConnectException: Connection refused (Connection refused) – Danilo Congradac Oct 21 '21 at 21:35
  • i made changes to my question – Danilo Congradac Oct 21 '21 at 21:43
  • yes it is, I made mistake last time, check now ss – Danilo Congradac Oct 21 '21 at 22:03
  • Just a tip, when uploading screenshots you should redact your server IP and username/password so that people with bad intentions can't see them. – Alessandro Leo Oct 21 '21 at 22:11
  • ok, thanks for tips, I appreciate it – Danilo Congradac Oct 21 '21 at 22:15
  • Can you connect to the database with a database client on your server? – Alessandro Leo Oct 21 '21 at 22:17
  • yes, I can access database from terminal on my server, but my application cant – Danilo Congradac Oct 21 '21 at 22:18
  • after typing this i get same error access denied , just it says '(using password: YES)' – Danilo Congradac Oct 21 '21 at 22:19
  • If you're absolutely sure credentials are correct you should try and check the database server logs. – Alessandro Leo Oct 21 '21 at 22:25
  • If logs don't contain the reason then look at this: https://stackoverflow.com/questions/41645309/mysql-error-access-denied-for-user-rootlocalhost – Alessandro Leo Oct 21 '21 at 22:35