English 中文(简体)
Javaassist and Webstart
原标题:Javaassist and Webstart

This looks like an old problem that is resolved, but unfortunately I couldn t find a good reference. I have a Java application using Javaassist. It was working fine until I upgraded it to a webstart application. Now Javaassist gives me a classNotFoundException. The class is definitely in class path though.

I found this related post https://community.jboss.org/message/302408 which is kind of old and I couldn t decode it. Can someone gime me a hand here?

感谢

这里是法典:

 ctClasses = new HashMap<String, CtClass>();
    classPool = ClassPool.getDefault();

    try {
        ctEntity = classPool.get("org.myclass");
    } catch (NotFoundException e) {
        logger.error("Could not find entity class, this should not happen");
        throw new RuntimeException("Could not find Entity class",e);
    }

没有任何障碍。

 java.lang.RuntimeException: Could not find Entity class
    at ca.cbc.panacea.metadata.JavassistClassGeneratorImpl.<init>(JavassistClassGeneratorImpl.java:32)
    at ca.cbc.panacea.metadata.ClassGeneratorFactory.getDefaultClassGenerator(ClassGeneratorFactory.java:12)
    at ca.cbc.panacea.metadata.ClassCreator.<init>(ClassCreator.java:30)
    at ca.cbc.panacea.Panacea.digestMappingFile(Panacea.java:75)
    at ca.cbc.panacea.console.PanaceaConsole.validateMappingFile(PanaceaConsole.java:46)
    at ca.cbc.panacea.console.PanaceaConsoleUI.actionPerformed(PanaceaConsoleUI.java:132)
    at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2028)
    at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2351)
    at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387)
    at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242)
    at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:236)
    at java.awt.Component.processMouseEvent(Component.java:6373)
    at javax.swing.JComponent.processMouseEvent(JComponent.java:3267)
    at java.awt.Component.processEvent(Component.java:6138)
    at java.awt.Container.processEvent(Container.java:2085)
    at java.awt.Component.dispatchEventImpl(Component.java:4735)
    at java.awt.Container.dispatchEventImpl(Container.java:2143)
    at java.awt.Component.dispatchEvent(Component.java:4565)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4621)
    at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4282)
    at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4212)
    at java.awt.Container.dispatchEventImpl(Container.java:2129)
    at java.awt.Window.dispatchEventImpl(Window.java:2478)
    at java.awt.Component.dispatchEvent(Component.java:4565)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:679)
    at java.awt.EventQueue.access$000(EventQueue.java:85)
    at java.awt.EventQueue$1.run(EventQueue.java:638)
    at java.awt.EventQueue$1.run(EventQueue.java:636)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)
    at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:98)
    at java.awt.EventQueue$2.run(EventQueue.java:652)
    at java.awt.EventQueue$2.run(EventQueue.java:650)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:649)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:296)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:211)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:201)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:196)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:188)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
     Caused by: javassist.NotFoundException: ca.cbc.panacea.metadata.Entity
    at javassist.ClassPool.get(ClassPool.java:436)
    at ca.cbc.panacea.metadata.JavassistClassGeneratorImpl.<init>       (JavassistClassGeneratorImpl.java:29)

问题实际上属于洛纳德语。 JNLP使用比java指挥线不同的班轮。 问题在于如何调和JNLP班装货员与Javasist。

最佳回答

钥匙是建立<条码>ClassPool,以看到您申请的班级装载器。 可以通过将班轮加到班轮来做到这一点:

ctClasses = new HashMap<String, CtClass>();
classPool = ClassPool.getDefault();

//Add the classloader of your application s classes so Javassist can find them
ClassLoader loader = org.MyClass.class.getClassLoader();
pool.appendClassPath(new LoaderClassPath(loader));

try {
    ctEntity = classPool.get("org.MyClass");
} catch (NotFoundException e) {
    logger.error("Could not find entity class, this should not happen");
    throw new RuntimeException("Could not find Entity class",e);
}

You need to do customize the classpath of the class pool for any application that does not load its classes from the system classloader, such as web-start applications, Eclipse plugins and applications that run under a Java EE container.

http://www.csg.is.titech.ac.jp/~chiba/javassist/tutorial/tutorial.html“rel=“nofollow”>Javassist tutorial

问题回答

暂无回答




相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签