1

I'm trying to use the org.apache.ddlutils package for reading database metadata. I've written the following method:

public static void readMetaData(DataSource dataSource) throws DdlUtilsException{

    final Platform platform = PlatformFactory.createNewPlatformInstance(dataSource);
}

But the statement throws DdlUtilsException gives the following error:

No exception of type DdlUtilsException can be thrown; an exception type must be a subclass of Throwable

I simply do not understand the reason behind this error because the API at http://db.apache.org/ddlutils/api/org/apache/ddlutils/DdlUtilsException.html clearly states the following:

java.lang.Object
  extended by java.lang.Throwable
      extended by java.lang.Exception
          extended by java.lang.RuntimeException
              extended by org.apache.commons.lang.exception.NestableRuntimeException
                  extended by org.apache.ddlutils.DdlUtilsException

Please advice.

n_g
  • 3,315
  • 8
  • 25
  • 29
  • Just for later reference. Apache DdlUtils 1.0 depends on Apache Commons Lang 2.6. Later versions (3.0+) are not compatible. – eonil Mar 25 '13 at 16:39

2 Answers2

3

My guess is that you've got another class called DdlUtilsException somewhere - possibly in the top-level package, given that the compiler isn't mentioning a full package name. If you're using Eclipse or something similar, try to navigate to the class declaration.

EDIT: Okay, judging by your comment, you aren't including the various dependencies. Make sure you've downloaded DdlUtils-1.0-bin.zip, and the dependencies are all in the lib directory. It's not immediately clear to me whether you need all of them, but you might as well use them all to start with, and then remove what you don't need.

Jon Skeet
  • 1,421,763
  • 867
  • 9,128
  • 9,194
  • Thanks Jon for the reply!! I've only used the jar DdlUtils-1.0.jar in the build path. There is no other jar file. But when I look in the errors view of eclipse, it says "The type org.apache.commons.lang.exception.NestableRuntimeException cannot be resolved. It is indirectly referenced from required .class files" What could be the reason for this error??? – n_g Feb 11 '11 at 15:21
  • @n_g: Sounds like the compiler is telling you exactly what's wrong. You need to add some dependencies, including apache.commons. The ddlutils home page should tell you want dependencies you need. – Jon Skeet Feb 11 '11 at 15:52
  • I've just looked at the DdlUtils 1.0 release, and the zip file contains various dependencies. – Jon Skeet Feb 11 '11 at 15:53
  • @n_g: But if you haven't added the other dependencies, you're likely to have a problem elsewhere... at execution time rather than compile-time maybe, but still a problem... – Jon Skeet Feb 11 '11 at 16:00
  • @Jon: You are right. But right now even I'm not sure about what other dependencies I'll need :) ... So I'll add other jars as I progress with my development. – n_g Feb 11 '11 at 16:10
1

It looks like that other class 'org.apache.commons.lang.exception.NestableRuntimeException' is located in commons-lang. Download and add that jar and it should work. Check the docs for DDL Utils and see what else it depends on.

Sarel Botha
  • 12,419
  • 7
  • 54
  • 59