Удаленный EJB: параметр trustAnchors должен быть непустым

#java #glassfish #ejb #jersey #ejb-3.1

#java #glassfish #ejb #джерси #ejb-3.1

Вопрос:

Я хочу вызвать удаленный ejb (размещенный на glassfish), но у меня следующее исключение:

 java.lang.RuntimeException: com.sun.jersey.api.client.ClientHandlerException: javax.net.ssl.SSLException: java.lang.RuntimeException: Unexpected error: java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty
at be.stijn.mz.io.FileSystemReader.readMovieDirectory(FileSystemReader.java:23)
at be.stijn.mz.IndexingService.index(IndexingService.java:22)
at be.stijn.mz.IndexingServiceIntegrationTest.index(IndexingServiceIntegrationTest.java:34)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
at org.junit.runners.BlockJUnit4ClassRunner.runNotIgnored(BlockJUnit4ClassRunner.java:79)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:71)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
  ...
  

Я использую следующий код:

 public PersisterLink() {
    try {
        Context ctx = getInitialContext();
        movieBean = (MovieBean) ctx.lookup("RemoteMovieBean");
    } catch (Exception e) {
        throw new PersisterLinkException(e);
    }
}

private Context getInitialContext() throws NamingException, FileNotFoundException, IOException {
    Properties p = new Properties();
    InputStream stream = PersisterLink.class.getResourceAsStream("../../../../jndi.properties");
    p.load(stream);
    return new InitialContext(p);
}
  

И это мои jndi.properties:

 java.naming.factory.initial = com.sun.enterprise.naming.SerialInitContextFactory
java.naming.factory.url.pkgs = com.sun.enterprise.naming
java.naming.factory.state = com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl
#optional.  Defaults to localhost.  Only needed if web server is running
#on a different host than the appserver
org.omg.CORBA.ORBInitialHost = localhost
#optional.  Defaults to 3700.  Only needed if target orb port is not 3700.
org.omg.CORBA.ORBInitialPort = 3700
  

И у меня есть эта зависимость в моем pom:

 <dependency>
    <groupId>org.glassfish.appclient</groupId>
    <artifactId>gf-client</artifactId>
    <version>3.1</version>
    <type>pom</type>
    <scope>compile</scope>
</dependency>
  

Я надеюсь, что кто-нибудь сможет мне помочь, потому что я некоторое время борюсь с этим.

Комментарии:

1. Это работает, когда я создаю клиент в netbeans, кстати (используя автоматически сгенерированный код, который использует @EJB iso для нового InitialContext)

2. Кажется, проблема при получении ejb в конструкторе

Ответ №1:

Это неясное сообщение действительно означает, что указанное вами хранилище доверия не может быть открыто.

Комментарии:

1. Но я не указал truststore или есть хранилище по умолчанию? У меня не было намерения использовать ssl или любую другую безопасность, кстати

2. @Stijn Vanpoucke существует JRE по умолчанию: см. Справочное руководство по JSSE download.oracle.com/javase/6/docs/technotes/guides/security /… , и я бы ожидал, что Glassfish имеет свою собственную конфигурацию по умолчанию или конфигурацию.