Send mail using rnote domino in Java - java

I'm working on some application which should send mail sometimes. Unfortunately administrator said that I can't send mail over traditional smtp protocol because he blocks it.
He told me that there is 2 ways to do it:
1) "set relay server to application in this case somestringrnotesmtp.domain.com"
In this case it looks like some smtp server provided by Lotus rnotes. But when I try to send mail using org.apache.commons.mail I'm getting exception
Caused by: javax.mail.MessagingException: Could not connect to SMTP host: somestringrnotesmtp.domain.com, port: 465;
nested exception is:
java.net.ConnectException: Connection refused
at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1972)
at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:642)
at javax.mail.Service.connect(Service.java:295)
at javax.mail.Service.connect(Service.java:176)
at javax.mail.Service.connect(Service.java:125)
at javax.mail.Transport.send0(Transport.java:194)
at javax.mail.Transport.send(Transport.java:124)
at org.apache.commons.mail.Email.sendMimeMessage(Email.java:1388)
... 40 more
Caused by: java.net.ConnectException: Connection refused
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)
at java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source)
at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at sun.security.ssl.SSLSocketImpl.connect(Unknown Source)
at com.sun.mail.util.SocketFetcher.createSocket(SocketFetcher.java:317)
at com.sun.mail.util.SocketFetcher.getSocket(SocketFetcher.java:207)
at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1938)
... 47 more
"use unix sendmail for this purpose"
I have no idea how to do it this way. Is there any java library which does that?

Related

Java.rmi.ConnectException: Connection refused to host: localhost

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.

Configuring jmxAgent in Camel

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.

Not send email in digital ocean server

I have an app stored in digital ocean that before was stored in other server.
Before my app send email normally, now I got error:
I already check firewal stuff, iptables config, change port and etc. In my local environment the email flows normal, if I deploy back in my older server the email flows normal.
What more can be?
org.apache.commons.mail.EmailException: Sending the email to the following server failed : smtp-mail.outlook.com:25
at org.apache.commons.mail.Email.sendMimeMessage(Email.java:1410)
at org.apache.commons.mail.Email.send(Email.java:1437)
at br.com.caelum.vraptor.simplemail.DefaultMailer.wrapUpAndSend(DefaultMailer.java:74)
at br.com.caelum.vraptor.simplemail.DefaultMailer.send(DefaultMailer.java:63)
at br.com.caelum.vraptor.simplemail.DefaultAsyncMailer$1.call(DefaultAsyncMailer.java:54)
at br.com.caelum.vraptor.simplemail.DefaultAsyncMailer$1.call(DefaultAsyncMailer.java:49)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: javax.mail.MessagingException: Could not connect to SMTP host: smtp-mail.outlook.com, port: 25;
nested exception is:
java.net.SocketTimeoutException: connect timed out
at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1961)
at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:654)
at javax.mail.Service.connect(Service.java:317)
at javax.mail.Service.connect(Service.java:176)
at javax.mail.Service.connect(Service.java:125)
at javax.mail.Transport.send0(Transport.java:194)
at javax.mail.Transport.send(Transport.java:124)
at org.apache.commons.mail.Email.sendMimeMessage(Email.java:1400)
... 9 more
Caused by: java.net.SocketTimeoutException: connect timed out
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)
at java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source)
at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at com.sun.mail.util.SocketFetcher.createSocket(SocketFetcher.java:319)
at com.sun.mail.util.SocketFetcher.getSocket(SocketFetcher.java:237)
at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1927)
After contacting the digital ocean support and opening a ticket informing this problem, I was informed that, they have a spam block activated by default for new accounts, being necessary contact to validate the owner identity.

Connection refused error in Tomcat 7 while doing load testing through Jmeter

My application is pointing to cloudant DB which supports high active connections. When I am trying to hit 500 concurrent hits, my API shows,
org.apache.http.conn.HttpHostConnectException: Connection to https://Testing.com:xxx refused
at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:190)
at org.apache.http.impl.conn.ManagedClientConnectionImpl.open(ManagedClientConnectionImpl.java:294)
at org.apache.http.impl.client.DefaultRequestDirector.tryConnect(DefaultRequestDirector.java:645)
at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:480)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:906)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:805)
at org.apache.jmeter.protocol.http.sampler.HTTPHC4Impl.sample(HTTPHC4Impl.java:286)
at org.apache.jmeter.protocol.http.sampler.HTTPSamplerProxy.sample(HTTPSamplerProxy.java:62)
at org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.sample(HTTPSamplerBase.java:1088)
at org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.sample(HTTPSamplerBase.java:1077)
at org.apache.jmeter.threads.JMeterThread.process_sampler(JMeterThread.java:428)
at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:256)
at java.lang.Thread.run(Unknown Source)
Caused by: java.net.ConnectException: Connection timed out: 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 com.sun.net.ssl.internal.ssl.SSLSocketImpl.connect(Unknown Source)
at org.apache.http.conn.ssl.SSLSocketFactory.connectSocket(SSLSocketFactory.java:549)
at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:180)
... 12 more
In tomcat server.xml, My max threads is 500, acceptCount is 500 and connection timeout is 20000. Still it shows the above mentioned error. I could see a pattern like only those threads between 100-250 are getting failed in consecutive runs. Can someone please help me on this
Please check Database connection pool maxtotal. It might be less and you may need to increase it.

Access Gmail behind Firewall Java

I have a problem with access the gmail from my working area. This is my code. It works in my home when network settings are default. The main problem is, in the working area there is more security on computers and network like firewalls etc..
I have to find a solution for run this script behind the firewall. Closing the firewall is not a permanent solution.
Also I added the error message to the below. Any help is appreciated.
`com.sun.mail.util.MailConnectException: Couldn't connect to host, port: imap.gmail.com, 993; timeout -1;
nested exception is:
java.net.ConnectException: Connection timed out: connect
at com.sun.mail.imap.IMAPStore.protocolConnect(IMAPStore.java:672)
at javax.mail.Service.connect(Service.java:345)
at javax.mail.Service.connect(Service.java:226)
at unreadmails.MailReader.<init>(MailReader.java:23)
at unreadmails.MailReader.main(MailReader.java:12)
Caused by: java.net.ConnectException: Connection timed out: connect
at java.net.TwoStacksPlainSocketImpl.socketConnect(Native Method)
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 com.sun.mail.util.SocketFetcher.createSocket(SocketFetcher.java:297)
at com.sun.mail.util.SocketFetcher.getSocket(SocketFetcher.java:229)
at com.sun.mail.iap.Protocol.<init>(Protocol.java:116)
at com.sun.mail.imap.protocol.IMAPProtocol.<init>(IMAPProtocol.java:115)
at com.sun.mail.imap.IMAPStore.newIMAPProtocol(IMAPStore.java:689)
at com.sun.mail.imap.IMAPStore.protocolConnect(IMAPStore.java:638)
... 4 more`

Categories