spring/hibernate/struts 2よくある異常総括

7175 ワード

  • Spring
  • ①Class NotFoundException:org.aspectj.weaver.refrectt.Reflection World$Reflection World Exception
    aspectjweaver.jarに欠けています.このjarカバンはspring aopによく使われています.
     
    ②java.lag.lassNotFoundException:org.spring frame ework.web.com ntxt.context Loader L 
    http://blessht.iteye.com/blog/1104450
     
    ③java.lang.NoSuchMethodException:$Proxy 7.メソッド名()
    spring aopでよく見られますが、aopの実現は代理店で、java分野の代理は2種類あります.jdkはインターフェースに対するコードとcglibはクラスのコードに対して持っています.spring aopはデフォルトでjdkインターフェースエージェントを使用しています.ある時訪問したbeanはインターフェースがないので、以上の問題が発生します.解決方法:aop構成で代理タイプを修正します.
     
    <aop:config proxy-target-class="true">
     
    ④Class NotFoundException javax/mail/MessagingException
    springはjavamalsenderigplを配置する時にエラーが発生しました.原因はmail.jarのこのカバンが足りないからです.このjarをプロジェクトlibに入れてもいいです.
     
    ⑤:cvc-complex-type.2.1:The matching wildcard is stric,butのdeclaration can be found for element'aop:config'.これはspring配置がaop命名規則に導入されていないことによるものです.下のこの部分は比較的に完全なネーミングルールです.
    <beans xmlns="http://www.springframework.org/schema/beans"
    	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:util="http://www.springframework.org/schema/util"
    	xmlns:tx="http://www.springframework.org/schema/tx" xmlns:aop="http://www.springframework.org/schema/aop"
    	xmlns:mvc="http://www.springframework.org/schema/mvc"
    	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
       http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd
       http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd  
       http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd"
       default-autowire="byName">
    
    <beans>
     
    ⑥起動項目が正常で、Controller時報にアクセスが間違っている
    java.lang.Null PointerException
    at org.springframe ework.web.servlet.DisplatServlet.processHandlerException(DisplatServlet.java:1003)
    at org.springframe ework.web.servlet.DisplatServlet.doDisplatch(DisplatServlet.java:792)
    at org.springframe ework.web.servlet.DisplatServlet.doService(DisplatSertch Servlet.java:716)
    へへ,この問題は私が新しい環境を作る時、私を困らせます.最初はexceptionResolaverが間違っていたと思いましたが、コメントを落としても無駄です.その後、各注釈が必要でないものはやはり誤報します.最終的に自分がorg.springframe ebork.web.servlet.Disppatch Servletを再実現したかと思うと、元に戻すか、springでデフォルトしています.結果は間違いないです.
    それから、私は自分のコードをよく見て、問題を発見しました.次のコードを見て、initStrategiesはとても重要です.開発者はシステムの中に各種の初期化操作を追加できます.しかし、super.init Strategiesを呼び出すことを忘れないでください.この方法はspring mvcを自分で初期化して使わなければならないのです.この文を削除して他のコードを追加したので、意味不明なエラーを引き起こしました.
    public class YdDispatcherServlet extends DispatcherServlet {
    	private static final long serialVersionUID = -8834249973970757619L;
    	
    	/**
    	 *   servlet init    ,          
    	 */
    	@Override	
    	protected void initStrategies(ApplicationContext context) {
    		//super.initStrategies(context);          
    	}
    }
     
     
     
  • ヒベルナタ
  • ①Unbale to locate apprate constructor on class
    指定類に対応する構造方法が見つからないので、hqlによく現れます.hqlの各タイプはHbernate構造方法に対応しています.また、構造方法の各パラメータタイプはhbm.xmlファイルに対応しています.
     
    ②org.hibernate.hql.ast.QuerySyntxException:unexpected token:ON near line 1
    異常はHQLの上で発生します. a.name、b.age from テーブルA a. left ジョン テーブル b ON a.id=b.id.もともとHibernateはONという表現をサポートしていませんでしたが、2つの表の関係を確立するにはWHEREに代わりONすればいいです.
    プロジェクト a.name、b.age from テーブルA a. left ジョン テーブル b where a.id=b.id
     
    ③java.lang.Null PointerException at org.hibernate.dialect.Dialect$3.get ReturnType(Dialect.java:125)
    異常はHQLで発生します.select a.name、sum(b.age)from Table a left jee Table a.id=b.id、異常発生原因は以下の④番目と同じです.
     
    ④org.hibernate.hql.ast.QuerySyntxException:Path expected for jin! 
    異常はHQLで発生しました.select a.name、count(b.age)from Table a left join TableB b where a.id=b.idです.③と④の異常は同じ原因です.もともとベクターでは、2つの表にone-to-manyのようなマッピング関係がないと、ジョインは使えません.③番目はsumとjoinが同時に発生したためのエラーで、④番目はleft joinがあるためです.修正方法は、left joinをカンマで「置換」します.select a.name、sum(b.age)from Tablea、TableB b where a.id=b.id
     
    ⑤バッtch udate returned unexpected row count from udate:0 actual row count:0 expected:1.私のコードは以下の通りです.ヒベルナトは耐久性が優れています.set方法で自動的にデータベースをアップロードできますが、このコードを実行する時はやはり上のエラーを報告します.
    User user = session.get(User.class,userId);
    user.setName("xxx");//    
     最後に原因を探してみると、Userテーブルはデータベース内で自己増加していますが、このデータはUIDによって保存されたキーです.最後に私はデータベースに行ってメインキーを増減してから間違えないようにしました.とてもおかしいです.
     
    ⑥Hibernate Exception:No Session found for current thread
    session Factory.current Sessionを通じてSessionオブジェクトを取得できませんでした.環境によって場面が違ってきます.Spring 3+Hibenate 4を統合する際に発生した問題です.
    以下の2つの解決策を考える.
    ソリューション1:spring配置session Factory Bernに、hibernate.current_を追加します.session_context.クラス属性の注入は以下のコードです.
    <property name="hibernateProperties">
      <props>
        ......
        <prop key="hibernate.current_session_context_class">org.springframework.orm.hibernate4.SpringSessionContext</prop>
        ......		
      </props>
    </property>
     
    方案二:説明式事務配置の断面表現が正しくない
    次の表式のように、私が望んでいる事務範囲はcomp.demo.任意の階層.manager.下級類.任意の方法(任意のパラメータ)ですが、ここの**と*は同じ意味ですので、彼の本当の事務範囲はcomp.demo.サブパッケージ.manager.下級類.任意の方法(任意のパラメータ)です.
    <!--      -->
    <aop:config >
        <aop:advisor advice-ref="txAdvice" pointcut="execution(* com.demo.**.manager.*.*(..)))" /> 
    </aop:config>
     解决方法は***を...
    <aop:advisor advice-ref="txAdvice" pointcut="execution(* com.demo..manager.*.*(..)))" /> 
     
    ⑦ java.lang.IllgalArgmentException:node to trverse cannot be null!
    HQL時報のこのような誤りを実行して、HQL文法が問題があることを表して、例えばselecは1つのtあるいはfromが欠けてformに書きました.
     
    JSP
     
    ①Page directive:illegal to have multiple occurrences of contentType with different values(old:text/)、charst=utf-8、new:text/html、charset=UTF-8)
    現在のJSPには「%@page」というタグがあり、他のJSPを導入しています.
    <%@ page contentType="text/html; charset=utf-8" isELIgnored="false"%>
    <%@ include file="/WEB-INF/jsp/common/common.jsp"%>
     他のJSPにも「%@page」というタグがあります.
    <%@ page contentType="text/html; charset=UTF-8" isELIgnored="false"%>
     エラーの原因は二つのJSPのcharset値が違っています.一つは大文字UTF-8で、一つは小文字utf-8です.同じに変更すればいいです.
     
    Tomcat
    ①Setting property'source'to'org.eclipse.jst.jee.server:first Project'did not find a matching property.
    問題があったのはEclipseで導入されたfirst Projectというdynamic web projectが起動されませんでした.
    解決方法詳細は、http://blog.csdn.net/z69183787/article/details/19911935
    作者の話が多いですが、簡単に言えば、Eclipseに配置されているserverを削除して、もう一つ作成すれば大丈夫です.