Letting EJB A (Glassfish A) communicate over IIOP to EJB B (Glassfish B) results in SecurityException - glassfish

I want to let Alice (EJB A; Glassfish A) communicate with Bob (EJB B; Glassfish B). Both EJBs are deployed on distinct Glassfish (Glassfish A and Glassfish B) servers. The communication shall be over IIOP. However, my experiments result in a java.lang.SecurityException. The question is: why is that, and how to solve it?
Alice and Bob both implement remote interfaces.
AliceRemote.java:
package com.fu.ba.alice.ejb;
import javax.ejb.Remote;
#Remote
public interface AliceRemote {
void callBob();
}
BobRemote.java:
package com.fu.ba.bob.ejb;
import javax.ejb.Remote;
#Remote
public interface BobRemote {
void sayHello();
}
The implementation of Alice and Bob are also straight-forward.
Alice.java:
package com.fu.ba.alice.ejb;
import javax.ejb.EJB;
import javax.ejb.Stateless;
import com.fu.ba.bob.ejb.BobRemote;
/**
* Session Bean implementation class Alice
*/
#Stateless(mappedName = "AliceMap")
public class Alice implements AliceRemote {
#EJB(name = "BobRemote")
private BobRemote bob;
/**
* Default constructor.
*/
public Alice() {
}
#Override
public void callBob() {
System.out.println("Hello this is Alice");
bob.sayHello();
}
}
Bob.java:
package com.fu.ba.bob.ejb;
import javax.ejb.Stateless;
/**
* Session Bean implementation class Bob
*/
#Stateless(mappedName = "BobMap")
public class Bob implements BobRemote {
/**
* Default constructor.
*/
public Bob() {
// TODO Auto-generated constructor stub
}
#Override
public void sayHello() {
System.out.println("Hello this is Bob");
}
}
In addition, Alice's EJB includes an ejb-jar.xml and a glassfish-ejb-jar.xml specifying the IIOP communication.
ejb-jar.xml:
<?xml version="1.0" encoding="UTF-8"?>
<ejb-jar xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:ejb="http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/ejb-jar_3_1.xsd" version="3.1">
<display-name>com.fu.ba.alice.ejb </display-name>
<ejb-client-jar>com.fu.ba.alice.ejbClient.jar</ejb-client-jar>
</ejb-jar>
glassfish-ejb-jar.xml:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE glassfish-ejb-jar PUBLIC "-//GlassFish.org//DTD GlassFish Application Server 3.1 EJB 3.1//EN" "http://glassfish.org/dtds/glassfish-ejb-jar_3_1-1.dtd">
<glassfish-ejb-jar>
<enterprise-beans>
<ejb>
<ejb-name>Alice</ejb-name>
<ejb-ref>
<ejb-ref-name>BobRemote</ejb-ref-name>
<jndi-name>corbaname:iiop:123.123.123.123:3700#java:global/com.fu.ba.bob/com.fu.ba.bob.ejb/Bob!com.fu.ba.bob.ejb.BobRemote</jndi-name>
</ejb-ref>
</ejb>
</enterprise-beans>
</glassfish-ejb-jar>
Deploying the EJBs to different Glassfish servers results in exceptions on Bob's and Alice's side.
Bob's side:
WARNING: JTS5071: Unexpected error occurred in registerSynchronization
org.omg.CORBA.COMM_FAILURE: FINE: 00410001: Connection failure: socketType: IIOP_CLEAR_TEXT; hostname: 169.254.32.79; port: 3700 vmcid: OMG minor code: 1 completed: No
at com.sun.proxy.$Proxy142.connectFailure(Unknown Source)
at com.sun.corba.ee.impl.transport.ConnectionImpl.<init>(ConnectionImpl.java:253)
at com.sun.corba.ee.impl.transport.ConnectionImpl.<init>(ConnectionImpl.java:276)
at com.sun.corba.ee.impl.transport.ContactInfoImpl.createConnection(ContactInfoImpl.java:129)
at com.sun.corba.ee.impl.protocol.ClientRequestDispatcherImpl.beginRequest(ClientRequestDispatcherImpl.java:243)
at com.sun.corba.ee.impl.protocol.ClientDelegateImpl.request(ClientDelegateImpl.java:227)
at org.omg.CORBA.portable.ObjectImpl._request(ObjectImpl.java:449)
at org.omg.CosTransactions._CoordinatorStub.register_synchronization(_CoordinatorStub.java:235)
at com.sun.jts.CosTransactions.TopCoordinator.register_synchronization(TopCoordinator.java:2430)
at com.sun.jts.jta.TransactionState.registerSynchronization(TransactionState.java:494)
at com.sun.jts.jta.TransactionImpl.registerSynchronization(TransactionImpl.java:313)
at com.sun.enterprise.transaction.JavaEETransactionManagerSimplified.createImportedTransaction(JavaEETransactionManagerSimplified.java:1568)
at com.sun.enterprise.transaction.jts.JavaEETransactionManagerJTSDelegate.getTransaction(JavaEETransactionManagerJTSDelegate.java:279)
at com.sun.enterprise.transaction.JavaEETransactionManagerSimplified.getTransaction(JavaEETransactionManagerSimplified.java:915)
at com.sun.ejb.containers.EJBContainerTransactionManager.preInvokeTx(EJBContainerTransactionManager.java:250)
at com.sun.ejb.containers.BaseContainer.preInvokeTx(BaseContainer.java:4433)
at com.sun.ejb.containers.BaseContainer.preInvoke(BaseContainer.java:1921)
at com.sun.ejb.containers.EJBObjectInvocationHandler.invoke(EJBObjectInvocationHandler.java:204)
at com.sun.ejb.containers.EJBObjectInvocationHandlerDelegate.invoke(EJBObjectInvocationHandlerDelegate.java:79)
at com.sun.proxy.$Proxy180.sayHello(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at com.sun.corba.ee.impl.presentation.rmi.ReflectiveTie.dispatchToMethod(ReflectiveTie.java:143)
at com.sun.corba.ee.impl.presentation.rmi.ReflectiveTie._invoke(ReflectiveTie.java:173)
at com.sun.corba.ee.impl.protocol.ServerRequestDispatcherImpl.dispatchToServant(ServerRequestDispatcherImpl.java:528)
at com.sun.corba.ee.impl.protocol.ServerRequestDispatcherImpl.dispatch(ServerRequestDispatcherImpl.java:199)
at com.sun.corba.ee.impl.protocol.MessageMediatorImpl.handleRequestRequest(MessageMediatorImpl.java:1549)
at com.sun.corba.ee.impl.protocol.MessageMediatorImpl.handleRequest(MessageMediatorImpl.java:1425)
at com.sun.corba.ee.impl.protocol.MessageMediatorImpl.handleInput(MessageMediatorImpl.java:930)
at com.sun.corba.ee.impl.protocol.giopmsgheaders.RequestMessage_1_2.callback(RequestMessage_1_2.java:213)
at com.sun.corba.ee.impl.protocol.MessageMediatorImpl.handleRequest(MessageMediatorImpl.java:694)
at com.sun.corba.ee.impl.protocol.MessageMediatorImpl.dispatch(MessageMediatorImpl.java:496)
at com.sun.corba.ee.impl.protocol.MessageMediatorImpl.doWork(MessageMediatorImpl.java:2222)
at com.sun.corba.ee.impl.threadpool.ThreadPoolImpl$WorkerThread.performWork(ThreadPoolImpl.java:497)
at com.sun.corba.ee.impl.threadpool.ThreadPoolImpl$WorkerThread.run(ThreadPoolImpl.java:540)
Caused by: java.lang.RuntimeException: java.net.ConnectException: Connection timed out: connect
at org.glassfish.enterprise.iiop.impl.IIOPSSLSocketFactory.createSocket(IIOPSSLSocketFactory.java:344)
at com.sun.corba.ee.impl.transport.ConnectionImpl.<init>(ConnectionImpl.java:250)
... 35 more
Caused by: java.net.ConnectException: Connection timed out: connect
at sun.nio.ch.Net.connect0(Native Method)
at sun.nio.ch.Net.connect(Net.java:364)
at sun.nio.ch.Net.connect(Net.java:356)
at sun.nio.ch.SocketChannelImpl.connect(SocketChannelImpl.java:623)
at com.sun.corba.ee.impl.misc.ORBUtility.openSocketChannel(ORBUtility.java:110)
at org.glassfish.enterprise.iiop.impl.IIOPSSLSocketFactory.createSocket(IIOPSSLSocketFactory.java:329)
... 36 more
WARNING: EJB5184:A system exception occurred during an invocation on EJB Bob, method: public void com.fu.ba.bob.ejb.Bob.sayHello()
WARNING: javax.ejb.EJBException: java.lang.SecurityException
at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:2016)
at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:1979)
at com.sun.ejb.containers.EJBObjectInvocationHandler.invoke(EJBObjectInvocationHandler.java:212)
at com.sun.ejb.containers.EJBObjectInvocationHandlerDelegate.invoke(EJBObjectInvocationHandlerDelegate.java:79)
at com.sun.proxy.$Proxy180.sayHello(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at com.sun.corba.ee.impl.presentation.rmi.ReflectiveTie.dispatchToMethod(ReflectiveTie.java:143)
at com.sun.corba.ee.impl.presentation.rmi.ReflectiveTie._invoke(ReflectiveTie.java:173)
at com.sun.corba.ee.impl.protocol.ServerRequestDispatcherImpl.dispatchToServant(ServerRequestDispatcherImpl.java:528)
at com.sun.corba.ee.impl.protocol.ServerRequestDispatcherImpl.dispatch(ServerRequestDispatcherImpl.java:199)
at com.sun.corba.ee.impl.protocol.MessageMediatorImpl.handleRequestRequest(MessageMediatorImpl.java:1549)
at com.sun.corba.ee.impl.protocol.MessageMediatorImpl.handleRequest(MessageMediatorImpl.java:1425)
at com.sun.corba.ee.impl.protocol.MessageMediatorImpl.handleInput(MessageMediatorImpl.java:930)
at com.sun.corba.ee.impl.protocol.giopmsgheaders.RequestMessage_1_2.callback(RequestMessage_1_2.java:213)
at com.sun.corba.ee.impl.protocol.MessageMediatorImpl.handleRequest(MessageMediatorImpl.java:694)
at com.sun.corba.ee.impl.protocol.MessageMediatorImpl.dispatch(MessageMediatorImpl.java:496)
at com.sun.corba.ee.impl.protocol.MessageMediatorImpl.doWork(MessageMediatorImpl.java:2222)
at com.sun.corba.ee.impl.threadpool.ThreadPoolImpl$WorkerThread.performWork(ThreadPoolImpl.java:497)
at com.sun.corba.ee.impl.threadpool.ThreadPoolImpl$WorkerThread.run(ThreadPoolImpl.java:540)
Caused by: java.lang.SecurityException
at com.sun.jts.jta.TransactionManagerImpl.rollback(TransactionManagerImpl.java:376)
at com.sun.enterprise.transaction.jts.JavaEETransactionManagerJTSDelegate.rollbackDistributedTransaction(JavaEETransactionManagerJTSDelegate.java:218)
at com.sun.enterprise.transaction.JavaEETransactionManagerSimplified.rollback(JavaEETransactionManagerSimplified.java:892)
at com.sun.ejb.containers.EJBContainerTransactionManager.destroyBeanAndRollback(EJBContainerTransactionManager.java:574)
at com.sun.ejb.containers.EJBContainerTransactionManager.completeNewTx(EJBContainerTransactionManager.java:697)
at com.sun.ejb.containers.EJBContainerTransactionManager.postInvokeTx(EJBContainerTransactionManager.java:503)
at com.sun.ejb.containers.BaseContainer.postInvokeTx(BaseContainer.java:4475)
at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:2009)
... 21 more
Alice's side:
Warning: Context path from ServletContext: /com.fu.ba.servlet differs from path from bundle: com.fu.ba.servlet
Information: Hello this is Alice
Warning: Context path from ServletContext: differs from path from bundle: /
Warning: EJB5184:A system exception occurred during an invocation on EJB Alice, method: public void com.fu.ba.alice.ejb.Alice.callBob()
Warning: javax.ejb.EJBException: java.lang.SecurityException
at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:2016)
at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:1979)
at com.sun.ejb.containers.EJBObjectInvocationHandler.invoke(EJBObjectInvocationHandler.java:212)
at com.sun.ejb.containers.EJBObjectInvocationHandlerDelegate.invoke(EJBObjectInvocationHandlerDelegate.java:79)
at com.sun.proxy.$Proxy180.sayHello(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at com.sun.corba.ee.impl.presentation.rmi.ReflectiveTie.dispatchToMethod(ReflectiveTie.java:143)
at com.sun.corba.ee.impl.presentation.rmi.ReflectiveTie._invoke(ReflectiveTie.java:173)
at com.sun.corba.ee.impl.protocol.ServerRequestDispatcherImpl.dispatchToServant(ServerRequestDispatcherImpl.java:528)
at com.sun.corba.ee.impl.protocol.ServerRequestDispatcherImpl.dispatch(ServerRequestDispatcherImpl.java:199)
at com.sun.corba.ee.impl.protocol.MessageMediatorImpl.handleRequestRequest(MessageMediatorImpl.java:1549)
at com.sun.corba.ee.impl.protocol.MessageMediatorImpl.handleRequest(MessageMediatorImpl.java:1425)
at com.sun.corba.ee.impl.protocol.MessageMediatorImpl.handleInput(MessageMediatorImpl.java:930)
at com.sun.corba.ee.impl.protocol.giopmsgheaders.RequestMessage_1_2.callback(RequestMessage_1_2.java:213)
at com.sun.corba.ee.impl.protocol.MessageMediatorImpl.handleRequest(MessageMediatorImpl.java:694)
at com.sun.corba.ee.impl.protocol.MessageMediatorImpl.dispatch(MessageMediatorImpl.java:496)
at com.sun.corba.ee.impl.protocol.MessageMediatorImpl.doWork(MessageMediatorImpl.java:2222)
at com.sun.corba.ee.impl.threadpool.ThreadPoolImpl$WorkerThread.performWork(ThreadPoolImpl.java:497)
at com.sun.corba.ee.impl.threadpool.ThreadPoolImpl$WorkerThread.run(ThreadPoolImpl.java:540)
Caused by: java.lang.SecurityException
at com.sun.jts.jta.TransactionManagerImpl.rollback(TransactionManagerImpl.java:376)
at com.sun.enterprise.transaction.jts.JavaEETransactionManagerJTSDelegate.rollbackDistributedTransaction(JavaEETransactionManagerJTSDelegate.java:218)
at com.sun.enterprise.transaction.JavaEETransactionManagerSimplified.rollback(JavaEETransactionManagerSimplified.java:892)
at com.sun.ejb.containers.EJBContainerTransactionManager.destroyBeanAndRollback(EJBContainerTransactionManager.java:574)
at com.sun.ejb.containers.EJBContainerTransactionManager.completeNewTx(EJBContainerTransactionManager.java:697)
at com.sun.ejb.containers.EJBContainerTransactionManager.postInvokeTx(EJBContainerTransactionManager.java:503)
at com.sun.ejb.containers.BaseContainer.postInvokeTx(BaseContainer.java:4475)
at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:2009)
... 21 more
Warning: StandardWrapperValve[com.fu.ba.servlet.CallBobServlet]: Servlet.service() for servlet com.fu.ba.servlet.CallBobServlet threw exception
javax.ejb.EJBException: java.lang.SecurityException
at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:2016)
at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:1979)
at com.sun.ejb.containers.EJBObjectInvocationHandler.invoke(EJBObjectInvocationHandler.java:212)
at com.sun.ejb.containers.EJBObjectInvocationHandlerDelegate.invoke(EJBObjectInvocationHandlerDelegate.java:79)
at com.sun.proxy.$Proxy180.sayHello(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at com.sun.corba.ee.impl.presentation.rmi.ReflectiveTie.dispatchToMethod(ReflectiveTie.java:143)
at com.sun.corba.ee.impl.presentation.rmi.ReflectiveTie._invoke(ReflectiveTie.java:173)
at com.sun.corba.ee.impl.protocol.ServerRequestDispatcherImpl.dispatchToServant(ServerRequestDispatcherImpl.java:528)
at com.sun.corba.ee.impl.protocol.ServerRequestDispatcherImpl.dispatch(ServerRequestDispatcherImpl.java:199)
at com.sun.corba.ee.impl.protocol.MessageMediatorImpl.handleRequestRequest(MessageMediatorImpl.java:1549)
at com.sun.corba.ee.impl.protocol.MessageMediatorImpl.handleRequest(MessageMediatorImpl.java:1425)
at com.sun.corba.ee.impl.protocol.MessageMediatorImpl.handleInput(MessageMediatorImpl.java:930)
at com.sun.corba.ee.impl.protocol.giopmsgheaders.RequestMessage_1_2.callback(RequestMessage_1_2.java:213)
at com.sun.corba.ee.impl.protocol.MessageMediatorImpl.handleRequest(MessageMediatorImpl.java:694)
at com.sun.corba.ee.impl.protocol.MessageMediatorImpl.dispatch(MessageMediatorImpl.java:496)
at com.sun.corba.ee.impl.protocol.MessageMediatorImpl.doWork(MessageMediatorImpl.java:2222)
at com.sun.corba.ee.impl.threadpool.ThreadPoolImpl$WorkerThread.performWork(ThreadPoolImpl.java:497)
at com.sun.corba.ee.impl.threadpool.ThreadPoolImpl$WorkerThread.run(ThreadPoolImpl.java:540)
Caused by: java.lang.SecurityException
at com.sun.jts.jta.TransactionManagerImpl.rollback(TransactionManagerImpl.java:376)
at com.sun.enterprise.transaction.jts.JavaEETransactionManagerJTSDelegate.rollbackDistributedTransaction(JavaEETransactionManagerJTSDelegate.java:218)
at com.sun.enterprise.transaction.JavaEETransactionManagerSimplified.rollback(JavaEETransactionManagerSimplified.java:892)
at com.sun.ejb.containers.EJBContainerTransactionManager.destroyBeanAndRollback(EJBContainerTransactionManager.java:574)
at com.sun.ejb.containers.EJBContainerTransactionManager.completeNewTx(EJBContainerTransactionManager.java:697)
at com.sun.ejb.containers.EJBContainerTransactionManager.postInvokeTx(EJBContainerTransactionManager.java:503)
at com.sun.ejb.containers.BaseContainer.postInvokeTx(BaseContainer.java:4475)
at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:2009)
... 21 more

Related

soap authentication while calling a webmethod

I would like help with a SOAP WebService. I was calling a webmethod without any issues; authentication is as follows:
public static void applyBasicAuth(String userName, String password) {
Properties p = System.getProperties();
p.remove("javax.net.ssl.trustStore");
p.remove("javax.net.ssl.trustStorePassword");
System.setProperty("javax.net.ssl.keyStorePassword", password);
Authenticator myAuth = new Authenticator()
{
#Override
protected PasswordAuthentication getPasswordAuthentication()
{
return new PasswordAuthentication(userName, password.toCharArray());
}
};
Authenticator.setDefault(myAuth);
}
As I told, I had no issues. But, all of a sudden, I started getting this stack trace:
com.sun.xml.ws.client.ClientTransportException: HTTP transport error: java.net.SocketException: java.security.NoSuchAlgorithmException: Error constructing implementation (algorithm: Default, provider: SunJSSE, class: sun.security.ssl.SSLContextImpl$DefaultSSLContext)
at com.sun.xml.ws.transport.http.client.HttpClientTransport.getOutput(HttpClientTransport.java:102)
at com.sun.xml.ws.transport.http.client.HttpTransportPipe.process(HttpTransportPipe.java:193)
at com.sun.xml.ws.transport.http.client.HttpTransportPipe.processRequest(HttpTransportPipe.java:115)
at com.sun.xml.ws.transport.DeferredTransportPipe.processRequest(DeferredTransportPipe.java:80)
at com.sun.xml.ws.api.pipe.Fiber.__doRun(Fiber.java:1106)
at com.sun.xml.ws.api.pipe.Fiber._doRun(Fiber.java:1020)
at com.sun.xml.ws.api.pipe.Fiber.doRun(Fiber.java:989)
at com.sun.xml.ws.api.pipe.Fiber.runSync(Fiber.java:847)
at com.sun.xml.ws.client.Stub.process(Stub.java:433)
at com.sun.xml.ws.client.sei.SEIStub.doProcess(SEIStub.java:161)
at com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:78)
at com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:62)
at com.sun.xml.ws.client.sei.SEIStub.invoke(SEIStub.java:131)
at com.sun.proxy.$Proxy31.siOSEnvioNovedades(Unknown Source)
at com.baeldung.soap.ws.client.ClientTest.executeEnvioDeNovedades(ClientTest.java:85)
at com.baeldung.soap.ws.client.ClientTest.main(ClientTest.java:17)
Caused by: java.net.SocketException: java.security.NoSuchAlgorithmException: Error constructing implementation (algorithm: Default, provider: SunJSSE, class: sun.security.ssl.SSLContextImpl$DefaultSSLContext)
at java.base/javax.net.ssl.DefaultSSLSocketFactory.throwException(SSLSocketFactory.java:263)
at java.base/javax.net.ssl.DefaultSSLSocketFactory.createSocket(SSLSocketFactory.java:270)
at java.base/sun.net.www.protocol.https.HttpsClient.createSocket(HttpsClient.java:414)
at java.base/sun.net.NetworkClient.doConnect(NetworkClient.java:162)
at java.base/sun.net.www.http.HttpClient.openServer(HttpClient.java:474)
at java.base/sun.net.www.http.HttpClient.openServer(HttpClient.java:569)
at java.base/sun.net.www.protocol.https.HttpsClient.<init>(HttpsClient.java:266)
at java.base/sun.net.www.protocol.https.HttpsClient.New(HttpsClient.java:373)
at java.base/sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.getNewHttpClient(AbstractDelegateHttpsURLConnection.java:203)
at java.base/sun.net.www.protocol.http.HttpURLConnection.plainConnect0(HttpURLConnection.java:1232)
at java.base/sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:1081)
at java.base/sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:189)
at java.base/sun.net.www.protocol.http.HttpURLConnection.getOutputStream0(HttpURLConnection.java:1367)
at java.base/sun.net.www.protocol.http.HttpURLConnection.getOutputStream(HttpURLConnection.java:1342)
at java.base/sun.net.www.protocol.https.HttpsURLConnectionImpl.getOutputStream(HttpsURLConnectionImpl.java:246)
at com.sun.xml.ws.transport.http.client.HttpClientTransport.getOutput(HttpClientTransport.java:89)
... 15 more
Caused by: java.security.NoSuchAlgorithmException: Error constructing implementation (algorithm: Default, provider: SunJSSE, class: sun.security.ssl.SSLContextImpl$DefaultSSLContext)
at java.base/java.security.Provider$Service.newInstance(Provider.java:1901)
at java.base/sun.security.jca.GetInstance.getInstance(GetInstance.java:236)
at java.base/sun.security.jca.GetInstance.getInstance(GetInstance.java:164)
at java.base/javax.net.ssl.SSLContext.getInstance(SSLContext.java:168)
at java.base/javax.net.ssl.SSLContext.getDefault(SSLContext.java:99)
at java.base/javax.net.ssl.SSLSocketFactory.getDefault(SSLSocketFactory.java:123)
at java.base/javax.net.ssl.HttpsURLConnection.getDefaultSSLSocketFactory(HttpsURLConnection.java:335)
at java.base/javax.net.ssl.HttpsURLConnection.<init>(HttpsURLConnection.java:292)
at java.base/sun.net.www.protocol.https.HttpsURLConnectionImpl.<init>(HttpsURLConnectionImpl.java:100)
at java.base/sun.net.www.protocol.https.Handler.openConnection(Handler.java:62)
at java.base/java.net.URL.openConnection(URL.java:1148)
at com.sun.xml.ws.api.EndpointAddress.openConnection(EndpointAddress.java:202)
at com.sun.xml.ws.transport.http.client.HttpClientTransport.createHttpConnection(HttpClientTransport.java:227)
at com.sun.xml.ws.transport.http.client.HttpClientTransport.getOutput(HttpClientTransport.java:86)
... 15 more
Caused by: java.security.KeyStoreException: problem accessing trust store
at java.base/sun.security.ssl.TrustManagerFactoryImpl.engineInit(TrustManagerFactoryImpl.java:73)
at java.base/javax.net.ssl.TrustManagerFactory.init(TrustManagerFactory.java:278)
at java.base/sun.security.ssl.SSLContextImpl$DefaultManagersHolder.getTrustManagers(SSLContextImpl.java:1053)
at java.base/sun.security.ssl.SSLContextImpl$DefaultManagersHolder.<clinit>(SSLContextImpl.java:1023)
at java.base/sun.security.ssl.SSLContextImpl$DefaultSSLContext.<init>(SSLContextImpl.java:1198)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
at java.base/java.security.Provider.newInstanceUtil(Provider.java:154)
at java.base/java.security.Provider$Service.newInstance(Provider.java:1894)
... 28 more
Caused by: java.io.IOException: Keystore was tampered with, or password was incorrect
at java.base/sun.security.provider.JavaKeyStore.engineLoad(JavaKeyStore.java:795)
at java.base/sun.security.util.KeyStoreDelegator.engineLoad(KeyStoreDelegator.java:243)
at java.base/java.security.KeyStore.load(KeyStore.java:1479)
at java.base/sun.security.ssl.TrustStoreManager$TrustAnchorManager.loadKeyStore(TrustStoreManager.java:365)
at java.base/sun.security.ssl.TrustStoreManager$TrustAnchorManager.getTrustedCerts(TrustStoreManager.java:313)
at java.base/sun.security.ssl.TrustStoreManager.getTrustedCerts(TrustStoreManager.java:55)
at java.base/sun.security.ssl.TrustManagerFactoryImpl.engineInit(TrustManagerFactoryImpl.java:49)
What does it mean ?. Do the admin people change some stuff related to security or credentials ?. if this is the case, do I need to ask for the keystore file ?.
thanks

ClassNotFoundException in CacheJdbcStoreExample run on cluster

I have a cluster with 2 nodes. Then I tried to run the CacheJdbcStoreExample in apache-ignite-fabric-2.1.0-bin/examples.But I got following exception:
visor> [06:51:41,113][SEVERE][tcp-disco-msg-worker-#13%null%][TcpDiscoverySpi] Failed to unmarshal discovery custom message.
class org.apache.ignite.IgniteCheckedException: Failed to find class with given class loader for unmarshalling (make sure same versions of all classes are available on all nodes or enable pee
r-class-loading) [clsLdr=sun.misc.Launcher$AppClassLoader#4aa4ceeb, cls=org.apache.ignite.examples.datagrid.store.jdbc.CacheJdbcStoreExample$1] at org.apache.ignite.marshaller.jdk.JdkMarshaller.unmarshal0(JdkMarshaller.java:124)
at org.apache.ignite.marshaller.AbstractNodeNameAwareMarshaller.unmarshal(AbstractNodeNameAwareMarshaller.java:94)
at org.apache.ignite.marshaller.jdk.JdkMarshaller.unmarshal0(JdkMarshaller.java:143)
at org.apache.ignite.marshaller.AbstractNodeNameAwareMarshaller.unmarshal(AbstractNodeNameAwareMarshaller.java:82)
at org.apache.ignite.internal.util.IgniteUtils.unmarshal(IgniteUtils.java:9733)
at org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryCustomEventMessage.message(TcpDiscoveryCustomEventMessage.java:81)
at org.apache.ignite.spi.discovery.tcp.ServerImpl$RingMessageWorker.notifyDiscoveryListener(ServerImpl.java:5436)
at org.apache.ignite.spi.discovery.tcp.ServerImpl$RingMessageWorker.processCustomMessage(ServerImpl.java:5321)
at org.apache.ignite.spi.discovery.tcp.ServerImpl$RingMessageWorker.processMessage(ServerImpl.java:2629)
at org.apache.ignite.spi.discovery.tcp.ServerImpl$RingMessageWorker.processMessage(ServerImpl.java:2420)
at org.apache.ignite.spi.discovery.tcp.ServerImpl$MessageWorkerAdapter.body(ServerImpl.java:6576)
at org.apache.ignite.spi.discovery.tcp.ServerImpl$RingMessageWorker.body(ServerImpl.java:2506)
at org.apache.ignite.spi.IgniteSpiThread.run(IgniteSpiThread.java:62)
Caused by: java.lang.ClassNotFoundException: org.apache.ignite.examples.datagrid.store.jdbc.CacheJdbcStoreExample$1
at java.net.URLClassLoader$1.run(URLClassLoader.java:359)
at java.net.URLClassLoader$1.run(URLClassLoader.java:348)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:347)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:278)
at org.apache.ignite.internal.util.IgniteUtils.forName(IgniteUtils.java:8465)
at org.apache.ignite.marshaller.jdk.JdkMarshallerObjectInputStream.resolveClass(JdkMarshallerObjectInputStream.java:54)
at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1817)
at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1711)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1982)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1533)
at java.io.ObjectInputStream.readArray(ObjectInputStream.java:1917)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1527)
at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:2227)
at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:2151)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:2009)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1533)
at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:2227)
at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:2151)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:2009)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1533)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:420)
at java.util.ArrayList.readObject(ArrayList.java:771)
at sun.reflect.GeneratedMethodAccessor16.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:1058)
at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:2118)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:2009)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1533)
at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:2227)
at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:2151)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:2009)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1533)
at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:2227)
at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:2151)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:2009)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1533)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:420)
at org.apache.ignite.marshaller.jdk.JdkMarshaller.unmarshal0(JdkMarshaller.java:121)
... 12 more
I decompiled CacheJdbcStoreExample$1.class and got following code:
CacheJdbcStoreExample$1
package org.apache.ignite.examples.datagrid.store.jdbc;
import javax.cache.configuration.Factory;
import org.apache.ignite.cache.store.CacheStoreSessionListener;
import org.apache.ignite.cache.store.jdbc.CacheJdbcStoreSessionListener;
import org.h2.jdbcx.JdbcConnectionPool;
class CacheJdbcStoreExample$1
implements Factory<CacheStoreSessionListener>
{
public CacheStoreSessionListener create()
{
CacheJdbcStoreSessionListener lsnr = new CacheJdbcStoreSessionListener();
lsnr.setDataSource(JdbcConnectionPool.create("jdbc:h2:tcp://localhost/mem:ExampleDb", "sa", ""));
return lsnr;
}
}
SO I think there is something wrong at row 90 in CacheJdbcStoreExample source code:
// Configure JDBC session listener.
cacheCfg.setCacheStoreSessionListenerFactories(new Factory<CacheStoreSessionListener>() {
#Override public CacheStoreSessionListener create() {
CacheJdbcStoreSessionListener lsnr = new CacheJdbcStoreSessionListener();
lsnr.setDataSource(JdbcConnectionPool.create("jdbc:h2:tcp://localhost/mem:ExampleDb", "sa", ""));
return lsnr;
}
});
If I run the example on only one node not a cluster, it's OK.
What should I do to fix it?
The problem is that you configured a cache with a factory of CacheStoreSessionListener-s, but this factory is not visible from other nodes as they don't have it in their classpath.
You should start additional remote nodes with org.apache.ignite.examples.ExampleNodeStartup class from examples module or add examples module to the classpath of other nodes.

EntityManager not injected in a #Stateless EJB, when I restart the app

My entry point is a #Singleton scheduled to be run twice a minute.
#Startup
#Singleton
public class MyScheduledProcess {
#Resource
protected TimerService timerService;
#Inject
private OutgoingMessageProvider provider;
// If I inject the em here, it is always well injected.
// #PersistenceContext
// EntityManager em;
/**
* Default startup method that will be called automatically to schedule the task.
*/
#PostConstruct
public void onStartup() {
// To erase all timers which may already exist...
stopAll();
// Schedule
timerService.createCalendarTimer(getScheduledExpression("* * */30"), new TimerConfig());
}
#Timeout
protected void onTimeout(final Timer timer) {
process(timer);
}
/**
* Business logic called when the timer is triggered.
* #param timer
*/
public void process(Timer t) {
logger.info("Start process");
// When em is injected here, there is no problem.
// OutgoingMessage outMsg = em.find(OutgoingMessage.class, 3L);
// logger.info("found:" + outMsg);
logger.info("provider :" + provider);
List<OutgoingMessage> findAll = provider.findByStatus("CREATED");
logger.info("Nb in list : " + findAll.size());
}
public static ScheduleExpression getScheduledExpression(String stringRepresentation) {
ScheduleExpression expression = new ScheduleExpression();
// [....]
return expression;
}
public void stopAll() {
for(Timer timer : timerService.getTimers()) {
logger.debug("Stopping " + timer);
timer.cancel();
}
}
}
In this Singleton, I inject my OutgoingMessageProvider, a Stateless bean.
#Stateless
public class OutgoingMessageProvider {
#PersistenceContext(unitName= "DefaultPU")
protected EntityManager em;
public List<OutgoingMessage> findByStatus(String status) {
logger.debug("Value of em : " + em);
return this.em.createQuery("SELECT m FROM OutgoingMessage m WHERE m.status = :status")
.setParameter("status", status)
.getResultList();
}
public OutgoingMessage findByMessageId(String messageId) {
return ........
}
public void create(OutgoingMessage entity) {
em.persist(entity);
}
....
}
When I upload and deploy my war on a weblogic (12.1.3), at the first start, everything is OK and works fine.
But when I stop my app and start it up again in the Weblogic Admin Console, I have a "NoSuchEJBException: Bean is already undeployed." :
22:22:16.216 [[ACTIVE] ExecuteThread: '15' for queue: 'weblogic.kernel.Default (self-tuning)'] INFO com.poc.schedul.MyScheduledProcess - provider :com.poc.schedul.OutgoingMessageProvider_ek022o_NoIntfViewImpl#6b6bebf1
<11-Sep-2016 22:22:16 o'clock CEST> <Error> <EJB> <BEA-011088> <The following error occurred while invoking the ejbTimeout(javax.ejb.Timer) method of EJB MyScheduledProcess(Application: poc2, EJBComponent: poc.war).
javax.ejb.EJBException: EJB Exception: : com.oracle.pitchfork.interfaces.LifecycleCallbackException: Failure to invoke public java.lang.Object org.jboss.weld.ejb.SessionBeanInterceptor.aroundInvoke(javax.interceptor.InvocationContext) throws java.lang.Exception on bean class class org.jboss.weld.ejb.SessionBeanInterceptor with args: [LifecycleEventCallbackInvocationContext(962794227)]
at com.oracle.pitchfork.inject.Jsr250Metadata.invokeLifecycleMethod(Jsr250Metadata.java:379)
at com.oracle.pitchfork.intercept.LifecycleEventCallbackInvocationContext.proceed(LifecycleEventCallbackInvocationContext.java:115)
at com.oracle.pitchfork.intercept.LifecycleEventCallbackInvocationContext.proceed(LifecycleEventCallbackInvocationContext.java:144)
at com.oracle.pitchfork.intercept.InterceptionMetadata.invokeTimeoutMethod(InterceptionMetadata.java:531)
at weblogic.ejb.container.injection.EjbComponentCreatorImpl.invokeTimer(EjbComponentCreatorImpl.java:71)
at weblogic.ejb.container.injection.InjectionBasedEjbComponentCreator.invokeTimer(InjectionBasedEjbComponentCreator.java:152)
at weblogic.ejb.container.manager.BaseEJBManager.invokeTimeoutMethod(BaseEJBManager.java:176)
at weblogic.ejb.container.timer.TimerImpl.timerExpired(TimerImpl.java:340)
at weblogic.timers.internal.TimerImpl.run(TimerImpl.java:304)
at weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl.run(SelfTuningWorkManagerImpl.java:548)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:311)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:263)
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.GeneratedMethodAccessor927.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.oracle.pitchfork.inject.Jsr250Metadata.invokeLifecycleMethod(Jsr250Metadata.java:377)
... 11 more
Caused by: com.oracle.pitchfork.interfaces.LifecycleCallbackException: Failure to invoke timeout method protected void com.poc.schedul.MyScheduledProcess.onTimeout(javax.ejb.Timer) on bean class class com.poc.schedul.MyScheduledProcess_szpi74_Impl with args: [[EJB Timer] id: 44 pk: 1 info: null isAutoCreated: false timer: 1473625336209.6(0) state: 2 ejb: MyScheduledProcess(Application: poc2, EJBComponent: poc.war) Thread: Thread[[ACTIVE] ExecuteThread: '15' for queue: 'weblogic.kernel.Default (self-tuning)',5,Pooled Threads]]]
at com.oracle.pitchfork.inject.Jsr250Metadata.invokeTimeoutMethodInternal(Jsr250Metadata.java:364)
at com.oracle.pitchfork.intercept.LifecycleEventCallbackInvocationContext.proceed(LifecycleEventCallbackInvocationContext.java:120)
at org.jboss.weld.ejb.SessionBeanInterceptor.aroundInvoke(SessionBeanInterceptor.java:49)
... 15 more
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.oracle.pitchfork.inject.Jsr250Metadata.invokeTimeoutMethodInternal(Jsr250Metadata.java:362)
... 17 more
Caused by: javax.ejb.NoSuchEJBException: Bean is already undeployed.
at weblogic.ejb.container.manager.BaseEJBManager.ensureDeployed(BaseEJBManager.java:131)
at weblogic.ejb.container.manager.BaseEJBManager.preInvoke(BaseEJBManager.java:136)
at weblogic.ejb.container.manager.StatelessManager.preInvoke(StatelessManager.java:138)
at weblogic.ejb.container.internal.BaseLocalObject.getBeanInstance(BaseLocalObject.java:148)
at weblogic.ejb.container.internal.BaseLocalObject.preInvoke(BaseLocalObject.java:105)
at weblogic.ejb.container.internal.BaseLocalObject.__WL_preInvoke(BaseLocalObject.java:70)
at weblogic.ejb.container.internal.SessionLocalMethodInvoker.invoke(SessionLocalMethodInvoker.java:22)
at com.poc.schedul.OutgoingMessageProvider_ek022o_NoIntfViewImpl.findByStatus(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.jboss.weld.util.reflection.SecureReflections$13.work(SecureReflections.java:267)
at org.jboss.weld.util.reflection.SecureReflectionAccess.run(SecureReflectionAccess.java:52)
at org.jboss.weld.util.reflection.SecureReflectionAccess.runAsInvocation(SecureReflectionAccess.java:137)
at org.jboss.weld.util.reflection.SecureReflections.invoke(SecureReflections.java:263)
at org.jboss.weld.bean.proxy.EnterpriseBeanProxyMethodHandler.invoke(EnterpriseBeanProxyMethodHandler.java:115)
at org.jboss.weld.bean.proxy.EnterpriseTargetBeanInstance.invoke(EnterpriseTargetBeanInstance.java:56)
at org.jboss.weld.bean.proxy.ProxyMethodHandler.invoke(ProxyMethodHandler.java:105)
at com.poc.schedul.OutgoingMessageProvider$Proxy$_$$_Weld$Proxy$.findByStatus(OutgoingMessageProvider$Proxy$_$$_Weld$Proxy$.java)
at com.poc.schedul.MyScheduledProcess.process(MyScheduledProcess.java:90)
at com.poc.schedul.MyScheduledProcess.onTimeout(MyScheduledProcess.java:111)
... 22 more
at weblogic.ejb.container.internal.EJBRuntimeUtils.throwEJBException(EJBRuntimeUtils.java:88)
at weblogic.ejb.container.internal.BaseLocalObject.handleSystemException(BaseLocalObject.java:503)
at weblogic.ejb.container.internal.BaseLocalObject.handleSystemException(BaseLocalObject.java:446)
at weblogic.ejb.container.internal.BaseLocalObject.postInvoke1(BaseLocalObject.java:251)
at weblogic.ejb.container.internal.BaseLocalObject.postInvoke(BaseLocalObject.java:431)
Truncated. see log file for complete stacktrace
Caused By: com.oracle.pitchfork.interfaces.LifecycleCallbackException: Failure to invoke public java.lang.Object org.jboss.weld.ejb.SessionBeanInterceptor.aroundInvoke(javax.interceptor.InvocationContext) throws java.lang.Exception on bean class class org.jboss.weld.ejb.SessionBeanInterceptor with args: [LifecycleEventCallbackInvocationContext(962794227)]
at com.oracle.pitchfork.inject.Jsr250Metadata.invokeLifecycleMethod(Jsr250Metadata.java:379)
at com.oracle.pitchfork.intercept.LifecycleEventCallbackInvocationContext.proceed(LifecycleEventCallbackInvocationContext.java:115)
at com.oracle.pitchfork.intercept.LifecycleEventCallbackInvocationContext.proceed(LifecycleEventCallbackInvocationContext.java:144)
at com.oracle.pitchfork.intercept.InterceptionMetadata.invokeTimeoutMethod(InterceptionMetadata.java:531)
at weblogic.ejb.container.injection.EjbComponentCreatorImpl.invokeTimer(EjbComponentCreatorImpl.java:71)
Truncated. see log file for complete stacktrace
Caused By: java.lang.reflect.InvocationTargetException
at sun.reflect.GeneratedMethodAccessor927.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.oracle.pitchfork.inject.Jsr250Metadata.invokeLifecycleMethod(Jsr250Metadata.java:377)
at com.oracle.pitchfork.intercept.LifecycleEventCallbackInvocationContext.proceed(LifecycleEventCallbackInvocationContext.java:115)
Truncated. see log file for complete stacktrace
Caused By: com.oracle.pitchfork.interfaces.LifecycleCallbackException: Failure to invoke timeout method protected void com.poc.schedul.MyScheduledProcess.onTimeout(javax.ejb.Timer) on bean class class com.poc.schedul.MyScheduledProcess_szpi74_Impl with args: [[EJB Timer] id: 44 pk: 1 info: null isAutoCreated: false timer: 1473625336209.6(0) state: 2 ejb: MyScheduledProcess(Application: poc2, EJBComponent: poc.war) Thread: Thread[[ACTIVE] ExecuteThread: '15' for queue: 'weblogic.kernel.Default (self-tuning)',5,Pooled Threads]]]
at com.oracle.pitchfork.inject.Jsr250Metadata.invokeTimeoutMethodInternal(Jsr250Metadata.java:364)
at com.oracle.pitchfork.intercept.LifecycleEventCallbackInvocationContext.proceed(LifecycleEventCallbackInvocationContext.java:120)
at org.jboss.weld.ejb.SessionBeanInterceptor.aroundInvoke(SessionBeanInterceptor.java:49)
at sun.reflect.GeneratedMethodAccessor927.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
Truncated. see log file for complete stacktrace
Caused By: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.oracle.pitchfork.inject.Jsr250Metadata.invokeTimeoutMethodInternal(Jsr250Metadata.java:362)
Truncated. see log file for complete stacktrace
Caused By: javax.ejb.NoSuchEJBException: Bean is already undeployed.
at weblogic.ejb.container.manager.BaseEJBManager.ensureDeployed(BaseEJBManager.java:131)
at weblogic.ejb.container.manager.BaseEJBManager.preInvoke(BaseEJBManager.java:136)
at weblogic.ejb.container.manager.StatelessManager.preInvoke(StatelessManager.java:138)
at weblogic.ejb.container.internal.BaseLocalObject.getBeanInstance(BaseLocalObject.java:148)
at weblogic.ejb.container.internal.BaseLocalObject.preInvoke(BaseLocalObject.java:105)
Truncated. see log file for complete stacktrace
So, can someone explain me why everything works fine when I deploy my app, and goes wrong when I restart ? What happens in the application server when an app starts or stops ?
As we can see in the log, the Singleton knows the provider, so I can only imagine the provider does not know the entity manager... Am I wrong ? But, if I try to inject the EntityManager in the singleton, everything works fine. Then it means that the entityManager are well managed by the app server... So why isn't it injected in the stateless bean ?
I tried to instantiate myself an entitymanager in the provider, by adding a PostConstruct (and removing the #PersistenceContext...) :
#PostConstruct
public void init()
{
EntityManagerFactory emf = Persistence.createEntityManagerFactory("DefaultPU");
em = emf.createEntityManager(); }
logger.info("ENTITY MANAGER HAS BEEN SET : " +em);
}
But this method is called only once, and I have no trace in my log when I restart the app.
Is it normal ?
The problem has been resolved by replacing the #Inject by a #EJB in my singleton :
#Startup
#Singleton
public class MyScheduledProcess {
#Resource
protected TimerService timerService;
#EJB
private OutgoingMessageProvider provider;
...
Yes, it seems logic that it works with #EJB.
But I do not understand the behaviour that I described with #Inject : works fine the first time (after deploy), but injections fail when I stop and start again the war. If someone knows, feel free to share :)

Jetty HttpClientTransportOverHTTP2 with SSL

I am trying to make a simple GET request using Jetty's HttpClientTransportOverHTTP2, but it fails. Here is my code:
import org.eclipse.jetty.client.HttpClient;
import org.eclipse.jetty.client.api.ContentResponse;
import org.eclipse.jetty.http2.client.HTTP2Client;
import org.eclipse.jetty.http2.client.http.HttpClientTransportOverHTTP2;
import org.eclipse.jetty.util.ssl.SslContextFactory;
public class JettyClientExample {
public static void main(String[] args) throws Exception {
HttpClientTransportOverHTTP2 clientTransport = new HttpClientTransportOverHTTP2(new HTTP2Client());
HttpClient client = new HttpClient(clientTransport, new SslContextFactory(true));
client.start();
ContentResponse response = client.GET("https://http2.akamai.com");
System.out.println("Version: " + response.getVersion());
System.out.println("Status: " + response.getStatus());
System.out.println("Content: " + response.getContentAsString());
}
}
And here is the Exception I get in the line client.GET("https://http2.akamai.com")
Exception in thread "main" java.util.concurrent.ExecutionException: java.nio.channels.ClosedChannelException
at org.eclipse.jetty.client.util.FutureResponseListener.getResult(FutureResponseListener.java:118)
at org.eclipse.jetty.client.util.FutureResponseListener.get(FutureResponseListener.java:101)
at org.eclipse.jetty.client.HttpRequest.send(HttpRequest.java:653)
at org.eclipse.jetty.client.HttpClient.GET(HttpClient.java:343)
at org.eclipse.jetty.client.HttpClient.GET(HttpClient.java:328)
at de.consol.labs.h2c.examples.client.okhttp.JettyClientExample.main(JettyClientExample.java:15)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:140)
Caused by: java.nio.channels.ClosedChannelException
at org.eclipse.jetty.http2.HTTP2Session.onShutdown(HTTP2Session.java:779)
at org.eclipse.jetty.http2.HTTP2Connection$HTTP2Producer.produce(HTTP2Connection.java:181)
at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.produceAndRun(ExecuteProduceConsume.java:162)
at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.execute(ExecuteProduceConsume.java:101)
at org.eclipse.jetty.http2.HTTP2Connection.onOpen(HTTP2Connection.java:80)
at org.eclipse.jetty.http2.client.HTTP2ClientConnectionFactory$HTTP2ClientConnection.onOpen(HTTP2ClientConnectionFactory.java:105)
at org.eclipse.jetty.io.ssl.SslConnection.onOpen(SslConnection.java:152)
at org.eclipse.jetty.io.ClientConnectionFactory$Helper.open(ClientConnectionFactory.java:70)
at org.eclipse.jetty.io.ClientConnectionFactory$Helper.replaceConnection(ClientConnectionFactory.java:63)
at org.eclipse.jetty.io.NegotiatingClientConnection.replaceConnection(NegotiatingClientConnection.java:113)
at org.eclipse.jetty.io.NegotiatingClientConnection.onFillable(NegotiatingClientConnection.java:89)
at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:245)
at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:95)
at org.eclipse.jetty.io.ssl.SslConnection.onFillable(SslConnection.java:192)
at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:245)
at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:95)
at org.eclipse.jetty.io.SelectChannelEndPoint$2.run(SelectChannelEndPoint.java:75)
at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.produceAndRun(ExecuteProduceConsume.java:213)
at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.run(ExecuteProduceConsume.java:147)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:654)
at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:572)
at java.lang.Thread.run(Thread.java:745)
I am using version 9.3.3.v20150827, and I put the ALPN JAR into my boot classpath with -Xbootclasspath/p:<path>.
For some reason, I didn't find any working example of HttpClientTransportOverHTTP2 with SSL on the Internet.
What am I missing?
You hit this bug, which is fixed in Jetty 9.3.4.

Object in mule's registry cannot be cast to org.mule.construct.AbstractFlowConstruct on application startup

I'm trying to store instance of some class in mule registry on flow application startup. Below you can see my java code and flow fragment. My problem is that sometimes application deployment fails with following error:
Caused by: java.lang.ClassCastException: com.company.test.sorter.model.Config cannot be cast to org.mule.construct.AbstractFlowConstruct
at org.mule.module.management.mbean.FlowConstructService.postRegister(FlowConstructService.java:139)
at org.mule.module.management.agent.ClassloaderSwitchingMBeanWrapper.postRegister(ClassloaderSwitchingMBeanWrapper.java:101)
You can find whole stacktrace below. I must repeat: this exception is raised only sometimes, approximately every fifth deployment of unchanged application. In most cases application runs perfectly fine. I googled for this exceptions and classes but I didn't find any solution. I am using Mule 3.2.1 (standalone). Is it a bug or am I doing something wrong?
#XmlRootElement(name = "config")
public class Config {
private String x2Regex;
private String x3Regex;
private String x2QueueName;
private String x3QueueName;
// constructors, getters and setters
}
public class Initializer implements
MuleContextNotificationListener<MuleContextNotification> {
#Override
public void onNotification(MuleContextNotification notification) {
if (notification.getAction() == MuleContextNotification.CONTEXT_STARTED) {
try {
notification.getMuleContext().getRegistry().registerObject("config", new Config());
} catch (RegistrationException e) {
// cut
}
}
}
}
<notifications>
<notification event="CONTEXT"/>
<notification-listener ref="Initializer"/>
</notifications>
<spring:beans>
<spring:bean id="Initializer" name="Initializer" class="com.company.test.sorter.Initializer" doc:name="Bean"/>
</spring:beans>
Below is fragment of mule's log with exception:
+ Failed to deploy app 'number-sorter', see below +
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
org.mule.module.launcher.DeploymentException: Failed to deploy application [number-sorter]
at org.mule.module.launcher.DefaultMuleDeployer.deploy(DefaultMuleDeployer.java:68)
at org.mule.module.launcher.DeploymentService.start(DeploymentService.java:175)
at org.mule.module.launcher.MuleContainer.start(MuleContainer.java:157)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.mule.module.reboot.MuleContainerWrapper.start(MuleContainerWrapper.java:56)
at org.tanukisoftware.wrapper.WrapperManager$12.run(WrapperManager.java:2788)
Caused by: org.mule.api.MuleRuntimeException: MBeans Failed to initialise
at org.mule.module.management.agent.JmxAgent$MuleContextStartedListener.onNotification(JmxAgent.java:707)
at org.mule.module.management.agent.JmxAgent$MuleContextStartedListener.onNotification(JmxAgent.java:685)
at org.mule.context.notification.Sender.dispatch(Sender.java:40)
at org.mule.context.notification.Policy.dispatch(Policy.java:122)
at org.mule.context.notification.ServerNotificationManager.notifyListeners(ServerNotificationManager.java:244)
at org.mule.context.notification.ServerNotificationManager.fireNotification(ServerNotificationManager.java:197)
at org.mule.DefaultMuleContext.fireNotification(DefaultMuleContext.java:404)
at org.mule.DefaultMuleContext.start(DefaultMuleContext.java:226)
at org.mule.module.launcher.application.DefaultMuleApplication.start(DefaultMuleApplication.java:146)
at org.mule.module.launcher.application.ApplicationWrapper.start(ApplicationWrapper.java:107)
at org.mule.module.launcher.DefaultMuleDeployer.deploy(DefaultMuleDeployer.java:52)
... 8 more
Caused by: javax.management.RuntimeMBeanException: RuntimeException thrown in postRegister method
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.postRegisterInvoke(Unknown Source)
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerDynamicMBean(Unknown Source)
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerObject(Unknown Source)
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerMBean(Unknown Source)
at com.sun.jmx.mbeanserver.JmxMBeanServer.registerMBean(Unknown Source)
at org.mule.module.management.agent.JmxAgent.registerFlowConstructServices(JmxAgent.java:428)
at org.mule.module.management.agent.JmxAgent$MuleContextStartedListener.onNotification(JmxAgent.java:700)
... 18 more
Caused by: java.lang.ClassCastException: com.company.test.sorter.model.Config cannot be cast to org.mule.construct.AbstractFlowConstruct
at org.mule.module.management.mbean.FlowConstructService.postRegister(FlowConstructService.java:139)
at org.mule.module.management.agent.ClassloaderSwitchingMBeanWrapper.postRegister(ClassloaderSwitchingMBeanWrapper.java:101)
... 25 more
Feels like a bug: after reading the source code, I find no reasonable explanation to why Mule would try to register your custom object in JMX while mistaking it for a Flow!
As a side note, why using a notification listener and the Mule registry when you can just build your object with Spring?