I have an EmailService EJB that has a very simple \'send_email\' method. I\'m receving the error in the title despite clearly having a public constructor that does not take para
Why you don't remove initialization from constructor into a @PostConstruct method?
@Stateless
public class EmailService {
@EJB ContextFinder ctf;
private static final String EMAIL_PASSWORD_JNDI_NAME = "EMAIL_PASSWORD";
private static final String EMAIL_USERNAME_JNDI_NAME = "EMAIL_USERNAME";
private static final String SMTP_SERVER_JNDI_NAME = "SMTP_SERVER";
private static final String SMTP_PORT_JNDI_NAME = "SMTP_PORT";
private String username;
private String password;
private String server;
private Integer port;
@PostConstruct
public void init() {
username = (String) ctf.lookup(EMAIL_USERNAME_JNDI_NAME);
password = (String) ctf.lookup(EMAIL_PASSWORD_JNDI_NAME);
server = (String) ctf.lookup(SMTP_SERVER_JNDI_NAME);
port = (Integer) ctf.lookup(SMTP_PORT_JNDI_NAME);
}
public void sendMail(String sendTo, String subject, String message) {
// send mail
}
}