JNDI中Context初始化的问题!请帮帮忙,急需解决!

04-04-10 seaman0916
Context initCtx = new InitialContext();

initCtx.bind("DataSource", source);

DataSource ds =(DataSource)initCtx.lookup("DataSource");

Connection conn=ds.getConnection();

我在JSP中是没有问题的,但是我现在想把它写在javabean中,就会出现:

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

请问:这个问题应该如何解决? 应该是设置InitialContext构造函数的参数吧!

猜你喜欢