开发者

Custom exception class not being compiled into .class file

开发者 https://www.devze.com 2023-02-08 11:56 出处:网络
I have created a pretty simp开发者_高级运维le custom class that extends Exception, code listed below.The problem I\'m running into is that this specific class is not being compiled into a .class file

I have created a pretty simp开发者_高级运维le custom class that extends Exception, code listed below. The problem I'm running into is that this specific class is not being compiled into a .class file (within the build/classes directory, and the jar file for the project). All other classes are compiled into .class files and packaged into a .jar file as expected.

jUnit tests run fine, even when they are run from other projects in the workspace, but when I attempt to reference this project from another project that depends on a jar the code is failing with a NoClassDefFoundError exception because it can't find this class in the .jar file that's generated.

I'm using Eclipse and Maven. All other classes in the same project appear to be compiling just fine and Google and Stack Overflow have not yielded any clues.

The class code is as follows:

public class DownstreamSystemFailureException extends Exception {

private static final long serialVersionUID = -5124591997847109725L;
@SuppressWarnings("unused")
private String systemDescription = null;
@SuppressWarnings("unused")
private Exception innerException = null;

public DownstreamSystemFailureException( String systemDescription, Exception innerException )
{
    this.systemDescription = systemDescription;
    this.innerException = innerException;
}

}


Try to create your jar with a different tool...


Ensure you have declared a package at the top of your custom Exception. Using the default package for classes is not recommended, and you will have trouble finding them within a jar.

0

精彩评论

暂无评论...
验证码 换一张
取 消