Caused by: java.net.ConnectException: Connection refused: no further information - java

When I run this programm it show this mistake. Dose it because i donot run the service? How to writ config files for the following code?
com.zeroc.Ice.ObjectPrx obj = communicator.stringToProxy("IceStorm/TopicManager:tcp -p 10000");
com.zeroc.IceStorm.TopicManagerPrx topicManager = com.zeroc.IceStorm.TopicManagerPrx.checkedCast(obj);

You need to run the IceStorm service to be able to connect to it, IceStorm/TopicManager is an object hosted by IceStorm service.
if you want to define the topic manager using a property you should use communicator.propertyToProxy instead of communicator.stringToProxy and define the proxy in the configuration file used to initialize the configuration.
com.zeroc.Ice.Communicator communicator = com.zeroc.Ice.Util.initialize(args, "config.sub", extraArgs);
com.zeroc.IceStorm.TopicManagerPrx manager = com.zeroc.IceStorm.TopicManagerPrx.uncheckedCast(
communicator.propertyToProxy("TopicManager.Proxy"));
You should check IceStorm clock demo.

Related

How to use dbus and NetworkManager to activate a connection

as per my previous SO questions, I'm still working on controlling NetworkManager via dbus from a Java application. I want to activate an existing wireless connection so here's my code, stripped as much as possible of irrelevancies:
DBusInterface iface = ...;
var nmIface = (NetworkManagerIface) instance.getRemoteObject(NetworkManagerIface._NM_IFACE, NetworkManagerIface._NM_PATH, NetworkManagerIface.class);
System.out.println("Attempting connection to " + iface.getObjectPath());
var result = nmIface.ActivateConnection(new DBusPath(iface.getObjectPath()), new DBusPath("/"), new DBusPath("/"));
System.out.println("Activate Connection " + result.getPath());
where NetworkManagerIface is here.
This runs alright and prints:
Attempting connection to /org/freedesktop/NetworkManager/Settings/4
Activate Connection /org/freedesktop/NetworkManager/ActiveConnection/4
so it looks like the call to ActivateConnection worked, inasmuch as it returned something sensible. However, the command nmcli c show shows the connection as not in-use.
NetworkManager holds eight connections in our system:
# dbus-send --system --print-reply --dest=org.freedesktop.NetworkManager /org/freedesktop/NetworkManager/Settings org.freedesktop.DBus.Properties.Get string:org.freedesktop.NetworkManager.Settings string:Connections
method return time=1575940954.061910 sender=:1.8 -> destination=:1.70 serial=9361 reply_serial=2
variant array [
object path "/org/freedesktop/NetworkManager/Settings/2"
object path "/org/freedesktop/NetworkManager/Settings/7"
object path "/org/freedesktop/NetworkManager/Settings/3"
object path "/org/freedesktop/NetworkManager/Settings/5"
object path "/org/freedesktop/NetworkManager/Settings/4"
object path "/org/freedesktop/NetworkManager/Settings/8"
object path "/org/freedesktop/NetworkManager/Settings/1"
object path "/org/freedesktop/NetworkManager/Settings/6"
]
The existing connection is the wired (ethernet) connection and I want to add a wireless connection. Why doesn't my ActivateConnection call do this?
If the ActivateConnection call returns success, but afterwards the profile is not actually activating/activated, it stands to reason that the activation shortly after failed.
Look at NetworkManager's logfile to understand why the activation failed. Possibly enable level=TRACE logging, see https://cgit.freedesktop.org/NetworkManager/NetworkManager/tree/contrib/fedora/rpm/NetworkManager.conf#n28 for hints about logging.
You could also run nmcli monitor in another terminal, to get an idea what happens.
The existing connection is the wired (ethernet) connection and I want to add a wireless connection
You want to add a connection profile? That is not what ActivateConnection does. See AddConnection and the D-Bus API in general: https://developer.gnome.org/NetworkManager/stable/spec.html
Why doesn't my ActivateConnection call do this?
Sorry, I don't understand. Do what?

SMTP/POP3 through proxy System.getProperties() vs new Properties()?

Im trying to get mail from a POP3 server through a proxy. Most "tutorials" suggest doing something like
Properties p = System.getProperties();
p.setProperty("proxySet", "true");//does this line even do anything?
p.setProperty("socksProxyHost", proxyHost);
p.setPorperty("socksProxyPort", proxyPort);
p.setProperty("socksProxyVersion", "5");//or 4 if you want to use 4
p.setProperty("mail.pop3.socketFactory.class", SSL_FACTORY);
p.setProperty("mail.pop3.socketFactory.fallback", "false");//also not sure what it does
p.setProperty("mail.pop3.port", portOnHostYouWantToTalkTo);
p.setProperty("mail.pop3.socketFactory.port", portOnHostYouWantToTalkTo);
Session session = Session.getDefaultInstance(p, null);
//or session = Session.getInstance(p, null);
URLName urlName = new URLName(protocol, hostYouwantToTalkTo, portOnHostYouWantToTalkTo, null, mailbox, mailboxPassword);
Store store = session.getStore(urlName);
Now, if I do something like this I get an exception:
java.net.SocketException: Can't connect to SOCKS proxy:Connection timed out: connect.
My POP3 server does not log any connections, suggesting there is a proxy issue or an error in my code. I am using 73.29.157.190:29099 for now.
2) If, however, I do
Properties p = new Properties();
//all the same logic and stuff
Session = Session.getInstance(p, null);
My POP3 server logs a connection from localhost, and works properly, suggesting that I am NOT using a proxy to connect to it and everything else is fine.
My question is, why do "tutorials" use System.getProperties() and pass it to getInstance()? Every Session instance will keep a reference to System.properties. So, effectively every Session instance will be affected every time you try to create a new one or alter System.getProperties() in any way so you might as well reuse the same one.
Does javamail need something set in System.properties specifically and not the ones passed to Session?
Also, what parameters do you need to set in order to get javamail to use a proxy? What does System.properties have that makes it work unlike my new Properties? A link to a good tutorial or documentation that explains it would be greatly appreciated.
Thanks!
First, get rid of all the socket factory stuff, you don't need it.
Next, make sure you really have a SOCKS proxy and not just a web proxy. If you do, see this JavaMail FAQ entry.
Setting the System properties for a SOCKS proxy will cause all network connections from your program to go through the proxy server, which may not be what you want.

How to drop a remote graph using Java in OrientDB

I am trying to setup a remote OrientDB Server and I am trying to enter vertices into it from local Java code.
When I try the following code:
private static final void dropDb() {
OrientGraphNoTx graph = new OrientGraphNoTx(ORIENT_URL);
graph.drop();
}
I get an Exception saying:
Exception in thread "main" com.orientechnologies.orient.core.exception.ODatabaseException: Cannot delete database
...
Caused by: java.lang.UnsupportedOperationException: Cannot delete a database in a remote server. Please use the console or the OServerAdmin class.
How do I go about deleting a remote graph, using Java, in OrientDB?
He jackofblades,
the Graph answers your question:
Please use the console or the OServerAdmin class
// CREATE A SERVER ADMIN CLIENT AGAINST A REMOTE SERVER
OServerAdmin serverAdmin = new OServerAdmin("remote:localhost/GratefulDeadConcerts").connect("admin", "admin");
serverAdmin.dropDatabase("GratefulDeadConcerts");
This is taken from the OrientDB Wiki Page
Patrick

Creating HBaseAdmin which connects to HBaseTestingUtility

I'm writing a code which manipulates data stored in HBase. I want to write also a test for this code. I want to use HBaseTestingUtility in my test, hence, in my #BeforeClass I create new instance of HBaseTestingUtility and I start the mini cluster:
#BeforeClass
public static void setUpClass() throws Exception {
utility = new HBaseTestingUtility();
utility.startMiniCluster();
}
It works good. However, I cannot connect to this embedded cluster in my code which is being tested. In the code I have:
Configuration config = HBaseConfiguration.create();
try (HBaseAdmin admin = new HBaseAdmin(config))
{
//code which manipulates the data
}
Unfortunately when new HBaseAdmin is created I'm getting a ConnectionError exception:
2013-11-21 11:20:35,778 WARN [main-SendThread(0:0:0:0:0:0:0:1:2181)] zookeeper.ClientCnxn (ClientCnxn.java:run(1089)) - Session 0x0 for server null, unexpected error, closing socket connection and attempting reconnect
java.net.ConnectException: Connection refused: no further information
at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:692)
at org.apache.zookeeper.ClientCnxnSocketNIO.doTransport(ClientCnxnSocketNIO.java:350)
at org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1068)
When I try another apporach to create HBaseAdmin:
try (HBaseAdmin admin = new HBaseAdmin(HBaseCacheTest.utility.getConfiguration()))
{
//code which manipulates the data
}
it works (note that here I'm accessing the instance of HBaseTestingUtility via HBaseCacheTest.utility).
Obviously this is not a good approach as I don't want to have a production code which depends on the testing code.
One approach I see to work here is to make it possible in my production class to set the Configuration and use this setter method in my tests.
However, I believe that there should be another way to connect to the embeded mini cluster created with HBaseTestingUtility.
Any ideas?
You should not create a new Configuration object, but use the one provided by HBaseTestingUtility:
HBaseAdmin admin = testingUtility.getHBaseAdmin();
Also, if you need configuration only you can use this one:
testingUtility.getConfiguration()
Just rechecked it in my UT. I'm using HBase 0.96-hadoop2
Hope this helps :)

Weblogic error while accessing datasource through a socket

I am getting an error when I try to establish connection through a DataSource created in weblogic server.Has anyone faced this error in past.I am getting exception in getConnection method of the DataSource.
java.lang.IllegalArgumentException: interface weblogic.jdbc.rmi.internal.ConnectionImpl_weblogic_jdbc_wrapper_PoolConnection_com_informix_jdbc_IfxSqliConnect_RemoteInterface is not visible from class loader
at java.lang.reflect.Proxy.getProxyClass(Proxy.java:337)
at java.lang.reflect.Proxy.newProxyInstance(Proxy.java:567)
at weblogic.rmi.internal.ProxyStub.newInstance(ProxyStub.java:69)
at weblogic.rmi.internal.OIDManager.resolveObject(OIDManager.java:242)
at weblogic.common.internal.ChunkedObjectInputStream.resolveObject(ChunkedObjectInputStream.java:81)
at weblogic.common.internal.ChunkedObjectInputStream$NestedObjectInputStream.resolveObject(ChunkedObjectInputStream.java:328)
at java.io.ObjectInputStream.checkResolve(ObjectInputStream.java:1321)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1274)
at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1835)
at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1759)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1646)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1274)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:322)
at weblogic.common.internal.ChunkedObjectInputStream.readObject(ChunkedObjectInputStream.java:139)
at weblogic.common.internal.ChunkedObjectInputStream.readObject(ChunkedObjectInputStream.java:152)
at weblogic.rmi.internal.ObjectIO.readObject(ObjectIO.java:56)
at weblogic.rmi.internal.BasicRemoteRef.unmarshalReturn(BasicRemoteRef.java:233)
at weblogic.rmi.cluster.ReplicaAwareRemoteRef.invoke(ReplicaAwareRemoteRef.java:264)
at weblogic.rmi.cluster.ReplicaAwareRemoteRef.invoke(ReplicaAwareRemoteRef.java:230)
at weblogic.rmi.internal.ProxyStub.invoke(ProxyStub.java:35)
at $Proxy2.getConnection(Unknown Source
It seems like you're trying to access the Datasource through a socket instead of looking up the JNDI name of the resource first and invoking getConnection on that reference.
You can simply find the cause of your issue by trying the following command:
java utils.dbping ORACLE_THIN scott tiger dbserver1:1561:demo
If this command returns Success!!!, you know, your connection to DB from server is okay, and you have to focus on middleware settings. If not, error detail will be provided.
scott = db username
tiger = db password
demo = db instance name
More information can be found here: http://docs.oracle.com/cd/E13222_01/wls/docs81/admin_ref/utils11.html
To execute java utils.dbping, make sure you have executed setWLSEnv.sh first, to setup java local variables.

Categories