Reputation: 11
JSF 2.3, CDI, Tomcat 10, Spring bean. I would like to use the latest JSF 2.3 capabilities from Jakarta with spring jdbc. Since JSF is now part of Jakarta and covered under CDI I am struggling how to initialise spring beans and connect it with JSF. My environment is
**I have my jsf bean as below **
@Named
@RequestScoped
public class UserProfile {
@Inject
private UserService userService;
public String getMessage() {
return userService.getMessage();
}
}
Spring service as
@Service
public class UserService {
@Inject
private UserDao userDao;
public String getMessage() {
return userDao.getMessage();
}
}
**And Dao as **
@Repository
public class UserDao extends JdbcDaoSupport{
@Autowired
private DataSource dataSource;
@PostConstruct
public void init() {
setDataSource(dataSource);
}
public String getMessage(){
Integer empCount = getJdbcTemplate().queryForObject("SELECT COUNT(*) FROM EMPLOYEE", Integer.class) ;
return empCount.toString();
}
}
Datasource, Hikari configuration and jdbcTemplate is defined under applicationContext.xml Unfortunately I am not getting my datasource initialised..
Any clue?
I have tried the traditional way of jsf spring integration but it did not work, my question is
Upvotes: 1
Views: 600