这可能与类路径问题有关,但我现在还不确定,因为我在某些机器上没有出现此错误.
堆栈顶部的错误是SAX2 driver class org.apache.crimson.parser.XMLReaderImpl not found.为什么我只在某些环境中获得此错误,而不是其他环境?我该如何进一步调查和/或解决这个问题?
环境:
POM中的版本:
CLASSPATH将"/ Users/smcho/Desktop/clojure"作为其路径之一,并且此目录具有文件hello.clj.
运行clojure并运行(require'hello)会显示此错误消息.
java.io.FileNotFoundException: Could not locate hello__init.class or hello.clj on classpath: (NO_SOURCE_FILE:0)
当我将目录更改为"/Users/.../clojure",并运行相同的(require'hello)时,没有问题.的.在CLASSPATH上.
运行
java -cp /Users/smcho/bin/jar/clojure.jar:/Users/smcho/Desktop/clojure clojure.lang.Repl
也有效.
为什么clojure无法在CLASSPATH上找到源代码?
我正在尝试从open jdk更改一些类,所以我创建了与open jdk类相同的包结构,并且我正在使用netbeans更改类.当我正在构建项目时,如果覆盖的类中出现错误,我会收到错误.如果成功构建我的项目,似乎应用程序不会考虑来自我的类的更改,而是使用开放的jdk类.知道如何使用我的课程而不是openjdk的课程?
例:
如果我在我的项目中创建类sun.net.www.protocol.https.HttpsURLConnectionImpl并在其中进行一些更改,我构建项目,但是当我运行应用程序时,我的更改不会出现,就像openjdk中的原始类一样使用,而不是我的班级.
我定义了一个shared_src在Eclipse中调用的类路径变量:
Window->Preferences->Java->Build Path->Classpath Variables
变量指向文件夹(C:\some_source).现在,我尝试使用此变量链接该源文件夹.
在项目属性中,我去:
Java Build Path -> Source -> Link Source然后单击Variables按钮.
"选择路径变量"弹出窗口中显示的变量列表不包括shared_src我最初定义的变量.
我的问题是,该shared_src变量是否可用于链接源文件夹,如果可以,我如何更改我的Eclipse设置以便能够使用该变量?
代码(编译):
for (Method m : ImmutableList.class.getMethods()) {
System.out.println(m);
}
ImmutableList.copyOf(Arrays.asList(new PlayerLevel[0]));
Run Code Online (Sandbox Code Playgroud)
输出(注释和缩写):
public final void com.google.common.collect.ImmutableList.add(int,java.lang.Object)
----> public static com.google.common.collect.ImmutableList com.google.common.collect.ImmutableList.copyOf(java.lang.Iterable)
public static com.google.common.collect.ImmutableList com.google.common.collect.ImmutableList.copyOf(java.util.Iterator)
(lots of other methods)
java.lang.NoSuchMethodError: com.google.common.collect.ImmutableList.copyOf(Ljava/util/Collection;)Lcom/google/common/collect/ImmutableList;
Run Code Online (Sandbox Code Playgroud)
咦?
(如果日志不够清楚,我得到一个错误,说这ImmutableList.copyOf(List)不是一个方法,但通过循环遍历所有方法,我看到有一个copyOf(Iterable),和List implements Iterable.)
我src/main/resources在我的JSF项目中放了一个属性文件.
我该如何处理它?我知道EL在辅助bean中不起作用.
注意:该文件位于src/main/resources- NOT src/main/webapps/resources,因此以下内容不起作用:
FacesContext context = FacesContext.getCurrentInstance();
File value = context.getApplication().evaluateExpressionGet(context, "#{resource['resources:email.properties']}", File.class);
Run Code Online (Sandbox Code Playgroud) 刚刚有一个关于我遇到的奇怪的运行时错误的问题.我正在使用JSON服务器,当外部源提示时,它会响应JSON对象.但是,截至目前,我只是尝试在发送之前启动并运行JSON对象.我的代码编译时没有指定任何类路径,但是当涉及到运行时,它会抛出一个NoClassDefFoundError如下所示:
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/lang/exception/NestableRuntimeException
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)
at java.lang.ClassLoader.defineClass(ClassLoader.java:615)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
at ExampleServer.sendData(ExampleServer.java:76)
at ExampleServer.runServer(ExampleServer.java:30)
at ExampleServer.main(ExampleServer.java:15)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.lang.exception.NestableRuntimeException
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
... 15 more
Run Code Online (Sandbox Code Playgroud)
我的代码如下:
import java.io.*;
import java.net.ServerSocket;
import java.net.Socket;
import java.lang.*;
import net.sf.json.*;
public class ExampleServer{
private DataOutputStream output;
private DataInputStream …Run Code Online (Sandbox Code Playgroud) 我想加载xml文件,其中包含Spring Maven项目中几个模块的一些错误定义.我想加载然后将文件传递给JAXB unmasheller.
这就是我到目前为止所做的
String path = "classpath*:/**/definitions/error-definition.xml";
ClassPathResource resource = new ClassPathResource(path);
unmarshaller.unmarshall(resource);
Run Code Online (Sandbox Code Playgroud)
我的资源文件位于以下位置
src/main/resource/module1/definitions/error-definition.xml
src/main/resource/module2/definitions/error-definition.xml
Run Code Online (Sandbox Code Playgroud)
这给了我以下错误
java.io.FileNotFoundException: class path resource [classpath*:/**/definitions/error-definition.xml] cannot be resolved to URL because it does not exist
Run Code Online (Sandbox Code Playgroud)
但是当我改变路径如下
String path = "/module1/definitions/error-definition.xml";
Run Code Online (Sandbox Code Playgroud)
有用
以下是我试过的另一张外卡,没有运气
String paths = "classpath:/**/definitions/error-definition.xml";
String paths = "classpath*:error-definition.xml";
String paths = "classpath*:*.xml";
Run Code Online (Sandbox Code Playgroud)
我想要做的是使用通配符从下面的任何文件夹中获取xml文件 src/main/resource
我之前提到过几个SO答案,但仍然无法弄清楚我做错了什么.
I have a CI server dumping several application jars and their various dependencies in a single folder. I'm trying to then run a jmeter test with all the jars in jmeter's classpath.
I can set jmeter's user.classpath property to a (semi-)colon separated list of individual jars, but using a wild card doesn't seem to be supported. Is there a way I can add the entire folder worth of jars to jmeter's classpath?
我正在使用Java代理和Javassist为一些JDK类添加一些日志记录.本质上,当系统加载一些TLS类时,Javassist将为它们添加一些额外的字节码,以帮助我调试一些连接问题.
这是问题,因为这个类包含在代理jar中:
package com.something.myagent;
public class MyAgentPrinter {
public static final void sayHello() {
System.out.println("Hello!");
}
}
Run Code Online (Sandbox Code Playgroud)
在我的代理的转换方法中,假设我试图使用javassist调用该类:
// this is only called for sun.security.ssl.Handshaker
ClassPool cp = getClassPool(classfileBuffer, className);
CtClass cc = cp.get(className);
CtMethod declaredMethod = cc.getDeclaredMethod("calculateKeys");
declaredMethod.insertAfter("com.something.myagent.MyAgentPrinter.sayHello();");
cc.freeze();
return cc.toBytecode();
Run Code Online (Sandbox Code Playgroud)
你认为这会有效,但我得到了这个:
java.lang.NoClassDefFoundError: com/something/myagent/MyAgentPrinter
at sun.security.ssl.Handshaker.printLogLine(Handshaker.java)
at sun.security.ssl.Handshaker.calculateKeys(Handshaker.java:1160)
at sun.security.ssl.ServerHandshaker.processMessage(ServerHandshaker.java:292)
Run Code Online (Sandbox Code Playgroud)
有没有办法将该类[ MyAgentPrinter] 添加到应用程序的类路径?