-
15. Re: Jboss 7.1 error on new InitialContext();
alisissa Dec 19, 2012 8:55 AM (in response to nickarls)i tried this with single backslash:
Object ref = context.lookup("ejb:myapp/MYbean!gss.myapp.sessions.MySecurityRemote?stateful");
but i am getting this error :S ax.naming.NamingException: JBAS011843: Failed instantiate InitialContextFactory org.jnp.interfaces.NamingContextFactory from classloader ModuleClassLoader for Module "deployment.myweb.war:main" from Service Module Loader
-
16. Re: Jboss 7.1 error on new InitialContext();
nickarls Dec 19, 2012 10:04 AM (in response to alisissa)ejb:/
-
17. Re: Jboss 7.1 error on new InitialContext();
alisissa Dec 19, 2012 10:38 AM (in response to nickarls)my code looks this now:
final Hashtable jndiProperties = new Hashtable();
jndiProperties.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");
jndiProperties.put("java.naming.factory.initial", "org.jboss.as.naming.InitialContextFactory");
jndiProperties.put("jboss.naming.client.ejb.context", true);
final Context context = new InitialContext(jndiProperties);
Object ref = context.lookup("ejb:/myApp/myBean!gss.myapp.sessions.MySecurityRemote");
The first error looks like it is fixed, now i am having this error:
javax.naming.NamingException: JBAS011843: Failed instantiate InitialContextFactory org.jnp.interfaces.NamingContextFactory from classloader ModuleClassLoader for Module "deployment.TPGApp.jar:main" from Service Module Loader
org.jboss.as.naming.InitialContextFactoryBuilder.createInitialContextFactory(InitialContextFactoryBuilder.java:64)
javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:681)
javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:305)
javax.naming.InitialContext.init(InitialContext.java:240)
javax.naming.InitialContext.<init>(InitialContext.java:192)
tpg.tpgapp.controller.EntityControllerBase.lookupEntityControllerBean(EntityControllerBase.java:168)
tpg.tpgapp.controller.EntityControllerBase.<init>(EntityControllerBase.java:19)
tpg.tpgapp.db.ApplicationServices.<init>(ApplicationServices.java:28)
tpg.tpgapp.sessions.CardValidatorBean.init(CardValidatorBean.java:65)
Any help?
-
18. Re: Jboss 7.1 error on new InitialContext();
nickarls Dec 19, 2012 12:03 PM (in response to alisissa)If @EJB injection works, is there a special reason you want to do the lookup yourself?
-
19. Re: Jboss 7.1 error on new InitialContext();
alisissa Dec 19, 2012 7:07 PM (in response to nickarls)Sorry for that, but can you please explain more (with samples from mycode) on how to do what you are suggesting?
I am no expert in Java and jboss.
Any help would be appreciated.
-
20. Re: Jboss 7.1 error on new InitialContext();
nickarls Dec 20, 2012 2:54 AM (in response to alisissa)If you have a WAR with a Servlet like
@WebServlet(urlPatterns = "/test") public class EJBTest extends HttpServlet { @EJB(lookup = "ejb:myapp/MYbean!gss.myapp.sessions.MySecurityRemote?stateful") MySecurityRemote remote; @Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { System.out.println(remote); } }
And access the servlet you should see the output. Not that the remote interface must also be available to the WAR.