构建build.xml文件时遇到了一些问题。我知道标签javac的类路径存在一些问题,但我不知道如何解决它。
[java] Exception in thread "main" java.lang.NoClassDefFoundError: javax/ws/rs/core/Response
[java] at java.lang.Class.getDeclaredMethods0(Native Method)
[java] at java.lang.Class.privateGetDeclaredMethods(Class.java:2521)
[java] at java.lang.Class.getMethod0(Class.java:2764)
[java] at java.lang.Class.getMethod(Class.java:1653)
[java] at sun.launcher.LauncherHelper.getMainMethod(LauncherHelper.java:494)
[java] at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:486)
[java] Caused by: java.lang.ClassNotFoundException: javax.ws.rs.core.Response
[java] at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
[java] at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
[java] at java.security.AccessController.doPrivileged(Native Method)
[java] at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
[java] at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
[java] at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
[java] at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
我的项目库位于" / WebContent / WEB-INF / lib /",这是我的文件" build.xml":
<property name="src" value="\${basedir}/src" />
<property name="build" value="classes" />
<property name="dist" value="dist" />
<property name="package" value="*" />
<target name="init">
<echo> Criando os diretorio classes, doc e dist.</echo>
<mkdir dir="..\${build}" />
<mkdir dir="..\${dist}" />
</target>
<target name="compile" depends="init" >
<echo> Compilando o projeto.</echo>
<javac srcdir="\${src}" destdir="..\${build}" includeantruntime="false">
<classpath>
<fileset dir="\${basedir}/WebContent/WEB-INF/lib/">
<include name="jersey-server-1.4.jar" />
</fileset>
</classpath>
</javac>
</target>
<target name="dist" depends="compile">
<echo> Gerando o .jar do projeto.</echo>
<jar jarfile="..\${dist}/InfosoundWebApp.jar" basedir="..\${build}">
<!-- Tornando o jar executável-->
<manifest>
<attribute name="Main-Class" value="com.informatec.restfull.ServerRestfull"/>
</manifest>
</jar>
</target>
<target name="all" depends="dist">
<echo> Executa o projeto.</echo>
<java jar="..\${dist}/InfosoundWebApp.jar" fork="true" />
</target>
<target name="clear">
<delete dir="..\${build}" />
<delete dir="..\${dist}" />
</target>
如果有人可以帮助我,我将不胜感激。
答案 0 :(得分:0)
看起来您正在尝试从JavaSE运行JavaEE应用程序。 类javax / ws / rs / core / Response仅在JavaEE(在您的Web服务器上)下可用。 你的build.xml目标=&#34;所有&#34;尝试在JavaSE下执行您的webapp。摆脱它。使目标=&#34; dist&#34;默认目标,然后将您的jar上传到您的网络服务器(Tomat等)。