NutzCN Logo
问答 有关linux上的问题
发布于 3202天前 作者 苍蓝猛兽 2622 次浏览 复制 上一个帖子 下一个帖子
标签:

ALL Nutz Log via Log4jLogAdapter
Log4j: 17:56:58 INFO org.nutz.log.Logs [] - Nutz is licensed under the Apache License, Version 2.0 .
Report bugs : https://github.com/nutzam/nutz/issues
Log4j: 17:56:58 DEBUG com.nari.nwims.skengine.base.nutz.ExtConfLoader [] - lastPath=/home/na/engine/etc/db.properties
Log4j: 17:57:06 DEBUG org.nutz.resource.Scans [] - Locations for Scans:
[FileSystemResourceLocation [root=/home/na/engine], JarResourceLocation [jarPath=/home/na/engine/sk-engine.jar]]
Log4j: 17:57:07 DEBUG org.nutz.resource.Scans [scan] - Found 0 resource by src( . ) , regex( ^(.+[.])(js|json)$ )
Log4j: 17:57:07 DEBUG org.nutz.castor.Castors [reload] - Using 91 castor for Castors
Exception in thread "main" java.lang.ExceptionInInitializerError
Caused by: org.nutz.lang.born.BorningException: Fail to born 'org.nutz.ioc.loader.json.JsonLoader'
by args: [
@(.)] becasue:
java.lang.RuntimeException: folder or file like '^(.+[.])(js|json)$' no found in .
at org.nutz.lang.born.DynamicConstructorBorning.born(DynamicConstructorBorning.java:21)
at org.nutz.lang.born.BornContext.doBorn(BornContext.java:60)
at org.nutz.lang.Mirror.born(Mirror.java:967)
at org.nutz.ioc.loader.combo.ComboIocLoader.createIocLoader(ComboIocLoader.java:113)
at org.nutz.ioc.loader.combo.ComboIocLoader.(ComboIocLoader.java:85)
at com.nari.nwims.skengine.base.nutz.IocMaster.getInstance(IocMaster.java:35)
at com.nari.nwims.skengine.SKEngine.(SKEngine.java:15)
Caused by: java.lang.RuntimeException: folder or file like '^(.+[.])(js|json)$' no found in .
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at org.nutz.lang.born.ConstructorBorning.born(ConstructorBorning.java:17)
at org.nutz.lang.born.BornContext.doBorn(BornContext.java:60)
at org.nutz.lang.Mirror.born(Mirror.java:967)
at org.nutz.lang.Lang.makeThrow(Lang.java:116)
at org.nutz.resource.Scans.loadResource(Scans.java:86)
at org.nutz.ioc.loader.json.JsonLoader.(JsonLoader.java:41)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at org.nutz.lang.born.DynamicConstructorBorning.born(DynamicConstructorBorning.java:19)
... 6 more
Could not find the main class: com.nari.nwims.skengine.SKEngine. Program will exit.

/**
* 外部配置文件载入器。
*
* @author wukong(wukonggg@139.com)
*/
public class ExtConfLoader extends MapLoader {

private static final String DB_PROPS = "db.properties";
private static Log log = Logs.get();

public ExtConfLoader() {
    NutMap map = new NutMap();


    String lastPath = System.getProperty("user.dir") + "/etc/" + DB_PROPS;
    log.debug("lastPath=" + lastPath);


    File file = Files.findFile(lastPath);

    if (Lang.isEmpty(file)) {
        throw Lang.makeThrow("Can Not Find Resource [%s] Any More", DB_PROPS);
    }
    map.setv("type", "org.nutz.ioc.impl.PropertiesProxy");
    ArrayList<String> args = new ArrayList<String>();
    args.add(file.getPath());
    map.setv("args", args);
    getMap().put("conf", map);
}

}

public class IocMaster {

private static final Log log = Logs.get();

private static Ioc ioc = null;

private IocMaster() {
    throw new RuntimeException("Shit! What are you doing?!");
}


public static Ioc getInstance() {
    if (null != ioc) {
       return ioc;
    }

    try {
        ioc = new NutIoc(new ComboIocLoader(
            "*com.nari.nwims.skengine.base.nutz.ExtConfLoader"
            , "*js", "."
            , "*anno", "com.nari.nwims.skengine"
            , "*tx"
            ));
    } catch (ClassNotFoundException e) {
        String msg = "create ioc failed...";
        log.error(msg);
        log.error(e.getMessage());
        throw new RuntimeException(e);

// } catch (MalformedURLException e) {
// e.printStackTrace();
}
return ioc;
}

}

db.js跟com在同级目录,大神们,这个是什么问题呢???

11 回复
"*js","."

这是非常不妥的写法

点号代表当前文件夹,这是运行时的工作目录

正确的用法应该是 ioc/ 一类的配置,让nutz在classpath路径下子文件夹中查找

@wendal 我已经把db.js放入ExtConfLoader 同级目录下,但是还是扫描不到,请问我该怎么做

建个ioc目录放进去,改iocby配置

@wendal 我已经把db.js放入ExtConfLoader 同级目录下,这是打包后的目录结构,运行环境是linux

@wendal 按照你的指导,创建ioc目录 修改 ioc = new NutIoc(new ComboIocLoader(
"*com.nari.nwims.skengine.base.nutz.ExtConfLoader"
, "*js", "./ioc"
, "*anno", "com.nari.nwims.skengine"
, "*tx"
));
但是依然报相同的错误

@qq_cdd73473

  1. 建个文件夹叫ioc,与com同级
  2. 把db.js移进去
  3. iocby里面的 "." 改成 "ioc/"

@qq_cdd73473 是 "ioc/" 不是 "./ioc"

@wendal 多谢,已经解决,大神就是厉害

@qq_cdd73473 顺带问一句,db.js 是放在jar之外的?

@wendal 目前是放在jar包外面的....

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