classpath

Java class.getResourceAsStream() returns incorrect byte

吃可爱长大的小学妹 提交于 2019-12-01 20:55:42
I have just run into a very strange problem with getResourceAsStream(). In my prod project JUnit test I read test data using getResourceAsStream(), I found that getResourceAsStream() sometimes substitutes some bytes: byte[] fileBytes = FileUtils.readFileToByteArray(new File( "resources/test/parser/test-short-enc.xml")); printBytes(fileBytes); byte[] classPathBytes = IOUtils.toByteArray(ParserTest.class .getResourceAsStream("/test/parser/test-short-enc.xml")) printBytes(classPathBytes); In this project output looks like this: D0 9A D1 80 D0 B8 D0 BC D0 B8 D0 BD D0 B0 D0 BB D0 B8 D1 81 D1 82 D0

Is it necessary/important to set a classpath in the RMI registry?

两盒软妹~` 提交于 2019-12-01 20:54:59
Is it necessary or important to set a class path in the registry for RMI to work correctly? Contrary to @Rahul's baseless assertion, it is indeed necessary to set a CLASSPATH for the RMI Registry, unless: You are starting the Registry from a directory which is also the head of a package structure of .class files. You are using the codebase feature, or You are starting the Registry in the same JVM as your RMI remote obects, via LocateRegistry.createRegistry(). If you don't do one of these four things, you will get a ServerException wrapping a ClassNotFoundException when you bind your remote

Why do I get a NullPointerException when initializing Spring

吃可爱长大的小学妹 提交于 2019-12-01 20:40:29
I've got a problem running a batch job on my server, whereas it runs fine from Eclipse on my development workstation. I've got my Spring environment set up using Roo, made an entity, and make a batch that does some work, and test it well on my develompent box. I initialize my context and do the work, but when I run my batch on the server, the context isn't initialized properly. Here's the code: public class TestBatch { private static ApplicationContext context; @SuppressWarnings("unchecked") public static void main(final String[] args) { context = new ClassPathXmlApplicationContext("/META-INF

Clojure's :require and Instaparse

北城余情 提交于 2019-12-01 20:21:14
I am trying to use instaparse lib for my clojure project. I use leiningen 2.0 and clojure 1.5.1 in my project dependencies. I add instaparse to my project dependencies as follow: (defproject bachelor "0.1.0-SNAPSHOT" :description "FIXME: write description" :url "http://example.com/FIXME" :license {:name "Eclipse Public License" :url "http://www.eclipse.org/legal/epl-v10.html"} :dependencies [[org.clojure/clojure "1.5.1"] [org.clojure/clojure-contrib "1.2.0"] [instaparse "1.1.0"]]) And that is my source where i'm trying to require that lib: (ns bachelor.data (:require [clojure.string :as str])

'Batik not in classpath' error when running servlet

折月煮酒 提交于 2019-12-01 19:30:34
I'm writing an extension of the FopServlet.java included in Apache FOP. My platform is Linux CentOS 5.7-64bit, with Tomcat 5.5. The servlet 'works', but I'm unable to process SVG files. The error I get when Tomcat runs the servlet is 'Batik not in classpath'. But in 'webapps/fop/WEB-INF/lib' there is 'batik-all-1.7.jar' and all the other jars. I'm not a java expert, so I'm unable to focus on the problem; googling around, maybe there is a missing jar, but which one? AVVERTENZA: Batik not in class path java.lang.NoClassDefFoundError: org/w3c/dom/svg/SVGDocument at java.lang.ClassLoader

Why do I get a NullPointerException when initializing Spring

[亡魂溺海] 提交于 2019-12-01 19:00:09
问题 I've got a problem running a batch job on my server, whereas it runs fine from Eclipse on my development workstation. I've got my Spring environment set up using Roo, made an entity, and make a batch that does some work, and test it well on my develompent box. I initialize my context and do the work, but when I run my batch on the server, the context isn't initialized properly. Here's the code: public class TestBatch { private static ApplicationContext context; @SuppressWarnings("unchecked")

Java - Can't import com.package.*(wildcard)

亡梦爱人 提交于 2019-12-01 18:41:55
This may be a simple issue, but Google has returned nothing. I have read Help with packages in java - import does not work I still don't understand why a direct import will work but wildcard will not. [EDIT] By class package I mean a package of classes. I am still new to Java so I do not know the semantics [EDIT] I have a class package: com.company.functions , when I try to import com.company.* I receive the following error. java: package com.company does not exist If I import com.company.function explicitly then I have no issues. So I suppose that I have a solution but for the sake of

“Could not find the main class”

倾然丶 夕夏残阳落幕 提交于 2019-12-01 17:56:13
I'm trying to run a sample Java application from the command promopt but I'm getting the following error: Exception in thread "main" java.lang.NoClassDefFoundError: com/badlogic/gdx/helloworld/HelloWorldDesktop Caused by: java.lang.ClassNotFoundException: com.badlogic.gdx.helloworld.HelloWorldDesktop 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

How do I place jars in jetty/lib on the jetty classpath?

故事扮演 提交于 2019-12-01 17:30:44
I have Jetty jetty-9.2.3.v20140905 My understanding was that jars in lib/jar or lib/ext were automatically on the classpath, but this may have been old behavior from jetty 8. I'm trying to deploy a webapp with websockets. With my deployed WAR file in the webapps directory, jetty keeps complaining that it cannot find jars sitting right there in the jetty/lib directory (jetty-http, jetty-io, jetty-security, jetty-server, jetty-servlet, jetty-util are the ones my webapp needs that it cannot find) jars placed in lib/ext are also not picked up when I do a --module-ext How can I resolve this? To

How can I discover resources in a Java jar with a wildcard name?

感情迁移 提交于 2019-12-01 16:19:44
I want to discover all xml files that my ClassLoader is aware of using a wildcard pattern. Is there any way to do this? It requires a little trickery, but here's an relevant blog entry . You first figure out the URLs of the jars, then open the jar and scan its contents. I think you would discover the URLs of all jars by looking for `/META-INF/MANIFEST.MF'. Directories would be another matter. A Spring ApplicationContext can do this trivially: ApplicationContext context = new ClassPathXmlApplicationContext("applicationConext.xml"); Resource[] xmlResources = context.getResources("classpath:/**/*