We have several server side components in our architecture. Each component uses JMX to expose various internal attributes. Initialization is done as follows:
try {
Registry registry = null;
for(int i = _serverInfo.getJMXStartPort(); i <= _serverInfo.getJMXEndPort(); i++) {
try {
registry = LocateRegistry.createRegistry(i);
if(registry != null) {
_statusPort = i;
logger.info("Using JMX port: "+_statusPort);
break;
}
} catch (Exception e) {
_statusPort++;
}
}
MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
_abstractServiceController = new AbstractServiceController(this);
ObjectName mbeanName = new ObjectName("MyServer:name=MyServer Service");
mbs.registerMBean(_abstractServiceController, mbeanName);
JMXServiceURL url = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://:"+_statusPort+"/jmxrmi");
JMXConnectorServer cs = JMXConnectorServerFactory.newJMXConnectorServer(url, System.getenv(), mbs);
cs.start();
} catch (Throwable e) {
logger.error("Unable to register MBean with JMX");
e.printStackTrace();
}
I guess I have two questions.
Does this look right?
The bigger question is, while this runs fine on java 1.6 (each subsequent server on a host uses the next available port, since LocateRegistry.createRegistry(i) throws an exception if the port is unavailable), not so on 1.7. As a result, we get the following exception when the second server attempts to JMXConnectorServer.start(). Does anyone know if the behavior changed for createRegistry? If so, is there something else we should do?
2013-02-07 15:34:28,451 INFO [main] Using JMX port: 9500
2013-02-07 15:34:28,929 ERROR [main] Unable to register MBean with JMX
java.io.IOException: Cannot bind to URL [rmi://:9500/jmxrmi]: javax.naming.NameAlreadyBoundException: jmxrmi [Root exception is java.rmi.AlreadyBoundException: jmxrmi]
at javax.management.remote.rmi.RMIConnectorServer.newIOException(RMIConnectorServe.java:826)
at javax.management.remote.rmi.RMIConnectorServer.start(RMIConnectorServer.java:431)
at com.theatre.services.framework.AbstractService.run(AbstractService.java:306)
at com.theatre.services.reporttree.TreeServerImpl.run(TreeServerImpl.java:690)
at com.theatre.services.framework.Launcher.main(Launcher.java:99)
Caused by: javax.naming.NameAlreadyBoundException: jmxrmi [Root exception is java.rmi.AlreadyBoundException: jmxrmi]
at com.sun.jndi.rmi.registry.RegistryContext.bind(RegistryContext.java:139)
at com.sun.jndi.toolkit.url.GenericURLContext.bind(GenericURLContext.java:226)
at javax.naming.InitialContext.bind(InitialContext.java:419)
at javax.management.remote.rmi.RMIConnectorServer.bind(RMIConnectorServer.java:643)
at javax.management.remote.rmi.RMIConnectorServer.start(RMIConnectorServer.java:426)
... 3 more
Caused by: java.rmi.AlreadyBoundException: jmxrmi
at sun.rmi.registry.RegistryImpl.bind(RegistryImpl.java:131)
at sun.rmi.registry.RegistryImpl_Skel.dispatch(Unknown Source)
at sun.rmi.server.UnicastServerRef.oldDispatch(UnicastServerRef.java:390)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:248)
at sun.rmi.transport.Transport$1.run(Transport.java:159)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:155)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:535)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:790)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:649)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)
at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:273)
at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:251)
at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:377)
at sun.rmi.registry.RegistryImpl_Stub.bind(Unknown Source)
at com.sun.jndi.rmi.registry.RegistryContext.bind(RegistryContext.java:137)
... 7 more
Does this look right?
No. Creating a Registry can fail for several reasons, not just because the port is in use.
registry cannot be null after createRegistry(), so testing for it is pointless.
If you're trying to find a free port, just open (and close) a ServerSocket(). Then create the Registry on that port if it worked.
The bigger question is, while this runs fine on java 1.6 (each subsequent server on a host uses the next available port, since LocateRegistry.createRegistry(i) throws an exception if the port is unavailable), not so on 1.7.
See above. Creating a Registry can also fail if there is already one running on that port, in any JDK. In earlier JDKs it would fail if there was one running on any port in the same JVM.
Related
I am trying to do remote ejb lookup in wildfly 10 server. Below is the code for lookup.
private static Object lookup() throws Exception {
Properties properties = new Properties();
properties.put("java.naming.factory.url.pkgs",
"org.jboss.ejb.client.naming");
properties.put("jboss.naming.client.ejb.context",
"false");
properties.put("org.jboss.ejb.client.scoped.context", "true");
properties.put("endpoint.name", "client-endpoint");
properties.put("remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED","false");
properties.put("remote.connections", "default");
properties.put("remote.connection.default.host", "192.168.1.13");
properties.put("remote.connection.default.port", "36430");
properties.put("remote.connection.default.username", "username");
properties.put("remote.connection.default.password", "pwd");
properties.put("remote.connection.default.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS", "false");
properties.put("remote.connection.default.connect.options.org.xnio.Options.SASL_POLICY_NOPLAINTEXT", "false");
properties.put("remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED", "false");
properties.put("remote.connectionprovider.create.options.org.jboss.remoting3.RemotingOptions.MAX_OUTBOUND_MESSAGES", "0x7fffffff");
properties.put("remote.connectionprovider.create.options.org.jboss.remoting3.RemotingOptions.MAX_INBOUND_MESSAGES", "0x7fffffff");
InitialContext ctx = new InitialContext(properties);
Object obj = (WorkFlowExternalFacade) ctx.lookup("ejb:cwapp/cwebl/WorkFlowExternalFacade!com.xxx.xxx.WorkFlowExternalFacadeRemote);
System.out.println("Lookup Success:"+obj)
obj.findAll();
}
The above code is working fine when I change the IP and Port to my local wildfly which is running on 9080 port i.e..
properties.put("remote.connection.default.host", "127.0.0.1");
properties.put("remote.connection.default.port", "9080");
I try to execute the code for remote lookup which wildfly is running in some other machine(192.168.1.13:36430) I am getting below exception..
java.io.IOException: Connection reset by peer
at sun.nio.ch.FileDispatcherImpl.read0(Native Method)
at sun.nio.ch.SocketDispatcher.read(SocketDispatcher.java:39)
at sun.nio.ch.IOUtil.readIntoNativeBuffer(IOUtil.java:223)
at sun.nio.ch.IOUtil.read(IOUtil.java:197)
at sun.nio.ch.SocketChannelImpl.read(SocketChannelImpl.java:380)
at org.xnio.nio.NioSocketConduit.read(NioSocketConduit.java:289)
at org.xnio.conduits.ConduitStreamSourceChannel.read(ConduitStreamSourceChannel.java:127)
at org.xnio.http.HttpUpgrade$HttpUpgradeState$UpgradeResultListener.handleEvent(HttpUpgrade.java:410)
at org.xnio.http.HttpUpgrade$HttpUpgradeState.flushUpgradeChannel(HttpUpgrade.java:369)
at org.xnio.http.HttpUpgrade$HttpUpgradeState.access$900(HttpUpgrade.java:165)
at org.xnio.http.HttpUpgrade$HttpUpgradeState$ConnectionOpenListener.handleEvent(HttpUpgrade.java:340)
at org.xnio.http.HttpUpgrade$HttpUpgradeState$ConnectionOpenListener.handleEvent(HttpUpgrade.java:320)
at org.xnio.ChannelListeners.invokeChannelListener(ChannelListeners.java:92)
at org.xnio.nio.WorkerThread$ConnectHandle.handleReady(WorkerThread.java:326)
at org.xnio.nio.WorkerThread.run(WorkerThread.java:567)
at ...asynchronous invocation...(Unknown Source)
at org.jboss.remoting3.EndpointImpl.doConnect(EndpointImpl.java:294)
at org.jboss.remoting3.EndpointImpl.connect(EndpointImpl.java:430)
at org.jboss.ejb.client.remoting.EndpointPool$PooledEndpoint.connect(EndpointPool.java:192)
at org.jboss.ejb.client.remoting.NetworkUtil.connect(NetworkUtil.java:153)
at org.jboss.ejb.client.remoting.NetworkUtil.connect(NetworkUtil.java:133)
at org.jboss.ejb.client.remoting.ConnectionPool.getConnection(ConnectionPool.java:78)
at org.jboss.ejb.client.remoting.RemotingConnectionManager.getConnection(RemotingConnectionManager.java:51)
at org.jboss.ejb.client.remoting.ConfigBasedEJBClientContextSelector.setupEJBReceivers(ConfigBasedEJBClientContextSelector.java:161)
at org.jboss.ejb.client.remoting.ConfigBasedEJBClientContextSelector.getCurrent(ConfigBasedEJBClientContextSelector.java:118)
at org.jboss.ejb.client.naming.ejb.EjbNamingContext.createIdentifiableEjbClientContext(EjbNamingContext.java:269)
at org.jboss.ejb.client.naming.ejb.EjbNamingContext.setupScopedEjbClientContextIfNeeded(EjbNamingContext.java:134)
at org.jboss.ejb.client.naming.ejb.EjbNamingContext.<init>(EjbNamingContext.java:101)
at org.jboss.ejb.client.naming.ejb.ejbURLContextFactory.getObjectInstance(ejbURLContextFactory.java:38)
at javax.naming.spi.NamingManager.getURLObject(NamingManager.java:601)
at javax.naming.spi.NamingManager.getURLContext(NamingManager.java:550)
at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:345)
at javax.naming.InitialContext.lookup(InitialContext.java:417)
The above exception is coming at ctx.lookup(..) but I am getting proxy object, I tried to print for proxy object
Lookup Success: Proxy for remote EJB StatelessEJBLocator for
"xx/xx/WorkFlowExternalFacade", view is interface
com.xxx.xxx.xxx.WorkFlowExternalFacadeRemote,
affinity is None
but when I try to call the API with the object obj.findAll() I am getting the below exception
java.lang.IllegalStateException: EJBCLIENT000025: No EJB receiver available for handling [appName:cwapp, moduleName:cwebl, distinctName:] combination for invocation context org.jboss.ejb.client.EJBClientInvocationContext#37918c79
at org.jboss.ejb.client.EJBClientContext.requireEJBReceiver(EJBClientContext.java:798)
at org.jboss.ejb.client.ReceiverInterceptor.handleInvocation(ReceiverInterceptor.java:128)
at org.jboss.ejb.client.EJBClientInvocationContext.sendRequest(EJBClientInvocationContext.java:186)
at org.jboss.ejb.client.EJBInvocationHandler.sendRequestWithPossibleRetries(EJBInvocationHandler.java:255)
at org.jboss.ejb.client.EJBInvocationHandler.doInvoke(EJBInvocationHandler.java:200)
at org.jboss.ejb.client.EJBInvocationHandler.doInvoke(EJBInvocationHandler.java:183)
at org.jboss.ejb.client.EJBInvocationHandler.invoke(EJBInvocationHandler.java:146)
at com.sun.proxy.$Proxy2.findAll(Unknown Source)
Can anyone help me how to fix the above issue?
I am using Java8 and have a Chat Server that works perfectly on my localhost, but when I deploy it to an OpenShift server, I get the following error:
java.net.SocketException: Permission denied
2016-09-05 10:36:11,300 INFO [stdout] (Thread-125) Starting Chat server on localhost:8000 ...
2016-09-05 10:36:13,194 ERROR [stderr] (Thread-125) Exception in thread "Thread-125" java.net.SocketException: Permission denied
2016-09-05 10:36:13,194 ERROR [stderr] (Thread-125) at sun.nio.ch.Net.bind0(Native Method)
2016-09-05 10:36:13,195 ERROR [stderr] (Thread-125) at sun.nio.ch.Net.bind(Net.java:433)
2016-09-05 10:36:13,195 ERROR [stderr] (Thread-125) at sun.nio.ch.Net.bind(Net.java:425)
2016-09-05 10:36:13,195 ERROR [stderr] (Thread-125) at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:223)
2016-09-05 10:36:13,195 ERROR [stderr] (Thread-125) at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:74)
2016-09-05 10:36:13,196 ERROR [stderr] (Thread-125) at io.netty.channel.socket.nio.NioServerSocketChannel.doBind(NioServerSocketChannel.java:125)
2016-09-05 10:36:13,196 ERROR [stderr] (Thread-125) at io.netty.channel.AbstractChannel$AbstractUnsafe.bind(AbstractChannel.java:476)
2016-09-05 10:36:13,196 ERROR [stderr] (Thread-125) at io.netty.channel.DefaultChannelPipeline$HeadHandler.bind(DefaultChannelPipeline.java:1000)
2016-09-05 10:36:13,196 ERROR [stderr] (Thread-125) at io.netty.channel.DefaultChannelHandlerContext.invokeBind(DefaultChannelHandlerContext.java:463)
2016-09-05 10:36:13,197 ERROR [stderr] (Thread-125) at io.netty.channel.DefaultChannelHandlerContext.bind(DefaultChannelHandlerContext.java:448)
2016-09-05 10:36:13,197 ERROR [stderr] (Thread-125) at io.netty.channel.DefaultChannelPipeline.bind(DefaultChannelPipeline.java:842)
2016-09-05 10:36:13,197 ERROR [stderr] (Thread-125) at io.netty.channel.AbstractChannel.bind(AbstractChannel.java:195)
2016-09-05 10:36:13,197 ERROR [stderr] (Thread-125) at io.netty.bootstrap.AbstractBootstrap$2.run(AbstractBootstrap.java:338)
2016-09-05 10:36:13,198 ERROR [stderr] (Thread-125) at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:370)
2016-09-05 10:36:13,198 ERROR [stderr] (Thread-125) at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:353)
2016-09-05 10:36:13,198 ERROR [stderr] (Thread-125) at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:116)
2016-09-05 10:36:13,198 ERROR [stderr] (Thread-125) at java.lang.Thread.run(Thread.java:745)
I have looked at the OpenShift web sockets guide here, which says port 8000 should be used. But I still get the error.
On Openshift I am running my chat server on a WildFly Application Server 10 cartridge.
Any advise appreciated.
Here is my code:
WebAppInitializer.java
try {
new Thread() {
public void run() {
com.jobs.spring.chat.Server chatServer = new com.jobs.spring.chat.Server();
chatServer.startServer();
}
}.start();
} catch (Exception e) {
e.printStackTrace();
}
Server.java
import java.net.Socket;
import com.corundumstudio.socketio.AckRequest;
import com.corundumstudio.socketio.Configuration;
import com.corundumstudio.socketio.SocketIOClient;
import com.corundumstudio.socketio.SocketIOServer;
import com.corundumstudio.socketio.listener.ConnectListener;
import com.corundumstudio.socketio.listener.DataListener;
import com.corundumstudio.socketio.listener.DisconnectListener;
import com.fasterxml.jackson.databind.ObjectMapper;
/**
* https://blog.openshift.com/paas-websockets/
* #author Richard
*
*/
public class Server {
//private static final String SERVER = "localhost";
private static final String SERVER = "jbosswildfly-easyjobs.rhcloud.com";
private static final Integer PORT = 8000;
public static void main(String[] args) {
startServer();
}
public static void startServer() {
Configuration config = new Configuration();
config.setHostname(SERVER);
config.setPort(PORT);
final SocketIOServer server = new SocketIOServer(config);
server.addConnectListener(new ConnectListener() {
#Override
public void onConnect(SocketIOClient client) {
System.out.println("onConnected");
client.sendEvent("chat_message:message", new Message("Welcome to the chat!"));
}
});
server.addDisconnectListener(new DisconnectListener() {
#Override
public void onDisconnect(SocketIOClient client) {
System.out.println("onDisconnected");
}
});
server.addEventListener("chat_message:send", String.class, new DataListener<String>() {
#Override
public void onData(SocketIOClient client, String data, AckRequest ackSender) throws Exception {
Message message = null;
try {
message = new ObjectMapper().readValue(data.toString(), Message.class);
} catch (Exception e) {
e.printStackTrace();
}
message.setDate(System.currentTimeMillis());
server.getBroadcastOperations().sendEvent("chat_message:message", message);
}
});
System.out.println("Starting Chat server on " + SERVER + ":" + PORT+" ...");
server.start();
System.out.println("Chat server started");
System.out.println("Chat server Environment Info: " + System.getenv());
try {
Socket socket = new Socket(SERVER, PORT);
printSocketInformation(socket);
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* Prints debug output (to stdout) for the given Java Socket.
*/
public static void printSocketInformation(Socket socket) {
try {
System.out.format("Port: %s\n", socket.getPort());
System.out.format("Canonical Host Name: %s\n", socket.getInetAddress().getCanonicalHostName());
System.out.format("Host Address: %s\n\n", socket.getInetAddress().getHostAddress());
System.out.format("Local Address: %s\n", socket.getLocalAddress());
System.out.format("Local Port: %s\n", socket.getLocalPort());
System.out.format("Local Socket Address: %s\n\n", socket.getLocalSocketAddress());
System.out.format("Receive Buffer Size: %s\n", socket.getReceiveBufferSize());
System.out.format("Send Buffer Size: %s\n\n", socket.getSendBufferSize());
System.out.format("Keep-Alive: %s\n", socket.getKeepAlive());
System.out.format("SO Timeout: %s\n", socket.getSoTimeout());
} catch (Exception e) {
e.printStackTrace();
}
}
}
In this link OpenShift talk about port binding and proxies. I don't really understand all of it. It looks like I should use port 8000 (which I am), but I am not clear what hostname I should use. I am using my application url name (jbosswildfly-easyjobs.rhcloud.com). Is that correct?
If I change the address to, http://jbosswildfly-easyjobs.rhcloud.com (i.e. prefix http://) I get the following error:
java.net.SocketException: Unresolved address
I was trying to find out solution. I have got some solutions. All are suggesting to add -Djava.net.preferIPv4Stack=true to the VM options.
Atlassian Documentation also got the root cause and solution given below:
Cause
This is one of the known issues with Java 7, as per this post.
This can also be caused by any anti-virus or firewall software
installed on the server.
Resolution
Use the -Djava.net.preferIPv4Stack=true JVM system property to help
enable support for IPv4 on Java 7.
Check that anti-virus and firewall software on the server is not
blocking Stash's ability to connect to the mail server.
This solution is for Java 7, but you are using Java 8. So I lookup your stacktrace. There is a line
at io.netty.channel.socket.nio.NioServerSocketChannel.doBind(NioServerSocketChannel.java:125)
Which is telling that you are using netty.
But netty has some requirement on version basis. There is also some limitations.
JDK 5 (Netty 3.x) or 6 (Netty 4.x) is enough. Some components such as
HTTP/2 might have more requirements
Requirements for Netty 4.x(link)
Java does not currently support ALPN or NPN (there is a tracking issue so go upvote it!). For lack of support in the JDK we need to
use the Jetty-ALPN (or Jetty-NPN if on Java < 8) bootclasspath
extension for OpenJDK. To do this, add a Xbootclasspath JVM option
referencing the path to the Jetty alpn-boot jar.
java -Xbootclasspath/p:/path/to/jetty/alpn/extension.jar ...
Note that you must use the release of the Jetty-ALPN jar specific
to the version of Java you are using.
JDK Ciphers
Java 7 does not support the cipher suites recommended by the HTTP2 RFC. To address this we suggest servers use Java 8 where
possible or use an alternative JCE implementation such as Bouncy
Castle. If this is not practical it is possible to use other
ciphers but you need to ensure that the services you intend to call
also support these ciphers forbidden by the HTTP/2 RFC and have
evaluated the security risks of doing so.
Enabling ALPN or NPN
The SslContextBuilder has a setter for an ApplicationProtocolConfig which is used to configure ALPN or NPN.
See the HTTP/2 examples for ALPN and SPDY examples for NPN
usage.
For details description, you can go through this link.
Suggestions:
So check your netty version and take decision according above issues. Or use JDK 7 if possible.
The linked blog post says that you can connect to websockets on OpenShift using ports 8000 and 8443. However, the server itself needs to be bound only to port 8080 and then you can connect externally to the ws ports above. This diagram that you have already found explains the configuration.
WildFly is using 8080 already, so you may want to use the DIY cartridge to deploy your app (don't forget to disable the default ruby server in the start action hook that is running on 8080) or be inspired here.
I have Two web applications the first do the following.
I have Two WARS
The first WAR creates and sets a remote object,
System.setSecurityManager(new SecurityManager());
try {
registry = LocateRegistry.createRegistry(Config.getRmiPort());
} catch(RemoteException ex) {
//if the registry is already created, try getting it instead of creating it
registry = LocateRegistry.getRegistry(Config.getRmiPort());
}
remotePDFGenerator remoteEasyPDFGenerator = new EasyPDFGenerator();
registryManager.rebind(PDFGeneratorRemoteInterface.REMOTE_PDF_GENERATOR_NAME, remoteEasyPDFGenerator);
so far so good I don't get any exceptions of any kind, and in the second war
ActionManager actionObj= ActionManagerImpl.getInstance();
System.setSecurityManager(new SecurityManager());
try {
Registry registry = LocateRegistry.getRegistry(EngineConfig.getRmiPort());// same port used in WAR1
String[] names=registry.list();//contians remotepdfGenerator (the name I set in WAR1)
remotePDFGenerator pdfObj=registry.lookup(names[0]);//remotePDFGenerator is the remote interface in WAR1, I exported it as a jar.
registry.unbind(names[0]);
registry.rebind(names[0], pdfObj);// works without any problems!!!
registry.rebind(fullRemoteName, actionObj);//trhows an exception
;
String names2 []=registry.list();
}
catch(AccessException e)
{
e.printStackTrace();
}
catch (RemoteException e) {
Object[] args = {fullRemoteName};
e.printStackTrace();
throw new RmiException(RmiException.MSG_FAILED_TO_REBIND_REMOTE_OBJECT_ARGS , args, e);
}
why the second rebind throws an exception, could it be because the registry is shared between those two wars, but since the first WAR has no access to the second WAR remote interface?, even though I exported ActionManager interface as a jar and referenced it in the First WAR but still no luck.
and when I run the First war on a different machine(not a different web server), this problem doesn't occur and everything goes smooth. here is the stack trace
java.rmi.ServerException: RemoteException occurred in server thread; nested exception is:
java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is:
java.lang.ClassNotFoundException: com.bla.blabla.business.cluster.actions.ActionManagerImpl_Stub (no security manager: RMI class loader disabled)
at sun.rmi.server.UnicastServerRef.oldDispatch(UnicastServerRef.java:419)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:267)
at sun.rmi.transport.Transport$1.run(Transport.java:177)
at sun.rmi.transport.Transport$1.run(Transport.java:174)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:173)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:556)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:811)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:670)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:744)
at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:275)
at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:252)
at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:378)
at sun.rmi.registry.RegistryImpl_Stub.rebind(Unknown Source)
at com.bla.blabla.rmi.RmiManager.rebind(RmiManager.java:107)
at com.bla.blabla.rmi.RmiServiceLocator.setService(RmiServiceLocator.java:242)
at com.bla.blabla.rmi.RmiServiceLocator.setService(RmiServiceLocator.java:224)
at com.bla.blabla.business.cluster.actions.ActionManagerImpl.init(ActionManagerImpl.java:60)
...
I have tried a snippet from Basho's docs which is given as below :
public class TasteOfRiak {
public static void main(String[] args) throws UnknownHostException, ExecutionException, InterruptedException
{
RiakClient client = RiakClient.newClient(port, "IP");
Location location = new Location(new Namespace("Bucket"), "bucketType");
FetchValue fv = new FetchValue.Builder(location).build();
FetchValue.Response response = client.execute(fv);
String value = response.getValue(String.class);
System.out.println(value);
client.shutdown();
}
}
But, this throws exception :
[main] ERROR com.basho.riak.client.core.RiakNode - Connection attempt failed: java.net.ConnectException:
Connection timed out: no further information:
Exception in thread "main" [pool-1-thread-2] INFO com.basho.riak.client.core.DefaultNodeManager - NodeManager moved node to unhealthy list; 3.34.211.202:8098
java.util.concurrent.ExecutionException: com.basho.riak.client.core.NoNodesAvailableException
at com.basho.riak.client.core.FutureOperation.get(FutureOperation.java:260)
at com.basho.riak.client.api.commands.CoreFutureAdapter.get(CoreFutureAdapter.java:52)
at com.basho.riak.client.api.RiakCommand.execute(RiakCommand.java:89)
at com.basho.riak.client.api.RiakClient.execute(RiakClient.java:293)
at TasteOfRiak.main(TasteOfRiak.java:20)
Caused by: com.basho.riak.client.core.NoNodesAvailableException
at com.basho.riak.client.core.DefaultNodeManager.executeOnNode(DefaultNodeManager.java:95)
at com.basho.riak.client.core.RiakCluster.execute(RiakCluster.java:197)
at com.basho.riak.client.core.RiakCluster.retryOperation(RiakCluster.java:328)
at com.basho.riak.client.core.RiakCluster.access$800(RiakCluster.java:44)
at com.basho.riak.client.core.RiakCluster$RetryTask.run(RiakCluster.java:340)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:178)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:292)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:744)
Check the the riak node is running (as Craig said), and you could see the node name in etc/vm.args.
Make sure erlang node cookie correct. Erlang VM will check the cookie from other VM is match, if not, it would refuse the ping or connection request. Local cookie place in ~/.erlang.cookie, suggest to try setting VM cookie as your local cookie before connect.
Another way:
$ bin/riak console
%% set cookie
erlang:set_cookie(your_riak_node_name, your_cookie)
The riak java client doesn't support HTTP. Make sure you are connecting using protocol buffer port. Default is 8087
Also make sure your Riak server is listening on the ip address you specify. You can edit the listeners in etc/riak/riak.conf
We are facing an issue in our production env. We have searched the net high and low and we were not able to come up with any answers.
This error(stacktrace below) occurs when an ejb lookup is made from managed server 1 to manager server 2. Virtual ip is used for the lookup. It occurs intermittently and at random intervals. We are not able to identify any pattern and If the ejb call is attempted two or three times, it gets through successfully.
Env details :
server : weblogic 10.0 MP1 running on java 1.5
os : solaris
Pls revert if any other details are required.
Source used for lookup :
private TreControlRemote getController() throws Exception {
Context context = null;
Properties p = new Properties();
TreControlHome treHome = null;
TreControlRemote remote = null;
ConfigurationLoader lAppLoader = null;
try {
mLog.debug("Entering");
lAppLoader = PropertiesFileLoader.getInstance("context.properties");
p.put(Context.INITIAL_CONTEXT_FACTORY, lAppLoader.getValue("INITIAL_CONTEXT_FACTORY"));
p.put(Context.PROVIDER_URL, lAppLoader.getValue("PROVIDER_URL"));
context = new InitialContext(p);
mLog.debug("context : " + context.getEnvironment());
remote = null;
treHome = (TreControlHome) context.lookup("CONTROL");
mLog.debug("Object --->>>>" + treHome);
remote = (TreControlRemote) treHome.create();
mLog.debug("Leaving");
} catch (Exception ex) {
mLog.fatal("Exception while getting remote", ex);
ex.printStackTrace();
throw ex;
} finally {
lAppLoader = null;
}
return remote;
}
The url is a virtual ip pointing to managed server 2 and it contains a ejb with jndi "CONTROL". The problem is that it successful on certain occassions and fails randomly with the error:
stack trace of the error :
*javax.naming.CommunicationException [Root exception is java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is:
java.io.StreamCorruptedException]
at weblogic.jndi.internal.ExceptionTranslator.toNamingException(ExceptionTranslator.java:74)
at weblogic.jndi.internal.WLContextImpl.translateException(WLContextImpl.java:426)
at weblogic.jndi.internal.WLContextImpl.lookup(WLContextImpl.java:382)
at weblogic.jndi.internal.WLContextImpl.lookup(WLContextImpl.java:367)
at javax.naming.InitialContext.lookup(InitialContext.java:351)
```````````````````````````````````````````````````````````````````
Caused by: java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is:
java.io.StreamCorruptedException
at weblogic.rjvm.ResponseImpl.unmarshalReturn(ResponseImpl.java:221)
at weblogic.rmi.cluster.ClusterableRemoteRef.invoke(ClusterableRemoteRef.java:338)
at weblogic.rmi.cluster.ClusterableRemoteRef.invoke(ClusterableRemoteRef.java:252)
at weblogic.jndi.internal.ServerNamingNode_1001_WLStub.lookup(Unknown Source)
at weblogic.jndi.internal.WLContextImpl.lookup(WLContextImpl.java:379)
... 33 more
Caused by: java.io.StreamCorruptedException
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1332)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:348)
at weblogic.utils.io.ChunkedObjectInputStream.readObject(ChunkedObjectInputStream.java:195)
at weblogic.rjvm.MsgAbbrevInputStream.readObject(MsgAbbrevInputStream.java:565)
at weblogic.utils.io.ChunkedObjectInputStream.readObject(ChunkedObjectInputStream.java:191)
at weblogic.jndi.internal.RootNamingNode_WLSkel.invoke(Unknown Source)
at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:589)
at weblogic.rmi.cluster.ClusterableServerRef.invoke(ClusterableServerRef.java:224)
at weblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.java:479)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:363)
at weblogic.security.service.SecurityManager.runAs(Unknown Source)
at weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:475)
at weblogic.rmi.internal.BasicServerRef.access$300(BasicServerRef.java:59)
at weblogic.rmi.internal.BasicServerRef$BasicExecuteRequest.run(BasicServerRef.java:1016)
... 2 more*
Obtained the below mentioned stacktrace from the weblogic log. Could this error be related to our problem mentioned above?
*####<Aug 25, 2009 2:11:04 AM BST> <Info> <RJVM> <pkssv049> <M1AP4> <ACTIVE ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)'> <<WLS Kernel>> <1251162664181> <BEA-000513> <Failure in heartbeat trigger for RJVM: 5433424963141690658S:169.93.73.0:10040,10040,-1,-1,-1,-1,-1:pkssv049.***.net:10240,pkssv049.***.net:10241,pkssv050.***.net:10240,pkssv050.***.net:10241:LIQP1_LMSDomain:M1AP3
java.io.IOException: The connection manager to ConnectionManager for: 'weblogic.rjvm.RJVMImpl#189ed0e - id: '5433424963141690658S:169.93.73.0:10040,10040,-1,-1,-1,-1,-1:pkssv049.***.net:10240,pkssv049.***.net:10241,pkssv050.***.net:10240,pkssv050.***.net:10241:LIQP1_LMSDomain:M1AP3' connect time: 'Mon Aug 24 20:24:02 BST 2009'' has already been shut down.
java.io.IOException: The connection manager to ConnectionManager for: 'weblogic.rjvm.RJVMImpl#189ed0e - id: '5433424963141690658S:169.93.73.0:10040,10040,-1,-1,-1,-1,-1:pkssv049.***.net:10240,pkssv049.***.net:10241,pkssv050.***.net:10240,pkssv050.***.net:10241:LIQP1_LMSDomain:M1AP3' connect time: 'Mon Aug 24 20:24:02 BST 2009'' has already been shut down
at weblogic.rjvm.ConnectionManager.getOutputStream(ConnectionManager.java:1686)
at weblogic.rjvm.ConnectionManager.createHeartbeatMsg(ConnectionManager.java:1629)
at weblogic.rjvm.ConnectionManager.sendHeartbeatMsg(ConnectionManager.java:607)
at weblogic.rjvm.RJVMImpl$HeartbeatChecker.timerExpired(RJVMImpl.java:1540)
at weblogic.timers.internal.TimerImpl.run(TimerImpl.java:273)
at weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl.run(SelfTuningWorkManagerImpl.java:464)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:200)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:172)*
Any help would be greatly appreciated.
Here is some additional info..
Is the problem intermittent, or does reproduce every single time? If the problem is intermittent, do you know what conditions it occurs under?
It occurs intermittently and we are not able to observe any pattern.
Are there any other errors/warnings logged either on the local server or on the remote server?
We see a lot of connection refused errors in the weblogic log
Are both the managed servers in the same domain?
Yes
when you pass an instance of com.myclientcompany.server.eai.interactionspecimpl as argument to
your ejb. the weblogic needs to deserialize(unmarshal) the object under the ejb context, and its needs the required class for unmarshalling. so if you include the interactionspecimpl class in your ejb-jar file, then you do not need to include those classes in your servers classpath
This issue can occur if you have either a Duplicate entry for or due to a blank space in between.
You need to check all the configuration files including the JDBC , JMS and the config.xml file to find such and entry.
Check if you have left a blank space while entering the JNDI name from the console as well.
Removing the blank space or removing the duplicate entry resolves this issue.