Hello,
I've spend an entire day trying to make glassfish v3 or my ear app to see a third party jar.
I've added it ot the web, ejb and ear projects in netbeans 6.8.
I've added it to the directories:
glassfishv3/glassfish/domains/domain1/lib
glassfishv3/glassfish/domains/domain1/lib/ext
glassfishv3/glassfish/domains/domain1/applib
And still when my web app tries to use an ejb method I get:
Caused by: java.lang.NoSuchMethodError: org.apache.commons.codec.binary.Hex.encodeHexString([B)Ljava/lang/String;
at fantasycards.services.PlayerDao.calcuatePasswordHash(PlayerDao.java:86)
at fantasycards.services.PlayerDao.registerPlayer(PlayerDao.java:56)
at fantasycards.services.PlayerDao.registerPlayer(PlayerDao.java:48)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.glassfish.ejb.security.application.EJBSecurityManager.runMethod(EJBSecurityManager.java:1052)
...
Is it impossible to accomplish or em I doing something wrong ?
My classes:
package fantasycards.control;
@WebServlet(urlPatterns={"/register.html"})
public class RegisterServlet extends HttpServlet {
private Logger log = Logger.getLogger(this.getClass().getName());
@EJB
private PlayerDao playerDao;
@Override
protected void doPost(
HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
playerDao.registerPlayer(request.getParameter("email"),
request.getParameter("password"));
}
}
package fantasycards.services;
@Stateless
public class PlayerDao {
private Logger logger = Logger.getLogger(PlayerDao.class.getName());
@PersistenceContext(unitName="prodPU")
private EntityManager em;
@Resource(mappedName="mail/fastom")
private Session mailSes;
@EJB
private Configuration conf;
public Player registerPlayer(String email, String password) {
return registerPlayer(email, password, true);
}
public Player registerPlayer(String email, String password,
boolean sendEmail) {
Player p = new Player();
p.setEmail(email);
p.setPasswordHash(calcuatePasswordHash(password));
p.setActivationToken(new Random().nextInt());
p.setRegisterDate(Calendar.getInstance().getTime());
em.persist(p);
sendActivationEmail(p);
return p;
}
public String calcuatePasswordHash(String password) {
try {
MessageDigest md = MessageDigest.getInstance("SHA1");
byte[] hash = md.digest(password.getBytes());
String hashStr = Hex.encodeHexString(hash);
return hashStr;
} catch (NoSuchAlgorithmException ex) {
logger.log(Level.SEVERE, null, ex);
return null;
}
}
}
[Message sent by forum member 'walec51']
http://forums.java.net/jive/thread.jspa?messageID=392438