java .lang.NoSuchMethodError при поиске контекста - PullRequest
0 голосов
/ 18 февраля 2020

Я пытаюсь запустить клиент ejb, чтобы получить информацию обо всех книгах, представленных в БД. Я развернул компонент без ошибок, но когда я пытаюсь запустить этот код:

package book;

import java.util.List;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;


public class BookAllListClient {

    /**
     * @param args the command line arguments
     * @throws javax.naming.NamingException
     */
    public static void main(String[] args) throws NamingException{

        Context ctx = new InitialContext();

        BookEJBRemote book = (BookEJBRemote)ctx.lookup("java:global/Book/BookEJB!book.BookEJBRemote");

        List<Book> books = book.allBook();

        books.forEach((b) -> {
            System.out.println(b);
        });
    }

}

Я всегда получаю эту ошибку

INFO: Cannot find javadb client jar file, derby jdbc driver will not be available by default.
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.glassfish.pfl.basic.reflection.Bridge$1 (file:/C:/Users/cirop/GlassFish_Server/glassfish/modules/pfl-basic.jar) to method java.io.ObjectInputStream.latestUserDefinedLoader()
WARNING: Please consider reporting this to the maintainers of org.glassfish.pfl.basic.reflection.Bridge$1
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
Exception in thread "main" java.lang.NoSuchMethodError: sun.misc.Unsafe.defineClass(Ljava/lang/String;[BIILjava/lang/ClassLoader;Ljava/security/ProtectionDomain;)Ljava/lang/Class;
    at org.glassfish.pfl.basic.reflection.BridgeBase.defineClass(BridgeBase.java:237)
    at org.glassfish.pfl.dynamic.codegen.impl.CodeGeneratorUtil.makeClass(CodeGeneratorUtil.java:41)
    at org.glassfish.pfl.dynamic.codegen.spi.Wrapper._generate(Wrapper.java:1023)
    at org.glassfish.pfl.dynamic.codegen.spi.Wrapper._generate(Wrapper.java:1006)
    at com.sun.corba.ee.impl.presentation.rmi.codegen.CodegenProxyCreator.create(CodegenProxyCreator.java:129)
    at com.sun.corba.ee.impl.presentation.rmi.codegen.StubFactoryCodegenImpl.getStubClass(StubFactoryCodegenImpl.java:84)
    at com.sun.corba.ee.impl.presentation.rmi.codegen.StubFactoryCodegenImpl.makeStub(StubFactoryCodegenImpl.java:106)
    at com.sun.corba.ee.impl.util.Utility.loadStub(Utility.java:798)
    at com.sun.corba.ee.impl.javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:215)
    at javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:129)
    at com.sun.enterprise.naming.impl.SerialContext$ProviderCacheKey.getNameService(SerialContext.java:1187)
    at com.sun.enterprise.naming.impl.SerialContext.getRemoteProvider(SerialContext.java:369)
    at com.sun.enterprise.naming.impl.SerialContext.getProvider(SerialContext.java:305)
    at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:453)
    at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:414)
    at java.naming/javax.naming.InitialContext.lookup(InitialContext.java:409)
    at bookclientjms.BookClientJMS.main(BookClientJMS.java:33)
C:\Users\cirop\AppData\Local\NetBeans\Cache\11.2\executor-snippets\run.xml:111: The following error occurred while executing this line:
C:\Users\cirop\AppData\Local\NetBeans\Cache\11.2\executor-snippets\run.xml:94: Java returned: 1
BUILD FAILED (total time: 12 seconds)

Я использую IDE NetBeans и клиент имеет библиотеки gf-client.jar, javaee web api 7 и javaee api. Что я могу сделать?

...