0

I have a very simple standalone command line Java app. Using the maven-assembly-plugin I create an executable fat jar with all dependencies, including the MySQL driver jar. I have opened the jar to verify the classes are indeed included.

Normally, this job is supposed to run (as root via incrond) in response to a file being uploaded to our SFTP site to import the uploaded data. However when it is run in this way, in the logs I see the error "java.sql.SQLException: No suitable driver found". However if I run the app directly as root with the same parameters, it works fine. In both cases the same java (/usr/bin/java) is being used. Also works on my local dev machine running as my user.

I did search for similar problems, but most of what I found were due to missing adding the driver to the fat jar, which as I mentioned I verified isn't the case here.

Update: Fixed. The problem actually nothing to do with the building of the jar file. The actual cause was, when running directly in bash I needed to put single quotes around the connection string and password parameters as cli options due to special chars. So I did the same in setting up the incrond conf files. Turns out incrond would pass the quotes as part of the values. Figures that after days of fighting with this and finally posting here I'd almost immediately find the real problem.

  • You should be using the maven-shade-plugin and include this transformer to handle the META-INF/services: – Rob Oct 18 '16 at 16:34
  • Thank you - not sure how I never turned up that similar question in multiple searches. Tho my problem turned out to be something else I'll update the plugin as well to help guard against future problems! – Eddie Sheffield Oct 18 '16 at 18:41

0 Answers0