NutzCN Logo
问答 我把nutz-book-project项目下载core与webapp加上hotplug引用
发布于 2185天前 作者 shuxinyun 1746 次浏览 复制 上一个帖子 下一个帖子
标签:

编译运行后,报如下错误

12:19:15.887 DEBUG (LogTimeProcessor.java:24) process - [GET ]URI=/user/avatar/me 200 14ms
12:19:15.882 WARN  (FailProcessor.java:28) process - Error@/admin/hotplug/list :
org.nutz.ioc.IocException: IocBean[hotplugModule] throw Exception when creating
	at org.nutz.ioc.impl.ObjectMakerImpl.make(ObjectMakerImpl.java:152) ~[nutz-1.r.67-SNAPSHOT.jar:1.r.67-SNAPSHOT]
	at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:241) ~[nutz-1.r.67-SNAPSHOT.jar:1.r.67-SNAPSHOT]
	at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:271) ~[nutz-1.r.67-SNAPSHOT.jar:1.r.67-SNAPSHOT]
	at org.nutz.mvc.impl.processor.ModuleProcessor.process(ModuleProcessor.java:116) ~[nutz-1.r.67-SNAPSHOT.jar:1.r.67-SNAPSHOT]
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44) ~[nutz-1.r.67-SNAPSHOT.jar:1.r.67-SNAPSHOT]
	at org.nutz.mvc.impl.processor.EncodingProcessor.process(EncodingProcessor.java:27) ~[nutz-1.r.67-SNAPSHOT.jar:1.r.67-SNAPSHOT]
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44) ~[nutz-1.r.67-SNAPSHOT.jar:1.r.67-SNAPSHOT]
	at org.nutz.mvc.impl.processor.UpdateRequestAttributesProcessor.process(UpdateRequestAttributesProcessor.java:15) ~[nutz-1.r.67-SNAPSHOT.jar:1.r.67-SNAPSHOT]
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44) ~[nutz-1.r.67-SNAPSHOT.jar:1.r.67-SNAPSHOT]
	at net.wendal.nutzbook.common.mvc.DailyUniqueUsersProcessor.process(DailyUniqueUsersProcessor.java:45) ~[nutzcn-core-3.1.0.jar:?]
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44) ~[nutz-1.r.67-SNAPSHOT.jar:1.r.67-SNAPSHOT]
	at net.wendal.nutzbook.common.mvc.LogTimeProcessor.process(LogTimeProcessor.java:19) ~[nutzcn-core-3.1.0.jar:?]
	at org.nutz.mvc.impl.NutActionChain.doChain(NutActionChain.java:44) [nutz-1.r.67-SNAPSHOT.jar:1.r.67-SNAPSHOT]
	at org.nutz.mvc.impl.ActionInvoker.invoke(ActionInvoker.java:67) [nutz-1.r.67-SNAPSHOT.jar:1.r.67-SNAPSHOT]
	at org.nutz.mvc.ActionHandler.handle(ActionHandler.java:31) [nutz-1.r.67-SNAPSHOT.jar:1.r.67-SNAPSHOT]
	at org.nutz.mvc.NutFilter.doFilter(NutFilter.java:202) [nutz-1.r.67-SNAPSHOT.jar:1.r.67-SNAPSHOT]
	at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1610) [jetty-servlet-9.4.14.v20181114.jar:9.4.14.v20181114]
	at org.apache.shiro.web.servlet.AbstractShiroFilter.executeChain(AbstractShiroFilter.java:449) [shiro-web-1.3.2.jar:1.3.2]
	at org.apache.shiro.web.servlet.AbstractShiroFilter$1.call(AbstractShiroFilter.java:365) [shiro-web-1.3.2.jar:1.3.2]
	at org.apache.shiro.subject.support.SubjectCallable.doCall(SubjectCallable.java:90) [shiro-core-1.3.2.jar:1.3.2]
	at org.apache.shiro.subject.support.SubjectCallable.call(SubjectCallable.java:83) [shiro-core-1.3.2.jar:1.3.2]
	at org.apache.shiro.subject.support.DelegatingSubject.execute(DelegatingSubject.java:383) [shiro-core-1.3.2.jar:1.3.2]
	at org.apache.shiro.web.servlet.AbstractShiroFilter.doFilterInternal(AbstractShiroFilter.java:362) [shiro-web-1.3.2.jar:1.3.2]
	at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125) [shiro-web-1.3.2.jar:1.3.2]
	at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1610) [jetty-servlet-9.4.14.v20181114.jar:9.4.14.v20181114]
	at com.alibaba.druid.support.http.WebStatFilter.doFilter(WebStatFilter.java:123) [druid-1.1.12.jar:1.1.12]
	at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1610) [jetty-servlet-9.4.14.v20181114.jar:9.4.14.v20181114]
	at org.nutz.mvc.WhaleFilter.doFilter(WhaleFilter.java:171) [nutz-1.r.67-SNAPSHOT.jar:1.r.67-SNAPSHOT]
	at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1602) [jetty-servlet-9.4.14.v20181114.jar:9.4.14.v20181114]
	at org.eclipse.jetty.websocket.server.WebSocketUpgradeFilter.doFilter(WebSocketUpgradeFilter.java:214) [websocket-server-9.4.14.v20181114.jar:9.4.14.v20181114]
	at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1610) [jetty-servlet-9.4.14.v20181114.jar:9.4.14.v20181114]
	at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:540) [jetty-servlet-9.4.14.v20181114.jar:9.4.14.v20181114]
	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:146) [jetty-server-9.4.14.v20181114.jar:9.4.14.v20181114]
	at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:548) [jetty-security-9.4.14.v20181114.jar:9.4.14.v20181114]
	at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132) [jetty-server-9.4.14.v20181114.jar:9.4.14.v20181114]
	at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:257) [jetty-server-9.4.14.v20181114.jar:9.4.14.v20181114]
	at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:1588) [jetty-server-9.4.14.v20181114.jar:9.4.14.v20181114]
	at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:255) [jetty-server-9.4.14.v20181114.jar:9.4.14.v20181114]
	at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1345) [jetty-server-9.4.14.v20181114.jar:9.4.14.v20181114]
	at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:203) [jetty-server-9.4.14.v20181114.jar:9.4.14.v20181114]
	at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:480) [jetty-servlet-9.4.14.v20181114.jar:9.4.14.v20181114]
	at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:1557) [jetty-server-9.4.14.v20181114.jar:9.4.14.v20181114]
	at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:201) [jetty-server-9.4.14.v20181114.jar:9.4.14.v20181114]
	at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1247) [jetty-server-9.4.14.v20181114.jar:9.4.14.v20181114]
	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:144) [jetty-server-9.4.14.v20181114.jar:9.4.14.v20181114]
	at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132) [jetty-server-9.4.14.v20181114.jar:9.4.14.v20181114]
	at org.eclipse.jetty.server.Server.handle(Server.java:502) [jetty-server-9.4.14.v20181114.jar:9.4.14.v20181114]
	at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:364) [jetty-server-9.4.14.v20181114.jar:9.4.14.v20181114]
	at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:260) [jetty-server-9.4.14.v20181114.jar:9.4.14.v20181114]
	at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:305) [jetty-io-9.4.14.v20181114.jar:9.4.14.v20181114]
	at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:103) [jetty-io-9.4.14.v20181114.jar:9.4.14.v20181114]
	at org.eclipse.jetty.io.ChannelEndPoint$2.run(ChannelEndPoint.java:118) [jetty-io-9.4.14.v20181114.jar:9.4.14.v20181114]
	at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.runTask(EatWhatYouKill.java:333) [jetty-util-9.4.14.v20181114.jar:9.4.14.v20181114]
	at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:310) [jetty-util-9.4.14.v20181114.jar:9.4.14.v20181114]
	at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.tryProduce(EatWhatYouKill.java:168) [jetty-util-9.4.14.v20181114.jar:9.4.14.v20181114]
	at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.run(EatWhatYouKill.java:126) [jetty-util-9.4.14.v20181114.jar:9.4.14.v20181114]
	at org.eclipse.jetty.util.thread.ReservedThreadExecutor$ReservedThread.run(ReservedThreadExecutor.java:366) [jetty-util-9.4.14.v20181114.jar:9.4.14.v20181114]
	at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:765) [jetty-util-9.4.14.v20181114.jar:9.4.14.v20181114]
	at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:683) [jetty-util-9.4.14.v20181114.jar:9.4.14.v20181114]
	at java.lang.Thread.run(Thread.java:748) [?:1.8.0_161]
Caused by: java.lang.RuntimeException: IocBean[hotplugModule] fail at field=[hotplug]
	at org.nutz.ioc.weaver.FieldInjector.inject(FieldInjector.java:40) ~[nutz-1.r.67-SNAPSHOT.jar:1.r.67-SNAPSHOT]
	at org.nutz.ioc.weaver.DefaultWeaver.fill(DefaultWeaver.java:67) ~[nutz-1.r.67-SNAPSHOT.jar:1.r.67-SNAPSHOT]
	at org.nutz.ioc.impl.ObjectMakerImpl.make(ObjectMakerImpl.java:138) ~[nutz-1.r.67-SNAPSHOT.jar:1.r.67-SNAPSHOT]
	... 59 more
Caused by: org.nutz.ioc.IocException: IocBean[class:org.nutz.plugins.hotplug.Hotplug] none ioc bean match class=org.nutz.plugins.hotplug.Hotplug
	at org.nutz.ioc.impl.NutIoc.getByType(NutIoc.java:461) ~[nutz-1.r.67-SNAPSHOT.jar:1.r.67-SNAPSHOT]
	at org.nutz.ioc.val.ReferTypeValue.get(ReferTypeValue.java:66) ~[nutz-1.r.67-SNAPSHOT.jar:1.r.67-SNAPSHOT]
	at org.nutz.ioc.weaver.FieldInjector.inject(FieldInjector.java:32) ~[nutz-1.r.67-SNAPSHOT.jar:1.r.67-SNAPSHOT]
	at org.nutz.ioc.weaver.DefaultWeaver.fill(DefaultWeaver.java:67) ~[nutz-1.r.67-SNAPSHOT.jar:1.r.67-SNAPSHOT]
	at org.nutz.ioc.impl.ObjectMakerImpl.make(ObjectMakerImpl.java:138) ~[nutz-1.r.67-SNAPSHOT.jar:1.r.67-SNAPSHOT]
	... 59 more
4 回复
package net.wendal.nutzbook.core.module;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

import org.apache.shiro.authz.annotation.RequiresRoles;
import org.nutz.dao.QueryResult;
import org.nutz.dao.pager.Pager;
import org.nutz.integration.jedis.pubsub.PubSubService;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.json.Json;
import org.nutz.lang.random.R;
import org.nutz.lang.util.NutMap;
import org.nutz.log.Log;
import org.nutz.log.Logs;
import org.nutz.mvc.annotation.AdaptBy;
import org.nutz.mvc.annotation.At;
import org.nutz.mvc.annotation.Ok;
import org.nutz.mvc.annotation.POST;
import org.nutz.mvc.annotation.Param;
import org.nutz.mvc.upload.TempFile;
import org.nutz.mvc.upload.UploadAdaptor;
import org.nutz.plugins.hotplug.Hotplug;
import org.nutz.plugins.hotplug.HotplugConfig;
import org.nutz.resource.NutResource;
import org.nutz.resource.Scans;

@IocBean
@At("/admin/hotplug")
@Ok("json")
public class HotplugModule extends BaseModule {
    @Inject
    protected Hotplug hotplug;

    @Inject
    protected PubSubService pubSubService;

    protected String selfId = R.UU32();

    @At
    public Object list(@Param("active")boolean activeOnly) throws Exception {
        List<NutResource> _list = Scans.me().scan("hotplug/", ".+.(js|json)$");
        List<NutMap> list = new ArrayList<>();
        for (NutResource nr : _list) {
            list.add(Json.fromJson(NutMap.class, nr.getReader()));
        }
        return ajaxOk(new QueryResult(list, new Pager()));
    }
    @RequiresRoles("admin")
    @POST
    @At
    @AdaptBy(type=UploadAdaptor.class, args="${app.root}/WEB-INF/tmp/hotplug")
    public NutMap add(@Param("file")TempFile f) throws Exception {
        boolean ok = hotplug.add(f.getFile());
        pubSubService.fire("hotplug:add", selfId + "," + f.getName());
        return ajaxOk(ok);
    }

    @RequiresRoles("admin")
    @POST
    @At
    public NutMap disable(@Param("name")String name) throws Exception {
        hotplug.disable(name);
        pubSubService.fire("hotplug:disable", selfId + "," + name);
        return ajaxOk(null);
    }

    @RequiresRoles("admin")
    @POST
    @At
    public NutMap enable(@Param("sha1")String sha1) throws Exception {
        for (HotplugConfig hc : Hotplug.getHotPlugJarList(true)) {
            if (sha1.equals(hc.getSha1())) {
                hotplug.enable(new File(hc.getOriginPath()), null);
                pubSubService.fire("hotplug:enable", selfId + "," + sha1);
                return ajaxOk(null);
            }
        }
        return ajaxFail("没找到该插件");
    }

    @RequiresRoles("admin")
    @POST
    @At
    public NutMap delete(@Param("sha1")String sha1) throws Exception {
        for (HotplugConfig hc : Hotplug.getHotPlugJarList(true)) {
            if (sha1.equals(hc.getSha1())) {
                boolean ok = new File(hc.getOriginPath()).delete();
                new File(hc.getOriginPath()+".enable").delete();
                pubSubService.fire("hotplug:delete", selfId + "," + sha1);
                return ajaxOk(ok);
            }
        }
        return ajaxFail("没找到该插件");
    }
}

为了热加载

用的是5.0版本改的

估计搞不定,要改就用3.x吧

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