classpath

Controlling the classpath in a servlet

怎甘沉沦 提交于 2019-11-27 14:51:11
My servlet application includes a number of library .jars, some of which contain embedded log4j.xml or log4j.properties files. I'd like to ensure that log4j finds my log4j.xml first! I've tried searching for some specification of the priorities of the various classpath elements in a servlet (e.g. does WEB-INF/classes always precede WEB-INF/lib?), or some way to configure or tweak the servlet's classloader so that a given resource directory appears early in the classpath. So far, I've drawn a blank. Any suggestions on ensuring that a servlet .war file loads the correct log4j.xml via the

URLClassLoader and accessibility of package-private methods

江枫思渺然 提交于 2019-11-27 14:42:16
I have a class Formula , located in package javaapplication4 , which I load with a URLClassLoader. However, when I call it from another class Test1 , located in the same package, I can't access its methods that have a default access modifier (I can access public methods). I get the following exception: java.lang.IllegalAccessException: Class javaapplication4.Test1 can not access a member of class javaapplication4.Formula with modifiers "" How can I access package-private methods of a class loaded at runtime from the same package? I suppose it is a problem with using a different class loader,

Weblogic 10.3.1.0 is using com.bea.core.apache.commons.net_1.0.0.0_1-4-1.jar… I want to use commons-net-2.0.jar from my code

≡放荡痞女 提交于 2019-11-27 14:28:06
Weblogic 10.3.1.0 is using com.bea.core.apache.commons.net_1.0.0.0_1-4-1.jar... I want to use commons-net-2.0.jar from my code. How can I force it to use the newer JAR in my code only? I want to use commons-net-2.0.jar from my code. WebLogic uses a parent class loader first strategy and you basically have two options to tweak this behavior: Use the prefer-web-inf-classes element in a weblogic.xml Web application deployment descriptor (that goes in WEB-INF next to the web.xml ) ~or~ Package your war insider an EAR and use WebLogic Filtering classloader that you configure in a weblogic

Java : loop on all the classes in the classpath [duplicate]

一曲冷凌霜 提交于 2019-11-27 14:24:09
This question already has an answer here: Can you find all classes in a package using reflection? 24 answers Is there a way to iterate over all the classes in the classpath ? I want to make some reflective checks on some classes implementing a certain interface, but I want to do it completely dynamically, without any input on which classes to check, just browsing the classpath. The Reflections library helps deal with this problem. As others have stated, it isn't fully possible in all class loading situations, but if all you have are jars and files, this will do it reliably. You can't do this

Is WEB-INF in the CLASSPATH?

你。 提交于 2019-11-27 12:59:58
Is the WEB-INF folder in the CLASSPATH of a Java Web application? Jack Leow I'm assuming you're referring to the /WEB-INF directory in the root of the web application folder structure. No, it's not in the classpath. /WEB-INF/classes is on the classpath though, and so are the JAR files in /WEB-INF/lib . Additionally files in WEB-INF are protected against being requested by the web-container, i.e. they are invisible to the outside world. 来源: https://stackoverflow.com/questions/793917/is-web-inf-in-the-classpath

adding classpath in linux

折月煮酒 提交于 2019-11-27 12:54:44
export CLASSPATH=.;../somejar.jar;../mysql-connector-java-5.1.6-bin.jar java -Xmx500m folder.subfolder../dit1/some.xml cd .. is the above statement for setting the classpath to already existing classpath in linux is correct or not flybywire I don't like setting CLASSPATH. CLASSPATH is a global variable and as such it is evil: If you modify it in one script, suddenly some java programs will stop working. If you put there the libraries for all the things which you run, and it gets cluttered. You get conflicts if two different applications use different versions of the same library. There is no

Java project: should .classpath .project file be committed into repository? [duplicate]

爷,独闯天下 提交于 2019-11-27 12:39:50
问题 This question already has an answer here: .classpath and .project - check into version control or not? 7 answers Should I check in my .project and .classpath files? My friend told me that I should only check in .java files and the build.xml to guarantee portability. He said ".classpath will cause you much less portability on different environment. .project is entirely your local eclipse setting" I agree with him, but partially. -- Not checking in .project file will make my development less

how to make jni.h be found?

ぃ、小莉子 提交于 2019-11-27 12:32:45
In Ubuntu 12.04, I have jdk7 from sun/oracle installed. When locate jni.h , it prints multiple locations /usr/lib/jvm/java-6-openjdk-amd64/include/jni.h /usr/lib/jvm/jdk1.7.0_07/include/jni.h ... In the header file generated by JDK, there is include <jni.h> , and currently it complains fatal error: jni.h: No such file or directory. In my Makefile , there is no specification of locations where jni.h is. And I am asking if possible to configure certain system parameter to make path of jni.h (say, /usr/lib/jvm/jdk1.7.0_07/include/jni.h ) to be known when being compiled. You have to tell your

How do I auto load a database jar in Groovy without using the -cp switch?

不羁的心 提交于 2019-11-27 12:29:28
I want to simplify my execution of a Groovy script that makes calls to an Oracle database. How do I add the ojdbc jar to the default classpath so that I can run: groovy RunScript.groovy instead of: groovy -cp ojdbc5.jar RunScript.groovy Summarized from Groovy Recipes , by Scott Davis, Automatically Including JARs in the ./groovy/lib Directory : Create .groovy/lib in your login directory Uncomment the following line in ${GROOVY_HOME}/conf/groovy-starter.conf load !{user.home}/.groovy/lib/*.jar Copy the jars you want included to .groovy/lib It appears that for Groovy 1.5 or later you get this by

Caused By: java.lang.NoClassDefFoundError: org/apache/log4j/Logger

那年仲夏 提交于 2019-11-27 12:19:44
I've got an interesting problem in which the org.apache.log4j.Logger class is not found during runtime. I'm trying to get authorized and that is where it's failing: OAuthAuthorizer oauthAuthorizer = new OAuthAuthorizer(OAUTH_CONSUMER_KEY, OAUTH_CONSUMER_SECRET, SAML_PROVIDER_ID, userId); I'm using JDeveloper 11.1.1.6. Here is what I know: I've looked in my UI.war/WEB-INF/lib directory and I see the log4j-1.2.17.jar there. The class complaining about it is org.opensaml.xml.XMLConfigurator Caused by: java.lang.NoClassDefFoundError: org/apache/log4j/Logger at org.opensaml.xml.XMLConfigurator.