I have a little training project running under Java Spring MVC and using MySQL on WAMP Server), it was working but i cloned it and had to reinstall database (restored from a dump) and Wamp64 also, but now my java application cannot connect and i get different errors.
In IntelliJ IDEA when i test the connection to the database, the connection is successfull, even in phpmyadmin, but not when i launch my application.
jdbc:mysql://localhost:3306/library?serverTimezone=UTC
(i had to use server timezone to fixe timezone error)
It's looking like my java app doesn't use the good datasource configuration, and instead use the old one but i can't figure out why.
My application is using SOAP protocol to connect to my webservices.
The main error is a javaNullPointer exception on the line where i try to get the user from database trough an input form.
The other error is (when i go in debug mode):
Failed to obtain JDBC Connection; nested exception is java.sql.SQLException: Accès refusé pour l'utilisateur: 'root'@'@localhost' (mot de passe: OUI) error.
This project was cloned from an old project. I suppose there is somewhere an old datasource used by the application.
It looks like my application uses old login settings for mysql (login: root, password: password). I recently changed the login information to my database, to an "admin_library" login that has all the privileges and a password.
I invalidated and restarted the IntelliJ cache, made an "mvn clean install", but when I run my two tomcat servers (one for the webservice, another one for the soap webserviceclient), my login screen appears but I have a null point exception (apparently due to a database connection problem.
Here is my configuration:
pom.xml:
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.15</version>
</dependency>
WEB-INF/SpringMVCDispatcher-servlet.xml:
<!-- CONFIG JDBC DATASOURCE // -->
<bean id = "jdbcTemplate"
class = "org.springframework.jdbc.core.JdbcTemplate">
<property name = "dataSource" ref = "dataSource" />
</bean>
<bean id = "dataSource"
class = "org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name = "driverClassName" value = "com.mysql.jdbc.Driver"/>
<property name = "url" value = "jdbc:mysql://localhost:3306/library"/>
<property name = "username" value = "admin_library"/>
<property name = "password" value = "password"/>
</bean>
Type Rapport d'exception
message Request processing failed; nested exception is com.sun.xml.ws.fault.ServerSOAPFaultException: Client received SOAP Fault from server: Failed to obtain JDBC Connection; nested exception is java.sql.SQLException: Accès refusé pour l'utilisateur: 'root'@'@localhost' (mot de passe: OUI) Please see the server log to find more detail regarding exact cause of the failure.
description Le serveur a rencontré une erreur interne qui l'a empêché de satisfaire la requête.
exception
org.springframework.web.util.NestedServletException: Request processing failed; nested exception is com.sun.xml.ws.fault.ServerSOAPFaultException: Client received SOAP Fault from server: Failed to obtain JDBC Connection; nested exception is java.sql.SQLException: Accès refusé pour l'utilisateur: 'root'@'@localhost' (mot de passe: OUI) Please see the server log to find more detail regarding exact cause of the failure.
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006)
org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:901)
javax.servlet.http.HttpServlet.service(HttpServlet.java:660)
org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:875)
javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:200)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
cause mère
com.sun.xml.ws.fault.ServerSOAPFaultException: Client received SOAP Fault from server: Failed to obtain JDBC Connection; nested exception is java.sql.SQLException: Accès refusé pour l'utilisateur: 'root'@'@localhost' (mot de passe: OUI) Please see the server log to find more detail regarding exact cause of the failure.
com.sun.xml.ws.fault.SOAP11Fault.getProtocolException(SOAP11Fault.java:193)
com.sun.xml.ws.fault.SOAPFaultBuilder.createException(SOAPFaultBuilder.java:128)
com.sun.xml.ws.client.sei.StubHandler.readResponse(StubHandler.java:253)
com.sun.xml.ws.db.DatabindingImpl.deserializeResponse(DatabindingImpl.java:206)
com.sun.xml.ws.db.DatabindingImpl.deserializeResponse(DatabindingImpl.java:293)
com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:119)
com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:92)
com.sun.xml.ws.client.sei.SEIStub.invoke(SEIStub.java:161)
com.sun.proxy.$Proxy47.findByEmail(Unknown Source)
fr.projet3.library.controller.LoginController.postLogin(LoginController.java:57)
java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
java.base/java.lang.reflect.Method.invoke(Method.java:566)
org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:215)
org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:142)
org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:102)
org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:895)
org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:800)
org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87)
org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1038)
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:942)
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:998)
org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:901)
javax.servlet.http.HttpServlet.service(HttpServlet.java:660)
org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:875)
javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:200)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
note La trace complète de la cause mère de cette erreur est disponible dans les fichiers journaux de ce serveur.
A look into the controller:
@PostMapping(value = {"/login","/", ""})
public String postLogin(@Valid @ModelAttribute("userLoginForm")UserLoginForm userLoginForm, BindingResult bindingResult, ModelMap modelMap, HttpSession session){
if(!bindingResult.hasErrors()){
UserWS u = libraryWS.findByEmail(userLoginForm.getEmail());
if(u == null){
return "login";
}
session.setAttribute("currentUser", u);
return "redirect:/userloan";
}
return "login";
}