To monitor and manage routes, we are trying to use JMX with camel.
Our jmxAgent configuration is as follows.
<camelContext xmlns="http://camel.apache.org/schema/spring">
<jmxAgent id="agent"
connectorPort="9999"
createConnector="false"
usePlatformMBeanServer="true"
serviceUrlPath="/jmxrmi/camel"
loadStatisticsEnabled="true"
statisticsLevel="All"/>
<route>
A simple java class is used to connect to the "jmxAgent"
try{
JMXServiceURL url = new JMXServiceURL("service:jmx:rmi://localhost:9999/jndi/rmi://localhost:1099/jmxrmi/camel");
JMXConnector jmxc = JMXConnectorFactory.connect(url);
MBeanServerConnection server = jmxc.getMBeanServerConnection();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
But I'm getting the following exception
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(Unknown Source)
at javax.management.remote.JMXConnectorFactory.connect(Unknown Source)
at javax.management.remote.JMXConnectorFactory.connect(Unknown Source)
at com.acme.jmx.bridgeJMXBridge.main(JMXBridge.java:19)
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(Unknown Source)
at com.sun.jndi.toolkit.url.GenericURLContext.lookup(Unknown Source)
at javax.naming.InitialContext.lookup(Unknown Source)
at javax.management.remote.rmi.RMIConnector.findRMIServerJNDI(Unknown Source)
at javax.management.remote.rmi.RMIConnector.findRMIServer(Unknown Source)
... 4 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(Unknown Source)
at sun.rmi.transport.tcp.TCPChannel.createConnection(Unknown Source)
at sun.rmi.transport.tcp.TCPChannel.newConnection(Unknown Source)
at sun.rmi.server.UnicastRef.newCall(Unknown Source)
at sun.rmi.registry.RegistryImpl_Stub.lookup(Unknown Source)
... 9 more
Caused by: java.net.ConnectException: Connection refused: connect
at java.net.DualStackPlainSocketImpl.connect0(Native Method)
at java.net.DualStackPlainSocketImpl.socketConnect(Unknown Source)
at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)
at java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source)
at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.<init>(Unknown Source)
at java.net.Socket.<init>(Unknown Source)
at sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(Unknown Source)
at sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(Unknown Source)
... 14 more
Please give me some pointers to solve this issue.
Thanks,
San
You need to set
createConnector="true"
And when you do that, then Camel should log at INFO level the service url you can use from java code or jconsole to connect to it.
Related
I'm having some issues for creating a simple socket, I'm new to this kind of stuff sorry for a simple question thanks. I tried to follow some tutorial for creating Sockets in java and tried this so far
try {
Socket chatSocket = new Socket("127.0.0.1", 4242);
System.out.println("connection established");
}
catch (IOException e) {
e.printStackTrace();
}
I'm getting this kind of error
java.net.ConnectException: Connection refused: connect
at java.net.DualStackPlainSocketImpl.connect0(Native Method)
at java.net.DualStackPlainSocketImpl.socketConnect(Unknown Source)
at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)
at java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source)
at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.<init>(Unknown Source)
at java.net.Socket.<init>(Unknown Source)
at application.main.main(main.java:15)
and when I try to access my localhost from my browser I see this error
The connection to '127.0.0.1' failed.
Error: ConnectionRefused (0x274d).
System.Net.Sockets.SocketException No connection could be made because the
target machine actively refused it 127.0.0.1:4242
I have no idea what is happening because, just followed what the tutorial does. I think the issue is on my local machine but I have no idea what is making the connection refuse
i have this very simple java class where i try to run a H2 DB like this:
public static void main(String[] args) {
Connection conn = null;
try {
Class.forName("org.h2.Driver");
Server server = Server.createTcpServer("-tcpPort", "50001", "-tcpAllowOthers").start();
conn = DriverManager.getConnection(
"jdbc:h2:tcp://localhost/~/H2TestDB/SMPS_DK", "sa", "sa");
I tried to copy what i found here and in the H2 doc already but for some reason the connection gets refused. I tried to find the solution here but havent been successfull so far. FYI: I am kind of a rookie so it would be great to get a more detailed answer if possible ;) Thanks in advance!
Here comes the stacktrace:
> org.h2.jdbc.JdbcSQLException: Verbindung ist unterbrochen: "java.net.ConnectException: Connection refused: connect: localhost"
Connection is broken: "java.net.ConnectException: Connection refused: connect: localhost" [90067-196]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:345)
at org.h2.message.DbException.get(DbException.java:168)
at org.h2.engine.SessionRemote.connectServer(SessionRemote.java:457)
at org.h2.engine.SessionRemote.connectEmbeddedOrServer(SessionRemote.java:334)
at org.h2.jdbc.JdbcConnection.<init>(JdbcConnection.java:116)
at org.h2.jdbc.JdbcConnection.<init>(JdbcConnection.java:100)
at org.h2.Driver.connect(Driver.java:69)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at connection.Main.main(Main.java:26)
Caused by: java.net.ConnectException: Connection refused: connect
at java.net.DualStackPlainSocketImpl.waitForConnect(Native Method)
at java.net.DualStackPlainSocketImpl.socketConnect(Unknown Source)
at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)
at java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source)
at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at org.h2.util.NetUtils.createSocket(NetUtils.java:103)
at org.h2.util.NetUtils.createSocket(NetUtils.java:83)
at org.h2.engine.SessionRemote.initTransfer(SessionRemote.java:115)
at org.h2.engine.SessionRemote.connectServer(SessionRemote.java:453)
... 7 more
So i have read up on similar questions but i haven't found anything that i fully understand yet.
http://www.coderanch.com/t/487650/java/java/java-rmi-ConnectException-Connection-refused
http://protegewiki.stanford.edu/wiki/Troubleshooting_Client_Server_Connections
what is RMI registry
http://docs.oracle.com/javase/7/docs/technotes/guides/rmi/faq.html#domain
I have a server which is crashing every few days and I am trying to work out where the problem lies. The software is running in an environment supplied by the customer and i need to know if we are the problem or windows/the network.
My question is... RMI registry, Is that something that java creates or is it something that exists in windows anyway? Why would a connection to localhost suddenly become unavailable or refused? Is there anything that i can do to troubleshoot immediately?
The RMI configuration is here:
<RMIService>
<class>com.s.i.system.RMIService</class>
<server name="Server">
<host>localhost</host>
<timeout>0</timeout>
</server>
</RMIService>
Here is the error that is created in the logs.
2015-04-02 16:52:10,057 ERROR [main] com...........gui.initialise.ClientInitialise - java.rmi.ConnectException: Connection refused to host: localhost; nested exception is:
java.net.ConnectException: Connection refused: connect
at sun.rmi.transport.tcp.TCPEndpoint.newSocket(Unknown Source)
at sun.rmi.transport.tcp.TCPChannel.createConnection(Unknown Source)
at sun.rmi.transport.tcp.TCPChannel.newConnection(Unknown Source)
at sun.rmi.server.UnicastRef.newCall(Unknown Source)
at sun.rmi.registry.RegistryImpl_Stub.lookup(Unknown Source)
at java.rmi.Naming.lookup(Unknown Source)
at com.s.i.system.RMIService.lookup(RMIService.java:570)
at com.s.i.system.RMIService.lookupServer(RMIService.java:377)
at com.s.i.process.RemoteRequestHandler$Dispatcher.run(RemoteRequestHandler.java:282)
at com.s.i.process.RemoteRequestHandler$Dispatcher.start(RemoteRequestHandler.java:269)
at com.s.i.process.RemoteRequestHandler.handle(RemoteRequestHandler.java:96)
at com.s.i.process.RequestDispatcher.dispatch(RequestDispatcher.java:136)
at com.s.i.client.ClientInitialiser.initialiseEnvironment(ClientInitialiser.java:498)
at com.s.i.client.ClientInitialiser.performEnvironmentInit(ClientInitialiser.java:145)
at com.s.i.client.ClientInitialiser.initialise(ClientInitialiser.java:128)
at com.s.i.client.ClientInitialiser.initialise(ClientInitialiser.java:106)
at com.s.i.gui.initialise.ClientInitialise.createInitialiser(ClientInitialise.java:136)
at com.s.i.gui.initialise.ClientInitialise.<init>(ClientInitialise.java:155)
at com.s.i.client.Client.initialise(Client.java:118)
at com.s.i.client.Client.main(Client.java:147)
Caused by: java.net.ConnectException: Connection refused: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(Unknown Source)
at java.net.PlainSocketImpl.connectToAddress(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.<init>(Unknown Source)
at java.net.Socket.<init>(Unknown Source)
at sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(Unknown Source)
at sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(Unknown Source)
... 20 more
The RMI Registry is a component of the JRE, not of Windows. Clearly it is crashing, or far more probably it is being closed down incorrectly for some reason. I've never seen an RMI Registry crash in 18 years.
I am trying to access a VM from an RMI client in my machine using VM DNS NAME and port 1099 after setting an endpoint with this port but I get a refused to connect to the VM. How can I tackle this problem?
this is the error I got
D:\Dropbox\client\xxxxxxx>java -Djava.rmi.server.hostname=xx.xx.xx.xx -cp . client
java.rmi.ConnectException: Connection refused to host: xx.xx.xx.xx; nested exception is: java.net.ConnectException:
Connection timed out: connect at
sun.rmi.transport.tcp.TCPEndpoint.newSocket(Unknown Source) at
sun.rmi.transport.tcp.TCPChannel.createConnection(Unknown Source) at
sun.rmi.transport.tcp.TCPChannel.newConnection(Unknown Source) at
sun.rmi.server.UnicastRef.invoke(Unknown Source) at
HelloImpl_Stub.getHelloMessage(Unknown Source) at
client.main(client.java:18)
Caused by: java.net.ConnectException:
Connection timed out: connect at
java.net.DualStackPlainSocketImpl.connect0(Native Method) at
java.net.DualStackPlainSocketImpl.socketConnect(Unknown Source) at
java.net.AbstractPlainSocketImpl.doConnect(Unknown Source) at
java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source) at
java.net.AbstractPlainSocketImpl.connect(Unknown Source) at java.net.PlainSocketImpl.connect(Unknown Source) at
java.net.SocksSocketImpl.connect(Unknown Source) at
java.net.Socket.connect(Unknown Source) at
java.net.Socket.connect(Unknown Source) at
java.net.Socket.(Unknown Source) at
java.net.Socket.(Unknown Source) at
sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(Unknown Source) at
sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(Unknown Source) ... 6 more
I have built a simple application which connects database made in derby(Netbeans) which binds with a jTable, using java persistence, entity manager. The problem is that when i run the .jar file on some other system it does not execute. Can anyone tell me why does it happen?
Error when running it on some other system:
C:\>java -jar persist.jar
[EL Info]: 2013-01-08 17:06:45.715--ServerSession(4597467)--EclipseLink, version
: Eclipse Persistence Services - 2.3.2.v20111125-r10461
[EL Severe]: 2013-01-08 17:06:48.24--ServerSession(4597467)--Exception [EclipseL
ink-4002] (Eclipse Persistence Services - 2.3.2.v20111125-r10461): org.eclipse.p
ersistence.exceptions.DatabaseException
Internal Exception: java.sql.SQLNonTransientConnectionException: java.net.Connec
tException : Error connecting to server localhost on port 1527 with message Conn
ection refused: connect.
Error Code: 40000
Exception in thread "AWT-EventQueue-0" javax.persistence.PersistenceException: E
xception [EclipseLink-4002] (Eclipse Persistence Services - 2.3.2.v20111125-r104
61): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: java.sql.SQLNonTransientConnectionException: java.net.Connec
tException : Error connecting to server localhost on port 1527 with message Conn
ection refused: connect.
Error Code: 40000
at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy(En
tityManagerSetupImpl.java:517)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryDelegate.get
DatabaseSession(EntityManagerFactoryDelegate.java:188)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryDelegate.cre
ateEntityManagerImpl(EntityManagerFactoryDelegate.java:277)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createE
ntityManagerImpl(EntityManagerFactoryImpl.java:294)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createE
ntityManager(EntityManagerFactoryImpl.java:272)
at persist.NewJFrame.initComponents(NewJFrame.java:30)
at persist.NewJFrame.<init>(NewJFrame.java:17)
at persist.NewJFrame$1.run(NewJFrame.java:101)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$200(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Sour
ce)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
Caused by: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.3.2.v2
0111125-r10461): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: java.sql.SQLNonTransientConnectionException: java.net.Connec
tException : Error connecting to server localhost on port 1527 with message Conn
ection refused: connect.
Error Code: 40000
at org.eclipse.persistence.exceptions.DatabaseException.sqlException(Dat
abaseException.java:324)
at org.eclipse.persistence.exceptions.DatabaseException.sqlException(Dat
abaseException.java:319)
at org.eclipse.persistence.sessions.DefaultConnector.connect(DefaultConn
ector.java:138)
at org.eclipse.persistence.sessions.DatasourceLogin.connectToDatasource(
DatasourceLogin.java:162)
at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.loginAn
dDetectDatasource(DatabaseSessionImpl.java:584)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryProvider.log
in(EntityManagerFactoryProvider.java:206)
at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy(En
tityManagerSetupImpl.java:488)
... 21 more
Caused by: java.sql.SQLNonTransientConnectionException: java.net.ConnectExceptio
n : Error connecting to server localhost on port 1527 with message Connection re
fused: connect.
at org.apache.derby.client.am.SQLExceptionFactory40.getSQLException(Unkn
own Source)
at org.apache.derby.client.am.SqlException.getSQLException(Unknown Sourc
e)
at org.apache.derby.jdbc.ClientDriver.connect(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at org.eclipse.persistence.sessions.DefaultConnector.connect(DefaultConn
ector.java:98)
... 25 more
Caused by: org.apache.derby.client.am.DisconnectException: java.net.ConnectExcep
tion : Error connecting to server localhost on port 1527 with message Connection
refused: connect.
at org.apache.derby.client.net.NetAgent.<init>(Unknown Source)
at org.apache.derby.client.net.NetConnection.newAgent_(Unknown Source)
at org.apache.derby.client.am.Connection.<init>(Unknown Source)
at org.apache.derby.client.net.NetConnection.<init>(Unknown Source)
at org.apache.derby.client.net.NetConnection40.<init>(Unknown Source)
at org.apache.derby.client.net.ClientJDBCObjectFactoryImpl40.newNetConne
ction(Unknown Source)
... 29 more
Caused by: java.net.ConnectException: Connection refused: connect
at java.net.DualStackPlainSocketImpl.connect0(Native Method)
at java.net.DualStackPlainSocketImpl.socketConnect(Unknown Source)
at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)
at java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source)
at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.<init>(Unknown Source)
at java.net.Socket.<init>(Unknown Source)
at javax.net.DefaultSocketFactory.createSocket(Unknown Source)
at org.apache.derby.client.net.OpenSocketAction.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
... 35 more
Take a look at this SO question. Seems like a similar problem (namely, the dependency jar(s) are probably not on the classpath).
EDIT
Since you posted the stack trace, it's pretty obvious now that you have some DB connection problems:
java.net.ConnectException : Error connecting to server localhost on port 1527 with messageConnection refused: connect.
Did you check if the database is up & running properly on that other system?
Check the database url in your persistence.xml
<properties>
<property name="javax.persistence.jdbc.password" value="sa"/>
<property name="javax.persistence.jdbc.user" value="sa"/>
<property name="javax.persistence.jdbc.driver"
value="org.apache.derby.jdbc.ClientDriver"/>
<property name="javax.persistence.jdbc.url" value="jdbc:derby://??:1527/??"/>
</properties>
Netbeans assigns default location when you are running app inside netbeans where your db is created. I suggest you to pass url as parameter for creating entity manager factory or have it in a property file and load it.
java -jar project.jar persistence.properties