classloader

URLClassLoader.getResources(“”) (empty resource name) not giving roots of jars

 ̄綄美尐妖づ 提交于 2019-12-22 05:45:31
问题 Consider a URLClassLoader parameterized with a collection of URL s which is a mix of expanded directories and jar files. For example: URL[] urls = new URL[] { new URL("file:/D:/work/temp/jars/spring-security-core-3.2.0.RELEASE.jar"), new URL("file:/D:/work/temp/jars/spring-security-config-3.2.0.RELEASE.jar"), ... new URL("file:/D:/work/temp/domain/bin/"), new URL("file:/D:/work/temp/web/bin/"), ... } URLClassLoader cl = new URLClassLoader(urls); The classloader correctly handles getResources(

Scala - Dynamic class loading - class A can not be cast to class A

强颜欢笑 提交于 2019-12-22 05:27:58
问题 I have a simple jar file containing class A : public class A {} Then I load it in runtime: var classLoader = new URLClassLoader(Array(my_jar_file.toURI.toURL)) var clazz = classLoader.loadClass("A") It is ok, it can load the class A . This command is also ok: clazz.newInstance But when I cast it to A : clazz.newInstance.asInstanceOf[A] I got this error: java.lang.ClassCastException: A cannot be cast to A Could you please help me? 回答1: Your code implies that you have "A" available in one

Use Absolute path for ClassLoader getResourceAsStream()

谁说我不能喝 提交于 2019-12-22 04:05:25
问题 I am trying to use ClassLoader getResourceAsStream() My Direcory structure is like below: Project1 -src -main -java -webapp -WEB-INF -MYLOC -someprops.properties For classloader.getResourceAsStream("MYLOC/someprops.properties") works fine. But now I have to move the properties file outside of the .war, like in C:\someprops.properties But, classloader.getResourceAsStream("C:\someprops.properties") does not work. Can it not use an absolute path? 回答1: If you have a native file path then you don

Tomcat Unable to create initial connections of pool

眉间皱痕 提交于 2019-12-22 00:31:42
问题 So I have a web app which I deploy / redeploy on a remote Tomcat server instance. Sometimes, the deploy and even redeploy (by redeploy I mean moving the ROOT.war through SFTP and leave Tomcat to actually redeploy it) work as expected, no issues whatsoever with the database connection. Unfortunately, other times, after redeploy, it just refuses to connect to the database, as apparently it doesn't recognize the MySQL driver anymore. The MySQL connector lib is inside Tomcat's lib folder, not

Tomcat6 ignores web-inf/lib

梦想与她 提交于 2019-12-21 21:44:14
问题 Brief: Tomcat6 can't recognize my ojdbc14.jar in WebRoot/WEB-INF/lib. I suppose I don't need to configure anything, just putting the .jar file in there and it should work. Details: I've created a web application and put ojdbc14.jar in WEB-INF/lib folder. When I start Tomcat6 and access an index.jsp page which creates an object that initiates a connection to my oracle database , an error occurs saying "Cannot load JDBC driver class 'oracle.jdbc.OracleDriver'". Apparently Tomcat6 can't

Jboss 4.2 Class Loading

你。 提交于 2019-12-21 19:45:33
问题 I have a jar in server/default/lib which contains Foo.class , Bar.class and the same class is there in my application/WEB-INF/classes which is deployed in server/default/deploy . and Example.class is using the Foo.class instance and Bar.class instance Now the situation is that Example.class shoud use the Foo.class in my application and Bar.class in default/lib jar file. i.e. my application should use the classes in the application clases folder if not found in classes folder then it should

Autowiring classes from external jar with Spring

﹥>﹥吖頭↗ 提交于 2019-12-21 09:27:12
问题 I'm trying to build a standalone application (not running inside an application server) with Spring and I'm facing the following problem : My standalone application (spring enabled) is depending on another project (bundled as a jar) which contains a lot of services in com.application.service (Annotated with @Service ). There is no spring related configuration in the external project and the standalone application context is very simple, it only contains : <context:component-scan base-package=

scala classloaders confusion

旧城冷巷雨未停 提交于 2019-12-21 09:21:35
问题 Please consider the following test program (using scala 2.9.0.1) object test { def main(args:Array[String]) = { println(ClassLoader.getSystemClassLoader.getResource("toto")) println(this.getClass.getClassLoader.getResource("toto")) println(classOf[Object].getClassLoader) } } I compile it and run it with "-cp /tmp" containing a file "toto", and I get the following output: null file:/tmp/toto null => the system classloader does not contain the classpath => the Object class has no classloader!

SBT how to use classes from Build.sbt inside plugin Task execution

99封情书 提交于 2019-12-21 04:57:16
问题 Any classes defined in project/*.scala files are made available for use by SBT inside the build definition code. I would like those classes to be available during the execution of an SBT plugin task, but they do not appear to be available. Why is that, and how can I fix it? The specific problem I am trying to solve is adding custom rules for Scalastyle . The project does not currently support writing your own rules, but I thought I might be able to add a rule to the project/*.sbt files and

SBT how to use classes from Build.sbt inside plugin Task execution

不想你离开。 提交于 2019-12-21 04:57:08
问题 Any classes defined in project/*.scala files are made available for use by SBT inside the build definition code. I would like those classes to be available during the execution of an SBT plugin task, but they do not appear to be available. Why is that, and how can I fix it? The specific problem I am trying to solve is adding custom rules for Scalastyle . The project does not currently support writing your own rules, but I thought I might be able to add a rule to the project/*.sbt files and