Line number info not available error while debugging Ant project in IntelliJ
Asked Answered
K

1

9

I am working with a fairly old Java Ant project, which I have imported into IntelliJ, it previously having been developed using Eclipse. The project consists of a small number of servlets. I am trying to debug from IntelliJ. IntelliJ can connect to remote Tomcat on port 8000, but when I try to add a breakpoint I get the following dreaded error:

Line numbers info is not available in class com.package.blah.SomeClass

Following advice on SO and elsewhere, I modified my Ant build script to the following:

<target name="compile" depends="web-skeleton">
    <ant dir="${deployment-wizard.dir}" target="uberjar"/>
    <javac debug="true" debuglevel="lines,vars,source" srcdir="${src.dir}"
        destdir="${build.dir}/WEB-INF/classes" classpathref="project.class.path"/>
</target>

I added the debug and debuglevel lines to the above target which calls javac. Also, I have tried running javap -v SomeClass.class, where I see things like the following:

  line 94: 418
  line 97: 433
  line 98: 443
LocalVariableTable:
  Start  Length  Slot  Name   Signature
    343      22    13 decrypted   Ljava/lang/String;
    370      11    13     e   Ljava/lang/Exception;
    244     189     7 keyParam   Ljava/lang/String;
    255     178     8 userParam   Ljava/lang/String;
    266     167     9 environmentParam   Ljava/lang/String;

I don't know if this means that the bytecode contains line numbers, but it certainly appears this way.

I have also tried cleaning and rebuilding from scratch and doing an invalidate caches/restart from IntelliJ.

I hope that someone can offer some help here. As a last resort, I can try porting it to a Maven project, but I would prefer to avoid this unless absolutely necessary.

Kelleykelli answered 20/4, 2018 at 4:58 Comment(3)
Have you tried to clean/rebuild your project after adding debug options?Related
Yes, I went way beyond this, even doing invalidate caches in IntelliJ, cleaning, restarting. I gave up...I spent the afternoon porting it to a Maven project, which now runs with breakpoints :-)Kelleykelli
I am highlighting the attributes which were missing in my case. It is easy to overlook. After adding the debug and debuglevel in compile target, the issue was resolved. Thank you.Marty
T
4

the same thing happened to me and it was because I had "shrinkResources true" and "minifyEnabled true" in Gradle App

buildTypes {
        debug {
            shrinkResources false
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
Tracery answered 23/4, 2019 at 17:48 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.