I have copied the war to apache-tomcat-8.0.43/webapps and started tomcat using ./startup.sh. When I try to access http://localhost:8080/swagger-ui.html, I get 404 but it's working when I say mvn spring-boot:run. Am I missing any configuration? Sample code below:
package com.user;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
import static springfox.documentation.builders.PathSelectors.regex;
#SpringBootApplication
#EnableSwagger2
public class UserMicroServicesApplication extends SpringBootServletInitializer {
private static ConfigurableApplicationContext ctx;
#Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(UserMicroServicesApplication.class);
}
public static void main(String[] args) throws Exception {
ctx = SpringApplication.run(UserMicroServicesApplication.class, args);
}
#Bean
public Docket productApi() {
return new Docket(DocumentationType.SWAGGER_2).select().apis(RequestHandlerSelectors.basePackage("com.user.controller")).paths(regex("/api.*")).build().apiInfo(apiInfo());
}
private ApiInfo apiInfo() {
return new ApiInfo("User API", "User service API.", "V1", "Terms of service", "", "", "");
}
}
controller class
-------------------
package com.user.controller;
import com.user.service.UserService;
import com.user.vo.UserVO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import java.util.List;
#RestController
#RequestMapping(value = "/api")
public class UserController {
private static final Logger logger = LoggerFactory.getLogger(UserController.class);
#Autowired
private UserService userService;
#RequestMapping(value = "/user", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
#ResponseStatus(HttpStatus.CREATED)
#ResponseBody
public UserVO createUser(#RequestBody #Valid UserVO user) {
logger.debug("creating user with email = {}", user);
UserVO updatedUserVO = userService.createUser(user);
logger.debug("user created with id {}", updatedUserVO.getId());
return updatedUserVO;
}
}
POM.xml
<packaging>war</packaging>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.6.RELEASE</version>
<relativePath/>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-cache</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-hateoas</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-rest</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-mongodb</artifactId>
<version>1.5.7.RELEASE</version>
</dependency>
You need to add context path to the link.
apache-tomcat-8.0.43/webapps/${war-name}
http://localhost:8080/${war-name}/swagger-ui.html
Related
When I compile my spring project, I got the following error.
Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Table [command_failure_notification] contains logical column name [user_id] referring to multiple physical column names: [user_id], ["user_id"]
I am using Eclipse and hibernate 6 and Postgres 15 Database.
I have DataBase with name "primo" and it has one table with name "test" and one column with name "id"
I wanted to connect my project to DB for fetching/save my data.
My Connection string in Application.Properties is
spring.datasource.url=jdbc:postgresql://localhost:5432/primo
spring.datasource.username=postgres
spring.datasource.password=postgres
# The SQL dialect makes Hibernate generate better SQL for the chosen database
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect
spring.datasource.hikari.connectionTimeout=20000
spring.datasource.hikari.maximumPoolSize=5
spring.jpa.hibernate.ddl-auto=update
spring.jpa.show-sql=true
spring.jpa.properties.hibernate.jdbc.lob.non_contextual_creation=true
My pom.xml file:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.0.1</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.example.</groupId>
<artifactId>DemoDB</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>DemoDB</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>17</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.hibernate.orm/hibernate-core -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>6.1.6.Final</version>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
</dependency>
<!-- https://mvnrepository.com/artifact/org.json/json -->
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20220924</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework/spring-web -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>6.0.3</version>
</dependency>
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-runtime</artifactId>
<version>3.0.0</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
And my Java Classes:
package com.example.DemoDB;
import java.util.List;
import org.hibernate.SessionFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import com.example.DemoDB.model.Test;
import jakarta.persistence.EntityManager;
#SpringBootApplication
public class DemoDbApplication {
public static void main(String[] args) {
SpringApplication.run(DemoDbApplication.class, args);
SessionFactory sf = HibernateUtil.getSessionFactory();
EntityManager entityManager = sf.createEntityManager();
entityManager.getTransaction().begin();
List<Test> result = entityManager.createQuery( "from Test", Test.class ).getResultList();
for ( Test t : result ) {
System.out.println( "Event (" + t.getId() );
}
entityManager.getTransaction().commit();
entityManager.close();
}
}
package com.example.DemoDB;
import org.hibernate.SessionFactory;
import org.hibernate.boot.Metadata;
import org.hibernate.boot.MetadataSources;
import org.hibernate.boot.registry.StandardServiceRegistry;
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
public class HibernateUtil {
private static SessionFactory sessionFactory = buildSessionFactory();
private static SessionFactory buildSessionFactory() {
try {
if (sessionFactory == null)
{
StandardServiceRegistry standardRegistry = new StandardServiceRegistryBuilder()
.configure("src/main/resources/hibernate.cfg.xml").build();
Metadata metaData = new MetadataSources(standardRegistry)
.getMetadataBuilder()
.build();
sessionFactory = metaData.getSessionFactoryBuilder().build();
}
return sessionFactory;
}
catch (Throwable ex) {
throw new ExceptionInInitializerError(ex);
}
}
public static SessionFactory getSessionFactory() {
return sessionFactory;
}
public static void shutdown() {
getSessionFactory().close();
}
}
package com.example.DemoDB.model;
import java.util.Objects;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.NamedQuery;
import jakarta.persistence.Table;
import org.json.JSONObject;
#Entity
#NamedQuery(name = "Test.findAll", query = "SELECT u FROM Test u")
public class Test extends ADbModelEntity
{
private static final long serialVersionUID = -5165500932608878421L;
#Id
#GeneratedValue(strategy = GenerationType.AUTO)
private String id;
public Test() {
}
public Test(String id) {
this.id = id;
}
public String getId() {
return id;
}
#Override
public String toString() {
// TODO Auto-generated method stub
return "User [id= " + id + "]";
}
#Override
public ADbModelEntity clone() {
// TODO Auto-generated method stub
return new Test(this.id);
}
#Override
public int hashCode() {
return Objects.hash(this.id) ;
}
#Override
public boolean equals(Object other) {
if(other instanceof Test) {
return this.id.equalsIgnoreCase( ((Test)other).id );
}
return false;
}
public JSONObject toJSONObject()
{
JSONObject json = new JSONObject();
json.put("id", this.id);
return json;
}
}
I am working on a springboot project using JPA repository for PostGres sql,
My pom.xml is
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.6.11</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.upload</groupId>
<artifactId>FileUpload</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>FileUpload</name>
<description>Exccel File Upload for Spring Boot</description>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>5.2.2</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>5.2.2</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<excludes>
<exclude>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
and my JPA Repository
package com.upload.FileUpload.service;
import com.upload.FileUpload.entity.FileEntries;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
#Repository
public interface UploadRepository extends JpaRepository<FileEntries,Integer> {
}
My Service Impl class is
package com.upload.FileUpload.service;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import javax.transaction.Transactional;
#Service
#AllArgsConstructor
#Slf4j
#Transactional
public class UploadServiceImpl implements UploadService {
private UploadRepository uploadRepository;
}
My Mainapplication.class
package com.upload.FileUpload;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
#SpringBootApplication(exclude={DataSourceAutoConfiguration.class})
public class FileUploadApplication {
public static void main(String[] args) {
SpringApplication.run(FileUploadApplication.class, args);
}
My application.properties
spring.datasource.driverClassName=org.postgresql.Driver
spring.datasource.url=jdbc:postgresql://localhost:5432/postgres
spring.datasource.username=postgres
spring.datasource.password=root
spring.jpa.database-platform=org.hibernate.dialect.PostgreSQL95Dialect
spring.jpa.generate-ddl=true
spring.jpa.show-sql=true
spring.datasource.sql-script-encoding=UTF-8
I am getting the below error
APPLICATION FAILED TO START
***************************
Description:
Parameter 0 of constructor in com.upload.FileUpload.service.UploadServiceImpl required a bean of
type 'com.upload.FileUpload.service.UploadRepository' that could not
be found.
Action:
Consider defining a bean of type 'com.upload.FileUpload.service.UploadRepository' in your
configuration.
Can someone tell me what is the issue here
you have to add #Autowired Annotation on your UploadRepository Declaration
package com.upload.FileUpload.service;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import javax.transaction.Transactional;
#Service
#AllArgsConstructor
#Slf4j
#Transactional
public class UploadServiceImpl implements UploadService {
#Autowired
private UploadRepository uploadRepository;
}
I'm new to spring boot. Trying to integrate with rest services and hibernate, where-in upon logging in with the correct credentials, getting the "Invalid password or username"
#Configuration
public class AppConfig {
#Bean
public userDao userRepository() {
System.out.println("repo from bean");
return new userDaoImpl();
}
#Bean
public userService userService() {
System.out.println("ser from bean");
return new userServiceImpl();
}
#SuppressWarnings("deprecation")
#Bean
public HibernateJpaSessionFactoryBean sessionFactory(){
System.out.println("seesion factory from bean");
return new HibernateJpaSessionFactoryBean();
}}
#Service
public class userServiceImpl implements userService {
#Autowired
private userDao userDao;
public void setUserDao(userDao userDao) {
this.userDao = userDao;
}
#Transactional
public Users validateUser(String Username, String password) {
return userDao.validateUser(Username, password);
}}
#Repository
public class userDaoImpl extends SpringBeanAutowiringSupport implements userDao {
private static final Logger logger = LoggerFactory.getLogger(userDaoImpl.class);
#Autowired
private SessionFactory sessionFactory;
public void setSessionFactory(SessionFactory sessionFactory) {
this.sessionFactory = sessionFactory;
}
public Users validateUser(String Username, String password) {
Criteria criteria = this.sessionFactory.getCurrentSession().createCriteria(Users.class);
if (!StringUtils.isEmpty(Username)) {
criteria.add(Restrictions.eq("username", Username));
}
if (!StringUtils.isEmpty(password)) {
criteria.add(Restrictions.eq("password", password));
}
#SuppressWarnings("unchecked")
List<Users> users = (List<Users>) criteria.list();
if (!users.isEmpty()) {
return users.get(0);
}
return null;
}}
application.properties
spring.datasource.url= jdbc:postgresql://localhost:5432/myusers
spring.datasource.username=postgres
spring.datasource.password=postgres
spring.datasource.driver-class-name=org.postgresql.Driver
spring.jpa.hibernate.ddl-auto=create-drop
spring.jpa.database-platform=org.hibernate.dialect.PostgreSQLDialect spring.jpa.properties.hibernate.current_session_context_class=org.springframework.orm.hibernate4.SpringSessionContext
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.PostgreSQLDialect
hibernate.show_sql=true
hibernate.hbm2ddl.auto=update
entitymanager.packagesToScan=com// com is my base package
#SpringBootApplication
#RestController
public class DemoApplication extends SpringBootServletInitializer {
public static void main(String[] args) {
SpringApplication.run(DemoApplication.class, args);
}
#Autowired
private userService userService;
#RequestMapping(value="/loginProcess" , method=RequestMethod.POST)
public Response publishMessage2(#QueryParam("username") String username, #QueryParam("password") String password) {
System.out.println("Hi " + username);
String responseStr = "response to " + username;
Users user = userService.validateUser(username, password);
if (null != user) {
System.out.println("WELCOME to the application " + user.getFirstname());
} else {
System.out.println("Username or Password is wrong!!");
}
return Response.status(200).entity(responseStr).build()
} }
pom.xml
<?xml version = "1.0" encoding = "UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.login</groupId>
<artifactId>demo2</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>login_spring_boot</name>
<description>login project for Spring Boot</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.8.RELEASE</version>
<relativePath />
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-
8</project.reporting.outputEncoding>
<java.version>1.6</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jersey</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-integration</artifactId>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>9.1-901.jdbc4</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
When I call my rest service from postman( http://localhost:8080/loginProcess?username=abc&password=xyz) where abc and xyz are the valid credentials of a user,"Hi abc" and "Username or password is wrong!! " is printed.
in application.properties file, defined are the db connection specifications like db.driver, username, pwd etc.Create a bean for datasource in appConfig.java, like
#Bean
public DataSource dataSource() {
DriverManagerDataSource dataSource = new DriverManagerDataSource();
//set values for datasource -username, pwd, driverclass etc.}
Sorry for my long post of code.
But I am just a beginner. I want to learn Spring Framework with MongoDB.
I am getting this exception but I have read some post about this problem. However, I didn't understand and how to fix it.
I haven't created application configuration. Is this the one that causes the exception?
Can anyone help me to fix this?
I am really appreciate it. Many thanks....
package com.mywebapp.dao;
import java.util.Date;
import java.util.List;
import org.bson.types.ObjectId;
import org.springframework.data.mongodb.repository.ReactiveMongoRepository;
import org.springframework.stereotype.Repository;
import com.mywebapp.model.Location;
import com.mywebapp.model.User;
#Repository
public interface UserRepository extends ReactiveMongoRepository<User, String>{
List<User> findAllUsers();
User findBy_id(ObjectId id);
User findByUsername(String username);
List<User> findByFirstName(String firstName);
List<User> findByLastName(String lastName);
User findByEmail(String email);
List<User> findByDateOfBirth(Date dob);
List<User> findByLocation(Location location);
}
package com.mywebapp.controller;
import java.util.Date;
import java.util.List;
import org.bson.types.ObjectId;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import com.mywebapp.model.Location;
import com.mywebapp.model.User;
import com.mywebapp.service.UserService;
#RestController
#RequestMapping("/user")
public class UserController {
#Autowired
private UserService userService;
#RequestMapping(value="/",method = RequestMethod.GET)
public List<User> getAllUser(){
return userService.findAllUsers();
}
#RequestMapping(value="/{username}",method = RequestMethod.GET)
public User getUserByUserName(#PathVariable("username") String userName){
return userService.findByUserName(userName);
}
#RequestMapping(value="/{firstname}",method = RequestMethod.GET)
public List<User> getUserByFirstName(#PathVariable("firstname") String firstName){
return userService.findByFirstName(firstName);
}
#RequestMapping(value="/{lastname}",method = RequestMethod.GET)
public List<User> getUserByLastName(#PathVariable("lastname") String lastName){
return userService.findByLastName(lastName);
}
#RequestMapping(value="/{email}",method = RequestMethod.GET)
public User getUserByEmail(#PathVariable("email") String email){
return userService.findByEmail(email);
}
#SuppressWarnings("deprecation")
#RequestMapping(value="/{dob}",method = RequestMethod.GET)
public List<User> getUserByDOB(#PathVariable("dob") String dob) throws Exception{
Date dateOfBirth = new Date(dob);
return userService.findByDateOfBirth(dateOfBirth);
}
#RequestMapping(value="/{location}",method = RequestMethod.GET)
public List<User> getUserByLocation(#PathVariable("location") Location location){
return userService.findByLocation(location);
}
#RequestMapping(value= "/{id}", method = RequestMethod.GET)
public User getUserById(#PathVariable("id") ObjectId id) {
return userService.findById(id);
}
}
package com.mywebapp.service;
import java.util.Date;
import java.util.List;
import org.bson.types.ObjectId;
import org.springframework.stereotype.Service;
import com.mywebapp.dao.UserRepository;
import com.mywebapp.model.Location;
import com.mywebapp.model.User;
#Service
public class UserService {
private UserRepository userRepo;
public UserService() {
}
public List<User> findAllUsers() {
return userRepo.findAllUsers();
}
public User findById(ObjectId id) {
return userRepo.findBy_id(id);
}
public User findByUserName(String username){
return userRepo.findByUsername(username);
}
public List<User> findByFirstName(String firstName){
return userRepo.findByFirstName(firstName);
}
public List<User> findByLastName(String lastName){
return userRepo.findByLastName(lastName);
}
public User findByEmail(String email){
return userRepo.findByEmail(email);
}
public List<User> findByDateOfBirth(Date dob){
return userRepo.findByDateOfBirth(dob);
}
public List<User> findByLocation(Location location){
return userRepo.findByLocation(location);
}
}
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>MyWebApplication</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>MyWebApplication</name>
<description>Demo project for Spring Boot</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.5.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>10</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-rest</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-mongodb</artifactId>
</dependency>
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>mongo-java-driver</artifactId>
<version>2.12.3</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.projectreactor</groupId>
<artifactId>reactor-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
Define below properties in application.properties under resources folder, replace actual values from yours. If MongoDB is default installed and there is no user name/ password then you don't need to define username and password properties.
spring.data.mongodb.host=localhost
spring.data.mongodb.port=27017
spring.data.mongodb.username=*********
spring.data.mongodb.password=*********
spring.data.mongodb.database=demo
Update
Update repository to extend MongoRepository
#Repository
public interface UserRepository extends MongoRepository<User, ObjectId>
{
Remove List<User> findAllUsers(); from your repository.
Change all method in your service to below
public List<User> findAllUsers() {
return userRepo.findAll();
}
I am trying to develop a fully annotation driven project using Spring Web MVC + Hibernate + Postgresql + Maven. But there is some problem with my DataSource configuration. I tried many combination but always getting this error:
org.springframework.web.util.NestedServletException: Request processing failed; nested exception is java.lang.UnsupportedOperationException: The application must supply JDBC connections**. All jars and connection string are good as it is working fine in XML version of project.
Code:
package com.matrix.nimble.config;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.ServletRegistration;
import org.springframework.web.WebApplicationInitializer;
import org.springframework.web.context.support.AnnotationConfigWebApplicationContext;
import org.springframework.web.servlet.DispatcherServlet;
/**
* #author Narayanan Madaswamy
*/
public class NimbleInitializer implements WebApplicationInitializer{
#Override
public void onStartup(ServletContext servletContext)throws ServletException
{
AnnotationConfigWebApplicationContext acwContext=new AnnotationConfigWebApplicationContext();
acwContext.register(NimbleContextConfig.class);
ServletRegistration.Dynamic dispatcher = servletContext.addServlet("SpringDispatcher",new DispatcherServlet(acwContext));
dispatcher.setLoadOnStartup(1);
dispatcher.addMapping("/init/*");
}
}
Configuration Class:
package com.matrix.nimble.config;
import com.matrix.nimble.databeans.dao.user.UserDAO;
import com.matrix.nimble.databeans.dao.user.UserDAOImpl;
import java.util.Properties;
import javax.sql.DataSource;
import org.apache.commons.dbcp.BasicDataSource;
import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.jdbc.datasource.SimpleDriverDataSource;
import org.springframework.orm.hibernate4.HibernateTransactionManager;
import org.springframework.orm.hibernate4.LocalSessionFactoryBuilder;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
import org.springframework.web.servlet.view.InternalResourceViewResolver;
import org.springframework.web.servlet.view.JstlView;
/**
*
* #author Narayanan Madaswamy
*/
#Configuration
#ComponentScan(basePackages = {"com.matrix.nimble.databeans.dao","com.matrix.nimble.controllers"})
#EnableTransactionManagement
public class NimbleContextConfig extends WebMvcConfigurerAdapter {
#Bean(name="viewResolver")
public InternalResourceViewResolver getViewResolver()
{
InternalResourceViewResolver viewResolver = new InternalResourceViewResolver();
viewResolver.setViewClass(JstlView.class);
viewResolver.setPrefix("/WEB-INF/views/");
viewResolver.setSuffix(".jsp");
return viewResolver;
}
#Bean(name="dataSource")
public DataSource getDataSource()
{
//BasicDataSource dataSource = new BasicDataSource();
//dataSource.setDriverClassName("org.postgresql.Driver");
//dataSource.setUrl("jdbc:postgresql://localhost:5432/folksinventory");
//dataSource.setUsername("postgres");
//dataSource.setPassword("algorithm");
SimpleDriverDataSource dataSource = new SimpleDriverDataSource(new org.postgresql.Driver(), "jdbc:postgresql://localhost:5432/folksinventory", "postgres", "password");
return dataSource;
}
#Autowired
#Bean(name="sessionFactory")
public SessionFactory getSessionFactory(DataSource dataSource)
{
LocalSessionFactoryBuilder sessionBuilder = new LocalSessionFactoryBuilder(dataSource);
sessionBuilder.scanPackages("com.matrix.nimble.databeans");
sessionBuilder.setProperties(getHibernateProperties());
return sessionBuilder.buildSessionFactory();
}
#Autowired
#Bean(name="transactionManager")
public HibernateTransactionManager getTransactionManager(SessionFactory sessionFactory)
{
HibernateTransactionManager transactionManager = new HibernateTransactionManager(sessionFactory);
return transactionManager;
}
private Properties getHibernateProperties() {
Properties properties = new Properties();
properties.put("hibernate.show_sql", "true");
properties.put("hibernate.dialect", "org.hibernate.dialect.PostgreSQLDialect");
properties.put("hibernate.current_session_context_class","thread");
properties.put("hibernate.cache.use_query_cache","true");
properties.put("hibernate.cache.use_second_level_cache","true");
properties.put("hibernate.cache.region.factory_class","org.hibernate.cache.ehcache.EhCacheRegionFactory");
return properties;
}
#Override
public void addResourceHandlers(final ResourceHandlerRegistry resourceRegistry)
{
resourceRegistry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/");
}
}
UserDAO:
package com.matrix.nimble.databeans.dao.user;
import com.matrix.nimble.databeans.user.User;
/**
*
* #author Narayanan Madaswamy
*/
public interface UserDAO {
public User validateUser(String loginid,String loginpass);
public String getErrmsg();
public boolean isSuccess();
}
UserDAOImpl:
package com.matrix.nimble.databeans.dao.user;
import com.matrix.nimble.databeans.user.User;
import com.matrix.nimble.utils.MadCryptor;
import java.security.NoSuchAlgorithmException;
import java.security.spec.InvalidKeySpecException;
import java.util.Calendar;
import org.hibernate.Query;
import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.hibernate.Session;
import org.springframework.stereotype.Service;
/**
*
* #author Narayanan Madaswamy
*/
#Service
public class UserDAOImpl implements UserDAO {
#Autowired
private SessionFactory sessionFactory;
private String errmsg;
private boolean success;
public UserDAOImpl(SessionFactory sessionFactory) {
this.sessionFactory = sessionFactory;
}
#Override
public User validateUser(String loginid, String loginpass) {
User user = null;
Session session = null;
setSuccess(false);
setErrmsg(null);
try {
MadCryptor mc = new MadCryptor();
loginid = mc.createHashedUsername(loginid);
session = this.sessionFactory.openSession();
String hql = "from User where username=:logId";
Query query = session.createQuery(hql);
query.setString("logId", loginid);
user = (User) query.uniqueResult();
Calendar cal = Calendar.getInstance();
cal.setTime(user.getActivesince());
if (!mc.validatePassword(loginpass, (cal.get(Calendar.YEAR) / 2) + ":" + user.getPair() + ":" + user.getPassword())) {
user = null;
setErrmsg("Invalid username or password");
} else if (user.getIsallowed() == 0) {
user = null;
setErrmsg("Your account is disabled. Contact administrator");
}
else
{
setSuccess(true);
}
} catch (NoSuchAlgorithmException | InvalidKeySpecException exce) {
user = null;
setErrmsg("Something bad happend. Please contact administrator.");
} finally {
if (session != null) {
session.close();
}
}
return user;
}
public String getErrmsg() {
return errmsg;
}
public void setErrmsg(String errmsg) {
this.errmsg = errmsg;
}
public boolean isSuccess() {
return success;
}
public void setSuccess(boolean success) {
this.success = success;
}
}
Login Controller:
package com.matrix.nimble.controllers.commons;
/**
*
* #author Narayanan Madaswamy
*/
import com.matrix.nimble.databeans.dao.user.UserDAO;
import com.matrix.nimble.databeans.dao.user.UserDAOImpl;
import com.matrix.nimble.databeans.user.User;
import com.matrix.nimble.models.commons.Login;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.SessionAttributes;
#Controller
#RequestMapping("/login/")
#SessionAttributes(value = "fsimSession", types = NimbleSession.class)
public class LoginController {
#Autowired
UserDAO userDAO;
#RequestMapping(method=RequestMethod.POST)
public String loginPage(ModelMap model)
{
model.addAttribute("login", new Login());
model.addAttribute("errMsg", null);
return "login";
}
#RequestMapping(value="authenticate",method=RequestMethod.POST)
public String authenticateUser(#ModelAttribute Login login, ModelMap model)
{
//UserDAO userDAO = ApplicationContextProvider.getApplicationContext().getBean(UserDAOImpl.class);
User user = userDAO.validateUser(login.getUsername(),login.getPassword());
if(!userDAO.isSuccess())
{
model.addAttribute("errMsg", "<span class='text-red'>"+userDAO.getErrmsg()+"</span>");
return "login";
}
else
{
System.out.println("Reached Here");
NimbleSession fsess=new NimbleSession(user.getId(),user.getFullname(),user.getGroupname(),user.getGroupid());
model.addAttribute("fsimSession", fsess);
return "redirect:../home/";
}
}
}
Project Structure:
Pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.matrix</groupId>
<artifactId>nimble</artifactId>
<version>2.0-Beta</version>
<packaging>war</packaging>
<name>nimble</name>
<properties>
<endorsed.dir>${project.build.directory}/endorsed</endorsed.dir>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<!-- Nimble Module Dependencies -->
<dependency>
<groupId>com.matrix</groupId>
<artifactId>utils</artifactId>
<version>2.0-Beta</version>
</dependency>
<!-- Nimble Module Dependencies Ends -->
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-web-api</artifactId>
<version>7.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>4.3.1.Final</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>4.3.1.RELEASE</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.0.1</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aop</artifactId>
<version>4.3.1.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>4.3.1.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>4.3.1.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
<version>4.3.1.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>4.3.1.RELEASE</version>
</dependency>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>2.0</version>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.core</artifactId>
<version>4.3.1</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-expression</artifactId>
<version>4.3.1.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>4.3.1.RELEASE</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>javax.el</groupId>
<artifactId>el-api</artifactId>
<version>2.2</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
</dependency>
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>jsp-api</artifactId>
<version>2.2</version>
</dependency>
<dependency>
<groupId>org.glassfish</groupId>
<artifactId>javax.servlet</artifactId>
<version>3.0-b72</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.5</version>
</dependency>
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>1.3</version>
</dependency>
<!-- Hibernate Dependencies -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>5.1.0.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-ehcache</artifactId>
<version>5.1.0.Final</version>
</dependency>
<dependency>
<groupId>net.sf.ehcache</groupId>
<artifactId>ehcache</artifactId>
<version>2.10.1</version>
</dependency>
<dependency>
<groupId>org.jboss.logging</groupId>
<artifactId>jboss-logging</artifactId>
<version>3.3.0.Final</version>
</dependency>
<dependency>
<groupId>org.jboss.logmanager</groupId>
<artifactId>jboss-logmanager</artifactId>
<version>1.5.2.Final</version>
</dependency>
<dependency>
<groupId>com.fasterxml</groupId>
<artifactId>classmate</artifactId>
<version>1.3.0</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.8.1</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.8.1</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>2.8.0</version>
</dependency>
<dependency>
<groupId>dom4j</groupId>
<artifactId>dom4j</artifactId>
<version>1.6.1</version>
</dependency>
<dependency>
<groupId>xml-apis</groupId>
<artifactId>xml-apis</artifactId>
<version>1.0.b2</version>
</dependency>
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-jta_1.1_spec</artifactId>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>org.hibernate.common</groupId>
<artifactId>hibernate-commons-annotations</artifactId>
<version>5.0.1.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate.javax.persistence</groupId>
<artifactId>hibernate-jpa-2.1-api</artifactId>
<version>1.0.0.Final</version>
</dependency>
<dependency>
<groupId>org.javassist</groupId>
<artifactId>javassist</artifactId>
<version>3.20.0-GA</version>
</dependency>
<dependency>
<groupId>antlr</groupId>
<artifactId>antlr</artifactId>
<version>2.7.7</version>
</dependency>
<dependency>
<groupId>org.jboss</groupId>
<artifactId>jandex</artifactId>
<version>2.0.0.Final</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.7</version>
</dependency>
<dependency>
<groupId>postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>9.1-901-1.jdbc4</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-orm</artifactId>
<version>4.3.1.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>4.3.1.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
<version>4.3.1.RELEASE</version>
</dependency>
<dependency>
<groupId>commons-dbcp</groupId>
<artifactId>commons-dbcp</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>commons-pool</groupId>
<artifactId>commons-pool</artifactId>
<version>1.5.4</version>
</dependency>
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>1.0.0.GA</version>
</dependency>
<!-- Bootstrap Webjars Dependencies -->
<dependency>
<groupId>org.webjars.bower</groupId>
<artifactId>adminlte</artifactId>
<version>2.3.5</version>
</dependency>
<dependency>
<groupId>org.webjars.bower</groupId>
<artifactId>font-awesome</artifactId>
<version>4.6.3</version>
</dependency>
<dependency>
<groupId>org.webjars.bower</groupId>
<artifactId>ionicons</artifactId>
<version>2.0.0</version>
</dependency>
<dependency>
<groupId>org.webjars.bower</groupId>
<artifactId>angular</artifactId>
<version>1.5.8</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
<compilerArguments>
<endorseddirs>${endorsed.dir}</endorseddirs>
</compilerArguments>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.3</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.6</version>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<outputDirectory>${endorsed.dir}</outputDirectory>
<silent>true</silent>
<artifactItems>
<artifactItem>
<groupId>javax</groupId>
<artifactId>javaee-endorsed-api</artifactId>
<version>7.0</version>
<type>jar</type>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Error Details:
HTTP Status 500 – Internal Server Error
Type Exception Report
Message Request processing failed; nested exception is java.lang.UnsupportedOperationException: The application must supply JDBC connections
Root Cause
java.lang.UnsupportedOperationException: The application must supply JDBC connections
org.hibernate.engine.jdbc.connections.internal.UserSuppliedConnectionProviderImpl.getConnection(UserSuppliedConnectionProviderImpl.java:44)
org.hibernate.internal.AbstractSessionImpl$NonContextualJdbcConnectionAccess.obtainConnection(AbstractSessionImpl.java:386)
org.hibernate.resource.jdbc.internal.LogicalConnectionManagedImpl.acquireConnectionIfNeeded(LogicalConnectionManagedImpl.java:84)
org.hibernate.resource.jdbc.internal.LogicalConnectionManagedImpl.getPhysicalConnection(LogicalConnectionManagedImpl.java:109)
org.hibernate.engine.jdbc.internal.StatementPreparerImpl.connection(StatementPreparerImpl.java:47)
org.hibernate.engine.jdbc.internal.StatementPreparerImpl$5.doPrepare(StatementPreparerImpl.java:146)
org.hibernate.engine.jdbc.internal.StatementPreparerImpl$StatementPreparationTemplate.prepareStatement(StatementPreparerImpl.java:172)
org.hibernate.engine.jdbc.internal.StatementPreparerImpl.prepareQueryStatement(StatementPreparerImpl.java:148)
org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1927)
org.hibernate.loader.Loader.executeQueryStatement(Loader.java:1896)
org.hibernate.loader.Loader.executeQueryStatement(Loader.java:1874)
org.hibernate.loader.Loader.doQuery(Loader.java:919)
org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:336)
org.hibernate.loader.Loader.doList(Loader.java:2610)
org.hibernate.loader.Loader.doList(Loader.java:2593)
org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2422)
org.hibernate.loader.Loader.list(Loader.java:2417)
org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:501)
org.hibernate.hql.internal.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:371)
org.hibernate.engine.query.spi.HQLQueryPlan.performList(HQLQueryPlan.java:216)
org.hibernate.internal.SessionImpl.list(SessionImpl.java:1339)
org.hibernate.internal.QueryImpl.list(QueryImpl.java:87)
org.hibernate.internal.AbstractQueryImpl.uniqueResult(AbstractQueryImpl.java:964)
com.matrix.nimble.databeans.dao.user.UserDAOImpl.validateUser(UserDAOImpl.java:48)
com.matrix.nimble.controllers.commons.LoginController.authenticateUser(LoginController.java:41)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
java.lang.reflect.Method.invoke(Method.java:498)
org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:180)
org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:440)
org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:428)
org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:963)
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:897)
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970)
org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:872)
javax.servlet.http.HttpServlet.service(HttpServlet.java:660)
org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846)
javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
Tomcat Version : 8.0,
Spring Release : 4.3.1,
Hibernate Version: 5.0.1,
PostgreSQL Version: 10,
PGSQL Jar Version: 9.1