我使用 Swarm 2017.3.X 和 2017.5.0。当我在新包中添加新类时,运行时出现由 java.lang.ClassNotFoundException 引起的 NoClassDefFoundError 。为什么?
org.jboss.resteasy.spi.UnhandledException: java.lang.NoClassDefFoundError
...
Caused by: java.lang.NoClassDefFoundError: com/example/myapp/newpackage/NewClass
at com.example.myapp.MyBean.getSomething(MyBean.java:51)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.__invoke(DelegatingMethodAccessorImpl.java:43)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:139)
at org.jboss.resteasy.core.ResourceMethodInvoker.invokeOnTarget(ResourceMethodInvoker.java:295)
at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:249)
at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:236)
at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:402)
... 45 more
Caused by: java.lang.ClassNotFoundException: com.example.myapp.newpackage.NewClass from [Module "deployment.198f19d8-46c4-4bf5-96fd-101dc0f57abd.war:main" from Service Module Loader]
at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:198)
at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:363)
at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:351)
at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:93)
... 57 more
Swarm 会在com.example.myapp(Main.java 所在的位置)中找到所有 Java 类,但不会找到com.example.myapp.newpackage(NewClass.java 所在的位置)中的类。