I have a java/maven project that runs some database stuff perfectly (classpath is working great). I use a proprietary database jar in order to connect to the database. When I go to package up my software into a shaded jar the proprietary jar isn't referenced. When I check the log files I see this error:
Exception: java.lang.ClassNotFoundException: com.sybase.jdbc4.jdbc.SybDriver
I'm trying to put everything into a shaded jar using Maven. Is there something that I'm not doing? Why is the database jar not working in my new shaded jar?
Adding the shade plugin configuration:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.4.3</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>package.class</mainClass>
</transformer>
</transformers>
<shadedArtifactAttached>true</shadedArtifactAttached>
<shadedClassifierName>launcher</shadedClassifierName>
</configuration>
</execution>
</executions>
</plugin>
I have followed the instructions about setting up a file repository since we don't have a corporate repository.
I created a folder at c:\my-repo and put the lone jconn4.jar file inside. I then added this to my pom.xml:
<repositories>
<repository>
<id>my-local-repo</id>
<url>file://${basedir}/my-repo</url>
</repository>
</repositories>
and
<dependency>
<groupId>company</groupId>
<artifactId>jconn4.jar</artifactId>
<version>16.0</version>
</dependency>
Finally, at a command prompt I ran the command:
$ mvn org.apache.maven.plugins:maven-install-plugin:2.3.1:install-file -Dfile=C:\my-repo\jconn4.jar -DgroupId=company -DartifactId=jconn4.jar -Dversion=16.0 -Dpackaging=jar -DlocalRepositoryPath=C:\my-repo
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building My_Project 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-install-plugin:2.3.1:install-file (default-cli) @ My_Project ---
[INFO] Installing C:\my-repo\jconn4.jar to C:\my-repo\company\jconn4.jar\16.0\jconn4.jar-16.0.jar
[INFO] Installing C:\Users\jsmith\AppData\Local\Temp\mvninstall7806841451724024532.pom to C:\my-repo\company\jconn4.jar\16.0\jconn4.jar-16.0.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.613 s
[INFO] Finished at: 2016-12-08T10:26:08-05:00
[INFO] Final Memory: 7M/245M
[INFO] ------------------------------------------------------------------------
That's all well and good but I keep getting this error in my pom.xml now "Missing artifact company:jconn4.jar:jar:16.0"
Have I implemented something incorrectly?