Error creating bean with name 'fisServer' defined in ServletContext resource [/W

时间:2020-12-12 08:55:58
各位大侠 我都快要疯了, 我在本地测试一点问题都没有(有MYECLIPSE)  远程到服务器上面用tomcat启动就出现这样的问题
为什么远程到服务器上就不好使呢

严重: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'fisServer' defined in ServletContext resource [/WEB-INF/classes/Spring/applicationContext.xml]: Invocation of init method failed; nested exception is java.lang.NullPointerException
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1338)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:473)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
at java.security.AccessController.doPrivileged(Native Method)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:429)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:728)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:380)
at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:255)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:199)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:45)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3843)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4342)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:525)
at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:926)
at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:889)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:492)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1149)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:719)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
at org.apache.catalina.core.StandardService.start(StandardService.java:516)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
at org.apache.catalina.startup.Catalina.start(Catalina.java:578)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
Caused by: java.lang.NullPointerException
at com.infor.fis.server.FISServer.start(FISServer.java:94)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeCustomInitMethod(AbstractAutowireCapableBeanFactory.java:1414)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1375)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1335)
... 39 more

下面是我application.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
    
    <import resource="classpath:Spring/fis_config.xml"></import>

    <bean id="fisServer" class="com.infor.fis.server.FISServer" init-method="start">
     <property name="listener" ref="parser"></property>
        <property name="fileMonitor" ref="fileMonitor"></property>
        <property name="soManager" ref="unitSOManager"></property>
        <property name="configurationManager" ref="configurationManager"></property>
        <property name="sessionFactory" ref="sessionFactory"></property>
    </bean>
    
    <bean id="beanFactoryResolver" class="com.infor.tools.BeanFactoryResolver" >
    </bean>
</beans>

2 个解决方案

#1


这是 fisServer

/**
 * ---Begin Copyright Notice---20071011T1133
 *
 * NOTICE
 *
 * THIS SOFTWARE IS THE PROPERTY OF AND CONTAINS CONFIDENTIAL INFORMATION OF
 * INFOR AND/OR ITS AFFILIATES OR SUBSIDIARIES AND SHALL NOT BE DISCLOSED
 * WITHOUT PRIOR WRITTEN PERMISSION. LICENSED CUSTOMERS MAY COPY AND ADAPT
 * THIS SOFTWARE FOR THEIR OWN USE IN ACCORDANCE WITH THE TERMS OF THEIR
 * SOFTWARE LICENSE AGREEMENT. ALL OTHER RIGHTS RESERVED.
 *
 * (c) COPYRIGHT 2008 INFOR. ALL RIGHTS RESERVED. THE WORD AND DESIGN MARKS
 * SET FORTH HEREIN ARE TRADEMARKS AND/OR REGISTERED TRADEMARKS OF INFOR
 * AND/OR ITS AFFILIATES AND SUBSIDIARIES. ALL RIGHTS RESERVED. ALL OTHER
 * TRADEMARKS LISTED HEREIN ARE THE PROPERTY OF THEIR RESPECTIVE OWNERS.
 *
 * ---End Copyright Notice---
 */
package com.infor.fis.server;

import java.io.IOException;
import java.util.Properties;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.SessionFactory;
import org.springframework.core.io.ClassPathResource;

import com.infor.fis.server.config.ConfigurationManager;
import com.infor.fis.server.jit.so.UnitSOManager;
import com.infor.tools.fm.FileMonitor;
import com.infor.tools.fm.FileMonitorListener;

/**
 * FISServer handles ...
 * 
 * @author derek_yang
 */
public class FISServer {
/**
 * 
 */
private static final String DELETE_UNIT_COMMAND = "deleteUnit#";

/**
 * 
 */
private static final String DELETE_ARC_COMMAND = "deleteArc#";

/**
 * Logger for this class
 */
private static final Log logger = LogFactory.getLog(FISServer.class);

private FileMonitor fileMonitor;

private FileMonitorListener listener;

private SessionFactory sessionFactory;

@SuppressWarnings("unused")
private UnitSOManager soManager;

private ConfigurationManager configurationManager;

private boolean started;

static {
Properties properties = new Properties();
try {   
properties.load(new ClassPathResource("map.properties").getInputStream());   
} catch (IOException e) {   
e.printStackTrace();   
}
if (Boolean.parseBoolean(properties.getProperty("runmap"))) {
 Runtime rt = Runtime.getRuntime();
        try {
            Process p = rt.exec(properties.getProperty(properties.getProperty("command1")));
            p.waitFor();
            p = rt.exec(properties.getProperty(properties.getProperty("command2")));
            p.waitFor();
        }
        catch (Exception ex) {
            ex.printStackTrace();
        }
}
    }

public void start() {
logger.info("************ Starting FIS Server *****************");

fileMonitor.addListener(listener);

if (configurationManager.getFISConfiguration().isStartServer()) {
startServer();
} else {
logger.info("Moniter and Unit Manager didn't startup, user need manullay start them!");
}

fileMonitor.start();

logger.info("************ FIS Server Startup*****************");
}

/**
 * 
 */
public void startServer() {
started = true;

fileMonitor.startMonitor();

// soManager.startService();
}

public void stopServer() {
started = false;

fileMonitor.stopMonitor();

// soManager.stopService();
}

public boolean isStarted() {
return started;
}


private String convertMemory(long memory) {
float mb = memory / (1024L * 1024L );

return String.format("%.3f MB", mb);
}


/**
 * @param listener the listener to set
 */
public void setListener(FileMonitorListener listener) {
this.listener = listener;
}

/**
 * @param fileMonitor the fileMonitor to set
 */
public void setFileMonitor(FileMonitor fileMonitor) {
this.fileMonitor = fileMonitor;
}

/**
 * @param soManager the soManager to set
 */
public void setSoManager(UnitSOManager soManager) {
this.soManager = soManager;
}

/**
 * @param configurationManager the configurationManager to set
 */
public void setConfigurationManager(ConfigurationManager configurationManager) {
this.configurationManager = configurationManager;
}

/**
 * @param sessionFactory the sessionFactory to set
 */
public void setSessionFactory(SessionFactory sessionFactory) {
this.sessionFactory = sessionFactory;
}
}

#2


该回复于2010-12-28 16:53:38被版主删除

#1


这是 fisServer

/**
 * ---Begin Copyright Notice---20071011T1133
 *
 * NOTICE
 *
 * THIS SOFTWARE IS THE PROPERTY OF AND CONTAINS CONFIDENTIAL INFORMATION OF
 * INFOR AND/OR ITS AFFILIATES OR SUBSIDIARIES AND SHALL NOT BE DISCLOSED
 * WITHOUT PRIOR WRITTEN PERMISSION. LICENSED CUSTOMERS MAY COPY AND ADAPT
 * THIS SOFTWARE FOR THEIR OWN USE IN ACCORDANCE WITH THE TERMS OF THEIR
 * SOFTWARE LICENSE AGREEMENT. ALL OTHER RIGHTS RESERVED.
 *
 * (c) COPYRIGHT 2008 INFOR. ALL RIGHTS RESERVED. THE WORD AND DESIGN MARKS
 * SET FORTH HEREIN ARE TRADEMARKS AND/OR REGISTERED TRADEMARKS OF INFOR
 * AND/OR ITS AFFILIATES AND SUBSIDIARIES. ALL RIGHTS RESERVED. ALL OTHER
 * TRADEMARKS LISTED HEREIN ARE THE PROPERTY OF THEIR RESPECTIVE OWNERS.
 *
 * ---End Copyright Notice---
 */
package com.infor.fis.server;

import java.io.IOException;
import java.util.Properties;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.SessionFactory;
import org.springframework.core.io.ClassPathResource;

import com.infor.fis.server.config.ConfigurationManager;
import com.infor.fis.server.jit.so.UnitSOManager;
import com.infor.tools.fm.FileMonitor;
import com.infor.tools.fm.FileMonitorListener;

/**
 * FISServer handles ...
 * 
 * @author derek_yang
 */
public class FISServer {
/**
 * 
 */
private static final String DELETE_UNIT_COMMAND = "deleteUnit#";

/**
 * 
 */
private static final String DELETE_ARC_COMMAND = "deleteArc#";

/**
 * Logger for this class
 */
private static final Log logger = LogFactory.getLog(FISServer.class);

private FileMonitor fileMonitor;

private FileMonitorListener listener;

private SessionFactory sessionFactory;

@SuppressWarnings("unused")
private UnitSOManager soManager;

private ConfigurationManager configurationManager;

private boolean started;

static {
Properties properties = new Properties();
try {   
properties.load(new ClassPathResource("map.properties").getInputStream());   
} catch (IOException e) {   
e.printStackTrace();   
}
if (Boolean.parseBoolean(properties.getProperty("runmap"))) {
 Runtime rt = Runtime.getRuntime();
        try {
            Process p = rt.exec(properties.getProperty(properties.getProperty("command1")));
            p.waitFor();
            p = rt.exec(properties.getProperty(properties.getProperty("command2")));
            p.waitFor();
        }
        catch (Exception ex) {
            ex.printStackTrace();
        }
}
    }

public void start() {
logger.info("************ Starting FIS Server *****************");

fileMonitor.addListener(listener);

if (configurationManager.getFISConfiguration().isStartServer()) {
startServer();
} else {
logger.info("Moniter and Unit Manager didn't startup, user need manullay start them!");
}

fileMonitor.start();

logger.info("************ FIS Server Startup*****************");
}

/**
 * 
 */
public void startServer() {
started = true;

fileMonitor.startMonitor();

// soManager.startService();
}

public void stopServer() {
started = false;

fileMonitor.stopMonitor();

// soManager.stopService();
}

public boolean isStarted() {
return started;
}


private String convertMemory(long memory) {
float mb = memory / (1024L * 1024L );

return String.format("%.3f MB", mb);
}


/**
 * @param listener the listener to set
 */
public void setListener(FileMonitorListener listener) {
this.listener = listener;
}

/**
 * @param fileMonitor the fileMonitor to set
 */
public void setFileMonitor(FileMonitor fileMonitor) {
this.fileMonitor = fileMonitor;
}

/**
 * @param soManager the soManager to set
 */
public void setSoManager(UnitSOManager soManager) {
this.soManager = soManager;
}

/**
 * @param configurationManager the configurationManager to set
 */
public void setConfigurationManager(ConfigurationManager configurationManager) {
this.configurationManager = configurationManager;
}

/**
 * @param sessionFactory the sessionFactory to set
 */
public void setSessionFactory(SessionFactory sessionFactory) {
this.sessionFactory = sessionFactory;
}
}

#2


该回复于2010-12-28 16:53:38被版主删除