Joseph Hwang [https://community.jboss.org/people/aupres] created the discussion
"javax.naming.NoInitialContextException..." To view the discussion, visit: https://community.jboss.org/message/731547#731547 -------------------------------------------------------------- I use ejb3.1 on JBoss 7.0.2. I develop bean with @Schedule annotation. The codes are : ==== IScheduleTestPort.java package com.aaa.ejb3; import javax.ejb.Remote; @Remote public interface IScheduleTestPort { public String getSignal(); } ===== ScheduleBean.java package com.aaa.ejb3; import java.util.Date; import javax.annotation.PostConstruct; import javax.ejb.Schedules; import javax.ejb.Schedule; import javax.ejb.Stateless; @Stateless public class ScheduleBean implements IScheduleTestPort { private String str; @PostConstruct public void doPostConstruct() { str = "Time is : "; } @Schedules({ @Schedule(dayOfMonth = "5", hour = "09-18", minute = "*", second="10/5", timezone = "America/Los_Angeles"), @Schedule(dayOfMonth = "Mon", hour = "10-17", minute = "*", second="*/5" , timezone = "Asia/Seoul") }) @Override public String getSignal() { // TODO Auto-generated method stub return str + new Date(); } } ===== ScheduleBeanClient.java package com.aaa.ejb3; import java.util.Properties; import javax.naming.InitialContext; import javax.naming.Context; public class ScheduleBeanClient { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub try { Properties props = new Properties(); props.put("java.naming.factory.initial","org.jnp.interfaces.NamingContextFactory"); props.put("java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces"); props.put("java.naming.provider.url", "jnp://localhost:1099"); Context ctx = new InitialContext(props); ScheduleBean schedule = (ScheduleBean)ctx.lookup("java:module/ScheduleBean"); while (true) { System.out.println(schedule.getSignal()); } } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } } But client throws exception like below : javax.naming.NoInitialContextException: Cannot instantiate class: org.jnp.interfaces.NamingContextFactory [Root exception is java.lang.ClassNotFoundException: org.jnp.interfaces.NamingContextFactory] at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:657) at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:288) at javax.naming.InitialContext.init(InitialContext.java:223) at javax.naming.InitialContext.<init>(InitialContext.java:197) at com.aaa.ejb3.ScheduleBeanClient.main(ScheduleBeanClient.java:47) Caused by: java.lang.ClassNotFoundException: org.jnp.interfaces.NamingContextFactory at java.net.URLClassLoader$1.run(URLClassLoader.java:202) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:190) at java.lang.ClassLoader.loadClass(ClassLoader.java:306) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301) at java.lang.ClassLoader.loadClass(ClassLoader.java:247) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:247) at com.sun.naming.internal.VersionHelper12.loadClass(VersionHelper12.java:46) at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:654) So i remove the parameter of InitialContext, public static void main(String[] args) { // TODO Auto-generated method stub try { Context ctx = new InitialContext(props); ScheduleBean schedule = (ScheduleBean)ctx.lookup("java:module/ScheduleBean"); while (true) { System.out.println(schedule.getSignal()); } } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } ... This the codes throws the following exception , javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:645) at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:288) at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:325) at javax.naming.InitialContext.lookup(InitialContext.java:392) at com.aaa.ejb3.ScheduleBeanClient.main(ScheduleBeanClient.java:49) I have no idea of what is wrong with my codes. I need your help! Thanks in advanced. -------------------------------------------------------------- Reply to this message by going to Community [https://community.jboss.org/message/731547#731547] Start a new discussion in EJB3 at Community [https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2029]
_______________________________________________ jboss-user mailing list jboss-user@lists.jboss.org https://lists.jboss.org/mailman/listinfo/jboss-user