• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

ANT/MySQL JDBC Classloader Problem

 
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I downloaded the J-Connect JDBC driver and am having difficulty getting it to run under ANT.

It runs fine when I use javac/java.

Here is my build.xml file.



Here is the basic code to load driver.



Here is the exception I am getting ...

processDatabase called ...
[java] java.util.zip.ZipException: error in opening zip file
[java] at java.util.zip.ZipFile.open(Native Method)
[java] at java.util.zip.ZipFile.<init>(ZipFile.java:114)
[java] at java.util.zip.ZipFile.<init>(ZipFile.java:131)
[java] at org.apache.tools.ant.AntClassLoader.getResourceURL(AntClassLoader.java:1014)
[java] at org.apache.tools.ant.AntClassLoader$ResourceEnumeration.findNextResource(AntClassLoader.java:146)
[java] at org.apache.tools.ant.AntClassLoader$ResourceEnumeration.<init>(AntClassLoader.java:108)
[java] at org.apache.tools.ant.AntClassLoader.findResources(AntClassLoader.java:958)
[java] at java.lang.ClassLoader.getResources(ClassLoader.java:1015)
[java] at sun.misc.Service$LazyIterator.hasNext(Service.java:249)
[java] at java.sql.DriverService.run(DriverManager.java:663)
[java] at java.security.AccessController.doPrivileged(Native Method)
[java] at java.sql.DriverManager.loadInitialDrivers(DriverManager.java:506)
[java] at java.sql.DriverManager.initialize(DriverManager.java:612)
[java] at java.sql.DriverManager.registerDriver(DriverManager.java:281)
[java] at com.mysql.jdbc.Driver.<clinit>(Driver.java:62)
[java] at java.lang.Class.forName0(Native Method)
[java] at java.lang.Class.forName(Class.java:169)
[java] at com.defenseknife.component.MysqlDatabaseProxy.initialize(Unknown Source)
[java] at com.defenseknife.component.MysqlDatabaseProxy.<init>(Unknown Source)
[java] at com.defenseknife.moteng.file.MotengDataFile.processDatabase(Unknown Source)
[java] at com.defenseknife.moteng.processor.MotengDataFileHandler.processFiles(Unknown Source)
[java] at com.defenseknife.moteng.processor.MotengProcessor.processFiles(Unknown Source)
[java] at com.defenseknife.server.MerchantTradersDataProcessor.main(Unknown Source)
[java] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[java] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
[java] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
[java] at java.lang.reflect.Method.invoke(Method.java:597)
[java] at org.apache.tools.ant.taskdefs.ExecuteJava.run(ExecuteJava.java:217)
[java] at org.apache.tools.ant.taskdefs.ExecuteJava.execute(ExecuteJava.java:152)
[java] at org.apache.tools.ant.taskdefs.Java.run(Java.java:747)
[java] at org.apache.tools.ant.taskdefs.Java.executeJava(Java.java:201)
[java] at org.apache.tools.ant.taskdefs.Java.execute(Java.java:104)
[java] at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
[java] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[java] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
[java] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
[java] at java.lang.reflect.Method.invoke(Method.java:597)
[java] at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:105)
[java] at org.apache.tools.ant.Task.perform(Task.java:348)
[java] at org.apache.tools.ant.Target.execute(Target.java:357)
[java] at org.apache.tools.ant.Target.performTasks(Target.java:385)
[java] at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1329)
[java] at org.apache.tools.ant.Project.executeTarget(Project.java:1298)
[java] at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
[java] at org.apache.tools.ant.Project.executeTargets(Project.java:1181)
[java] at org.apache.tools.ant.Main.runBuild(Main.java:698)
[java] at org.apache.tools.ant.Main.startAnt(Main.java:199)
[java] at org.apache.tools.ant.launch.Launcher.run(Launcher.java:257)
[java] at org.apache.tools.ant.launch.Launcher.main(Launcher.java:104)

Any insight is GREATLY appreciated!

Thanks,
Aryeh
 
Bartender
Posts: 4121
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This error can be thrown when a JAR file on the classpath is corrupted. Are you using all the same JAR files in the classpath when running from the command-line?

Also, why is ${src.dir} on your classpath?
 
Aryeh Golob
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Nate ...

I owe you BIG TIME!!!

The issue was the ${src.dir} in the classpath. This must have been a remnant from when I was first trying to setup ANT. Never had an issue before, so I thought everything was OK.

Funny thing is, when I compiled using Java 1.5.x, everything worked fine.

I have been breaking my head over this for 1 1/2 days, so I REALLY appreciate your help.

Thanks ALOT!
Aryeh
 
Bring out your dead! Or a tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic