You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Embedded Tomcat启动时Jar包扫描失败问题求助

Fixing Embedded Tomcat Jar Scan Failures with Maven

Hey there, let's tackle this issue step by step—since you're new to Maven, I'll keep things clear and actionable. Those scan warnings pop up because Tomcat can't find certain JAR files in your local Maven repository, even though your build succeeded. Here's how to fix it:

1. Check Your Maven Dependency Configuration (pom.xml)

First off, the most common culprit here is incorrect dependency scopes or missing repository entries.

  • Fix the scope for JAX-WS/JAXB dependencies: If your jaxws-rt or related dependencies have a <scope>provided</scope> tag, Maven won't download them to your local repository (since "provided" assumes the runtime environment—like a full Tomcat server—will supply them). But since you're using embedded Tomcat, you need these JARs at runtime. Remove the scope tag or set it to compile/runtime:

    <dependency>
        <groupId>com.sun.xml.ws</groupId>
        <artifactId>jaxws-rt</artifactId>
        <version>2.1.7</version>
        <!-- Remove <scope>provided</scope> or change to compile -->
    </dependency>
    
  • Add the Java.net Repository: Many older Sun/Oracle dependencies (like the ones you're missing) aren't in the default Maven Central repository. Add this repository to your pom.xml to let Maven find them:

    <repositories>
        <repository>
            <id>java.net-public</id>
            <url>https://maven.java.net/content/repositories/public/</url>
        </repository>
    </repositories>
    

2. Force Maven to Re-Download Dependencies

Eclipse's "Update Project" can sometimes be less thorough than command-line Maven. Open a terminal in your project root and run this command—it will clean your build, force update all dependencies, and reinstall them:

mvn clean install -U

The -U flag tells Maven to ignore cached versions and pull fresh copies from the repositories. After running this, check your .m2 repository again to see if the missing JARs are now present.

3. Check for Dependency Conflicts or Exclusions

Sometimes, Maven might exclude transitive dependencies (the JARs that your direct dependencies rely on) due to version conflicts. To see exactly what's going on with your dependencies, run:

mvn dependency:tree

Look through the output to see if any of the missing JARs are marked as excluded. If you find one, you can manually add it to your pom.xml to ensure it's downloaded. For example, if saaj-impl is missing:

<dependency>
    <groupId>com.sun.xml.messaging.saaj</groupId>
    <artifactId>saaj-impl</artifactId>
    <version>1.3.3</version>
</dependency>

4. Temporary Fix: Skip Jar Scanning in Embedded Tomcat

If you're still having trouble downloading some of the very old JARs, you can tell Tomcat to skip scanning them to suppress the warnings. Add this code to your embedded Tomcat startup logic:

// After creating your Tomcat context
StandardJarScanner jarScanner = (StandardJarScanner) context.getJarScanner();
// Skip scanning specific problematic JARs
jarScanner.setSkipJars("saaj-impl.jar,jsr173_1.0_api.jar,activation.jar,jaxb-impl.jar");
// Or disable manifest scanning entirely (less targeted but effective)
jarScanner.setScanManifest(false);

Note: This is a band-aid—you should still try to fix the dependency issue to avoid runtime errors later.

Version 2.1.7 of jaxws-rt is extremely old (released in 2008!), and many of its dependencies are no longer actively maintained or hosted in standard repositories. Upgrading to a newer, supported version (like 2.3.5) will make it much easier for Maven to find all required JARs, and it will also give you bug fixes and security updates:

<dependency>
    <groupId>com.sun.xml.ws</groupId>
    <artifactId>jaxws-rt</artifactId>
    <version>2.3.5</version>
</dependency>

Run mvn clean install -U again after updating the version, and you should see all necessary dependencies download successfully.


内容的提问来源于stack exchange,提问作者Gabriel

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.27 07:28:43