web-dev-qa-db-ja.com

jdk1.7 / jre / lib / rt.jarのアクセス制限

こんにちはJAXBパーサーを作成しているときに非常に奇妙なことに直面しました。 EclipseからJAXBクラスを生成しようとすると、1つのクラスで非常に奇妙なエラーが表示されます

Access restriction: The type QName is not accessible due to restriction on required library /usr/lib/jvm/jdk1.7.0_02/jre/lib/rt.jar

これは私のクラスです

package generated;

import javax.xml.bind.JAXBElement;
import javax.xml.bind.annotation.XmlElementDecl;
import javax.xml.bind.annotation.XmlRegistry;
//import javax.xml.namespace.QName;
import javax.xml.namespace.*;


@XmlRegistry
public class ObjectFactory {

ここにこの行でエラーメッセージが表示されます

private final static QName _ExpenseReport_QNAME = new QName( ""、 "expenseReport");

    /**
     * Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: generated
     * 
     */
    public ObjectFactory() {
    }

    /**
     * Create an instance of {@link ExpenseT }
     * 
     */
    public ExpenseT createExpenseT() {
        return new ExpenseT();
    }

    /**
     * Create an instance of {@link UserT }
     * 
     */
    public UserT createUserT() {
        return new UserT();
    }

    /**
     * Create an instance of {@link ItemT }
     * 
     */
    public ItemT createItemT() {
        return new ItemT();
    }

    /**
     * Create an instance of {@link ItemListT }
     * 
     */
    public ItemListT createItemListT() {
        return new ItemListT();
    }

    /**
     * Create an instance of {@link JAXBElement }{@code <}{@link ExpenseT }{@code >}}
     * 
     */
    @XmlElementDecl(namespace = "", name = "expenseReport")
    public JAXBElement<ExpenseT> createExpenseReport(ExpenseT value) {
        return new JAXBElement<ExpenseT>(_ExpenseReport_QNAME, ExpenseT.class, null, value);
    }

}
18
khan

この問題は、プロジェクトが開いているJREではなくJDKをクラスパスが参照している場合に発生します。

ビルドパス>ライブラリ

含まれているランタイムを削除し、jdkランタイムを追加すると、問題が解決します。

39
Akash Yadav

次のエラーが発生しました:アクセス制限:

必要なライブラリC:\ Program Files(x86)\ Java\jre7\lib\rt.jarの制限により、タイプXmlRegistryにアクセスできません

これは私が持っていたのと同じ問題を修正した方法です:

1.Go to the Build Path settings in the project properties. (Right click on your application, then in the popout window you will see 'Build Path', slide right and click on 'Configure Build Path...')
2.Remove the JRE System Library
3.Add it back; Select "Add Library" and select the JRE System Library. 

デフォルトは私のために働いた。

12
S. Mayol

同じJREシステムライブラリを削除して再度追加するだけです。

注:削除と再追加を行う際は、必ず[OK]をクリックしてダイアログを閉じてください。

2
user1782556

この状況は次のように解決できます。

1-[プロジェクトのプロパティ]ダイアログのJavaコンパイラセクションに移動してから、エラーと警告に移動します。2-[プロジェクト固有の設定を有効にする]をチェックします。 )警告または無視します。

4-私のあなたの祈りを忘れないでください

0
Zia Ur Rahman