I am receiving a nullpointer exception because of the following code returning null.  conn = ds.getConnection();  I've spent the whole evening trying to debug it, without any luck. And I'm aware of that there is a lot of posts about nullpointer exceptions with dataSource.getConnection(), but nothing has helped.   The website worked perfectly fine running on my Mac, but now I want to host it on my Raspberry Pi through Tomcat. I have installed Tomcat, and MySQL and set it all up. The website works, except for when it needs to use something from the database, when the nullpointer occurs.   I have confirmed that ds is not null from: ds = (DataSource) context.lookup("java:comp/env/jdbc/psite"); I've tried different varians of getConnection, such as DriverManager.getConnection(name,username,psw); On my Raspberry Pi in my Tomcat/lib I have my mysql-connector-...jar   My xml files looks like this:  Tomcat/conf/context.xml  &lt;WatchedResource&gt;WEB-INF/web.xml&lt;/WatchedResource&gt; &lt;Resource     name="jdbc/psite"     auth="Container"     type="javax.sql.DataSource"     username="sonie"     password="******"     driverClassName="com.mysql.jdbc.Driver"     url="jdbc:mysql://localhost:3306/psite     maxActive="8"     maxIdle="4" /&gt;   Tomcat/conf/server.xml  &lt;Resource name="jdbc/psite"       global="jdbc/psite"       auth="Container"       type="javax.sql.DataSource"       driverClassName="com.mysql.jdbc.Driver"       url="jdbc:mysql://localhost:3306/psite"       username="sonie"       password="******"        maxActive="100"       maxIdle="20"       minIdle="5"       maxWait="10000"/&gt;   MyProject/WEB-INF/web.xml  &lt;resource-ref&gt;     &lt;res-ref-name&gt;      jdbc/psite     &lt;/res-ref-name&gt;     &lt;res-type&gt;      javax.sql.DataSource     &lt;/res-type&gt;     &lt;res-auth&gt;      Container     &lt;/res-auth&gt;   &lt;/resource-ref&gt;   Any ideas what might be wrong? I'm pretty sure I've nailed it down to being some configuration problems on my Raspberry Pi, as it worked fine on my Mac previously.  EDIT:  Even though yes it is a Nullpointer, I haven't managed to debug it like a normal Nullpointer as it works fine on my Mac in eclipse, but not when it's deployed on the Raspberry Pi. So I can't get the printstack.  It's not duplicated because it's not possible to debug this like a normal NullPointer.
What are Null Pointer Exceptions (java.lang.NullPointerException) and what causes them?  What methods/tools can be used to determine the cause so that you stop the exception from causing the program to terminate prematurely?
Is it still bad to use swap on a modern SSD? I have a Samsung 960 Pro SSD with Ubuntu 18.04  is it safe to put the swap file on there or would it hurt it in the long run,  I heard some people saying that new SSDs don't suffer from that issue anymore, is this true? How to do volumetric lighting for a forest scene? Possible to replay repetitive tasks using Python? Write space with TCPDF into a PDF file sum of the residue at all poles of the rational function p/q is 0. We are given two polynomials p, q with deg(q)>1+deg(p). Show that the sum of the residue at all poles of the rational function p/q is 0.   How do I go about solving this? A continuation of .  I'm fighting a page-limit in a single-column layout and I need to put a Figure and a Table side-by-side and provide them with independent captions. However, the style guide for the publishers (LNCS) wants Figure captions below and Table captions above (probably something to do with ).   =======================================================  If I adapt @lockstep's floatrow example from  accordingly to have a Table caption above ...  \documentclass{article}  \usepackage{floatrow} % Table float box with bottom caption, box width adjusted to content  %% ********************************** %% just adding \captop to original example %% ********************************** \newfloatcommand{capbtabbox}{table}[\captop][\FBwidth]  \usepackage{blindtext}   \begin{document}  \blindtext  \begin{figure} \begin{floatrow} \ffigbox{%   \rule{3cm}{3cm}% }{%   \caption{A figure}% } \capbtabbox{%   \begin{tabular}{cc} \hline   Author &amp; Title \\ \hline   Knuth &amp; The \TeX book \\   Lamport &amp; \LaTeX \\ \hline   Knuth &amp; The \TeX book \\   Lamport &amp; \LaTeX \\ \hline   Knuth &amp; The \TeX book \\   Lamport &amp; \LaTeX \\ \hline   \end{tabular} }{%   \caption{A table}% } \end{floatrow} \end{figure}  \end{document}   =======================================================  The problem becomes clear ...    =======================================================  The floatrow doesn't correctly line up the Table and Caption. I reluctantly tried to use vspace to solve the problem, but it didn't work out.  Any suggestions on how to get these two to align? I'm happy to accept any alignment that ensures that the Table and Figure fit within the same "box".  (A similar-ish question was , but specific for subfig and with a very localised problem it seems.) How can I parse dates and convert time zones in Perl? Background image resize in Ubuntu 18.04.1 LTS Recently updated to 18.04.1 and now I cannot resize my background image from fill screen to center image.  How can I resize the image now that 18 doesnt have the quick resize feature? How to calculate $\lim \limits_{n \to \infty}(1 +\frac{a}{n})^n$? $\lim_{n \rightarrow \infty} \sum^n_{k=1} \frac{1}{k+n}$ Could you explain how to find this limit?  $\lim_{n \rightarrow \infty} \sum^n_{k=1} \frac{1}{k+n}$ Fastest way to remove non-numeric characters from a VARCHAR in SQL Server I'm writing an import utility that is using phone numbers as a unique key within the import.  I need to check that the phone number does not already exist in my DB. The problem is that   phone numbers in the DB could have things like dashes and parenthesis and possibly other things. I wrote a function to remove these things, the problem is that it is slow and with thousands of records in my DB and thousands of records to import at once, this process can be unacceptably slow. I've already made the phone number column an index.  I tried using the script from this post:   But that didn't speed it up any.  Is there a faster way to remove non-numeric characters? Something that can perform well when 10,000 to 100,000 records have to be compared.  Whatever is done needs to perform fast.  Update Given what people responded with, I think I'm going to have to clean the fields before I run the import utility.   To answer the question of what I'm writing the import utility in, it is a C# app. I'm comparing BIGINT to BIGINT now, with no need to alter DB data and I'm still taking a performance hit with a very small set of data (about 2000 records).   Could comparing BIGINT to BIGINT be slowing things down?  I've optimized the code side of my app as much as I can (removed regexes, removed unneccessary DB calls). Although I can't isolate SQL as the source of the problem anymore, I still feel like it is. Deploy Community Builder audience page assignments with ant migration tool? Divisor in $\mathbb{C}[X]$ $\implies$ divisor in $\mathbb{R}[X]$? let $P \in \mathbb{R}[X]$ be a real polynomial divisible by a polynomial $Q \in \mathbb{R}[X]$ in $\mathbb{C}[X]$. How can I easily show that $P$ is also divisible by $Q$ in $\mathbb{R}[X]$?  A simple argument without using higher algebraic theorems is desirable. If I could use instruments of higher algebra, the exercise I have to do in whole would be done in two lines. But I'm not allowed to use. I think there would be an easy argument which I can't see yet because of my mental fogginess that I have sometimes.  Thank you beforehand. What is the purpose of the thin wire at the top of power transmission lines? I know a power transmission line carries usually two sets of 3 phase conductors. But I have noticed a relatively thin wire at the center-top of the power transmission line. What is the purpose of this thin wire? Georeferencing old map in QGIS? I have an old map over a part of Laos and wondering how do I georeference the map with the help of the Grid lines and other Longitude and Latitude information on the scanned map? I have searched for information on the internet and tried many times. My scanned map wont overly correctly on the base map. Any base map would be fine. As long as I can check the result.  Do I add X/East and Y/North values from the grid line crossings as marked and written in some parts of the map? How do I begin georeferencing this map? Do I have to add zeros after the two digits? For example if the Easting is 24 (its in KM right? Do I add like three/four zeros to convert it to meters?  I georeferenced the map with the option "From Map Canvas" in the georeferencer tool and I succeeded but I want to know the coordinate of a point on my old scanned map and write them as X/East and Y/North to georeference the map.   I hope I am not babbling and someone understands what I mean!  We can set the CRS to WGS84, EPSG:4326. Reading a Set in PostLoad on JPA/Hibernate Pattern matching with LIKE, SIMILAR TO or regular expressions in PostgreSQL I had to write a simple query where I go looking for people's name that start with a B or a D :   SELECT s.name  FROM spelers s  WHERE s.name LIKE 'B%' OR s.name LIKE 'D%' ORDER BY 1   I was wondering if there is a way to rewrite this to become more performant. So I can avoid or and / or like? Possible point location algorithm Dual boot windows 8 and Ubuntu with Windows 8 Boot manager "There are no shortage of applications" I've been having an argument with a colleague about this sentence, could you please let me know which one of us is correct:     There are no shortage of applications for our product in this   space.   She is convinced that are should be replaced by is, and I think it should stand as it is. Thanks for your help!