java.io.IOException: Cannot bind to URL: javax.naming.NoInitialContextException: Cannot instantiate class: org.osjava.sj.SimpleContextFactory [Root exception is java.lang.ClassNotFoundException: org.osjava.sj.SimpleContextFactory]
at javax.management.remote.rmi.RMIConnectorServer.newIOException(RMIConnectorServer.java:804)
at javax.management.remote.rmi.RMIConnectorServer.stop(RMIConnectorServer.java:555)
at com.eos.system.management.MBeanServerConnector.stop(MBeanServerConnector.java:248)
at com.primeton.system.impl.service.JMXService.stop(JMXService.java:221)
at com.eos.system.LifecycleSupport.handleEvent(LifecycleSupport.java:92)
at com.eos.system.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:79)
at com.primeton.ext.system.service.SystemService.stop(SystemService.java:244)
at com.primeton.runtime.core.impl.RuntimeCoreHelper.stopSystemService(RuntimeCoreHelper.java:731)
at com.primeton.ext.runtime.core.RuntimeJ2EEHost.contextDestroyed(RuntimeJ2EEHost.java:83)
at weblogic.servlet.internal.EventsManager$FireContextListenerAction.run(EventsManager.java:482)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
at weblogic.servlet.internal.EventsManager.notifyContextDestroyedEvent(EventsManager.java:200)
at weblogic.servlet.internal.WebAppServletContext.destroy(WebAppServletContext.java:3225)
at weblogic.servlet.internal.ServletContextManager.destroyContext(ServletContextManager.java:247)
at weblogic.servlet.internal.HttpServer.unloadWebApp(HttpServer.java:461)
at weblogic.servlet.internal.WebAppModule.destroyContexts(WebAppModule.java:1545)
at weblogic.servlet.internal.WebAppModule.deactivate(WebAppModule.java:509)
at weblogic.application.internal.flow.ModuleStateDriver$2.previous(ModuleStateDriver.java:387)
at weblogic.application.utils.StateMachineDriver.previousState(StateMachineDriver.java:223)
at weblogic.application.utils.StateMachineDriver.previousState(StateMachineDriver.java:215)
at weblogic.application.internal.flow.ModuleStateDriver.deactivate(ModuleStateDriver.java:141)
at weblogic.application.internal.flow.ScopedModuleDriver.deactivate(ScopedModuleDriver.java:206)
at weblogic.application.internal.flow.ModuleListenerInvoker.deactivate(ModuleListenerInvoker.java:261)
at weblogic.application.internal.flow.DeploymentCallbackFlow$2.previous(DeploymentCallbackFlow.java:547)
at weblogic.application.utils.StateMachineDriver.previousState(StateMachineDriver.java:223)
at weblogic.application.utils.StateMachineDriver.previousState(StateMachineDriver.java:215)
at weblogic.application.internal.flow.DeploymentCallbackFlow.deactivate(DeploymentCallbackFlow.java:192)
at weblogic.application.internal.flow.DeploymentCallbackFlow.deactivate(DeploymentCallbackFlow.java:184)
at weblogic.application.internal.BaseDeployment$2.previous(BaseDeployment.java:677)
at weblogic.application.utils.StateMachineDriver.previousState(StateMachineDriver.java:223)
at weblogic.application.utils.StateMachineDriver.previousState(StateMachineDriver.java:215)
at weblogic.application.internal.BaseDeployment.deactivate(BaseDeployment.java:234)
at weblogic.application.internal.EarDeployment.deactivate(EarDeployment.java:59)
at weblogic.application.internal.DeploymentStateChecker.deactivate(DeploymentStateChecker.java:198)
at weblogic.deploy.internal.targetserver.AppContainerInvoker.deactivate(AppContainerInvoker.java:98)
at weblogic.deploy.internal.targetserver.BasicDeployment.deactivate(BasicDeployment.java:263)
at weblogic.deploy.internal.targetserver.BasicDeployment.deactivateFromServerLifecycle(BasicDeployment.java:458)
at weblogic.management.deploy.internal.DeploymentAdapter$1.doDeactivate(DeploymentAdapter.java:73)
at weblogic.management.deploy.internal.DeploymentAdapter.deactivate(DeploymentAdapter.java:215)
at weblogic.management.deploy.internal.AppTransition 6. t r a n s i t i o n A p p ( A p p T r a n s i t i o n . j a v a : 66 ) a t w e b l o g i c . m a n a g e m e n t . d e p l o y . i n t e r n a l . C o n f i g u r e d D e p l o y m e n t s . t r a n s i t i o n A p p s ( C o n f i g u r e d D e p l o y m e n t s . j a v a : 240 ) a t w e b l o g i c . m a n a g e m e n t . d e p l o y . i n t e r n a l . C o n f i g u r e d D e p l o y m e n t s . d e a c t i v a t e ( C o n f i g u r e d D e p l o y m e n t s . j a v a : 198 ) a t w e b l o g i c . m a n a g e m e n t . d e p l o y . i n t e r n a l . C o n f i g u r e d D e p l o y m e n t s . u n d e p l o y ( C o n f i g u r e d D e p l o y m e n t s . j a v a : 191 ) a t w e b l o g i c . m a n a g e m e n t . d e p l o y . i n t e r n a l . D e p l o y m e n t S e r v e r S e r v i c e . s h u t d o w n A p p s ( D e p l o y m e n t S e r v e r S e r v i c e . j a v a : 195 ) a t w e b l o g i c . m a n a g e m e n t . d e p l o y . i n t e r n a l . D e p l o y m e n t S e r v e r S e r v i c e . s h u t d o w n H e l p e r ( D e p l o y m e n t S e r v e r S e r v i c e . j a v a : 127 ) a t w e b l o g i c . a p p l i c a t i o n . A p p l i c a t i o n S h u t d o w n S e r v i c e . s t o p ( A p p l i c a t i o n S h u t d o w n S e r v i c e . j a v a : 105 ) a t w e b l o g i c . t 3. s r v r . S e r v e r S e r v i c e s M a n a g e r . s t o p I n t e r n a l ( S e r v e r S e r v i c e s M a n a g e r . j a v a : 495 ) a t w e b l o g i c . t 3. s r v r . S e r v e r S e r v i c e s M a n a g e r . s t o p ( S e r v e r S e r v i c e s M a n a g e r . j a v a : 316 ) a t w e b l o g i c . t 3. s r v r . T 3 S r v r . s h u t d o w n ( T 3 S r v r . j a v a : 1117 ) a t w e b l o g i c . t 3. s r v r . T 3 S r v r . g r a c e f u l S h u t d o w n ( T 3 S r v r . j a v a : 1017 ) a t w e b l o g i c . t 3. s r v r . G r a c e f u l S h u t d o w n R e q u e s t . r u n ( G r a c e f u l S h u t d o w n R e q u e s t . j a v a : 41 ) a t w e b l o g i c . w o r k . C o n t e x t W r a p . r u n ( C o n t e x t W r a p . j a v a : 41 ) a t w e b l o g i c . w o r k . S e l f T u n i n g W o r k M a n a g e r I m p l 6.transitionApp(AppTransition.java:66) at weblogic.management.deploy.internal.ConfiguredDeployments.transitionApps(ConfiguredDeployments.java:240) at weblogic.management.deploy.internal.ConfiguredDeployments.deactivate(ConfiguredDeployments.java:198) at weblogic.management.deploy.internal.ConfiguredDeployments.undeploy(ConfiguredDeployments.java:191) at weblogic.management.deploy.internal.DeploymentServerService.shutdownApps(DeploymentServerService.java:195) at weblogic.management.deploy.internal.DeploymentServerService.shutdownHelper(DeploymentServerService.java:127) at weblogic.application.ApplicationShutdownService.stop(ApplicationShutdownService.java:105) at weblogic.t3.srvr.ServerServicesManager.stopInternal(ServerServicesManager.java:495) at weblogic.t3.srvr.ServerServicesManager.stop(ServerServicesManager.java:316) at weblogic.t3.srvr.T3Srvr.shutdown(T3Srvr.java:1117) at weblogic.t3.srvr.T3Srvr.gracefulShutdown(T3Srvr.java:1017) at weblogic.t3.srvr.GracefulShutdownRequest.run(GracefulShutdownRequest.java:41) at weblogic.work.ContextWrap.run(ContextWrap.java:41) at weblogic.work.SelfTuningWorkManagerImpl 6.transitionApp(AppTransition.java:66)atweblogic.management.deploy.internal.ConfiguredDeployments.transitionApps(ConfiguredDeployments.java:240)atweblogic.management.deploy.internal.ConfiguredDeployments.deactivate(ConfiguredDeployments.java:198)atweblogic.management.deploy.internal.ConfiguredDeployments.undeploy(ConfiguredDeployments.java:191)atweblogic.management.deploy.internal.DeploymentServerService.shutdownApps(DeploymentServerService.java:195)atweblogic.management.deploy.internal.DeploymentServerService.shutdownHelper(DeploymentServerService.java:127)atweblogic.application.ApplicationShutdownService.stop(ApplicationShutdownService.java:105)atweblogic.t3.srvr.ServerServicesManager.stopInternal(ServerServicesManager.java:495)atweblogic.t3.srvr.ServerServicesManager.stop(ServerServicesManager.java:316)atweblogic.t3.srvr.T3Srvr.shutdown(T3Srvr.java:1117)atweblogic.t3.srvr.T3Srvr.gracefulShutdown(T3Srvr.java:1017)atweblogic.t3.srvr.GracefulShutdownRequest.run(GracefulShutdownRequest.java:41)atweblogic.work.ContextWrap.run(ContextWrap.java:41)atweblogic.work.SelfTuningWorkManagerImplWorkAdapterImpl.run(SelfTuningWorkManagerImpl.java:545)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:256)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:221)
Caused by: javax.naming.NoInitialContextException: Cannot instantiate class: org.osjava.sj.SimpleContextFactory [Root exception is java.lang.ClassNotFoundException: org.osjava.sj.SimpleContextFactory]
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.(InitialContext.java:197)
at javax.management.remote.rmi.RMIConnectorServer.stop(RMIConnectorServer.java:544)
… 54 more
Caused by: java.lang.ClassNotFoundException: org.osjava.sj.SimpleContextFactory
at weblogic.utils.classloaders.GenericClassLoader.findLocalClass(GenericClassLoader.java:297)
at weblogic.utils.classloaders.GenericClassLoader.findClass(GenericClassLoader.java:270)
at weblogic.utils.classloaders.ChangeAwareClassLoader.findClass(ChangeAwareClassLoader.java:64)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
at weblogic.utils.classloaders.GenericClassLoader.loadClass(GenericClassLoader.java:179)
at weblogic.utils.classloaders.ChangeAwareClassLoader.loadClass(ChangeAwareClassLoader.java:52)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:249)
at com.sun.naming.internal.VersionHelper12.loadClass(VersionHelper12.java:46)
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:654)
… 58 more
系统使用了weblogic的JNDI,查看源码
// An highlighted block
package org.pentaho.di.core;
import java.io.File;
import org.pentaho.di.core.exception.KettleException;
public class JndiUtil
{
public static void initJNDI()
throws KettleException
{
String path = Const.JNDI_DIRECTORY;
if ((path == null) || (path.equals(""))) {
try {
File file = new File("simple-jndi");
path = file.getCanonicalPath();
} catch (Exception e) {
throw new KettleException("Error initializing JNDI", e);
}
Const.JNDI_DIRECTORY = path;
}
System.setProperty("java.naming.factory.initial", "org.osjava.sj.SimpleContextFactory");
System.setProperty("org.osjava.sj.root", path);
System.setProperty("org.osjava.sj.delimiter", "/");
}
}
其中System.setProperty(“java.naming.factory.initial”, “org.osjava.sj.SimpleContextFactory”);直接设置了数据JNDI为org.osjava.sj.SimpleContextFactory
再次查看调用JndiUtil.init()的代码
package org.pentaho.di.core;
import java.io.PrintStream;
import org.pentaho.di.core.exception.KettleException;
import org.pentaho.di.core.exception.KettlePluginException;
import org.pentaho.di.core.lifecycle.KettleLifecycleSupport;
import org.pentaho.di.core.logging.LogTablePluginType;
import org.pentaho.di.core.plugins.CartePluginType;
import org.pentaho.di.core.plugins.ImportRulePluginType;
import org.pentaho.di.core.plugins.JobEntryPluginType;
import org.pentaho.di.core.plugins.KettleLifecyclePluginType;
import org.pentaho.di.core.plugins.LifecyclePluginType;
import org.pentaho.di.core.plugins.PartitionerPluginType;
import org.pentaho.di.core.plugins.PluginRegistry;
import org.pentaho.di.core.plugins.RepositoryPluginType;
import org.pentaho.di.core.plugins.StepPluginType;
import org.pentaho.di.i18n.BaseMessages;
import org.pentaho.di.repository.IUser;
import org.pentaho.di.repository.Repository;
import org.pentaho.di.trans.step.RowDistributionPluginType;
public class KettleEnvironment
{
private static Class<?> PKG = Const.class;
private static Boolean initialized;
public static void init()
throws KettleException
{
init(true);
}
public static void init(boolean simpleJndi)
throws KettleException
{
if (initialized == null)
{
if (!KettleClientEnvironment.isInitialized()) {
KettleClientEnvironment.init();
}
if (simpleJndi) {
JndiUtil.initJNDI();
}
PluginRegistry.addPluginType(RowDistributionPluginType.getInstance());
PluginRegistry.addPluginType(StepPluginType.getInstance());
PluginRegistry.addPluginType(PartitionerPluginType.getInstance());
PluginRegistry.addPluginType(JobEntryPluginType.getInstance());
PluginRegistry.addPluginType(LogTablePluginType.getInstance());
PluginRegistry.addPluginType(RepositoryPluginType.getInstance());
PluginRegistry.addPluginType(LifecyclePluginType.getInstance());
PluginRegistry.addPluginType(KettleLifecyclePluginType.getInstance());
PluginRegistry.addPluginType(ImportRulePluginType.getInstance());
PluginRegistry.addPluginType(CartePluginType.getInstance());
PluginRegistry.init();
KettleVariablesList.init();
initLifecycleListeners();
initialized = Boolean.valueOf(true);
}
}
private static void initLifecycleListeners()
throws KettleException
{
KettleLifecycleSupport s = new KettleLifecycleSupport();
s.onEnvironmentInit();
Runtime.getRuntime().addShutdownHook(new Thread(s) {
public void run() {
try {
this.val$s.onEnvironmentShutdown();
} catch (Throwable t) {
System.err.println(BaseMessages.getString(KettleEnvironment.PKG, "LifecycleSupport.ErrorInvokingKettleEnvironmentShutdownListeners", new String[0]));
t.printStackTrace();
}
}
});
}
public static boolean isInitialized()
{
return initialized != null;
}
public void loadPluginRegistry()
throws KettlePluginException
{
}
public static void setExecutionInformation(ExecutorInterface executor, Repository repository)
{
executor.setExecutingUser(System.getProperty("user.name"));
if (repository != null) {
IUser userInfo = repository.getUserInfo();
if (userInfo != null) {
executor.setExecutingUser(userInfo.getLogin());
}
}
executor.setExecutingServer(Const.getHostname());
}
}
在KettleEnvironment.init的时候,参数simpleJndi如果不传,将默认使用simpleJndi,查看调用执行脚本的地方,果然发现KettleEnvironment.init没有传入false参数,
增加上false参数,问题解决