NutzCN Logo
问答 nutzwk mini war包运行。MyMainLauncher启动报错,init方法不执行
发布于 1841天前 作者 码农 1598 次浏览 复制 上一个帖子 下一个帖子
标签: nutzwk

系统可以正常访问,定时任务不执行,
Globals.AppBase = Mvcs.getServletContext().getContextPath();
是99行

[DEBUG] 13:13:05.891 [localhost-startStop-1] org.nutz.ioc.impl.NutIoc - Get 'trafficDao'<interface org.nutz.dao.Dao>
[DEBUG] 13:13:05.897 [localhost-startStop-1] org.nutz.ioc.impl.ScopeContext - Remove object 'myMainLauncher' from [app]
[ERROR] 13:13:05.905 [localhost-startStop-1] org.nutz.boot.NbApp - something happen!!
org.nutz.ioc.IocException: IocBean[myMainLauncher] throw Exception when creating
        at org.nutz.ioc.impl.ObjectMakerImpl.make(ObjectMakerImpl.java:153)
        at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:241)
        at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:271)
        at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:161)
        at org.nutz.boot.NbApp.execute(NbApp.java:214)
        at org.nutz.boot.starter.servlet3.NbServletContextListener.contextInitialized(NbServletContextListener.java:79)
        at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4699)
        at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5165)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
        at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:743)
        at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:719)
        at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:705)
        at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:970)
        at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1841)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.NullPointerException: null
        at cn.wizzer.app.web.commons.core.MyMainLauncher.init(MyMainLauncher.java:99)
        at cn.wizzer.app.web.commons.core.MyMainLauncher$FM$init$90b4805a831d8f489b4c19bed76a5eeb.invoke(MyMainLauncher.java)
        at org.nutz.ioc.impl.ObjectMakerImpl$2.trigger(ObjectMakerImpl.java:181)
        at org.nutz.ioc.weaver.DefaultWeaver.onCreate(DefaultWeaver.java:89)
        at org.nutz.ioc.impl.ObjectMakerImpl.make(ObjectMakerImpl.java:141)
        ... 18 common frames omitted
[DEBUG] 13:13:05.911 [localhost-startStop-1] org.nutz.ioc.impl.NutIoc - Get 'druidWebStatServletStarter'<interface org.nutz.boot.starter.WebServletFace>
@IocBean(create = "init", depose = "depose")
@Modules(packages = "cn.wizzer")
@Localization(value = "locales/", defaultLocalizationKey = "zh_CN")
@Encoding(input = "UTF-8", output = "UTF-8")
@ChainBy(args = "chain/nutzwk-mvc-chain.json")
@SessionBy(ShiroSessionProvider.class)
public class MyMainLauncher {
    private static final Log log = Logs.get();
    @Inject("refer:$ioc")
    private Ioc ioc;
    @Inject
    private PropertiesProxy conf;
    @Inject
    private JedisAgent jedisAgent;
    @Inject
    private WebPubSub webPubSub;//注入一下为了初始化
    @Inject
    private GroupTemplate groupTemplate;
    @Inject
    private TaskPlatformService taskPlatformService;
    @Inject
    private SysTaskService sysTaskService;
    @Inject
    private Dao dao;
    @Inject
    private Dao kljkDao;
    @Inject
    private Dao yygfDao;
    @Inject
    private Dao parkDao;
    @Inject
    private Dao ditieDao;
    @Inject
    private Dao trafficDao;




    public static void main(String[] args) throws Exception {
        NbApp nb = new NbApp().setArgs(args).setPrintProcDoc(true);
        nb.getAppContext().setMainPackage("cn.wizzer");
        nb.run();
    }

    public static NbApp warMain(ServletContext sc) {
        NbApp nb = new NbApp().setPrintProcDoc(true);
        nb.getAppContext().setMainPackage("cn.wizzer");

        return nb;
    }

    public void init() {

        Mvcs.X_POWERED_BY = "NutzWk-Mini 1.0.0 <wizzer.cn>";
        Globals.AppBase = Mvcs.getServletContext().getContextPath();
        Globals.AppRoot = Mvcs.getServletContext().getRealPath("/");
        //注册自定义标签
        groupTemplate.registerTagFactory("cms_channel_list", () -> ioc.get(CmsChannelListTag.class));
        groupTemplate.registerTagFactory("cms_channel", () -> ioc.get(CmsChannelTag.class));
        groupTemplate.registerTagFactory("cms_article_list", () -> ioc.get(CmsArticleListTag.class));
        groupTemplate.registerTagFactory("cms_article", () -> ioc.get(CmsArticleTag.class));
        groupTemplate.registerTagFactory("cms_link_list", () -> ioc.get(CmsLinkListTag.class));
        init_sys();
        init_task();
        ioc.get(Globals.class);
    }

4 回复

Globals.AppBase = Mvcs.getServletContext().getContextPath(); 作用是什么?

我说错了,init方法应该是执行了,我将99行代码注释掉,接着100报一样的错,

        Mvcs.X_POWERED_BY = "NutzWk-Mini 1.0.0 <wizzer.cn>";
        //Globals.AppBase = Mvcs.getServletContext().getContextPath();
        Globals.AppRoot = Mvcs.getServletContext().getRealPath("/");

先写测试用例。
看着像是其它的BEAN 影响IOC 模块初始化。

添加回复
请先登陆
回到顶部