This is my project directory structure.
All controller and other classes and directories, which are beans, are under the "WebPortalApplication" class, and as Spring Boot doc states, we do not explicitly specify the package to scan for beans, whenever those packages locate unther the "main" class directory, right?
So when I run the "WebPortalApplication" file, it builds, but with such exceptions.
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'userRestController': Unsatisfied dependency expressed through field 'userService';
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'userService': Unsatisfied dependency expressed through field 'roleRepository';
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'roleRepository': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException:
Caused by: java.lang.IllegalArgumentException: Not a managed type: class com.epam.webPortal.model.Role
#RestController
public class UserRestController {
#Autowired
UserService userService;
private static final Logger LOGGER = LoggerFactory.getLogger(UserRestController.class);
//-------------------Retrieve All Users--------------------------------------------------------
#RequestMapping(value = "/user/", method = RequestMethod.GET)
public String listAllUsers() {
String userAsJson = "";
List<User> users = userService.findAllUsers();
try {
userAsJson = JsonConvertor.toJson(users);
} catch (Exception ex) {
LOGGER.error("Something went wrong during converting json format");
}
LOGGER.info("displaying all users in json format");
return userAsJson;
}
package com.epam.webPortal.service.user;
import com.epam.webPortal.model.User;
import com.epam.webPortal.repository.role.RoleRepository;
import com.epam.webPortal.repository.user.UserRepository;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional
import java.util.Date;
import java.util.HashSet;
import java.util.List;
#Service("userService")
#Transactional
public class UserServiceImpl implements UserService {
private static final Logger LOGGER = LoggerFactory.getLogger(UserServiceImpl.class);
#Autowired
private UserRepository userRepository;
#Autowired
private RoleRepository roleRepository;
#Autowired
private BCryptPasswordEncoder bCryptPasswordEncoder;
#Override
public void saveUser(User user) {
user.setPassword(bCryptPasswordEncoder.encode(user.getPassword()));
user.setRoles(new HashSet<>(roleRepository.findAll()));
user.setDateRegistered(new Date());
userRepository.save(user);
LOGGER.info("user with username {} successfully saved", user.getUsername());
}
#Override
public User findByUsername(String username) {
return userRepository.findByUsername(username);
}
#Override
public List<User> findAllUsers() {
return userRepository.findAllUsers();
}
#Override
public User findById(Long Id) {
return userRepository.findById(Id);
}
#Override
public void updateUser(User user) {
final User entity = userRepository.findById(user.getId());
if (entity != null) {
entity.setFirstName(user.getFirstName());
entity.setLastName(user.getLastName());
entity.setEmail(user.getEmail());
entity.setSkypeID(user.getSkypeID());
entity.setDateRegistered(new Date());
entity.setPassword(bCryptPasswordEncoder.encode(user.getPassword()));
userRepository.save(entity);
LOGGER.info("user with id {} successfully updated", user.getId());
}
}
#Override
public void deleteUserById(Long id) {
userRepository.deleteById(id);
LOGGER.info("user with id {} successfully deleted", id);
}
}
package com.epam.webPortal.model;
import javax.persistence.*;
import java.util.Set;
#Entity
#Table(name = "role")
public class Role {
#Id
#GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
private String name;
#ManyToMany(mappedBy = "roles", fetch = FetchType.EAGER)
private Set<User> users;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Set<User> getUsers() {
return users;
}
public void setUsers(Set<User> users) {
this.users = users;
}
}
It looks like you're using JPA.
All JPA entities must be annotated with #Entity.
Caused by: java.lang.IllegalArgumentException: Not a managed type: class com.epam.webPortal.model.Role
means, Role class is missing #Entity annotation.
Have you enabled your repos?
#SpringBootApplication
#EnableJpaRepositories
public class WebPortalApplication {
public static void main(String[] args) {
SpringApplication.run(WebPortalApplication.class, args);
}
}
I expect below definition on your RoleRepository; sharing this file will help to further analyze on what is missing.
public interface RoleRepository implements CrudRepository<Role, Long> {
...
}
Related
I know that this question is a duplicate, but I have tried many of the suggestions that I found with no effect.
I am a beginner to spring boot, and I am following a tutorial using Spring boot and Cassandra. I get this error once SpringApplication.run(ReadstrackerDataLoaderApplication.class, args) is executed.
ReadstrackerDataLoaderApplication.java
package com.readstracker.demo;
#SpringBootApplication(scanBasePackages = {"com.readstracker.repositories", "com.readstracker.entities"})
//#ComponentScan("repositories.AuthorRepository")
#EnableConfigurationProperties(DataStaxAstraProperties.class)
#EnableCassandraRepositories("com.readstracker.repositories")
#ComponentScan("com.readstracker.entities")
#Service
public class ReadstrackerDataLoaderApplication {
#Autowired
private AuthorRepository authorRepository;
public static void main(String[] args) {
SpringApplication.run(ReadstrackerDataLoaderApplication.class, args);
}
#PostConstruct
public void start() {
Author author = new Author();
author.setId("id");
author.setName("name");
author.setPersonalName("personalName");
authorRepository.save(author);
}
#Bean
public CqlSessionBuilderCustomizer sessionBuilderCustomizer(DataStaxAstraProperties astraProperties) {
Path bundle = astraProperties.getSecureConnectBundle().toPath();
return builder -> builder.withCloudSecureConnectBundle(bundle);
}
}
AuthorRepository.java
package com.readstracker.repositories;
import org.springframework.data.cassandra.repository.CassandraRepository;
import org.springframework.stereotype.Repository;
import org.springframework.stereotype.Service;
import com.readstracker.entities.Author;
#Repository
public interface AuthorRepository extends CassandraRepository<Author, String> {
}
Author.java
package com.readstracker.entities;
import org.springframework.data.annotation.Id;
import org.springframework.data.cassandra.core.cql.PrimaryKeyType;
import org.springframework.data.cassandra.core.mapping.CassandraType;
import org.springframework.data.cassandra.core.mapping.CassandraType.Name;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
import org.springframework.data.cassandra.core.mapping.Column;
import org.springframework.data.cassandra.core.mapping.PrimaryKeyColumn;
import org.springframework.data.cassandra.core.mapping.Table;
#Table(value = "author_by_id")
#Component
public class Author {
#Id
#PrimaryKeyColumn(name = "author_id", ordinal = 0, type = PrimaryKeyType.PARTITIONED)
private String id;
#Column("author_name")
#CassandraType(type = Name.TEXT)
private String name;
#Column("personal_name")
#CassandraType(type = Name.TEXT)
private String personalName;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getPersonalName() {
return personalName;
}
public void setPersonalName(String personalName) {
this.personalName = personalName;
}
}
Here is my project directory
I am a fish in Spring Boot and Data Jpa, I Tried to create a basic Spring boot application but every time I am encountering the error. Can you help me?
That's my code:
Spring Boot Application class:
#SpringBootApplication
#ComponentScan(basePackages = "com.project.*")
#EnableJpaRepositories(basePackages = "com.project.repository.*")
#EntityScan(basePackages = "com.project.entities.*")
#EnableAutoConfiguration
public class MainApplication {
public static void main(String[] args) {
SpringApplication.run(MainApplication.class, args);
}
}
Controller Class:
#RestController
#RequestMapping(value = "/api")
public class controller {
private IUserServices userServices;
#Autowired
public controller(IUserServices userServices) {
this.userServices = userServices;
}
#GetMapping(value = "/merhaba")
public String sayHello(){
return "Hello World";
}
#GetMapping(value = "/getall")
public List<User> getAll(){
return this.userServices.getAllUsers();
}
}
Repository Class:
#Repository
public interface UserRepository extends JpaRepository<User,Long> {
}
IServices Class:
#Service
public interface IUserServices {
void saveUser(User user);
List<User> getAllUsers();
}
ServicesImpl Class:
#Service
public class UserServicesImpl implements IUserServices{
private UserRepository userRepository;
#Autowired
public UserServicesImpl(UserRepository userRepository) {
this.userRepository = userRepository;
}
#Override
public void saveUser(User user) {
this.userRepository.save(user);
}
#Override
public List<User> getAllUsers() {
return this.userRepository.findAll();
}
}
Entity Class:
#Entity
#Table(catalog = "users")
public class User {
#Id
#GeneratedValue(strategy = GenerationType.IDENTITY)
private int id;
private String name;
public User() {
}
public User(int id, String name) {
this.id = id;
this.name = name;
}
public void setId(int id) {
this.id = id;
}
public void setName(String name) {
this.name = name;
}
public int getId() {
return id;
}
public String getName() {
return name;
}
#Override
public String toString() {
return "User{" +
"id=" + id +
", name='" + name + '\'' +
'}';
}
}
AND THIS MY ERROR MESSAGE:
***************************
APPLICATION FAILED TO START
***************************
Description:
Parameter 0 of constructor in com.project.services.UserServicesImpl required a bean of
type 'com.project.repository.UserRepository' that could not be found.
Action:
Consider defining a bean of type 'com.project.repository.UserRepository' in your
configuration.
Process finished with exit code 0
SO This is application properties file:
spring.jpa.properties.hibernate.dialect =
org.hibernate.dialect.PostgreSQLDialect
spring.jpa.hibernate.ddl-auto=update
spring.jpa.hibernate.show-sql=true
spring.datasource.url=jdbc:postgresql://localhost:5432/u
spring.datasource.username=postgres
spring.datasource.password=1234
spring.jpa.properties.javax.persistence.validation.mode = none
There are some issues that you should fix them.
First
When you have the spring boot application with #SpringBootApplication you don't need other stuff such as #EnableAutoConfiguration and etc, So remove them all.
You can read more about it here.
Second
You don't need to annotate your service interface with #Service, because you did it in the UserServicesImpl class.
Third
You defined id as an integer in your user entity but in the repository, you wrote your id as Long. It's wrong. It should be something like this.
#Repository
public interface UserRepository extends JpaRepository<User,Integer> {
}
Try the above solutions and let me know the result.
I am building simple ManyToOne relationship using spring JAP. i get UnsatisfiedDependencyException Error with bean name Unsatisfied dependency expressed through field
UnsatisfiedDependencyException: Error creating bean with name 'procjectController': Unsatisfied
Here is my file.
project.java
package com.ganesh.dto;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import com.fasterxml.jackson.annotation.JsonIgnore;
#Entity
public class Project {
#Id
private int projectId;
private String projectName;
//Relation establish
#ManyToOne(
fetch = FetchType.LAZY,
optional = false
)
#JoinColumn(
name = "employee_id",
nullable = false
)
#JsonIgnore
private Employee employee;
public Project() {
}
public Project(int projectId, String projectName, int eId) {
super();
this.projectId = projectId;
this.projectName = projectName;
//Adding employee
this.employee = new Employee(eId,"","");
}
public int getProjectId() {
return projectId;
}
public void setProjectId(int projectId) {
this.projectId = projectId;
}
public String getProjectName() {
return projectName;
}
public void setProjectName(String projectName) {
this.projectName = projectName;
}
//Adding getter and setters Employee reference
public Employee getEmployee() {
return employee;
}
public void setEmployee(Employee employee) {
this.employee = employee;
}
}
ProjectDao.java
package com.ganesh.dao;
import java.util.List;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
import com.ganesh.dto.Project;
#Repository
public interface ProjectDao extends JpaRepository<Project, Integer> {
List<Project> findEmployeeById(int eId);
}
ImpProjectService.java
package com.ganesh.service;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ganesh.dao.*;
import com.ganesh.dto.Project;
#Service
public class ImpProjectService implements ProjectService {
#Autowired
private ProjectDao projectDao;
#Override
public List<Project> getProjectList(int eId) {
System.out.println("in Dao class employee id"+ eId);
return projectDao.findEmployeeById(eId);
}
#Override
public Project getProjectById(int id) {
return projectDao.getOne(id);
}
#Override
public void addProject(Project project) {
projectDao.save(project);
}
#Override
public void updateProject(Project project) {
projectDao.save(project);
}
#Override
public void deleteProjectById(int id) {
projectDao.deleteById(id);
}
#Override
public List<Project> getAllProject() {
return projectDao.findAll();
}
}
ProcjectController.java
package com.ganesh.controller;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import com.ganesh.dto.*;
import com.ganesh.service.*;
#RestController
public class ProcjectController {
#Autowired
private ImpProjectService projectService;
#RequestMapping("/projects")
public List<Project> getProjectList(){
return projectService.getAllProject();
}
#RequestMapping("/employees/{eId}/projects")
public List<Project> getAllProjects(#PathVariable int eId){
System.out.println("In Project Controller");
List<Project> projList = projectService.getProjectList(eId);
System.out.println(projList);
return projList;
}
#RequestMapping("/employees/{eId}/projects/{id}")
public Project getProjectById(#PathVariable int id) {
return projectService.getProjectById(id);
}
#RequestMapping(method = RequestMethod.POST, value="/employees/{eId}/projects")
public void addProject(#RequestBody Project project, #PathVariable int eId) {
project.setEmployee(new Employee(eId,"",""));
projectService.addProject(project);
}
#RequestMapping(method = RequestMethod.PUT, value="/employees/{eId}/projects/{id}")
public void updateProject(#RequestBody Project project, #PathVariable int eId) {
project.setEmployee(new Employee(eId,"",""));
projectService.updateProject(project);
}
#RequestMapping(method = RequestMethod.DELETE, value="/projects/{id}")
public void deleteProjecstById(#PathVariable int id) {
projectService.deleteProjectById(id);
}
}
Note: This answer is based on insufficient data, because stack trace is not available. With correct and complete stacktrace, we might be able to provide more precise answer.
Answer:
Looks like a problem in your Dao class.
You have written
#Repository
public interface ProjectDao extends JpaRepository<Project, Integer> {
List<Project> findEmployeeById(int eId);
}
Which means you are creating a repository of type Project and trying to fire a query as findEmployeeById, It should either be findByEmployee, which accepts Employee as a parameter, or should not be there in place at all. Because the query syntax and the Template parameters do not match. So Spring will not be able to initialize the query handlers for the same.
Try changing it as below, if is satisfies your purpose.
#Repository
public interface ProjectDao extends JpaRepository {
List<Project> findAllByEmployee(Employee emp);
}
Please check the same, and correct. If it still doesn't work, please post the full stack trace, and we can help you out.
I am developing an JavaFx application with spring boot,JPA, and H2. I have a user entity when I try to add a new user into the DB it throws NPE in the controller on the button's click action. As it is seen I use only autowire notation. I researched
but findings did not help out. Any help please?
package com.core;
#SpringBootApplication
#Import(SharedSpringConfiguration.class)
public class Runner extends Application {
private ConfigurableApplicationContext context;
public static void main(String[] args) {
launch(args);
}
#Override
public void init() {
context = SpringApplication.run(Runner.class);
}
}
package com.dao;
#Entity
#Table(name = "user")
public class User {
#Id
#Column(name = "id", updatable = false, nullable = false)
private long ID;
#Column(nullable = false)
private String userName;
#Column(nullable = false)
private String userPass;
public User() {
}
public User(long ID, String userName, String userPass) {
this.ID = ID;
this.userName = userName;
this.userPass = userPass;
}
}
package com.service;
#Service
public class UserService {
#Autowired
private UserRepository userRepository;
public UserService() {
}
public void saveUser(User user) {
userRepository.save(user);
}
}
package com.repository;
public interface UserRepository extends CrudRepository<User, Long> {}
package com.controller
#Controller
public class MethodController implements Initializable {
#Autowired
private UserService userService;
#FXML
void methodSave(MouseEvent event) {
userService.saveUser(new User(11, "TestUser", "noPass")); //Throws NPE. Indicates that userService is null. But I autowire the userService.
}
}
I don't know what's in SharedSpringConfiguration, but you probably need #EnableJpaRepositories on one of your configuration classes. #Repository on the CrudRepo should be unnecessary.
Change your SpringBootApplication package from com.core to com
because SpringBootApplication by default will scan only that packages and sub packages.
else
add #ComponentScan annotation in SpringBootApplication and scan the packages.
I am learning Play Framework and I need to bind Address to Person from web form.
There are my entities:
#Entity
#Table(name = "address")
public class Address {
#Id
#GeneratedValue(strategy= GenerationType.IDENTITY)
private Integer id;
private String country;
#OneToMany(mappedBy = "address", fetch = FetchType.EAGER)
private List<Person> persons;
// get/set
}
#Entity
#Table(name = "person")
public class Person {
#Id
#GeneratedValue(strategy= GenerationType.IDENTITY)
private Integer id;
private String name;
#ManyToOne(fetch = FetchType.EAGER)
private Address address;
// get/set
}
I have folllowing controller and dao:
public class HomeController extends Controller {
#Inject
private Configuration configuration;
#Inject
private PersonManager personManager;
#Inject
private AddressManager addressManager;
#Inject
FormFactory formFactory;
#Inject
Formatters formatters;
#Transactional
public Result index() {
List<Person> persons = personManager.findAll();
List<Address> addresses = addressManager.findAll();
return ok(index.render("Hello, world", persons, addresses));
}
#Transactional
public Result addPerson() {
DynamicForm requestData = formFactory.form().bindFromRequest();
System.out.println("form: " + requestData.get("address"));
Person person = Form.form(Person.class).bindFromRequest().get();
personManager.save(person);
return redirect(routes.HomeController.index());
}
#Transactional
public Result addAddress() {
Address address = Form.form(Address.class).bindFromRequest().get();
addressManager.save(address);
return redirect(routes.HomeController.index());
}
// ...
}
package dao;
public class PersonDaoImpl implements PersonDao {
#Inject
private JPAApi jpaApi;
#Override
public void save(Person user) {
jpaApi.em().persist(user);
}
#Override
public void delete(Person user) {
jpaApi.em().remove(user);
}
#Override
public void update(Person user) {
jpaApi.em().merge(user);
}
#Override
public List<Person> findAll() {
return jpaApi.em().createQuery("from Person").getResultList();
}
#Override
public Person findById(int id) {
return (Person) jpaApi.em().find(Person.class, id);
}
#Override
public Person findByName(String name) {
return (Person) jpaApi.em().createQuery("SELECT p FROM Person p WHERE p.name LIKE :name").setParameter("name", name).getSingleResult();
}
}
package dao;
public class AddreessDaoImpl implements AddressDao {
#Inject
private JPAApi jpaApi;
#Override
public void save(Address address) {
jpaApi.em().persist(address);
}
#Override
public void delete(Address address) {
jpaApi.em().remove(address);
}
#Override
public void update(Address address) {
jpaApi.em().merge(address);
}
#Override
public List<Address> findAll() {
return jpaApi.em().createQuery("from Address").getResultList();
}
#Override
public Address findById(int id) {
return (Address) jpaApi.em().find(Address.class, id);
}
#Override
public Address findByCountry(String name) {
return (Address) jpaApi.em().createQuery("SELECT a FROM Address a WHERE a.country LIKE :country").setParameter("country", name).getSingleResult();
}
}
View:
#(message: String, persons: List[Person], addresses: List[Address])
#main("Welcome to Play") {
<form action="#routes.HomeController.addPerson()" method="post">
<input type="text" name="name" />
<select name="address">
#for(address <- addresses) {
<option value="#address.getId">
#address.getCountry
</option>
}
</select>
<button>Add Person</button>
</form>
}
I need to add new person with existing Address. I'm trying to bind address to person using Formatters:
package service;
import dao.AddressManager;
import models.Address;
import play.data.format.Formatters;
import play.i18n.MessagesApi;
import javax.inject.Inject;
import javax.inject.Provider;
import javax.inject.Singleton;
import java.text.ParseException;
import java.util.Locale;
#Singleton
public class FormattersProvider implements Provider<Formatters> {
private final MessagesApi messagesApi;
#Inject
public FormattersProvider(MessagesApi messagesApi) {
this.messagesApi = messagesApi;
}
#Inject
private AddressManager addressManager;
#Override
public Formatters get() {
Formatters formatters = new Formatters(messagesApi);
formatters.register(Address.class, new Formatters.SimpleFormatter<Address>(){
#Override
public Address parse(String input, Locale locale) throws ParseException {
Address address = addressManager.findById(Integer.getInteger(input));
return address;
}
#Override
public String print(Address address, Locale locale) {
return address.getCountry();
}
});
return formatters;
}
}
package service;
import com.google.inject.AbstractModule;
import play.data.format.Formatters;
public class FormattersModule extends AbstractModule {
#Override
protected void configure() {
bind(Formatters.class).toProvider(FormattersProvider.class);
}
}
But how can I use Formatters?
If I add address, it is ok.
But if I add new Person using web form address column in db have NULL value, or app crash:
[error] application -
! #720fgnbfl - Internal server error, for (POST) [/person] ->
play.api.http.HttpErrorHandlerExceptions$$anon$1: Execution exception[[CompletionException: java.lang.IllegalStateException: Error(s) binding form: {"address":["Invalid value"]}]]
at play.api.http.HttpErrorHandlerExceptions$.throwableToUsefulException(HttpErrorHandler.scala:280)
at play.api.http.DefaultHttpErrorHandler.onServerError(HttpErrorHandler.scala:206)
at play.api.GlobalSettings$class.onError(GlobalSettings.scala:160)
at play.api.DefaultGlobal$.onError(GlobalSettings.scala:188)
at play.api.http.GlobalSettingsHttpErrorHandler.onServerError(HttpErrorHandler.scala:98)
at play.core.server.netty.PlayRequestHandler$$anonfun$2$$anonfun$apply$1.applyOrElse(PlayRequestHandler.scala:100)
at play.core.server.netty.PlayRequestHandler$$anonfun$2$$anonfun$apply$1.applyOrElse(PlayRequestHandler.scala:99)
at scala.concurrent.Future$$anonfun$recoverWith$1.apply(Future.scala:344)
at scala.concurrent.Future$$anonfun$recoverWith$1.apply(Future.scala:343)
at scala.concurrent.impl.CallbackRunnable.run(Promise.scala:32)
Caused by: java.util.concurrent.CompletionException: java.lang.IllegalStateException: Error(s) binding form: {"address":["Invalid value"]}
at java.util.concurrent.CompletableFuture.encodeThrowable(CompletableFuture.java:292)
at java.util.concurrent.CompletableFuture.completeThrowable(CompletableFuture.java:308)
at java.util.concurrent.CompletableFuture.uniApply(CompletableFuture.java:593)
at java.util.concurrent.CompletableFuture$UniApply.tryFire(CompletableFuture.java:577)
at java.util.concurrent.CompletableFuture.postComplete(CompletableFuture.java:474)
at java.util.concurrent.CompletableFuture.completeExceptionally(CompletableFuture.java:1977)
at scala.concurrent.java8.FuturesConvertersImpl$CF.apply(FutureConvertersImpl.scala:21)
at scala.concurrent.java8.FuturesConvertersImpl$CF.apply(FutureConvertersImpl.scala:18)
at scala.concurrent.impl.CallbackRunnable.run(Promise.scala:32)
at scala.concurrent.BatchingExecutor$Batch$$anonfun$run$1.processBatch$1(BatchingExecutor.scala:63)
Caused by: java.lang.IllegalStateException: Error(s) binding form: {"address":["Invalid value"]}
at play.data.Form.get(Form.java:634)
at controllers.HomeController.addPerson(HomeController.java:106)
at router.Routes$$anonfun$routes$1$$anonfun$applyOrElse$2$$anonfun$apply$2.apply(Routes.scala:293)
at router.Routes$$anonfun$routes$1$$anonfun$applyOrElse$2$$anonfun$apply$2.apply(Routes.scala:293)
at play.core.routing.HandlerInvokerFactory$$anon$4.resultCall(HandlerInvoker.scala:157)
at play.core.routing.HandlerInvokerFactory$$anon$4.resultCall(HandlerInvoker.scala:156)
at play.core.routing.HandlerInvokerFactory$JavaActionInvokerFactory$$anon$14$$anon$3$$anon$1.invocation(HandlerInvoker.scala:136)
at play.core.j.JavaAction$$anon$1.call(JavaAction.scala:73)
at play.http.HttpRequestHandler$1.call(HttpRequestHandler.java:54)
at play.db.jpa.TransactionalAction.lambda$call$4(TransactionalAction.java:28)
Why? How can I bind it?