Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 5 years ago.
Improve this question
I have a very simple RMI server/client that works fine on the same machine. I'm trying to now execute the server on one machine and client on another both are on the same network. I've set the property to network ip using:
System.getProperty("java.rmi.server.hostname", "192.168.x.x");
& disabled firewall on both machines but connection still fails.
Client code uses this to connect to server (the server uses createRegistry on 8888):
Registry registry = LocateRegistry.getRegistry("192.168.x.x",8888);
ITest stub = (ITest) registry.lookup("ITest");
However the execption being caught seems to show an IP not the same as the one given eg 192.168.x.x vs 169.254.x.x:
Client exception: java.rmi.ConnectionException: Connection refused to host: 169.254.x.x; nested exception is ...
As dave_thompson_085 said I was calling System.getProperty which was a typo that I completely missed. Calling System.setProperty corrects this problem and now works.
There could be couple of reasons for this exception:
You have not started your rmiregistry in background.
You are trying to connect to the wrong port number.
Your firewall maybe blocking the connections.
Also make sure to check and disable any routers firewall restriction if any.
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
Ok, so I am a little bit stuck with this problem and could really use some guidance...I have a java application that I have written in Java on eclipse and I also have a database created in mySQL on the same computer, now say I want to copy my java application to another computer on a different network but connect to that same database on my original computer on mySQL, what modifications do I have to make so I can connect to my database on different networks and areas? any guidance or help would be greatly appreciated. Beginner in Java and Databases so please try to explain thoroughly.
Since you use a pure JDBC application you simply need to set the JDBC URL to match with your requirements knowing that the format is something like:
jdbc:mysql://[host1][:port1][,[host2][:port2]]...[/[database]][?propertyName1=propertyValue1[&propertyName2=propertyValue2]...]
So assuming that your hostname is foo and the port is 3306, the first thing that you will have to do is to change the current JDBC URL of your application for something like jdbc:mysql://foo:3306 (assuming that your host is accessible from the other computer and you configured your firewall to accept connections on the port of your database).
More info here
For the second part of the job to do (assuming that you have a static IP address), you will need to configure a port forwarding rule at your internet modem level such that any access to your public IP on a given port will be directly routed to the local IP address of your machine on the mysql port. Check the documentation of your modem to know how to do such thing. Here is more info about port forwarding
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I cannot connect to a IPv6 server through HttpsURLConnection, getInputStream() returns null when I sent a request.
I didn't find any useful information: Android developer guide said HttpURLConnection can transparent support IPv6, but didn't mention HttpsURLConnection can support IPv6 or not. Does anyone have experience about this?
Update - 1:
On server side I found a error log when connection failed:
[error] Hostname [xxxx:xxxx:x:xx::xxx] provided via SNI and
hostname xxxx:xxxx:x:xx::xxx provided via HTTP are different
To connect to same IPv6 Apache server (version 2.2.27), Apache HttpClient works without any problem, but HttpsURLConnection doesn't. So it may not be a server side issue. Does anyone see this error before when using HttpsURLConnection?
Java supports IPv6, and has done for many years. HttpsURLConnection supports whatever Java supports.
You might also have noticed that HttpsURLConnection extends HttpURLConnection.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
I am getting this error when i try to make script in bash which copy OAF personalization from one serwer to another. Here is my code:
java oracle.jrad.tools.xml.importer.XMLImporter /ORACLE/apps/apps_st/comn/html_personal/oracle/apps/eng/changemgmt/webui/customizations/site/0/UserAttributesPG.xml
-username apps
-password apps
-dbconnection "(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST= 172.30.32.222)(PORT=22))(CONNECT_DATA=(SID=SRV)))"
-rootdir ORACLE/apps/apps_st/comn/html_personal/oracle/apps/eng/changemgmt/webui/customizations/site/0/
Any ideas?
You are connecting to port 22, which is traditionally reserved for ssh. If I connect to that port with a JDBC connection I get the same error stack you showed in your previous question:
Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String index out of range: 25978
at java.lang.String.checkBounds(String.java:401)
at java.lang.String.<init>(String.java:338)
at oracle.net.ns.Packet.extractData(Packet.java:429)
at oracle.net.ns.RefusePacket.<init>(RefusePacket.java:72)
at oracle.net.ns.NSProtocol.connect(NSProtocol.java:356)
at oracle.jdbc.driver.T4CConnection.connect(T4CConnection.java:1102)
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:320)
at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:546)
at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:236)
at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:32)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:521)
at oracle.jdbc.pool.OracleDataSource.getPhysicalConnection(OracleDataSource.java:280)
at oracle.jdbc.pool.OracleDataSource.getConnection(OracleDataSource.java:207)
at oracle.jdbc.pool.OracleDataSource.getConnection(OracleDataSource.java:157)
Well, slightly different stack because of how I'm connecting and the version I'm using, but the String index is identical. Looks like ssh is responding to the connection with more data that the JDBC driver ever expects to see back from a listener.
Changing just the port number to a valid SQL*Net listener port removes this error and the connection succeeds.
So, change to use your listener's actual port number; 1521 by default but you might have something custom. lsnrctl status will tell you what it is. It's unlikely to be 22 even if it is customised since that is in the privileged range and the listener would need to be running as root to bind to it.
The only reason I can think you might have tried this is because you're tunnelling your SQL*Net connection over ssh, to a remote server. If that is the case then you need to use the local port (from a -L flag) that maps to the actual listener port on the remote server. So if you had, say, ssh -L 1234:127.0.0.1:1521 -l user 172.30.32.222, your dbconnection would point to localhost and port 1234. I'm speculating as to why you'd have used 22 though, clearly.
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
I'm developing and android application that communicates with a server through sockets. I have one thread reading the socket, while the Main thread executes an Asynk Task that sends the messages through the same socket. The problem here is, there are some times (lets say 50% of times) that I call the OutputStream.write() method of the socket connection, the servers log shows that the client closed connection. I read that the java sockets are full duplex, which should allow me to send and receive messages through the same socket with no problems. So, why is this happening? Is the problem from the application? Or is it the server side code (to which I dont have access) the one closing the connection??
EDIT: The server is a raspberry Pi with a raspbian distribution, running only one java application which is the one communicating with my application. I have no access to the java code running on the server, or any of the logs the server shows, I only can acces to the screen connected to the server, which prints the messages the code "tells" it to print. When I execute the OutputStram.Write(), the server shows on screen: "Connection to client closed".
Many Thanks!
Why does OutputStream.write() closes socket connection?
It doesn't. It writes data to an OutputStream.
some times (lets say 50% of times) that I call the OutputStream.write() method of the socket connection, the servers log shows that the client closed connection.
No it doesn't. This is what it really shows:
When I execute the OutputStram.Write(), the server shows on screen: "Connection to client closed".
This says that the server closed the connection to the client. Not the other way around.
Probably you sent something invalid and the server barfed.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 8 years ago.
Improve this question
I have jdbc and hibernate working just fine on my local web app, but when I deploy it to a remote server, I get this error:
HTTP Status 401 - Could not open Hibernate Session for transaction; nested exception is org.hibernate.exception.JDBCConnectionException: Could not open connection
The server is on the same machine as the mysql database. Could that be a problem? If not, what could it be?
It is no problem to have application and database on one machine. Check the connection string of the database for IP/hostname, user name, password and database port in related configuration file or JNDI resource. There is more information needed to put specific answer. The driver may also be the problem here.