JavaEE error整理(不斷更新)

該文章用於整理開發中遇到的一些錯誤,及解決方法,不斷整理更新。html

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.jarjava

2. 加載出錯

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

當spring 配置多個properties 文件的時候須要特殊處理web

方式1:spring

    <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:mongodb

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

PS :  重要屬性:apache

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

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
 
 
一、首先關閉MyEclipse工做空間。
二、而後刪除工做空間下的
「/.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.
相關文章
相關標籤/搜索