NutzCN Logo
问答 AbstractProcessor实现类获取ioc对象出错
发布于 2518天前 作者 qq_d6c9c504 1837 次浏览 复制 上一个帖子 下一个帖子
标签:

我需要拿到jedisAgent对象,不知道怎么取

public class AttackProcessor extends AbstractProcessor {
    private static final Log log = Logs.get();

    protected JedisAgent jedisAgent;

    public void init(NutConfig config, ActionInfo ai) throws Throwable {
        jedisAgent = config.getIoc().get(JedisAgent.class);
    }

    @Override
    public void process(ActionContext ac) throws Throwable {
        String userAgent = Toolkit.userAgent();
        if(userAgent.contains("baidu")){
            return;
        }
        String ipStr = Toolkit.ip();
        if(StringUtils.isNotBlank(ipStr) && !ipStr.equalsIgnoreCase("-")){
            List<String> ips = Splitter.on(",").splitToList(ipStr);
            String ip = ips.get(ips.size()-1);
            try (Jedis jedis = jedisAgent.getResource()) {
                if(jedis.exists(ip)){
                    long count = jedis.incr(ip);
                    if(count>=5){
                        log.infof("ip=%s",ip);
                        return;
                    }
                }else{
                    jedis.setex(ip, 86400,"1");
                }
            }
        }
        doNext(ac);
    }
}

下面是错误日志

12:50:01.464 ERROR (NutLoading.java:125) load - Error happend during start serivce!
org.nutz.ioc.IocException: IocBean[jedisAgent] throw Exception when creating
	at org.nutz.ioc.impl.ObjectMakerImpl.make(ObjectMakerImpl.java:152) ~[nutz-1.r.65-SNAPSHOT.jar:1.r.65-SNAPSHOT]
	at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:240) ~[nutz-1.r.65-SNAPSHOT.jar:1.r.65-SNAPSHOT]
	at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:270) ~[nutz-1.r.65-SNAPSHOT.jar:1.r.65-SNAPSHOT]
	at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:160) ~[nutz-1.r.65-SNAPSHOT.jar:1.r.65-SNAPSHOT]
	at net.wendal.nutzbook.yvr.processor.AttackProcessor.init(AttackProcessor.java:29) ~[nutzcn-yvr-3.1.0.jar:3.1.0]
	at org.nutz.mvc.impl.NutActionChainMaker.eval(NutActionChainMaker.java:38) ~[nutz-1.r.65-SNAPSHOT.jar:1.r.65-SNAPSHOT]
	at org.nutz.mvc.impl.UrlMappingImpl.add(UrlMappingImpl.java:54) ~[nutz-1.r.65-SNAPSHOT.jar:1.r.65-SNAPSHOT]
	at org.nutz.plugins.apidoc.ApidocUrlMapping.add(ApidocUrlMapping.java:92) ~[nutzcn-core-3.1.0.jar:3.1.0]
	at org.nutz.mvc.impl.NutLoading.evalUrlMapping(NutLoading.java:205) ~[nutz-1.r.65-SNAPSHOT.jar:1.r.65-SNAPSHOT]
	at org.nutz.mvc.impl.NutLoading.load(NutLoading.java:108) [nutz-1.r.65-SNAPSHOT.jar:1.r.65-SNAPSHOT]
	at org.nutz.plugins.hotplug.Hotplug.load(Hotplug.java:117) [nutzcn-core-3.1.0.jar:3.1.0]
	at org.nutz.mvc.ActionHandler.<init>(ActionHandler.java:19) [nutz-1.r.65-SNAPSHOT.jar:1.r.65-SNAPSHOT]
	at org.nutz.mvc.NutFilter._init(NutFilter.java:91) [nutz-1.r.65-SNAPSHOT.jar:1.r.65-SNAPSHOT]
	at org.nutz.mvc.NutFilter.init(NutFilter.java:69) [nutz-1.r.65-SNAPSHOT.jar:1.r.65-SNAPSHOT]
	at org.eclipse.jetty.servlet.FilterHolder.initialize(FilterHolder.java:139) [jetty-servlet-9.4.8.v20171121.jar:9.4.8.v20171121]
	at org.eclipse.jetty.servlet.ServletHandler.initialize(ServletHandler.java:741) [jetty-servlet-9.4.8.v20171121.jar:9.4.8.v20171121]
	at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:348) [jetty-servlet-9.4.8.v20171121.jar:9.4.8.v20171121]
	at org.eclipse.jetty.webapp.WebAppContext.startWebapp(WebAppContext.java:1515) [jetty-webapp-9.4.8.v20171121.jar:9.4.8.v20171121]
	at org.eclipse.jetty.maven.plugin.JettyWebAppContext.startWebapp(JettyWebAppContext.java:360) [jetty-maven-plugin-9.4.8.v20171121.jar:9.4.8.v20171121]
	at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1477) [jetty-webapp-9.4.8.v20171121.jar:9.4.8.v20171121]
	at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:785) [jetty-server-9.4.8.v20171121.jar:9.4.8.v20171121]
	at org.eclipse.jetty.servlet.ServletContextHandler.doStart(ServletContextHandler.java:261) [jetty-servlet-9.4.8.v20171121.jar:9.4.8.v20171121]
	at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:545) [jetty-webapp-9.4.8.v20171121.jar:9.4.8.v20171121]
	at org.eclipse.jetty.maven.plugin.JettyWebAppContext.doStart(JettyWebAppContext.java:428) [jetty-maven-plugin-9.4.8.v20171121.jar:9.4.8.v20171121]
	at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68) [jetty-util-9.4.8.v20171121.jar:9.4.8.v20171121]
	at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:133) [jetty-util-9.4.8.v20171121.jar:9.4.8.v20171121]
	at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:115) [jetty-util-9.4.8.v20171121.jar:9.4.8.v20171121]
	at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:113) [jetty-server-9.4.8.v20171121.jar:9.4.8.v20171121]
	at org.eclipse.jetty.server.handler.ContextHandlerCollection.doStart(ContextHandlerCollection.java:167) [jetty-server-9.4.8.v20171121.jar:9.4.8.v20171121]

25 回复

报错信息没贴全的样子

12:50:01.393 INFO  (NutLoading.java:159) evalUrlMapping - Build URL mapping by org.nutz.plugins.apidoc.ApidocUrlMapping ...
12:50:01.464 ERROR (NutLoading.java:125) load - Error happend during start serivce!
org.nutz.ioc.IocException: IocBean[jedisAgent] throw Exception when creating
	at org.nutz.ioc.impl.ObjectMakerImpl.make(ObjectMakerImpl.java:152) ~[nutz-1.r.65-SNAPSHOT.jar:1.r.65-SNAPSHOT]
	at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:240) ~[nutz-1.r.65-SNAPSHOT.jar:1.r.65-SNAPSHOT]
	at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:270) ~[nutz-1.r.65-SNAPSHOT.jar:1.r.65-SNAPSHOT]
	at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:160) ~[nutz-1.r.65-SNAPSHOT.jar:1.r.65-SNAPSHOT]
	at net.wendal.nutzbook.yvr.processor.AttackProcessor.init(AttackProcessor.java:29) ~[nutzcn-yvr-3.1.0.jar:3.1.0]
	at org.nutz.mvc.impl.NutActionChainMaker.eval(NutActionChainMaker.java:38) ~[nutz-1.r.65-SNAPSHOT.jar:1.r.65-SNAPSHOT]
	at org.nutz.mvc.impl.UrlMappingImpl.add(UrlMappingImpl.java:54) ~[nutz-1.r.65-SNAPSHOT.jar:1.r.65-SNAPSHOT]
	at org.nutz.plugins.apidoc.ApidocUrlMapping.add(ApidocUrlMapping.java:92) ~[nutzcn-core-3.1.0.jar:3.1.0]
	at org.nutz.mvc.impl.NutLoading.evalUrlMapping(NutLoading.java:205) ~[nutz-1.r.65-SNAPSHOT.jar:1.r.65-SNAPSHOT]
	at org.nutz.mvc.impl.NutLoading.load(NutLoading.java:108) [nutz-1.r.65-SNAPSHOT.jar:1.r.65-SNAPSHOT]
	at org.nutz.plugins.hotplug.Hotplug.load(Hotplug.java:117) [nutzcn-core-3.1.0.jar:3.1.0]
	at org.nutz.mvc.ActionHandler.<init>(ActionHandler.java:19) [nutz-1.r.65-SNAPSHOT.jar:1.r.65-SNAPSHOT]
	at org.nutz.mvc.NutFilter._init(NutFilter.java:91) [nutz-1.r.65-SNAPSHOT.jar:1.r.65-SNAPSHOT]
	at org.nutz.mvc.NutFilter.init(NutFilter.java:69) [nutz-1.r.65-SNAPSHOT.jar:1.r.65-SNAPSHOT]
	at org.eclipse.jetty.servlet.FilterHolder.initialize(FilterHolder.java:139) [jetty-servlet-9.4.8.v20171121.jar:9.4.8.v20171121]
	at org.eclipse.jetty.servlet.ServletHandler.initialize(ServletHandler.java:741) [jetty-servlet-9.4.8.v20171121.jar:9.4.8.v20171121]
	at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:348) [jetty-servlet-9.4.8.v20171121.jar:9.4.8.v20171121]
	at org.eclipse.jetty.webapp.WebAppContext.startWebapp(WebAppContext.java:1515) [jetty-webapp-9.4.8.v20171121.jar:9.4.8.v20171121]
	at org.eclipse.jetty.maven.plugin.JettyWebAppContext.startWebapp(JettyWebAppContext.java:360) [jetty-maven-plugin-9.4.8.v20171121.jar:9.4.8.v20171121]
	at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1477) [jetty-webapp-9.4.8.v20171121.jar:9.4.8.v20171121]
	at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:785) [jetty-server-9.4.8.v20171121.jar:9.4.8.v20171121]
	at org.eclipse.jetty.servlet.ServletContextHandler.doStart(ServletContextHandler.java:261) [jetty-servlet-9.4.8.v20171121.jar:9.4.8.v20171121]
	at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:545) [jetty-webapp-9.4.8.v20171121.jar:9.4.8.v20171121]
	at org.eclipse.jetty.maven.plugin.JettyWebAppContext.doStart(JettyWebAppContext.java:428) [jetty-maven-plugin-9.4.8.v20171121.jar:9.4.8.v20171121]
	at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68) [jetty-util-9.4.8.v20171121.jar:9.4.8.v20171121]
	at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:133) [jetty-util-9.4.8.v20171121.jar:9.4.8.v20171121]
	at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:115) [jetty-util-9.4.8.v20171121.jar:9.4.8.v20171121]
	at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:113) [jetty-server-9.4.8.v20171121.jar:9.4.8.v20171121]
	at org.eclipse.jetty.server.handler.ContextHandlerCollection.doStart(ContextHandlerCollection.java:167) [jetty-server-9.4.8.v20171121.jar:9.4.8.v20171121]
	at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68) [jetty-util-9.4.8.v20171121.jar:9.4.8.v20171121]
	at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:133) [jetty-util-9.4.8.v20171121.jar:9.4.8.v20171121]
	at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:115) [jetty-util-9.4.8.v20171121.jar:9.4.8.v20171121]
	at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:113) [jetty-server-9.4.8.v20171121.jar:9.4.8.v20171121]
	at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68) [jetty-util-9.4.8.v20171121.jar:9.4.8.v20171121]
	at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:133) [jetty-util-9.4.8.v20171121.jar:9.4.8.v20171121]
	at org.eclipse.jetty.server.Server.start(Server.java:418) [jetty-server-9.4.8.v20171121.jar:9.4.8.v20171121]
	at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:107) [jetty-util-9.4.8.v20171121.jar:9.4.8.v20171121]
	at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:113) [jetty-server-9.4.8.v20171121.jar:9.4.8.v20171121]
	at org.eclipse.jetty.server.Server.doStart(Server.java:385) [jetty-server-9.4.8.v20171121.jar:9.4.8.v20171121]
	at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68) [jetty-util-9.4.8.v20171121.jar:9.4.8.v20171121]
	at org.eclipse.jetty.maven.plugin.AbstractJettyMojo.startJetty(AbstractJettyMojo.java:461) [jetty-maven-plugin-9.4.8.v20171121.jar:9.4.8.v20171121]
	at org.eclipse.jetty.maven.plugin.AbstractJettyMojo.execute(AbstractJettyMojo.java:327) [jetty-maven-plugin-9.4.8.v20171121.jar:9.4.8.v20171121]
	at org.eclipse.jetty.maven.plugin.JettyRunMojo.execute(JettyRunMojo.java:183) [jetty-maven-plugin-9.4.8.v20171121.jar:9.4.8.v20171121]
	at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134) [maven-core-3.3.9.jar:3.3.9]
	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207) [maven-core-3.3.9.jar:3.3.9]
	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153) [maven-core-3.3.9.jar:3.3.9]
	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145) [maven-core-3.3.9.jar:3.3.9]
	at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116) [maven-core-3.3.9.jar:3.3.9]
	at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80) [maven-core-3.3.9.jar:3.3.9]
	at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51) [maven-core-3.3.9.jar:3.3.9]
	at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128) [maven-core-3.3.9.jar:3.3.9]
	at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307) [maven-core-3.3.9.jar:3.3.9]
	at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193) [maven-core-3.3.9.jar:3.3.9]
	at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106) [maven-core-3.3.9.jar:3.3.9]
	at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863) [maven-embedder-3.3.9.jar:3.3.9]
	at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288) [maven-embedder-3.3.9.jar:3.3.9]
	at org.apache.maven.cli.MavenCli.main(MavenCli.java:199) [maven-embedder-3.3.9.jar:3.3.9]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_144]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_144]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_144]
	at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_144]
	at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289) [plexus-classworlds-2.5.2.jar:?]
	at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229) [plexus-classworlds-2.5.2.jar:?]
	at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415) [plexus-classworlds-2.5.2.jar:?]
	at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356) [plexus-classworlds-2.5.2.jar:?]
	at org.codehaus.classworlds.Launcher.main(Launcher.java:47) [plexus-classworlds-2.5.2.jar:?]
Caused by: java.lang.RuntimeException: IocBean[jedisAgent] fail at field=[conf]
	at org.nutz.ioc.weaver.FieldInjector.inject(FieldInjector.java:40) ~[nutz-1.r.65-SNAPSHOT.jar:1.r.65-SNAPSHOT]
	at org.nutz.ioc.weaver.DefaultWeaver.fill(DefaultWeaver.java:67) ~[nutz-1.r.65-SNAPSHOT.jar:1.r.65-SNAPSHOT]
	at org.nutz.ioc.impl.ObjectMakerImpl.make(ObjectMakerImpl.java:138) ~[nutz-1.r.65-SNAPSHOT.jar:1.r.65-SNAPSHOT]
	... 65 more
Caused by: org.nutz.ioc.IocException: IocBean[conf] For object [conf] - type:[]
	at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:249) ~[nutz-1.r.65-SNAPSHOT.jar:1.r.65-SNAPSHOT]
	at org.nutz.ioc.val.ReferValue.get(ReferValue.java:24) ~[nutz-1.r.65-SNAPSHOT.jar:1.r.65-SNAPSHOT]
	at org.nutz.ioc.weaver.FieldInjector.inject(FieldInjector.java:32) ~[nutz-1.r.65-SNAPSHOT.jar:1.r.65-SNAPSHOT]
	at org.nutz.ioc.weaver.DefaultWeaver.fill(DefaultWeaver.java:67) ~[nutz-1.r.65-SNAPSHOT.jar:1.r.65-SNAPSHOT]
	at org.nutz.ioc.impl.ObjectMakerImpl.make(ObjectMakerImpl.java:138) ~[nutz-1.r.65-SNAPSHOT.jar:1.r.65-SNAPSHOT]
	... 65 more
Caused by: org.nutz.ioc.ObjectLoadException: Object 'conf' without define!
	at org.nutz.ioc.loader.combo.ComboIocLoader.load(ComboIocLoader.java:157) ~[nutz-1.r.65-SNAPSHOT.jar:1.r.65-SNAPSHOT]
	at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:194) ~[nutz-1.r.65-SNAPSHOT.jar:1.r.65-SNAPSHOT]
	at org.nutz.ioc.val.ReferValue.get(ReferValue.java:24) ~[nutz-1.r.65-SNAPSHOT.jar:1.r.65-SNAPSHOT]
	at org.nutz.ioc.weaver.FieldInjector.inject(FieldInjector.java:32) ~[nutz-1.r.65-SNAPSHOT.jar:1.r.65-SNAPSHOT]
	at org.nutz.ioc.weaver.DefaultWeaver.fill(DefaultWeaver.java:67) ~[nutz-1.r.65-SNAPSHOT.jar:1.r.65-SNAPSHOT]
	at org.nutz.ioc.impl.ObjectMakerImpl.make(ObjectMakerImpl.java:138) ~[nutz-1.r.65-SNAPSHOT.jar:1.r.65-SNAPSHOT]
	... 65 more
12:50:01.469 ERROR (NutLoading.java:127) load - try to depose ioc

缺配置信息的ioc bean呢

Object 'conf' without define!

这个在哪定义的呢,我是用的nutz论坛项目

core下面只有mail的ioc配置

我这写法和CoreMainSetup里面写有区别吗?为啥CoreMainSetup可以运行呢

public class CoreMainSetup implements Setup {

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

    public void init(NutConfig nc) {
		// 检查环境,必须运行在UTF-8环境
		if (!Charset.defaultCharset().name().equalsIgnoreCase(Encoding.UTF8)) {
			log.error("This project must run in UTF-8, pls add -Dfile.encoding=UTF-8 to JAVA_OPTS");
		}
		// Log4j 2.x的JMX默认启用,会导致reload时内存不释放!!
		if (!"true".equals(System.getProperty("log4j2.disable.jmx")))
		    log.error("log4j2 jmx will case reload memory leak! pls add -Dlog4j2.disable.jmx=true to JAVA_OPTS");
		
		R.setR(new SecureRandom());

		// 获取Ioc容器及Dao对象
		Ioc ioc = nc.getIoc();

        Dao dao = ioc.get(Dao.class);
        // 获取配置对象
        conf = ioc.get(PropertiesProxy.class, "conf");

		// 初始化JedisAgent
		JedisAgent jedisAgent = ioc.get(JedisAgent.class);
        
        // 为全部标注了@Table的bean建表
        Daos.createTablesInPackage(dao, getClass().getPackage().getName(), false);

		// 获取NutQuartzCronJobFactory从而触发计划任务的初始化与启动
		ioc.get(NutQuartzCronJobFactory.class);

		Mvcs.disableFastClassInvoker = false;
		
		// BeetlViewMaker要处理一下
		for (ViewMaker vm : nc.getViewMakers()) {
            if (vm instanceof BeetlViewMaker) {
                GroupTemplate groupTemplate = ((BeetlViewMaker)vm).groupTemplate;
                Map<String, Object> share = groupTemplate.getSharedVars();
                if (share == null) {
                    share = new NutMap();
                    groupTemplate.setSharedVars(share);
                }
                NutMap re = Toolkit.getTemplateShareVars();
                share.putAll(re);
                groupTemplate.getSharedVars().put("ioc", ioc);
                groupTemplate.getSharedVars().put("conf", conf);
                groupTemplate.getSharedVars().put("cdnbase", "");// 暂时弃用
            }
        }
	}

改成这样试试

public class AttackProcessor extends AbstractProcessor {
    private static final Log log = Logs.get();

    protected JedisAgent jedisAgent;

    public void init(NutConfig config, ActionInfo ai) throws Throwable {

    }

    @Override
    public void process(ActionContext ac) throws Throwable {
        String userAgent = Toolkit.userAgent();
        if(userAgent.contains("baidu")){
            return;
        }
        String ipStr = Toolkit.ip();
        if(StringUtils.isNotBlank(ipStr) && !ipStr.equalsIgnoreCase("-")){
            List<String> ips = Splitter.on(",").splitToList(ipStr);
            String ip = ips.get(ips.size()-1);
            if (jedisAgent == null)
                jedisAgent = ac.getIoc().get(JedisAgent.class);
            try (Jedis jedis = jedisAgent.getResource()) {
                if(jedis.exists(ip)){
                    long count = jedis.incr(ip);
                    if(count>=5){
                        log.infof("ip=%s",ip);
                        return;
                    }
                }else{
                    jedis.setex(ip, 86400,"1");
                }
            }
        }
        doNext(ac);
    }
}

还是不行呢,空指针异常

哪里空指针?

CoreMainSetup初始化了JedisAgent ,理论上应该能从ioc拿到,难道AbstractProcessor初始化比CoreMainSetup早?

13:24:19.625 WARN  (FailProcessor.java:28) process - Error@/ :
java.lang.NullPointerException
	at net.wendal.nutzbook.yvr.processor.AttackProcessor.process(AttackProcessor.java:41) ~[nutzcn-yvr-3.1.0.jar:3.1.0]
	at org.nutz.mvc.impl.NutActionChain.doChain(NutActionChain.java:44) [nutz-1.r.65-SNAPSHOT.jar:1.r.65-SNAPSHOT]
	at org.nutz.mvc.impl.ActionInvoker.invoke(ActionInvoker.java:67) [nutz-1.r.65-SNAPSHOT.jar:1.r.65-SNAPSHOT]
	at org.nutz.mvc.ActionHandler.handle(ActionHandler.java:31) [nutz-1.r.65-SNAPSHOT.jar:1.r.65-SNAPSHOT]
	at org.nutz.mvc.NutFilter.doFilter(NutFilter.java:202) [nutz-1.r.65-SNAPSHOT.jar:1.r.65-SNAPSHOT]
	at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1637) [jetty-servlet-9.4.8.v20171121.jar:9.4.8.v20171121]
	at org.nutz.plugins.hotplug.HotplugFilter.doFilter(HotplugFilter.java:73) [nutzcn-core-3.1.0.jar:3.1.0]
	at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1637) [jetty-servlet-9.4.8.v20171121.jar:9.4.8.v20171121]
	at org.apache.shiro.web.servlet.AbstractShiroFilter.executeChain(AbstractShiroFilter.java:449) [nutzcn-core-3.1.0.jar:3.1.0]
	at org.apache.shiro.web.servlet.AbstractShiroFilter$1.call(AbstractShiroFilter.java:365) [nutzcn-core-3.1.0.jar:3.1.0]
	at org.apache.shiro.subject.support.SubjectCallable.doCall(SubjectCallable.java:90) [nutzcn-core-3.1.0.jar:3.1.0]
	at org.apache.shiro.subject.support.SubjectCallable.call(SubjectCallable.java:83) [nutzcn-core-3.1.0.jar:3.1.0]
	at org.apache.shiro.subject.support.DelegatingSubject.execute(DelegatingSubject.java:383) [nutzcn-core-3.1.0.jar:3.1.0]
	at org.apache.shiro.web.servlet.AbstractShiroFilter.doFilterInternal(AbstractShiroFilter.java:362) [nutzcn-core-3.1.0.jar:3.1.0]
	at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125) [nutzcn-core-3.1.0.jar:3.1.0]
	at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1629) [jetty-servlet-9.4.8.v20171121.jar:9.4.8.v20171121]
	at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:533) [jetty-servlet-9.4.8.v20171121.jar:9.4.8.v20171121]
	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143) [jetty-server-9.4.8.v20171121.jar:9.4.8.v20171121]
	at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:548) [jetty-security-9.4.8.v20171121.jar:9.4.8.v20171121]
	at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132) [jetty-server-9.4.8.v20171121.jar:9.4.8.v20171121]
	at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:190) [jetty-server-9.4.8.v20171121.jar:9.4.8.v20171121]
	at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:1595) [jetty-server-9.4.8.v20171121.jar:9.4.8.v20171121]
	at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:188) [jetty-server-9.4.8.v20171121.jar:9.4.8.v20171121]
	at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1253) [jetty-server-9.4.8.v20171121.jar:9.4.8.v20171121]
	at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:168) [jetty-server-9.4.8.v20171121.jar:9.4.8.v20171121]
	at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:473) [jetty-servlet-9.4.8.v20171121.jar:9.4.8.v20171121]
	at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:1564) [jetty-server-9.4.8.v20171121.jar:9.4.8.v20171121]
	at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:166) [jetty-server-9.4.8.v20171121.jar:9.4.8.v20171121]
	at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1155) [jetty-server-9.4.8.v20171121.jar:9.4.8.v20171121]
	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141) [jetty-server-9.4.8.v20171121.jar:9.4.8.v20171121]
	at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:219) [jetty-server-9.4.8.v20171121.jar:9.4.8.v20171121]
	at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:126) [jetty-server-9.4.8.v20171121.jar:9.4.8.v20171121]
	at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132) [jetty-server-9.4.8.v20171121.jar:9.4.8.v20171121]
	at org.eclipse.jetty.server.Server.handle(Server.java:530) [jetty-server-9.4.8.v20171121.jar:9.4.8.v20171121]
	at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:347) [jetty-server-9.4.8.v20171121.jar:9.4.8.v20171121]
	at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:256) [jetty-server-9.4.8.v20171121.jar:9.4.8.v20171121]
	at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:279) [jetty-io-9.4.8.v20171121.jar:9.4.8.v20171121]
	at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:102) [jetty-io-9.4.8.v20171121.jar:9.4.8.v20171121]
	at org.eclipse.jetty.io.ChannelEndPoint$2.run(ChannelEndPoint.java:124) [jetty-io-9.4.8.v20171121.jar:9.4.8.v20171121]
	at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:247) [jetty-util-9.4.8.v20171121.jar:9.4.8.v20171121]
	at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.produce(EatWhatYouKill.java:140) [jetty-util-9.4.8.v20171121.jar:9.4.8.v20171121]
	at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.run(EatWhatYouKill.java:131) [jetty-util-9.4.8.v20171121.jar:9.4.8.v20171121]
	at org.eclipse.jetty.util.thread.ReservedThreadExecutor$ReservedThread.run(ReservedThreadExecutor.java:382) [jetty-util-9.4.8.v20171121.jar:9.4.8.v20171121]
	at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:708) [jetty-util-9.4.8.v20171121.jar:9.4.8.v20171121]
	at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:626) [jetty-util-9.4.8.v20171121.jar:9.4.8.v20171121]
	at java.lang.Thread.run(Thread.java:748) [?:1.8.0_144]

jedisAgent是空的

 try (Jedis jedis = jedisAgent.getResource()) {

没加上我写的这两行?

            if (jedisAgent == null)
                jedisAgent = ac.getIoc().get(JedisAgent.class);

好了,谢谢兽总,在请教个问题,我在用nutz代码的时候,昨天遇到个诡异问题,就是重启的时候cup100%,有时候持续一个多小时才会降级下来,我以为是攻击导致的,我就把域名解析停掉。我重新启动,cup也是那么高。那时候没有访问,启动非常缓慢。不知道你遇到过这情况吗?我jstack出来也发现问题,可能水平问题

我们用了一个多月,一直没出现这情况

然后昨天晚上莫名的自己好了

下次遇到了, jmap 导出内存镜像看看吧

好的,感谢感谢,如果AttackProcessor要获取dao操作数据库,还是在porcess方法一样获取?

是的, 还不知道是哪里的问题,但porcess里面肯定能取到

兽总,cup高的例子又出现了,出现的时候会报错
ue Jan 30 14:53:00 CST 2018 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.

然后我jmap出来txt文件

&useSSL=false我加这个也不行

txt? 得输出dump文件呢,在qq群里发dump文件给我吧

现在又降下去了,我复现下

跟ssl没关系的。。。

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