javamavenjarsbtbcel

Project unable to find org.apache.bcel.constants during runtime


I am importing a jar file which has bcel as a dependency(imported via maven) via sbt in my scala project. There are no compilation issues but during runtime I get the following error-

[info] org.foo.bar.FirstSpec *** ABORTED ***
[info]   java.lang.NoClassDefFoundError: org/apache/bcel/Constants

It says it is unable to find the org.apache.bcel.constants class. Is there any fix for this issue?

On further research, I found a solution this problem as I stated in my answer. The bcel class needed to be explicitly imported in the sbt project.

But why does bcel need to be explicitly imported when there are no usages of it except when passing function calls to the imported jar(which does have bcel as a dependency) using it?


Solution

  • Explicitly importing org.apache.bcel via sbt solved the issue.

    I added the following line to my build.sbt -

    libraryDependencies += "org.apache.bcel" % "bcel" % "5.2"