Creating an RMI Connector Client - java

I am trying to connect to MBean server. I need to write JMX Client application. This is the code used for client application. But I have got an exception related to this
Failed to retrieve RMIServer stub:
javax.naming.ServiceUnavailableException [Root exception is
java.rmi.ConnectException: Connection refused to host: localhost;
nested exception is:
Can somebody help me to fix this.
import java.io.IOException;
import javax.management.MBeanServerConnection;
import javax.management.MBeanServerInvocationHandler;
import javax.management.MalformedObjectNameException;
import javax.management.ObjectName;
import javax.management.remote.JMXConnector;
import javax.management.remote.JMXConnectorFactory;
import javax.management.remote.JMXServiceURL;
public class SystemConfigClient {
public static final String HOST = "localhost";
public static final String PORT = "1099";
public static void main(String[] args) throws IOException, MalformedObjectNameException {
JMXServiceURL url =new JMXServiceURL("service:jmx:rmi:///jndi/rmi://" + HOST + ":" +PORT+ "/jmxrmi");
JMXConnector jmxConnector = JMXConnectorFactory.connect(url);
MBeanServerConnection mbeanServerConnection = jmxConnector.getMBeanServerConnection();
//ObjectName should be same as your MBean name
ObjectName mbeanName = new ObjectName("ifs.demo1.jmx:type=SystemConfig");
//Get MBean proxy instance that will be used to make calls to registered MBean
SystemConfigMBean mbeanProxy =
(SystemConfigMBean) MBeanServerInvocationHandler.newProxyInstance(
mbeanServerConnection, mbeanName, SystemConfigMBean.class, true);
//let's make some calls to mbean through proxy and see the results.
System.out.println("Current SystemConfig::" + mbeanProxy.doConfig());
mbeanProxy.setSchemaName("NewSchema");
mbeanProxy.setThreadCount(5);
System.out.println("New SystemConfig::" + mbeanProxy.doConfig());
//let's terminate the mbean by making thread count as 0
mbeanProxy.setThreadCount(0);
//close the connection
jmxConnector.close();
}
}
I have run this code with following arguments.
Dcom.sun.management.jmxremote Dcom.sun.management.jmxremote.port=1099
Dcom.sun.management.jmxremote.authenticate=false
Dcom.sun.management.jmxremote.ssl=false
but I got the exception of
Exception in thread "main" java.io.IOException: Failed to retrieve
RMIServer stub: javax.naming.ServiceUnavailableException [Root
exception is java.rmi.ConnectException: Connection refused to host:
localhost; nested exception is: java.net.ConnectException:
Connection refused: connect] at
javax.management.remote.rmi.RMIConnector.connect(RMIConnector.java:338)
at
javax.management.remote.JMXConnectorFactory.connect(JMXConnectorFactory.java:248)
at
javax.management.remote.JMXConnectorFactory.connect(JMXConnectorFactory.java:207)
at com.demo1.jmx.SystemConfigClient.main(SystemConfigClient.java:29)
Caused by: javax.naming.ServiceUnavailableException [Root exception is
java.rmi.ConnectException: Connection refused to host: localhost;
nested exception is: java.net.ConnectException: Connection refused:
connect] at
com.sun.jndi.rmi.registry.RegistryContext.lookup(RegistryContext.java:101)
at
com.sun.jndi.toolkit.url.GenericURLContext.lookup(GenericURLContext.java:185)
at javax.naming.InitialContext.lookup(InitialContext.java:392) at
javax.management.remote.rmi.RMIConnector.findRMIServerJNDI(RMIConnector.java:1886)
at
javax.management.remote.rmi.RMIConnector.findRMIServer(RMIConnector.java:1856)
at
javax.management.remote.rmi.RMIConnector.connect(RMIConnector.java:257)
... 3 more Caused by: java.rmi.ConnectException: Connection refused
to host: localhost; nested exception is: java.net.ConnectException:
Connection refused: connect at
sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:601) at
sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:198)
at
sun.rmi.transport.tcp.TCPChannel.newConnection(TCPChannel.java:184)
at sun.rmi.server.UnicastRef.newCall(UnicastRef.java:322) at
sun.rmi.registry.RegistryImpl_Stub.lookup(Unknown Source) at
com.sun.jndi.rmi.registry.RegistryContext.lookup(RegistryContext.java:97)
... 8 more Caused by: java.net.ConnectException: Connection refused:
connect at java.net.PlainSocketImpl.socketConnect(Native Method) at
java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333) at
java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182) at
java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366) at
java.net.Socket.connect(Socket.java:529) at
java.net.Socket.connect(Socket.java:478) at
java.net.Socket.(Socket.java:375) at
java.net.Socket.(Socket.java:189) at
sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(RMIDirectSocketFactory.java:22)
at
sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(RMIMasterSocketFactory.java:128)
at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:595)
... 13 more Java Result: 1

Have you noticed that you are using the VM arguments with "D" and not "-D"? Or is it just a typo?
The correct would be:
-Dcom.sun.management.jmxremote
-Dcom.sun.management.jmxremote.port=1099
-Dcom.sun.management.jmxremote.authenticate=false
-Dcom.sun.management.jmxremote.ssl=false

Related

How to connect to Oracle Database with JDBC [duplicate]

This question already has answers here:
java.net.ConnectException: Connection refused
(19 answers)
Closed 1 year ago.
I'm using Eclipse to connect to a remote database with the following details:
name: MSbdd**
Hostname 155.158.xxx.xx
Port: 1521
SID: olt*****
And the authentication type: Default
username: msbd**
password: haslo****
This is the code I have in Eclipse:
package net.codejava;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
public class JavaOracleTest {
public static void main(String[] args) {
String dbURL = "jdbc:oracle:thin:#localhost:1521:xe";
String username = "msbd**";
String password = "haslo****";
try {
Connection connection = DriverManager.getConnection(dbURL, username, password);
System.out.println("Połączono z serwerem Oracle");
} catch (SQLException e) {
System.out.println("Error");
e.printStackTrace();
}
}
}
And this is the error I get:
java.sql.SQLRecoverableException: IO Error: The Network Adapter could not establish the connection (CONNECTION_ID=yV+3U5v4TK2js7gMFTixxA==)
Error
at oracle.jdbc.driver.T4CConnection.handleLogonNetException(T4CConnection.java:882)
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:687)
at oracle.jdbc.driver.PhysicalConnection.connect(PhysicalConnection.java:1086)
at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:90)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:728)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:649)
at java.sql/java.sql.DriverManager.getConnection(DriverManager.java:677)
at java.sql/java.sql.DriverManager.getConnection(DriverManager.java:228)
at net.codejava.JavaOracleTest.main(JavaOracleTest.java:15)
Caused by: oracle.net.ns.NetException: The Network Adapter could not establish the connection (CONNECTION_ID=yV+3U5v4TK2js7gMFTixxA==)
at oracle.net.nt.ConnStrategy.execute(ConnStrategy.java:677)
at oracle.net.resolver.AddrResolution.resolveAndExecute(AddrResolution.java:568)
at oracle.net.ns.NSProtocol.establishConnection(NSProtocol.java:953)
at oracle.net.ns.NSProtocol.connect(NSProtocol.java:350)
at oracle.jdbc.driver.T4CConnection.connect(T4CConnection.java:2155)
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:652)
... 7 more
Caused by: java.io.IOException: Connection refused: connect, socket connect lapse 2003 ms. localhost 1521 0 (2/2) true
at oracle.net.nt.TcpNTAdapter.establishSocket(TcpNTAdapter.java:421)
at oracle.net.nt.TcpNTAdapter.doLocalDNSLookupConnect(TcpNTAdapter.java:303)
at oracle.net.nt.TcpNTAdapter.connect(TcpNTAdapter.java:265)
at oracle.net.nt.ConnOption.connect(ConnOption.java:238)
at oracle.net.nt.ConnStrategy.executeConnOption(ConnStrategy.java:902)
at oracle.net.nt.ConnStrategy.execute(ConnStrategy.java:638)
... 12 more
Caused by: java.net.ConnectException: Connection refused: connect
at java.base/sun.nio.ch.Net.connect0(Native Method)
at java.base/sun.nio.ch.Net.connect(Net.java:482)
at java.base/sun.nio.ch.Net.connect(Net.java:474)
at java.base/sun.nio.ch.SocketChannelImpl.connect(SocketChannelImpl.java:694)
at java.base/java.nio.channels.SocketChannel.open(SocketChannel.java:194)
at oracle.net.nt.TimeoutSocketChannel.connect(TimeoutSocketChannel.java:184)
at oracle.net.nt.TimeoutSocketChannel.<init>(TimeoutSocketChannel.java:158)
at oracle.net.nt.TcpNTAdapter.establishSocket(TcpNTAdapter.java:380)
... 17 more
I've replaced some details with * because it's a database from school.
Your error is:
Caused by: java.net.ConnectException: Connection refused: connect
Check that you have:
The correct hostname.
For example, you say that the hostname is 155.158.xxx.xx but you are using:
String dbURL = "jdbc:oracle:thin:#localhost:1521:xe";
Should it be:
String dbURL = "jdbc:oracle:thin:#155.158.xxx.xx:1521:xe";
the correct port.
the correct SID.
For example, should it be:
String dbURL = "jdbc:oracle:thin:#155.158.xxx.xx:1521:olt*****";
the correct username and password.
access to the database.
I.e. you are running it on a network that can access the server and not from a network that cannot access the server (your school may require you to be directly connected to or logged in to their network to access the server and may refuse connections from unauthenticated users outside their network).

Connection refused when trying to use rest over https

I'm having trouble trying to use https rest on my remote server. I have a remote server deployed using jelastic that is working in https. Im going to host another server in jelastic that would act as the client.But when I try to run this code:
String result;
Client client = ClientBuilder.newClient();
WebTarget target = client
.target("https://myresturi/Test");
Invocation invocation = target.request().buildGet();
Response response = invocation.invoke();
result = (String) response.readEntity(new GenericType<String>() {});
I get :
Caused by: javax.ws.rs.ProcessingException: RESTEASY004655: Unable to invoke request: org.apache.http.conn.HttpHostConnectException: Connect to mysecreturi:443 [mysecreturi/10.1.4.83] failed: Connection refused (Connection refused)
at org.jboss.resteasy.resteasy-jaxrs#3.13.2.Final//org.jboss.resteasy.client.jaxrs.engines.ApacheHttpClient4Engine.invoke(ApacheHttpClient4Engine.java:328)
at org.jboss.resteasy.resteasy-jaxrs#3.13.2.Final//org.jboss.resteasy.client.jaxrs.internal.ClientInvocation.invoke(ClientInvocation.java:443)
at org.jboss.resteasy.resteasy-jaxrs#3.13.2.Final//org.jboss.resteasy.client.jaxrs.internal.ClientInvocation.invoke(ClientInvocation.java:63)
at deployment.ROOT.ear.socio-logistico-web.war//laboratorio.tse.AutenticacionBean.autenticar(AutenticacionBean.java:36)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at javax.el.api#2.0.0.Final//javax.el.ELUtil.invokeMethod(ELUtil.java:245)
at javax.el.api#2.0.0.Final//javax.el.BeanELResolver.invoke(BeanELResolver.java:338)
at javax.el.api#2.0.0.Final//javax.el.CompositeELResolver.invoke(CompositeELResolver.java:198)
at org.glassfish.jakarta.el#3.0.3.jbossorg-2//com.sun.el.parser.AstValue.getValue(AstValue.java:110)
at org.glassfish.jakarta.el#3.0.3.jbossorg-2//com.sun.el.parser.AstValue.getValue(AstValue.java:177)
at org.glassfish.jakarta.el#3.0.3.jbossorg-2//com.sun.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:183)
at org.jboss.weld.core#3.1.5.Final//org.jboss.weld.module.web.el.WeldValueExpression.getValue(WeldValueExpression.java:50)
at org.jboss.weld.core#3.1.5.Final//org.jboss.weld.module.web.el.WeldValueExpression.getValue(WeldValueExpression.java:50)
at com.sun.jsf-impl#2.3.14.SP01//com.sun.faces.facelets.el.ELText$ELTextVariable.toString(ELText.java:205)
at com.sun.jsf-impl#2.3.14.SP01//com.sun.faces.facelets.el.ELText$ELTextComposite.toString(ELText.java:131)
at com.sun.jsf-impl#2.3.14.SP01//com.sun.faces.facelets.compiler.CommentInstruction.write(CommentInstruction.java:36)
at com.sun.jsf-impl#2.3.14.SP01//com.sun.faces.facelets.compiler.UIInstructions.encodeBegin(UIInstructions.java:41)
at com.sun.jsf-impl#2.3.14.SP01//com.sun.faces.facelets.compiler.UILeaf.encodeAll(UILeaf.java:169)
at javax.faces.api#3.0.0.SP04//javax.faces.component.UIComponent.encodeAll(UIComponent.java:1650)
at com.sun.jsf-impl#2.3.14.SP01//com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:468)
at com.sun.jsf-impl#2.3.14.SP01//com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:170)
at javax.faces.api#3.0.0.SP04//javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:132)
at javax.faces.api#3.0.0.SP04//javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:132)
at com.sun.jsf-impl#2.3.14.SP01//com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:102)
at com.sun.jsf-impl#2.3.14.SP01//com.sun.faces.lifecycle.Phase.doPhase(Phase.java:76)
at com.sun.jsf-impl#2.3.14.SP01//com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:199)
at javax.faces.api#3.0.0.SP04//javax.faces.webapp.FacesServlet.executeLifecyle(FacesServlet.java:708)
... 51 more
Caused by: org.apache.http.conn.HttpHostConnectException: Connect to mysecreturi:443 [mysecreturi/10.1.4.83] failed: Connection refused (Connection refused)
at org.apache.httpcomponents.core//org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:156)
at org.apache.httpcomponents.core//org.apache.http.impl.conn.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:376)
at org.apache.httpcomponents.core//org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:393)
at org.apache.httpcomponents.core//org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:236)
at org.apache.httpcomponents.core//org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:186)
at org.apache.httpcomponents.core//org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:89)
at org.apache.httpcomponents.core//org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:110)
at org.apache.httpcomponents.core//org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:185)
at org.apache.httpcomponents.core//org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:83)
at org.apache.httpcomponents.core//org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:56)
at org.jboss.resteasy.resteasy-jaxrs#3.13.2.Final//org.jboss.resteasy.client.jaxrs.engines.ApacheHttpClient4Engine.invoke(ApacheHttpClient4Engine.java:323)
... 80 more
Caused by: java.net.ConnectException: Connection refused (Connection refused)
at java.base/java.net.PlainSocketImpl.socketConnect(Native Method)
at java.base/java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:399)
at java.base/java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:242)
at java.base/java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:224)
at java.base/java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.base/java.net.Socket.connect(Socket.java:609)
at java.base/sun.security.ssl.SSLSocketImpl.connect(SSLSocketImpl.java:289)
at org.apache.httpcomponents.core//org.apache.http.conn.ssl.SSLConnectionSocketFactory.connectSocket(SSLConnectionSocketFactory.java:368)
at org.apache.httpcomponents.core//org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:142)
What is weird is that if I try to run this code localy in ecliple it works fine, and if I try using https://reqbin.com/ it works fine as well. If I try using http instead of https it works remotely as well

Connect to db2 server in windows

I am connecting to a db2 database server using this piece of java code.
import java.sql.*;
import java.util.logging.Level;
import java.util.logging.Logger;
public class DatabaseConnect {
Connection co=null;
Statement st=null;
PreparedStatement pstmt;
ResultSet rs;
int status;
void makeConnection() throws ClassNotFoundException, SQLException
{
Class.forName("com.ibm.db2.jcc.DB2Driver");
co=DriverManager.getConnection("jdbc:db2://localhost:50000/databasename","username","password");
//st=co.createStatement();
}
Connection getConnection()
{
return co;
}
void endConnection() throws SQLException
{
co.close();
}
public static void main(String args[]) throws ClassNotFoundException, SQLException
{
DatabaseConnect db=new DatabaseConnect();
db.makeConnection();
new MaintainHash().createHashMap(db.getConnection());
new Login(db.getConnection()).setVisible(true);
}
}
It works good if hostname is localhost but when i provide hostname of remote server, the program hangs and shows this error.
Exception in thread "main" com.ibm.db2.jcc.am.DisconnectNonTransientConnectionException: [jcc][t4][2043][11550][3.68.61] Exception java.net.ConnectException: Error opening socket to server /192.168.80.1 on port 50,000 with message: Connection timed out: connect. ERRORCODE=-4499, SQLSTATE=08001
at com.ibm.db2.jcc.am.gd.a(gd.java:329)
at com.ibm.db2.jcc.am.gd.a(gd.java:410)
at com.ibm.db2.jcc.t4.ac.a(ac.java:439)
at com.ibm.db2.jcc.t4.ac.<init>(ac.java:96)
at com.ibm.db2.jcc.t4.a.b(a.java:358)
at com.ibm.db2.jcc.t4.b.newAgent_(b.java:2066)
at com.ibm.db2.jcc.am.Connection.initConnection(Connection.java:780)
at com.ibm.db2.jcc.am.Connection.<init>(Connection.java:725)
at com.ibm.db2.jcc.t4.b.<init>(b.java:333)
at com.ibm.db2.jcc.DB2SimpleDataSource.getConnection(DB2SimpleDataSource.java:233)
at com.ibm.db2.jcc.DB2SimpleDataSource.getConnection(DB2SimpleDataSource.java:199)
at com.ibm.db2.jcc.DB2Driver.connect(DB2Driver.java:474)
at com.ibm.db2.jcc.DB2Driver.connect(DB2Driver.java:115)
at java.sql.DriverManager.getConnection(DriverManager.java:664)
at java.sql.DriverManager.getConnection(DriverManager.java:247)
at DatabaseConnect.makeConnection(DatabaseConnect.java:31)
at DatabaseConnect.main(DatabaseConnect.java:58)
Caused by: java.net.ConnectException: Connection timed out: connect
at java.net.DualStackPlainSocketImpl.connect0(Native Method)
at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:79)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:345)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.net.Socket.connect(Socket.java:589)
at com.ibm.db2.jcc.t4.w.run(w.java:49)
at java.security.AccessController.doPrivileged(Native Method)
at com.ibm.db2.jcc.t4.ac.a(ac.java:425)
... 14 more
Java Result: 1
BUILD SUCCESSFUL (total time: 25 seconds)
I am able to telnet and ping to the host ip address.
Got it.
The solution is actually quite simple as well as a bit off topic. Thanks Ian for pointing it out. I had to add port number of db2 to the inbound and outbound rules of firewall.
If anyone is having the same problem, you can follow these steps:
Go to Windows Firewall in control panel.
Click on Advanced Settings.
Select Inbound Rules and then click on New Rule.
Select Port option and then type the port number you want to add.
Repeat the above steps for outbound rules.

How to set a custom port for RMI regisrty?

In my RMI program I want to set up my RMI registry on the port 8080, but when I do it, I get an exception.
Here is my server code
public class Server {
public static void main(String[] args) {
try {
LocateRegistry.createRegistry(8080);
MathServerImpl mathServer = new MathServerImpl();
Naming.rebind("MathServer", mathServer);
System.out.println("Math Server has started and is running");
} catch (RemoteException | MalformedURLException e) {
System.out.println(e.getMessage());
e.printStackTrace();
}
}
}
The code works properly for the port 1099, which is it's default port as far as I know, but for this case it gives me a java.net.ConnectException, and here is the log.
java.rmi.ConnectException: Connection refused to host: 10.100.25.173; nested exception is:
java.net.ConnectException: Connection refused
at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:619)
at sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:216)
at sun.rmi.transport.tcp.TCPChannel.newConnection(TCPChannel.java:202)
at sun.rmi.server.UnicastRef.newCall(UnicastRef.java:341)
at sun.rmi.registry.RegistryImpl_Stub.rebind(Unknown Source)
at java.rmi.Naming.rebind(Naming.java:177)
at server.Server.main(Server.java:16)
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.intellij.rt.execution.application.AppMain.main(AppMain.java:134)
Caused by: java.net.ConnectException: Connection refused
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:339)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:200)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:182)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.net.Socket.connect(Socket.java:579)
at java.net.Socket.connect(Socket.java:528)
at java.net.Socket.<init>(Socket.java:425)
at java.net.Socket.<init>(Socket.java:208)
at sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(RMIDirectSocketFactory.java:40)
at sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(RMIMasterSocketFactory.java:147)
at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:613)
... 11 more
You are creating a registry on port 8080 but then attempting to rebind your object in the default registry on port 1099. You need to either:
pass a full URL to Naming.rebind including the port number, i.e. //localhost:8080/MathServer or
save a reference to the Registry object returned by LocateRegistry.createRegistry and bind the object using that registry's instance methods rather than the static methods of Naming
Similarly, you will need to use the full //localhost:8080/MathServer URL form in your clients when they lookup the object, to make sure they're talking to the right registry.
Naming.rebind("MathServer", mathServer);
Change that to
Naming.rebind("//localhost:8080/MathServer", mathServer);
If you are linux Ubuntu user then while starting RMI registry use command
rmiregistry 8080 &
For Windows
start rmiregistry 8080

DeploymentManagerCreationException

When I run the following code in command window
java weblogic.Deployer -adminurl localhost:7001 -user weblogic -password weblogic -start -name myTestDeployment"
I am getting the following error:
javax.enterprise.deploy.spi.exceptions.DeploymentManagerCreationException at
weblogic.deploy.api.spi.deploy.WebLogicDeploymentManagerImpl.<init>(W
ebLogicDeploymentManagerImpl.java:121) at
weblogic.deploy.api.spi.factories.internal.DeploymentFactoryImpl.getD
eploymentManager(DeploymentFactoryImpl.java:84) at
weblogic.deploy.api.tools.SessionHelper.getDeploymentManager(SessionH elper.java:432) at
weblogic.deploy.api.tools.deployer.Jsr88Operation.connect(Jsr88Operat ion.java:304) at
weblogic.deploy.api.tools.deployer.Deployer.perform(Deployer.java:137 ) at
weblogic.deploy.api.tools.deployer.Deployer.runBody(Deployer.java:88) at
weblogic.utils.compiler.Tool.run(Tool.java:158) at
weblogic.utils.compiler.Tool.run(Tool.java:115) at
weblogic.Deployer.run(Deployer.java:70) at weblogic.Deployer.main(Deployer.java:54)
Caused by: weblogic.deploy.api.spi.exceptions.ServerConnectionException at
weblogic.deploy.api.spi.deploy.internal.ServerConnectionImpl.init(Ser
verConnectionImpl.java:143) at
weblogic.deploy.api.spi.deploy.WebLogicDeploymentManagerImpl.getNewCo
nnection(WebLogicDeploymentManagerImpl.java:148) at
weblogic.deploy.api.spi.deploy.WebLogicDeploymentManagerImpl.<init>(W
ebLogicDeploymentManagerImpl.java:118) ... 9 more Caused by:
javax.naming.CommunicationException [Root exception is java.net.Conne ctException:
localhost:7001: Destination unreachable; nested exception is : java.net.ConnectException:
Connection refused: connect; No available rou ter to destination] at
weblogic.jndi.internal.ExceptionTranslator.toNamingException(Exceptio nTranslator.java:40)
at weblogic.jndi.WLInitialContextFactoryDelegate.toNamingException(WLIni
tialContextFactoryDelegate.java:773) at
weblogic.jndi.WLInitialContextFactoryDelegate.getInitialContext(WLIni
tialContextFactoryDelegate.java:363) at
weblogic.jndi.Environment.getContext(Environment.java:307) at
weblogic.jndi.Environment.getContext(Environment.java:277) at
weblogic.jndi.Environment.createInitialContext(Environment.java:200) at
weblogic.jndi.Environment.getInitialContext(Environment.java:184) at
weblogic.jndi.Environment.getInitialContext(Environment.java:162) at
weblogic.deploy.api.spi.deploy.internal.ServerConnectionImpl.getConte
xt(ServerConnectionImpl.java:330) at
weblogic.deploy.api.spi.deploy.internal.ServerConnectionImpl.getEnvir
onment(ServerConnectionImpl.java:302) at
weblogic.deploy.api.spi.deploy.internal.ServerConnectionImpl.init(Ser
verConnectionImpl.java:141) ... 11 more Caused by: java.net.ConnectException:
localhost:7001: Destination unreach able; nested exception is: java.net.ConnectException:
Connection refused: connect; No available rou ter to destination at
weblogic.rjvm.RJVMFinder.findOrCreate(RJVMFinder.java:204) at
weblogic.rjvm.ServerURL.findOrCreateRJVM(ServerURL.java:154) at
weblogic.jndi.WLInitialContextFactoryDelegate$1.run(WLInitialContextF
actoryDelegate.java:342) at
weblogic.security.acl.internal.AuthenticatedSubject.doAs(Authenticate dSubject.java:363)
at weblogic.security.service.SecurityManager.runAs(Unknown Source) at
weblogic.jndi.WLInitialContextFactoryDelegate.getInitialContext(WLIni
tialContextFactoryDelegate.java:337) ... 19 more Caused by: java.rmi.ConnectException:
Destination unreachable; nested exception is: java.net.ConnectException: Connection
refused: connect; No available rou ter to destination at
weblogic.rjvm.ConnectionManager.bootstrap(ConnectionManager.java:472) at
weblogic.rjvm.ConnectionManager.bootstrap(ConnectionManager.java:323) at
weblogic.rjvm.RJVMManager.findOrCreateRemoteInternal(RJVMManager.java :263) at
weblogic.rjvm.RJVMManager.findOrCreate(RJVMManager.java:206) at
weblogic.rjvm.RJVMFinder.findOrCreateRemoteServer(RJVMFinder.java:226 ) at
weblogic.rjvm.RJVMFinder.findOrCreateRemoteCluster(RJVMFinder.java:30 8) at
weblogic.rjvm.RJVMFinder.findOrCreate(RJVMFinder.java:194) ... 24 more Unable to connect
to 'localhost:7001': Destination unreachable; nested ex ception is:
java.net.ConnectException: Connection refused: connect; No available rou ter to
destination. Ensure the url represents a running admin server and that th e credentials
are correct. If using http protocol, tunneling must be enabled on the admin server.
Please help me to solve this problem.
Check if the admin server is running on this server port 7001:
javax.naming.CommunicationException [Root exception is java.net.Conne ctException:
localhost:7001: Destination unreachable; nested exception is : java.net.ConnectException:
Connection refused: connect; No available rou ter to destination]

Categories