NetBeans Forums

 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
  

[SOLVED] Impossible to add a class library jar to Glassfish

 
Post new topic   Reply to topic    NetBeans Forums -> Java EE Users
View previous topic :: View next topic  
Author Message
walec51



Joined: 17 Mar 2010
Posts: 9

PostPosted: Wed Mar 17, 2010 9:58 pm    Post subject: [SOLVED] Impossible to add a class library jar to Glassfish Reply with quote

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 to 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:
Code:

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:

Code:

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;
        }
    }
}
[/code]
Back to top
walec51



Joined: 17 Mar 2010
Posts: 9

PostPosted: Thu Mar 18, 2010 9:44 pm    Post subject: Reply with quote

If any one else runs in to this the problem got solved here:

http://forums.java.net/jive/thread.jspa?messageID=392643&#392643
Back to top
jyeary



Joined: 21 Oct 2008
Posts: 610
Location: Simpsonville, SC

PostPosted: Thu Mar 18, 2010 10:02 pm    Post subject: Re: Impossible to add a class library jar to Glassfish Reply with quote

See

http://forums.java.net/jive/thread.jspa?messageID=388797


On Wed, Mar 17, 2010 at 5:58 PM, walec51 <address-removed ([email]address-removed[/email])> wrote:
Quote:
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 to 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:

Code:

Caused by: java.lang.NoSuchMethodError: org.apache.commons.codec.binary.Hex.encodeHexString([B)Ljava/lang/String;
Back to top
Display posts from previous:   
Post new topic   Reply to topic    NetBeans Forums -> Java EE Users All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB
By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo