NutzCN Logo
问答 IOC异常,不会解决了。
发布于 3118天前 作者 mingkaili 2606 次浏览 复制 上一个帖子 下一个帖子
标签:

org.nutz.ioc.IocException: Wrong type name: 'com.mxlvniao.common.PropertiesProxyManager' For object [propertiesProxyManager] - type:[] FAIL to create Ioc Bean name=[dataSource] FAIL to create Ioc Bean name=[dao] FAIL to create Ioc Bean name=[poiService] FAIL to create Ioc Bean name=[pOIAction]
at org.nutz.ioc.impl.ObjectMakerImpl.make(ObjectMakerImpl.java:147)
at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:204)
at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:229)
at org.nutz.mvc.impl.processor.ModuleProcessor.process(ModuleProcessor.java:116)
at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
at org.nutz.mvc.impl.processor.EncodingProcessor.process(EncodingProcessor.java:27)
at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
at org.nutz.mvc.impl.processor.UpdateRequestAttributesProcessor.process(UpdateRequestAttributesProcessor.java:15)
at org.nutz.mvc.impl.NutActionChain.doChain(NutActionChain.java:44)
at org.nutz.mvc.impl.ActionInvoker.invoke(ActionInvoker.java:67)
at org.nutz.mvc.ActionHandler.handle(ActionHandler.java:31)
at org.nutz.mvc.NutServlet.service(NutServlet.java:73)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
at com.translationTool.translate.demo.action.TestCase.test(TestCase.java:15)
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.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
at org.junit.runners.BlockJUnit4ClassRunner.runNotIgnored(BlockJUnit4ClassRunner.java:79)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:71)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: org.nutz.ioc.IocException: Wrong type name: 'com.mxlvniao.common.PropertiesProxyManager' For object [propertiesProxyManager] - type:[] FAIL to create Ioc Bean name=[dataSource] FAIL to create Ioc Bean name=[dao] FAIL to create Ioc Bean name=[poiService]
at org.nutz.ioc.impl.ObjectMakerImpl.make(ObjectMakerImpl.java:147)
at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:204)
at org.nutz.ioc.val.ReferTypeValue.get(ReferTypeValue.java:27)
at org.nutz.ioc.weaver.FieldInjector.inject(FieldInjector.java:31)
at org.nutz.ioc.weaver.DefaultWeaver.fill(DefaultWeaver.java:56)
at org.nutz.ioc.impl.ObjectMakerImpl.make(ObjectMakerImpl.java:135)
... 38 more
Caused by: org.nutz.ioc.IocException: Wrong type name: 'com.mxlvniao.common.PropertiesProxyManager' For object [propertiesProxyManager] - type:[] FAIL to create Ioc Bean name=[dataSource] FAIL to create Ioc Bean name=[dao]
at org.nutz.ioc.impl.ObjectMakerImpl.make(ObjectMakerImpl.java:147)
at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:204)
at org.nutz.ioc.val.ReferTypeValue.get(ReferTypeValue.java:27)
at org.nutz.ioc.weaver.FieldInjector.inject(FieldInjector.java:31)
at org.nutz.ioc.weaver.DefaultWeaver.fill(DefaultWeaver.java:56)
at org.nutz.ioc.impl.ObjectMakerImpl.make(ObjectMakerImpl.java:135)
... 43 more
Caused by: org.nutz.ioc.IocException: Wrong type name: 'com.mxlvniao.common.PropertiesProxyManager' For object [propertiesProxyManager] - type:[] FAIL to create Ioc Bean name=[dataSource]
at org.nutz.ioc.impl.ObjectMakerImpl.make(ObjectMakerImpl.java:147)
at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:204)
at org.nutz.ioc.val.ReferValue.get(ReferValue.java:24)
at org.nutz.ioc.impl.ObjectMakerImpl.make(ObjectMakerImpl.java:75)
... 48 more
Caused by: org.nutz.ioc.IocException: Wrong type name: 'com.mxlvniao.common.PropertiesProxyManager' For object [propertiesProxyManager] - type:[]
at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:211)
at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:229)
at org.nutz.ioc.java.IocObjectNode.getValue(IocObjectNode.java:19)
at org.nutz.ioc.java.ChainNode.eval(ChainNode.java:24)
at org.nutz.ioc.java.ChainNode.eval(ChainNode.java:19)
at org.nutz.ioc.val.JavaValue.get(JavaValue.java:69)
at org.nutz.ioc.weaver.FieldInjector.inject(FieldInjector.java:31)
at org.nutz.ioc.weaver.DefaultWeaver.fill(DefaultWeaver.java:56)
at org.nutz.ioc.impl.ObjectMakerImpl.make(ObjectMakerImpl.java:135)
... 51 more
Caused by: org.nutz.ioc.ObjectLoadException: Wrong type name: 'com.mxlvniao.common.PropertiesProxyManager'
at org.nutz.ioc.IocLoading.E(IocLoading.java:32)
at org.nutz.ioc.IocLoading.map2iobj(IocLoading.java:59)
at org.nutz.ioc.loader.map.MapLoader.load(MapLoader.java:86)
at org.nutz.ioc.loader.combo.ComboIocLoader.load(ComboIocLoader.java:147)
at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:176)
... 59 more
Caused by: java.lang.ClassNotFoundException: com.mxlvniao.common.PropertiesProxyManager
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at org.nutz.lang.Lang.loadClass(Lang.java:1989)
at org.nutz.ioc.IocLoading.map2iobj(IocLoading.java:55)
... 62 more

5 回复

类名写错了吧

Caused by: java.lang.ClassNotFoundException: com.mxlvniao.common.PropertiesProxyManager

package com.translationTool.common;

import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Properties;

import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.lang.Lang;
import org.nutz.lang.Strings;
import org.nutz.lang.util.MultiLineProperties;
import org.nutz.log.Log;
import org.nutz.log.Logs;
import org.nutz.resource.NutResource;
import org.nutz.resource.Scans;

/**
* 代理Properties文件,以便直接在Ioc配置文件中使用
*
* @author wendal(wendal1985@gmail.com)
* @author zozoh(zozohtnt@gmail.com)
*
* @since 1.b.37
*/
@IocBean
public class PropertiesProxyManager {

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

// 是否为UTF8格式的Properties文件
private final boolean utf8;
// 是否忽略无法加载的文件
private boolean ignoreResourceNotFound = false;

private MultiLineProperties mp = new MultiLineProperties();

public PropertiesProxyManager() {
    this(true);
}

public PropertiesProxyManager(boolean utf8) {
    this.utf8 = utf8;
}

public PropertiesProxyManager(String... paths) {
    this(true);
    this.setPaths(paths);
}

public PropertiesProxyManager(InputStream in) {
    this(true);
    try {
        mp = new MultiLineProperties();
        mp.load(new InputStreamReader(in));
    }
    catch (IOException e) {
        throw Lang.wrapThrow(e);
    }
}

/**
 * @param r
 *            文本输入流
 * @since 1.b.50
 */
public PropertiesProxyManager(Reader r) {
    this(true);
    try {
        mp = new MultiLineProperties();
        mp.load(r);
    }
    catch (IOException e) {
        throw Lang.wrapThrow(e);
    }
}

/**
 * 加载指定文件/文件夹的Properties文件,合并成一个Properties对象
 * <p>
 * <b style=color:red>如果有重复的key,请务必注意加载的顺序!!<b/>
 * 
 * @param paths
 *            需要加载的Properties文件路径
 */
public void setPaths(String... paths) {
    mp = new MultiLineProperties();

    try {
        List<NutResource> list = getResources(paths);
        if (utf8)
            for (NutResource nr : list)
                mp.load(nr.getReader(), false);
        else {
            Properties p = new Properties();
            for (NutResource nr : list) {
                p.load(nr.getInputStream());
            }
            mp.putAll(p);
        }
    }
    catch (IOException e) {
        throw Lang.wrapThrow(e);
    }
}

/**
 * 加载指定文件/文件夹的Properties文件
 * 
 * @param paths
 *            需要加载的Properties文件路径
 * @return 加载到的Properties文件Resource列表
 */
private List<NutResource> getResources(String... paths) {
    List<NutResource> list = new ArrayList<NutResource>();
    for (String path : paths) {
        try {
            List<NutResource> resources = Scans.me()
                                               .loadResource("^.+[.]properties$",
                                                             path);
            list.addAll(resources);
        }
        catch (Exception e) {
            if (ignoreResourceNotFound) {
                if (log.isWarnEnabled()) {
                    log.warn("Could not load resource from "
                             + path
                             + ": "
                             + e.getMessage());
                }
            } else {
                throw Lang.wrapThrow(e);
            }
        }
    }
    return list;
}

public void setIgnoreResourceNotFound(boolean ignoreResourceNotFound) {
    this.ignoreResourceNotFound = ignoreResourceNotFound;
}

/**
 * @param key
 *            键
 * @return 是否包括这个键
 * @since 1.b.50
 */
public boolean has(String key) {
    return mp.containsKey(key);
}

public void put(String key, String value) {
    mp.put(key, value);
}

public String get(String key) {
    return mp.get(key);
}

public String get(String key, String version) {
    String str = key+get(version);
    return get(str);
}


public String trim(String key) {
    return Strings.trim(get(key));
}

public String trim(String key, String defaultValue) {
    return Strings.trim(get(key, defaultValue));
}

public int getInt(String key) {
    return getInt(key, -1);
}

public int getInt(String key, int defaultValue) {
    try {
        return Integer.parseInt(get(key));
    }
    catch (NumberFormatException e) {
        return defaultValue;
    }
}

public long getLong(String key) {
    return getLong(key, -1);
}

public long getLong(String key, long dfval) {
    try {
        return Long.parseLong(get(key));
    }
    catch (NumberFormatException e) {
        return dfval;
    }
}

public String getTrim(String key) {
    return Strings.trim(get(key));
}

public String getTrim(String key, String defaultValue) {
    return Strings.trim(get(key, defaultValue));
}

public List<String> getKeys() {
    return mp.keys();
}

public Collection<String> getValues() {
    return mp.values();
}

public Properties toProperties() {
    Properties p = new Properties();
    for (String key : mp.keySet()) {
        p.put(key, mp.get(key));
    }
    return p;
}

public Map<String, String> toMap() {
    return new HashMap<String, String>(mp);
}

}

@wendal 哪个类名 ?使这个吗? PropertiesProxyManager?

你贴的代码头部写的是:

package com.translationTool.common;

报错信息提示的是

Caused by: java.lang.ClassNotFoundException: com.mxlvniao.common.PropertiesProxyManager

两者对不上呢

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