Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/317.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 使用maven project的NetBeans在附加到另一个应用程序中的jvm时不会单步执行代码_Java_Maven_Debugging_Netbeans - Fatal编程技术网

Java 使用maven project的NetBeans在附加到另一个应用程序中的jvm时不会单步执行代码

Java 使用maven project的NetBeans在附加到另一个应用程序中的jvm时不会单步执行代码,java,maven,debugging,netbeans,Java,Maven,Debugging,Netbeans,我第一次在Maven中使用NetBeans。在NetBeans中,一切都很好。可以构建、包安装等。可以调试和单步执行代码。当我试图通过附加到另一个链接JVM实例的应用程序而不是在NetBeans中调试代码时,问题就开始了 我使用共享内存传输连接到一个进程,它成功了。当我从该进程调用带有断点的java方法时,它会中断。我可以检查变量,可以看出它停在了正确的位置,但它拒绝单步执行代码。NetBeans没有在它停止的那一行用绿色高亮显示,代码的单步执行导致NetBeans进入一些Java内部,弹出In

我第一次在Maven中使用NetBeans。在NetBeans中,一切都很好。可以构建、包安装等。可以调试和单步执行代码。当我试图通过附加到另一个链接JVM实例的应用程序而不是在NetBeans中调试代码时,问题就开始了

我使用共享内存传输连接到一个进程,它成功了。当我从该进程调用带有断点的java方法时,它会中断。我可以检查变量,可以看出它停在了正确的位置,但它拒绝单步执行代码。NetBeans没有在它停止的那一行用绿色高亮显示,代码的单步执行导致NetBeans进入一些Java内部,弹出Integer类、HashMap类等,并抱怨没有可用的源代码。不过,我可以在代码中设置另一个断点,然后单击“继续”。它会停在那里,但不会再前进

我的猜测是它与maven和类文件中不完整的调试信息有关。如果我重新配置我的项目以使用ant,那么一切都正常工作,但是回到maven会再次把它搞砸

NetBeans中的调试视图显示“隐藏的源代码调用”:

有人有什么想法吗?谢谢

我使用链接的jvm.dll启动应用程序,并使用以下选项:

-Xdebug-Xrunjdwp:transport=dt_shmem,address=myexecutable,server=y,suspend=n

以下是我的示例pom文件:

http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0

<groupId>com.some.company.edited</groupId>
<artifactId>atpg-parent</artifactId>
<version>0.1</version>
<packaging>pom</packaging>
<name>Parent Project</name>

<properties>
    <!-- Build Metadata -->
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    <!-- App & Platform Versions -->
    <java.target.version>1.7</java.target.version>
    <junit.version>4.12</junit.version>
    <!-- Build Plugin Versions -->
    <maven.compiler.plugin>3.2</maven.compiler.plugin>
</properties>

<modules>
    <module>atpg-main</module>
    <module>atpg-dm</module>
</modules>

<!-- Dependency VERSIONS -->
<dependencyManagement>
    <dependencies>
        <!-- Test Dependencies -->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>${junit.version}</version>
            <scope>test</scope>
        </dependency>
    </dependencies>
</dependencyManagement>

<!-- Shared Dependencies -->
<dependencies>
    <!-- Test Dependencies (can't hurt to include these all the time) -->
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <scope>test</scope>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <version>${maven.compiler.plugin}</version>
            <artifactId>maven-compiler-plugin</artifactId>
            <configuration>
                <source>${java.target.version}</source>
                <target>${java.target.version}</target>
                <debug>true</debug>
                <debuglevel>lines,vars,source</debuglevel>
            </configuration>
        </plugin>
    </plugins>
</build>
<parent>
    <groupId>com.some.company.edited</groupId>
    <artifactId>atpg-parent</artifactId>
    <version>0.1</version>
</parent>

<artifactId>atpg-main</artifactId>
<packaging>jar</packaging>
<name>Main Project</name>

<dependencies>
    <!-- Project module dependencies -->
    <dependency>
        <groupId>${project.groupId}</groupId>
        <artifactId>atpg-dm</artifactId>
        <version>${project.version}</version>
    </dependency>
</dependencies>
<parent>
    <groupId>com.some.company.edited</groupId>
    <artifactId>atpg-parent</artifactId>
    <version>0.1</version>
</parent>

<artifactId>atpg-dm</artifactId>
<packaging>jar</packaging>
<name>Exchange Format Data Model</name>

<build>
    <plugins>
        <plugin>
            <groupId>org.jvnet.jaxb2.maven2</groupId>
            <version>0.13.1</version>
            <artifactId>maven-jaxb2-plugin</artifactId>
            <executions>
                <execution>
                    <goals>
                        <goal>generate</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>
com.some.company.edited
atpg父母
0.1
聚甲醛
父项目
UTF-8
UTF-8
1.7
4.12
3.2
atpg干线
atpg-dm
朱尼特
朱尼特
${junit.version}
测试
朱尼特
朱尼特
测试
org.apache.maven.plugins
${maven.compiler.plugin}
maven编译器插件
${java.target.version}
${java.target.version}
真的
行、变量、源

http://maven.apache.org/maven-v4_0_0.xsd"> 4.0.0

<groupId>com.some.company.edited</groupId>
<artifactId>atpg-parent</artifactId>
<version>0.1</version>
<packaging>pom</packaging>
<name>Parent Project</name>

<properties>
    <!-- Build Metadata -->
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    <!-- App & Platform Versions -->
    <java.target.version>1.7</java.target.version>
    <junit.version>4.12</junit.version>
    <!-- Build Plugin Versions -->
    <maven.compiler.plugin>3.2</maven.compiler.plugin>
</properties>

<modules>
    <module>atpg-main</module>
    <module>atpg-dm</module>
</modules>

<!-- Dependency VERSIONS -->
<dependencyManagement>
    <dependencies>
        <!-- Test Dependencies -->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>${junit.version}</version>
            <scope>test</scope>
        </dependency>
    </dependencies>
</dependencyManagement>

<!-- Shared Dependencies -->
<dependencies>
    <!-- Test Dependencies (can't hurt to include these all the time) -->
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <scope>test</scope>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <version>${maven.compiler.plugin}</version>
            <artifactId>maven-compiler-plugin</artifactId>
            <configuration>
                <source>${java.target.version}</source>
                <target>${java.target.version}</target>
                <debug>true</debug>
                <debuglevel>lines,vars,source</debuglevel>
            </configuration>
        </plugin>
    </plugins>
</build>
<parent>
    <groupId>com.some.company.edited</groupId>
    <artifactId>atpg-parent</artifactId>
    <version>0.1</version>
</parent>

<artifactId>atpg-main</artifactId>
<packaging>jar</packaging>
<name>Main Project</name>

<dependencies>
    <!-- Project module dependencies -->
    <dependency>
        <groupId>${project.groupId}</groupId>
        <artifactId>atpg-dm</artifactId>
        <version>${project.version}</version>
    </dependency>
</dependencies>
<parent>
    <groupId>com.some.company.edited</groupId>
    <artifactId>atpg-parent</artifactId>
    <version>0.1</version>
</parent>

<artifactId>atpg-dm</artifactId>
<packaging>jar</packaging>
<name>Exchange Format Data Model</name>

<build>
    <plugins>
        <plugin>
            <groupId>org.jvnet.jaxb2.maven2</groupId>
            <version>0.13.1</version>
            <artifactId>maven-jaxb2-plugin</artifactId>
            <executions>
                <execution>
                    <goals>
                        <goal>generate</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

com.some.company.edited
atpg父母
0.1
atpg干线
罐子
主要项目
${project.groupId}
atpg-dm
${project.version}

http://maven.apache.org/maven-v4_0_0.xsd"> 4.0.0

<groupId>com.some.company.edited</groupId>
<artifactId>atpg-parent</artifactId>
<version>0.1</version>
<packaging>pom</packaging>
<name>Parent Project</name>

<properties>
    <!-- Build Metadata -->
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    <!-- App & Platform Versions -->
    <java.target.version>1.7</java.target.version>
    <junit.version>4.12</junit.version>
    <!-- Build Plugin Versions -->
    <maven.compiler.plugin>3.2</maven.compiler.plugin>
</properties>

<modules>
    <module>atpg-main</module>
    <module>atpg-dm</module>
</modules>

<!-- Dependency VERSIONS -->
<dependencyManagement>
    <dependencies>
        <!-- Test Dependencies -->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>${junit.version}</version>
            <scope>test</scope>
        </dependency>
    </dependencies>
</dependencyManagement>

<!-- Shared Dependencies -->
<dependencies>
    <!-- Test Dependencies (can't hurt to include these all the time) -->
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <scope>test</scope>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <version>${maven.compiler.plugin}</version>
            <artifactId>maven-compiler-plugin</artifactId>
            <configuration>
                <source>${java.target.version}</source>
                <target>${java.target.version}</target>
                <debug>true</debug>
                <debuglevel>lines,vars,source</debuglevel>
            </configuration>
        </plugin>
    </plugins>
</build>
<parent>
    <groupId>com.some.company.edited</groupId>
    <artifactId>atpg-parent</artifactId>
    <version>0.1</version>
</parent>

<artifactId>atpg-main</artifactId>
<packaging>jar</packaging>
<name>Main Project</name>

<dependencies>
    <!-- Project module dependencies -->
    <dependency>
        <groupId>${project.groupId}</groupId>
        <artifactId>atpg-dm</artifactId>
        <version>${project.version}</version>
    </dependency>
</dependencies>
<parent>
    <groupId>com.some.company.edited</groupId>
    <artifactId>atpg-parent</artifactId>
    <version>0.1</version>
</parent>

<artifactId>atpg-dm</artifactId>
<packaging>jar</packaging>
<name>Exchange Format Data Model</name>

<build>
    <plugins>
        <plugin>
            <groupId>org.jvnet.jaxb2.maven2</groupId>
            <version>0.13.1</version>
            <artifactId>maven-jaxb2-plugin</artifactId>
            <executions>
                <execution>
                    <goals>
                        <goal>generate</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

com.some.company.edited
atpg父母
0.1
atpg-dm
罐子
交换格式数据模型
org.jvnet.jaxb2.maven2
0.13.1
maven-jaxb2-plugin
生成

问题已解决。解决方法非常简单。事实证明,对于在NetBeans环境之外创建的Maven项目,不仅要打开父项目,还要打开项目中的所有模块。由于我的无知,我没有这样做。我只打开了父项目

在“打开项目”对话框中,实际上有一个复选框“打开所需的项目:”并且该复选框处于关闭状态。我选中该复选框后,我的父项将所有模块作为单独的项目打开,所有模块都运行得很好

因此,这个问题与Java类文件中不完整的调试信息无关。默认情况下,此复选框处于关闭状态只是NetBeans的一个特性