Ant javac任务无法访问类。

3
运行我的ant构建文件时,我收到以下消息。
-build-middleware-securitymanager:
     [echo] -> httpbean.securitymanager
     [echo] -> httpbean.securitymanager.config
     [echo] -> httpbean.securitymanager.context
     [echo] -> httpbean.securitymanager.login
     [echo] -> C:\eclipse\current\RunImported
    [javac] Compiling 4 source files to C:\eclipse\current\new\classes
    [javac] C:\eclipse\current\httpbean\securitymanager\login\integration\bellsouth\LoginUserWS.java:192: cannot access ServiceException
    [javac] file ServiceException.class not found
    [javac]             final LoginInfo info = _login.login(user, clrpasswd, _token);
    [javac]                                                ^

检查了我的构建文件后,它指向以下部分。
    <echo message="-> httpbean.securitymanager.login" />
    <echo message="-> ${run-imported}" />
    <javac  includeantruntime="${ant8compat}" debug="${debug}" srcdir="${src}" destdir="${classes}" includes="httpbean/securitymanager/login/**/*.java" encoding="UTF-8">
        <exclude name="**/*_UnitTest.java" />
        <classpath>
            <path refid="Axis" />
            <path refid="commons-logging" />
            <path refid="shark-1.1" />
            <path refid="log4j" />
        </classpath>
    </javac>

ServiceException类是javax.xml.rpc包的一部分,位于shark-1.1目录中的jaxrpc.jar中,shark-1.1的引用为

  <path id="shark-1.1">
    <fileset dir="${run-imported}/shark-1.1">
      <include name="*.jar" />
    </fileset>
  </path>

我检查过${run-imported}/shark-1.1目录,可以清楚地看到正确的jar文件就在那里!

我尝试在javac任务的类路径部分添加一个pathelement标记,直接指向缺失类所在的jar文件,但这也不起作用。

编辑:

导入是

import javax.xml.rpc.ServiceException;

以下是jar文件的目录结构,ServiceException部分被标识出来。

JAR directory structure


不,它就在下面 - PDStat
3
以debug模式运行ant(-v),这将打印javac的类路径,您可以验证所有jar包是否正确放置。 - oers
1
@oers 很有用,谢谢。运行后确实显示了正确的jar包在类路径上,现在我陷入了困境! - PDStat
你确定异常就在那个jar包里吗?根据findjar.com,匹配的jar包是jaxrpc-api.jar。 - oers
一切看起来都很好,应该完全可以工作。没有任何问题了 :D - oers
显示剩余8条评论
1个回答

0
您确定ServiceException在默认包中吗?这很不可能。 应该是类似于“com.acme.bfo.cyberdyne.ServiceException”。 使用

jar tf shark-1.1.jar | find "ServiceException"

查看该包。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接