Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Deploying maven project on glassfish using deploy command

I have a java ee application with maven, when i build the project then deploy the ear generated on target folder, i try to signup to the application so i have to call a locale EJB Session (ConfigUser) , i get the following error:

javax.naming.NamingException: Lookup failed for 'java:global/myproject-ear/myproject-ejb-1.0/UserFacade!myproject.service.ConfigUser' in SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl, java.naming.factory.url.pkgs=com.sun.enterprise.naming} [Root exception is javax.naming.NameNotFoundException: myproject-ear] at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:518) at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:455) at javax.naming.InitialContext.lookup(InitialContext.java:411) at javax.naming.InitialContext.lookup(InitialContext.java:411) at org.apache.jsp.index_jsp._jspService(index_jsp.java:79) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:111) at javax.servlet.http.HttpServlet.service(HttpServlet.java:770) at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:411) at  

I tried deploying using the command call asadmin --host localhost --user admin deploy --force "C:\myproject\target\myproject-ear-1.0.ear", i also tried deploying from glassfish administration console, but the problem persist.

It works fine when i deploy from netbeans, knowing that the project is structured in the pom file like this:

  <modules>
    <module>myproject-ear</module>
    <module>myproject-ejb</module>
    <module>myproject-web</module>
  </modules>

This is the jsp page :

Context c = new InitialContext();
ConfigUser configUser = (ConfigUser) c.lookup("java:global/myproject-ear/myproject-ejb-1.0/ConfigUser!myproject.service.ConfigUser");
like image 453
Bilal Dekar Avatar asked Apr 27 '18 18:04

Bilal Dekar


Video Answer


1 Answers

Since there was no answer to this problem, i'm answering my own question, after research i've found the reason to the javax.naming.NamingException: Lookup failed problem, the EJB ConfigUser that i was looking for was not correctly mapped to the JNDI name, so after the deploy i checked the server log and the JNDI name was :

java:global/myproject-ear-1.0/myproject-ejb-1.0/ConfigUser!myproject.service.ConfigUser

instead of :

java:global/myproject-ear/myproject-ejb-1.0/ConfigUser!myproject.service.ConfigUser
like image 157
Bilal Dekar Avatar answered Sep 28 '22 05:09

Bilal Dekar