classloader

Rails class loading skips namespaced class when another class of same name in root namespace is loaded

我们两清 提交于 2019-11-30 20:42:43
I have two namespaces, each with its own controller and presenter classes: Member::DocumentsController Member::DocumentPresenter Guest::DocumentsController Guest::DocumentPresenter Both presenters inherit from ::DocumentPresenter . Controllers access their respective presenters without namespace specified, e.g.: class Guest::DocumentsController < ActionController::Base def show DocumentPresenter.new(find_document) end end This usually calls presenter within same namespace. However sometimes in development environment I see base ::DocumentPresenter is being used. I suspect the cause is that

Loading a JAR dynamically from memory

女生的网名这么多〃 提交于 2019-11-30 20:29:23
I want to load a JAR dynamically, straight for memory. Say, I have a buffer that contains a JAR, and I want to load all the classes inside the JAR, or at least list all of the files that exist inside the JAR. (classes, images, etc...). What do I do if the first class that I load depends on the second class, for example? Does java know how to handle this? Or I have take care of this by myself? Since you said “at least list all of the files that exist inside the JAR”, let’s begin with that rather easy task. Suppose, you have your JarFile in a byte array, byte[] buffer : try(JarInputStream is=new

How to load unknown class from downloaded jar file during runtime?

佐手、 提交于 2019-11-30 20:22:44
问题 I'm building a client server application. During runtime the client application loads a jar file from the server application and stores it. I run both the client and the server application as jar files. I now want to load the class contained in this downloaded jar file. For example I have an interface A and a class B implementing A. The client application does not know about the class B, its name or even its existence. After the start of the client application the client applications

A dozer map exception related to Spring boot devtools

瘦欲@ 提交于 2019-11-30 20:18:14
I have encountered a very strange exception, and I don't know how to find the reason. Business background: Add goods and meantime it's price list, a goods have 5 price for diff level user. In controller, first convert goodForm to goods by using dozer, then call goodsService to save goods. In goodsService after saving goods, traversal goods price list and populate goodsId to goods price, GoodsForm: @Mapping("priceList") List<GoodsPriceForm> goodsPriceFormList; Goods: List<GoodsPrice> priceList; Controller: Goods goods = BeanMapper.map(goodsForm, Goods.class); goodsService.saveGoods(adminId,

Dynamically loading Jar and instanciate an Object of a loaded Class

本小妞迷上赌 提交于 2019-11-30 19:38:36
问题 I try to load dynamically a jar into my Java project. Here's the class loader's code : public class ClassLoad { public static void main(String[] args) { String filePath = new String("C:/Users/Mehdi/Desktop/JavaClassLoader/jarred.jar"); URL myJarFile = null; try { myJarFile = new URL("file://"+filePath); } catch (MalformedURLException e1) { System.out.println("1"); e1.printStackTrace(); } URLClassLoader cl = URLClassLoader.newInstance(new URL[]{myJarFile}); Class Jarred = null; try { Jarred =

Ensure spring bean loaded from non spring context

纵饮孤独 提交于 2019-11-30 19:22:40
I have spring application alongside (jersey 2.6 classes and ) servlets . I need to get Spring bean(s) from jersey/ non spring context, Similar question suggested to get context in a static wrapper of context public static ApplicationContext getContext() { return context; } How can I be sure the context is already loaded or not null? If I can't, how should I wait/check until it spring context is loaded? In case of calling from jersey context or calling bean from a simple HttpServlet code EDIT Jersey is working fine using jersey-spring3 dependency jar, so my question is only about Servlets out

Modify Executing Jar file

蹲街弑〆低调 提交于 2019-11-30 19:10:18
Hello Stack Overflow friends. I have a simple problem which i fear doesnt have a simple solution and i need advice as to how to proceed. I am developing a java application packaged as and executable JAR but it requires to modify some of its JAR file contents during execution. At this stage i hit a problem because some OS lock the file preventing writes to it. It is essential that the user sees an updated version of the jar file by the time the application exits allthough i can be pretty flexible as to how to achieve this. A clean and efficient solution is obviously prefereable but portability

ProviderImpl not found Jboss 5.1

余生颓废 提交于 2019-11-30 18:48:15
问题 I use jaxws 2.2.3 and Jboss 5.1 with JDK 6. When calling ws client, I get java.util.ServiceConfigurationError: javax.xml.ws.spi.Provider: Provider org.jboss.ws.core.jaxws.spi.ProviderImpl not found (see full stack trace below) When I remove libs jbossws-native-*.jar from jboss/lib/endorsed everthing works fine. But they must be there. I tried to tell jboss to use com.sun.xml.ws.spi.ProviderImpl: META-INF/services/javax.xml.ws.spi.Provider -Djavax.xml.ws.spi.Provider to read first my libs WEB

AspectJ: ClassLoading issue when trying to use external aop.xml file

老子叫甜甜 提交于 2019-11-30 18:19:03
问题 I m trying to externalize the configuration of aop.xml so I removed the aop.xml from META-INF and made it available in the server for manual configuration by sys admins. When I try to use an external aop.xml using -Dorg.aspectj.weaver.loadtime.configuration="file:D:\Workspace\tomcat7\shared\lib\aop.xml" I get java.lang.RuntimeException: Cannot register non aspect: aspectclass.... mainly because the aj casses are not loaded by AppClassLoader yet at that time. And the next time it tries to

Overriding single classes from rt.jar

喜欢而已 提交于 2019-11-30 18:01:05
问题 I'm looking for a neat way to override a class from the bootstrap class path, rt.jar . The reason is OpenJDK7 bug http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=7104625 The fix for this bug is a trivial (see linked mailing list post) change to sun.awt.X11.XComponentPeer . So I was wondering if there is an easy way to override just this one affected class on my classpath, without having to repack/rebuild rt.jar (so the fix isn't lost on the next automatic update of OpenJDK). Ideally, it