• JavaEE error整理(不断更新)


    该文章用于整理开发中遇到的一些错误,及解决方法,不断整理更新。

    1. 缺包异常

    异常1:
    java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory
    at org.springframework.web.context.ContextLoader.<clinit>(ContextLoader.java:146)
    at org.springframework.web.context.ContextLoaderListener.createContextLoader(ContextLoaderListener.java:53)
    at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:44)
    需要加上:commons-logging.jar,log4j-1.2.11.jar
    ———————————————————————————
    异常2:
    org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from class path resource [text.xml]; nested exception is java.lang.NoClassDefFoundError: org/aspectj/weaver/reflect/ReflectionWorld$ReflectionWorldException
    Caused by: java.lang.NoClassDefFoundError: org/aspectj/weaver/reflect/ReflectionWorld$ReflectionWorldException
    at java.lang.Class.forName0(Native Method)
    需要加上:aspectjweaver.jar
    ———————————————————————————
    异常3:
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘logBean’ defined in class path resource [spring.xml]: Initialization of bean failed; nested exception is org.springframework.aop.framework.AopConfigException: Cannot proxy target class because CGLIB2 is not available. Add CGLIB to the class path or specify proxy interfaces.
    Caused by: org.springframework.aop.framework.AopConfigException: Cannot proxy target class because CGLIB2 is not available. Add CGLIB to the class path or specify proxy interfaces.
    需要加上:cglib-2.1.3.jar
    ———————————————————————————
    异常4:
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘logBean’ defined in class path resource of ServletContext: Instantiation of bean failed; nested exception is java.lang.NoClassDefFoundError: javax/transaction/TransactionManager
    java.lang.NoClassDefFoundError: javax/transaction/TransactionManager
    需要加上:jta.jar
    ———————————————————————————
    异常6:
    java.lang.NoClassDefFoundError: org/dom4j/Attribute
    需要加上:dom4j.jar
    ———————————————————————————
    异常7:
    java.lang.NoClassDefFoundError: net/sf/ehcache/CacheException
    需要加上:ehcache.jar
    ———————————————————————————
    异常8:
    java.lang.NoClassDefFoundError: net/sf/cglib/core/KeyFactory
    需要加上:cglib-full.jar

    2. 加载出错

    2.1 <context:property-placeholder>:Could not resolve placeholder XXX in string value XXX

    当spring 配置多个properties 文件的时候需要特殊处理

    方式1:

        <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
            <property name="locations">
                <list>
                    <value>classpath*:mongodb.properties</value>
                    <value>classpath*:xxx.properties</value>
                    <value>classpath*:bbb.properties</value>
                </list>
            </property>
            <property name="ignoreUnresolvablePlaceholders" value="true" /> 
        </bean>

     方式2:

    <context:property-placeholder location="classpath*:xxx.properties" ignore-unresolvable="true" />

    PS :  重要属性:

    <property name="ignoreUnresolvablePlaceholders" value="true" />    ignore-unresolvable="true"

    2.2 Errors running builder 'DeploymentBuilder' on project_java 

    此问题一般发生在Myeclipse 保存文件并自动部署时候。
    Errors occurred during the build.
    Errors running builder 'DeploymentBuilder' on project '项目名'.
    java.lang.NullPointerException
     
    有一种产生此错误的原因是因为此项目不不是由myeclipse创建的。
    所以你需要检查.project 文件。
    并且添加com.genuitec.eclipse.j2eedt.core.webnature
     
     
    1、首先关闭MyEclipse工作空间。
    2、然后删除工作空间下的
    “/.metadata/.plugins/org.eclipse.core.runtime/.settings/com.genuitec.eclipse.ast.deploy.core.prefs”
     
    取消myeclipse的自动部署:
    右键点击项目 ->properties -> Builders ,将DeploymentBuilder勾选去除.

    3 Other

    在myeclipse中启动tomcat自动进入debug 解决方法

    将你的服务器启动方式设置为run方式,不要设置为debug方式。
    具体采用的方法:
    如下:
    window->preferences  然后找到你的tomcat所在的目录,打开launch窗口,然后修改tomcat lanuch mode为Run mode。然后点击Apply,最后点击OK.
    这样设置之后,以后服务器就是在run mode下运行了
    如果你不这样设置,那就在每次启动的时候,选择run server,而不是debug server.
  • 相关阅读:
    webpy使用笔记(一)
    如何衡量离散程度
    Hash哈希(二)一致性Hash(C++实现)
    Hash哈希(一)
    sqlmap使用笔记
    Windows7 IIS7.5 HTTP Error 503 The service is unavailable 另类解决方案
    [转]IP动态切换脚本
    全国各地电信DNS服务器地址
    比较好的汉字拼音化类
    c#读取INI文件类
  • 原文地址:https://www.cnblogs.com/loveincode/p/7551900.html
Copyright © 2020-2023  润新知