issue when using SMTP and javax.mail - java

I am using the following in my sbt build file (versions are mentioned in the build file):
"javax.mail" % "javax.mail-api" % "1.5.5",
"javax.mail" % "mail" % "1.4.7",
I can run the application that runs the following code on one computer but not another. I have tried clearing up the ivy cache and reloading the javax mail packages but that has not helped. Any idea what I might be doing wrong?
final Transport transport = session.getTransport(prop.getProperty("mail.smtp.protocol"));
transport.connect(prop.getProperty("smtp.username"), "");
The properties being used are not null and are being used locally on one computer (and also by another process on the same computer where I am running into issues - that process is no longer running on that computer and should not have an open transport connection).
Exception
java.lang.NoSuchMethodError: com.sun.mail.util.TraceInputStream.<init>(Ljava/io/InputStream;Lcom/sun/mail/util/MailLogger;)V
at com.sun.mail.smtp.SMTPTransport.initStreams(SMTPTransport.java:2014)
at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1936)
at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:654)
at javax.mail.Service.connect(Service.java:291)
at javax.mail.Service.connect(Service.java:172)
at javax.mail.Service.connect(Service.java:192)
com.sun.mail.smtp.SMTPTransport v1.4.7
private void More ...initStreams() throws IOException {
2011 boolean quote = PropUtil.getBooleanSessionProperty(session,
2012 "mail.debug.quote", false);
2013
2014 traceInput =
2015 new TraceInputStream(serverSocket.getInputStream(), traceLogger);
Any thoughts on how I should go about troubleshooting this? I have tried running the session in debug:
session.setDebug(true);
I do not think its a firewall issue because I can run another process using the same SMTP config (host/port/credentials) and that is able to connect without any exceptions.

The issue was caused by transitive dependency in the build file (whereby another dependency was pulling an older version of javax.mail for the application). Excluding the transitive dependency (using the exclusion rule in sbt) should resolve the issue.

This error is related to a missing smtp.jar on your classpath.
You can download it as part of the JavaMail API here

Related

Could not create File Client. Mismatch found for java and native libraries java build version

I am trying to access mapr path remotely, using a spring boot application. I have set the fs.mapr.bailout.on.library.mismatch property to false, to avoid the error on version mismatch. Still whenever the getFileStatus() function gets called, the application stops with the following error:
2020-12-15 10:07:18,7377 ERROR JniCommon fs/client/fileclient/cc/jni_MapRClient.cc:691 Thread: 123145425235968 Mismatch found for java and native libraries java build version 6.0.1.20180404222005.GA, native build version 6.0.1.20190808152212.GA java patch vserion $Id: mapr-version: 6.0.1.20180404222005.GA 1aeeb6d3c17c777fcba0, native patch version $Id: mapr-version: 6.0.1.20190808152212.GA 1aeeb6d3c17c777fcba0
2020-12-15 10:07:18,7378 ERROR JniCommon fs/client/fileclient/cc/jni_MapRClient.cc:708 Thread: 123145425235968 Client initialization failed.
Code:
FileSystem fileSystem = FileSystem.newInstance(new Configuration());
Configuration conf = fileSystem.getConf();
conf.set("fs.mapr.bailout.on.library.mismatch", "false");
Path OffsetPath = new Path(filePath);
FileStatus file = fileSystem.getFileStatus(filePath); ====> This statement gives error
hbase dependencies used:
<dependency>
<groupId>com.mapr.fs</groupId>
<artifactId>mapr-hbase</artifactId>
<version>6.0.1-mapr</version>
</dependency>
<dependency>
<groupId>org.apache.hbase</groupId>
<artifactId>hbase-client</artifactId>
<version>1.1.8-mapr-1710</version>
</dependency>
How can I correct this?
So it isn't a great idea to just disable the version mismatch error. Some mismatch is OK for some tasks, but some mismatch can be fatal.
To say much more, it would be helpful to have a little bit of clarification.
when you say remote access, are you talking from one cluster to another? Or from a client machine that is outside the cluster?
assuming that you mean the second case (client outside the cluster), what did you install on the client machine?
why did you disable the version mismatch? What versions are you worried will not match?
does the POSIX interface or the local loopback NFS work from the problem node?
does the hadoop shell work from the problem node?

Spring Boot War File Tomcat 9 Deployment Help Status 500 Error

UPDATE 8/12/2020 approx. 11:00 AM - I checked my logs folder catalina.2020-08-12.log log in the tomcat9 ($CATALINA_BASE) folder and I found three exceptions "org.apache.catalina.LifecycleException: Protocol handler intialization failed", "java.net.BindException: Address already in use (bind failed)","java.lang.IllegalArgumentException: Invalid character found in the HTTP protocol [HTTP/1.10x0aHost:]".
Here is the full error log here: https://drive.google.com/file/d/1pSk5ESHLIRP5Srxwr4R1Tp_1TTcYMf2Y/view?usp=sharing and https://drive.google.com/file/d/1C-RALR3066_hYKeoo4dIJqTKwNDOQ0R0/view?usp=sharing.
UPDATE 8/12/2020 approx. 11:30 AM - I found that there are two servlet dispatchers running by checking the localhost.2020-08-12.log log when I restarted tomcat and tried to access my api again: https://drive.google.com/file/d/1GFKUIDLtZrAraHyMjyyWV9kXK33gQ-Mu/view?usp=sharing.
UPDATE 8/12/2020 approx. 11:35 AM - HA HAAAA I looked in the catalina.out log (finally some of you guys were probably yelling at the screen like "CHECK THE CATALINA.OUT FILE"). I checked it and I found the exception: "java.lang.IllegalArgumentException: dataSource or dataSourceClassName or jdbcUrl is required": https://drive.google.com/file/d/1A7ZLh70IHOmWXfQ56bgtq951EE_AX68P/view?usp=sharing. Now if I go to my PostgresDataSource class which is where my Hikari config is: https://drive.google.com/file/d/1lYN1dTqiAM4ZqliRGC5J5_VWhNeN-k2d/view?usp=sharing, and I review my application.yaml file from earlier: https://drive.google.com/file/d/1xvPhPneVjMU4BoN6F0Q63l2wCnF20BYq/view?usp=sharing, the jdbc url is present because it is the same one I used for developing. Now postgres is already set up and I manually made all of the tables on the ubuntu droplet. I did not download the jdbc postgresql driver for tomcat yet.
UPDATE 8/12/2020 approx. 1:20 PM - After setting up the jdbc driver now I get this error from catalina.out logs: " Failed to get driver instance for jdbcUrl=java:/comp/env/jdbc:postgresql://localhost:5432/****" and then I get "Caused by: java.sql.SQLException: No suitable driver". I used the postgresql section of this link to set it up: https://tomcat.apache.org/tomcat-9.0-doc/jndi-datasource-examples-howto.html.
Hi I am using Digital Ocean with apache tomcat 9 to deploy a war file that is generated using IntelliJ. I have the war file generated using mvn clean install and I get the default tomcat page when I go to the droplet IP address on port 8080. I am not sure why I get a 500 error with no stack trace information even though my spring boot application works fine when I run it in IntelliJ. My CSS styling also does not show up when I go to my hosted application I have tried to configure a few things in my application.yml file and it still does not work. I figured it might have to do with a spring security issue with CORS, but I am not knowledgeable enough in that area to know for sure. I started my server by using sudo $CATALINA_HOME/bin/startup.sh and it said tomcat started and it showed the default tomcat page when I went there in the browser. I used the hobynapi.war file in my target folder a picture of my target folder directory can be viewed here https://drive.google.com/file/d/1XXga1Bgf5-_81gceuWjpvVIX6J0jiNgQ/view?usp=sharing. I copied the war file that was generated after using mvn clean install to the /var/lib/tomcat9/webapps folder. I then ran sudo $CATALINA_HOME/bin/startup.sh again and it ran tomcat successfully again. Then the error happened as I tried to log in with the admin account with spring security basic authentication where I get the 500 error. I also have no artifacts in the artifact section of the project structure settings if that means anything.
UPDATE 8/12/2020 approx. 10:00 AM - I've removed the exclusions tag in the pom.xml file as well as the profiles tag at the bottom of the file. This is because I read here that using the spring-boot-starter-tomcat dependency removes the embedded server for you: https://developer.okta.com/blog/2019/04/16/spring-boot-tomcat.
This is the screen without the CSS styling that should be there:
https://drive.google.com/file/d/1CEKuB556ek8pTZspvprNTa9M5XCI7qtT/view?usp=sharing
This is the error I get without a stack trace:
https://drive.google.com/file/d/19gYGQFhZdZ_4IwwGE5tQzb4dTqlBpg9L/view?usp=sharing
These are pictures of my pom.xml file:
https://drive.google.com/file/d/1ir5uBuBuJqCb_U8Jarly9mraO468QA_y/view?usp=sharing
https://drive.google.com/file/d/1ma1_EPro4NvJiOy8lWPrAmGLMrVWHZPS/view?usp=sharing
https://drive.google.com/file/d/11NDIwA9g02zkCKnsmYSLSNF5R-BrFpgt/view?usp=sharing
https://drive.google.com/file/d/1p6T9-oOwyfj7NUsLxTRLtqXKHU4qHrZx/view?usp=sharing
https://drive.google.com/file/d/1spD7KT-3WBo7KFF0Hb_WgJ5dVKRHF-un/view?usp=sharing
https://drive.google.com/file/d/16QtJQtT9zaU7nGcpnm2KXJ6jiLywNt5s/view?usp=sharing
https://drive.google.com/file/d/1cnZJshFS5xW-HbeaH_C_e6KcDo9xYRdY/view?usp=sharing
This is my application.yml file:
https://drive.google.com/file/d/1xvPhPneVjMU4BoN6F0Q63l2wCnF20BYq/view?usp=sharing
https://drive.google.com/file/d/1B9_5WueRvqQv4ODsJAfbUzGIm-xaaSYV/view?usp=sharing
This is my main application java file:
https://drive.google.com/file/d/1K9lzzlzIKT8irqXsPY1WeiBvN-9vsoWT/view?usp=sharing
This is my web config file in my config package:
https://drive.google.com/file/d/19EYa2kkqqPu9Wh8nN-U02szSVBT30lOP/view?usp=sharing
https://drive.google.com/file/d/11Zw8dLrAu6c_OI29j0NsljvXdeDam0-t/view?usp=sharing
This is my spring security config file in my config package:
https://drive.google.com/file/d/1inqlTjfxahcF6ZeJ_xkJM18UgsDu119n/view?usp=sharing
https://drive.google.com/file/d/1nTeYiKhiNOH71Km-s_T4IT1BKRyJG4mS/view?usp=sharing
I hope that these pictures help for diagnosing the issue.
I figured it out. First I changed the postgres jdbc url back to the original one that I had and then I altered my data source config file to the following: https://drive.google.com/file/d/1Zmv8cfnVzW8NcQfjNxN14D4aKFaXpdfU/view?usp=sharing. One important thing I also messed up on was not setting a password for the default user "postgres" when downloading postgresql. I did this my calling "ALTER USER postgres PASSWORD 'myPassword';" in the postgresql command line. Also make sure that you use systemctl restart postgresql after any changes are made to postgresql in the postgresql command line.

How to fix netty dependency when executing a java jar containing google-cloud app in raspbian

I have a java application in which I am using google cloud speech recognition. Everything works fine when I execute the runnable jar in Ubuntu, but when I execute the runnable jar in my raspberry pi 3 with OS Raspbian using the command java -jar JarFile.jar I get an error about a dependency with netty, which I have never used.
I have read this question
Failed to load libraries: [netty_tcnative_linux_arm_32, netty_tcnative_linux_arm_32_fedora, netty_tcnative_arm_32, netty_tcnative]
which is exactly the same as mine, but I don't know how to carry out the answer provided there. If someone could give me more information about how to do that I would be very pleased.
I have already tried:
Using netty in my maven dependencies although I don't need it.
Installing tomcat apache (I thought it could provide some SSL solution)
Adding latest netty .jar to my dependencies
These are the first lines of the error trace I get:
dic 30, 2018 11: 14: 39 PM io.grpc.netty.shaded.io.grpc.netty.GrpcSslContexts defaultSslProvider
INFORMACIÓN: netty - tcnative unavailable(this may be normal)
java.lang.IllegalArgumentException: Failed to load any of the given libraries: [netty_tcnative_linux_arm_32, netty_tcnative_linux_arm_32_fedora, netty_tcnative_arm_32, netty_tcnative]
at io.grpc.netty.shaded.io.netty.util.internal.NativeLibraryLoader.loadFirstAvailable(NativeLibraryLoader.java: 93)
at
Netty does not provide a netty-tcnative artifact for arm32 so you will need to either build it yourself or use another SSL implementation together with grpc. As far as I know they also support using the one which is provided as part of the JDK or allow to use conscrypt.

Cloud Bigtable Failure due to NPN/ALPN extensions not installed

Trying to interact with Google Cloud Bigtable via Java lib and after successfully creating connection object, send "list" command and I am getting the following error for command.run() method:
command.run(connection, argsList.subList(1, argsList.size()));
specifically:
Jul 06, 2015 1:12:15 PM io.grpc.transport.netty.ProtocolNegotiators$AbstractBufferingHandler fail
SEVERE: Transport failed during protocol negotiation
io.netty.channel.ChannelPipelineException: io.grpc.transport.netty.ProtocolNegotiators$1$1.handlerAdded() has thrown an exception; removed.
at io.netty.channel.DefaultChannelPipeline.callHandlerAdded0(DefaultChannelPipeline.java:600)
at io.netty.channel.DefaultChannelPipeline.callHandlerAdded(DefaultChannelPipeline.java:582)
at io.netty.channel.DefaultChannelPipeline.addFirst0(DefaultChannelPipeline.java:124)
at io.netty.channel.DefaultChannelPipeline.addFirst(DefaultChannelPipeline.java:108)
at io.netty.channel.DefaultChannelPipeline.addFirst(DefaultChannelPipeline.java:291)
at io.netty.channel.DefaultChannelPipeline.addFirst(DefaultChannelPipeline.java:246)
at io.grpc.transport.netty.ProtocolNegotiators$AbstractBufferingHandler.channelRegistered(ProtocolNegotiators.java:233)
at io.netty.channel.ChannelHandlerInvokerUtil.invokeChannelRegisteredNow(ChannelHandlerInvokerUtil.java:32)
at io.netty.channel.DefaultChannelHandlerInvoker.invokeChannelRegistered(DefaultChannelHandlerInvoker.java:50)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRegistered(AbstractChannelHandlerContext.java:114)
at io.netty.channel.DefaultChannelPipeline.fireChannelRegistered(DefaultChannelPipeline.java:833)
at io.netty.channel.AbstractChannel$AbstractUnsafe.register0(AbstractChannel.java:487)
at io.netty.channel.AbstractChannel$AbstractUnsafe.access$100(AbstractChannel.java:401)
at io.netty.channel.AbstractChannel$AbstractUnsafe$1.run(AbstractChannel.java:461)
at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:322)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:356)
at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:703)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.IllegalStateException: NPN/ALPN extensions not installed
Just following;https://cloud.google.com/bigtable/docs/samples-simple-cli
Any help would be highly appreciated!
It is necessary to modify your eclipse java run to load the alpn-boot jar in front of all other classes / jars. Using the line:
-Xbootclasspath/p:$(pwd)/lib/bigtable/alpn-boot-${ALPN_VERSION}.jar
For more information, see ALPN.
For Unit Testing in Maven, you can look at our example
UPDATE You can now work w/o alpn-boot by using the Netty TCNative jar w/ BoringSSL we have two examples with that currently, the Managed-VM-Sample and the Quickstart. See the pom.xml for the details, the MVM sample shows how to setup your pom to compile locally and deploy. The Quickstart pom shows a compile and run on the same machine form. We hope to have all the Java samples using this soon.

Newrelic Install for WebSphere - ClassNotFoundException

We've installed the NewRelic java agent on our WebSphere Application / WebSphere Commerce system and in the NewRelic logs we are seeing this:
Sep 3, 2013 22:47:53 -0400 NewRelic 14 INFO: The data collector is temporarily unavailable. This can happen periodically. In the event that availability of our servers is not restored after a period of time, then please report this to New Relic. java.net.SocketException: java.lang.ClassNotFoundException: Cannot find the specified class com.ibm.websphere.ssl.protocol.SSLSocketFactory
at javax.net.ssl.DefaultSSLSocketFactory.a(SSLSocketFactory.java:11)
at javax.net.ssl.DefaultSSLSocketFactory.createSocket(SSLSocketFactory.java:6)
at com.ibm.net.ssl.www2.protocol.https.c.afterConnect(c.java:161)
at com.ibm.net.ssl.www2.protocol.https.d.connect(d.java:36)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1184)
at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:390)
at com.ibm.net.ssl.www2.protocol.https.b.getResponseCode(b.java:75)
at com.newrelic.agent.transport.DataSenderImpl.connectAndSend(DataSenderImpl.java:550)
at com.newrelic.agent.transport.DataSenderImpl.send(DataSenderImpl.java:600)
at com.newrelic.agent.transport.DataSenderImpl.invoke(DataSenderImpl.java:480)
at com.newrelic.agent.transport.DataSenderImpl.invokeNoRunId(DataSenderImpl.java:475)
at com.newrelic.agent.transport.DataSenderImpl.getRedirectHost(DataSenderImpl.java:203)
at com.newrelic.agent.transport.DataSenderImpl.connect(DataSenderImpl.java:193)
at com.newrelic.agent.RPMService.launch(RPMService.java:194)
at com.newrelic.agent.rpm.RPMConnectionServiceImpl$RPMConnectionTask.attemptConnection(RPMConnectionServiceImpl.java:301)
at com.newrelic.agent.rpm.RPMConnectionServiceImpl$RPMConnectionTask.access$1100(RPMConnectionServiceImpl.java:101)
at com.newrelic.agent.rpm.RPMConnectionServiceImpl$RPMConnectionTask$3.run(RPMConnectionServiceImpl.java:235)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:452)
at java.util.concurrent.FutureTask$Sync.innerRunAndReset(FutureTask.java:328)
at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:161)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$101(ScheduledThreadPoolExecutor.java:109)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.runPeriodic(ScheduledThreadPoolExecutor.java:191)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:215)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:897)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:919)
at java.lang.Thread.run(Thread.java:738)
Caused by: java.lang.ClassNotFoundException: Cannot find the specified class com.ibm.websphere.ssl.protocol.SSLSocketFactory
at javax.net.ssl.SSLJsseUtil.b(SSLJsseUtil.java:125)
at javax.net.ssl.SSLSocketFactory.getDefault(SSLSocketFactory.java:3)
at javax.net.ssl.HttpsURLConnection.getDefaultSSLSocketFactory(HttpsURLConnection.java:41)
at javax.net.ssl.HttpsURLConnection.<init>(HttpsURLConnection.java:46)
at com.ibm.net.ssl.www2.protocol.https.b.<init>(b.java:26)
at com.ibm.net.ssl.www2.protocol.https.Handler.openConnection(Handler.java:1)
at com.ibm.net.ssl.www2.protocol.https.Handler.openConnection(Handler.java:5)
at java.net.URL.openConnection(URL.java:957)
at com.newrelic.agent.transport.DataSenderImpl.createConnection(DataSenderImpl.java:676)
at com.newrelic.agent.transport.DataSenderImpl.connectAndSend(DataSenderImpl.java:540)
... 18 more
There seems to be some documentation about how to update an Eclipse based IDE environment to overcome this error in other situations, but nothing specific to NewRelic. Has anyone seen this before that can offer suggestions on how to fix the issue?
The next release of New Relics Java agent should make it possible to run without any configuration changes. With version 2.21.X and earlier please submit a request for support at support.newrelic.com
Read and see if this publication gives you a hint:
http://www-01.ibm.com/support/docview.wss?uid=swg21584437
I went through the same thing. As you might have gathered from the article liked by Robban WebSphere has some restriction in the SSLConnectionFactory, so a quit fix would be to just edit the newrelic.yml and configure:
# The agent communicates with New Relic via https by
# default. If you want to communicate with newrelic via http,
# then turn off SSL by setting this value to false.
# This work is done asynchronously to the threads that process your
# application code, so response times will not be directly affected
# by this change.
# Default is true.
ssl: false
Good luck.
Version 3.0.0 or later of New Relic's Java Agent should completely resolve this issue without any custom configuration, certainly without turning off SSL! Release notes.

Categories