将GWT-RPC-Applicaton部署到JBoss AS 7.1.1时出现ClassNotFoundException

时间:2012-11-26 14:44:51

标签: gwt jboss gwt-rpc

我有一个maven base GWT-Application。

当我通过Maven编译,构建并部署到JBoss AS 7.1.1时,我的GWT-RPC-Service获得了ClassNotFoundException。在我包含我已部署并且我可以显示GWT-Widgets之前,所以GWT-Jars应该在那里......

My Maven-Dependencies看起来像这样:

<dependency>
  <groupId>com.google.gwt</groupId>
  <artifactId>gwt-dev</artifactId>
  <version>2.5.0</version>
  <scope>compile</scope>
</dependency>
<dependency>
  <groupId>com.google.gwt</groupId>
  <artifactId>gwt-user</artifactId>
  <version>2.5.0</version>
  <scope>compile</scope>
</dependency>
<dependency>
  <groupId>com.google.gwt</groupId>
  <artifactId>gwt-servlet</artifactId>
  <version>2.5.0</version>
  <scope>compile</scope>
</dependency>

我的EAR看起来像这样:

-myEar.ear
|  |
|  |- core.jar
|
|--|- gwt-ui.war
|  |
|  |-- gwt-ui
|  |   |--  gwt
|  |   |--  sc
|  |   |--  wgt-ui.nocache.js
|  |
|  |-- META-INF
|  |   | (is Empty)
|  |
|  |-- WEB-INF
|  |   |-- classes
|  |   |     |
|  |   |     |- mygwtProj.client
|  |   |     |   |- services
|  |   |     |   |   | - MyService.class
|  |   |     |   |   | - MyServiceAsync.class
|  |   |     |   |- dto
|  |   |     |   |   | - DTO.class
|  |   |     |
|  |   |     |- mygwtProj.server
|  |   |     |   |- MyServiceImpl.class
|  |   |-- deploy
|  |   |-- lib
|  |   |     | (all gwt-jars-files)
|  |   |-- beans.xml
|  |   |-- web.xml

为MyService:

import java.util.List;
import com.google.gwt.user.client.rpc.RemoteService;
import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
import mygwtProj.client.dto.DTO;

@RemoteServiceRelativePath("myService")
public interface ShopService extends RemoteService{
    List<DTO> getAircrafts();
}

MyServiceAsync中

import java.util.List;
import com.google.gwt.user.client.rpc.AsyncCallback;
import mygwtProj.client.dto.DTO;

@RemoteServiceRelativePath("myService")
public interface ShopService extends RemoteService{
    void getAircrafts(AsyncCallback<List<DTO>> callback); 
}

MyServiceImpl

import java.util.ArrayList;
import java.util.List;
import com.google.gwt.user.server.rpc.RemoteServiceServlet;
import mygwtProj.client.dto.DTO;
import mygwtProj.client.services.MyService;

public class MyServiceImpl extends RemoteServiceServlet implements MyService {
    private static final long serialVersionUID = 1L;

@Override
public List<DTO> getAircrafts() {

    List<DTO> list = new ArrayList<DTO>(1);
    list.add(new ShopItemDTO(1, "man", "typ", 1.0));
    return list;
}
}

堆栈跟踪:

15:28:24,684 WARN  [org.jboss.modules] (MSC service thread 1-6) Failed to define class mygwtProj.server.MyServiceImpl in Module "deployment.myEar.ear.gwt-UI.war:main" from Service Module Loader: java.lang.LinkageError: Failed to link mygwtProj/server/MyServiceImpl (Module "deployment.myEar.ear.gwt-UI.war:main" from Service Module Loader)
at org.jboss.modules.ModuleClassLoader.defineClass(ModuleClassLoader.java:396)
at org.jboss.modules.ModuleClassLoader.loadClassLocal(ModuleClassLoader.java:243)
at org.jboss.modules.ModuleClassLoader$1.loadClassLocal(ModuleClassLoader.java:73)
at org.jboss.modules.Module.loadModuleClass(Module.java:517)
at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:182)
at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:468)
at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:456)
at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:398)
at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:120)
at org.jboss.as.weld.WeldModuleResourceLoader.classForName(WeldModuleResourceLoader.java:68) [jboss-as-weld-7.1.1.Final.jar:7.1.1.Final]
at org.jboss.weld.bootstrap.BeanDeployer.loadClass(BeanDeployer.java:107) [weld-core-1.1.5.AS71.Final.jar:2012-10-12 10:00]
at org.jboss.weld.bootstrap.BeanDeployer.addClass(BeanDeployer.java:77) [weld-core-1.1.5.AS71.Final.jar:2012-10-12 10:00]
at org.jboss.weld.bootstrap.BeanDeployer.addClasses(BeanDeployer.java:135) [weld-core-1.1.5.AS71.Final.jar:2012-10-12 10:00]
at org.jboss.weld.bootstrap.BeanDeployment.createBeans(BeanDeployment.java:184) [weld-core-1.1.5.AS71.Final.jar:2012-10-12 10:00]
at org.jboss.weld.bootstrap.WeldBootstrap.deployBeans(WeldBootstrap.java:349) [weld-core-1.1.5.AS71.Final.jar:2012-10-12 10:00]
at org.jboss.as.weld.WeldContainer.start(WeldContainer.java:82) [jboss-as-weld-7.1.1.Final.jar:7.1.1.Final]
at org.jboss.as.weld.services.WeldService.start(WeldService.java:76) [jboss-as-weld-7.1.1.Final.jar:7.1.1.Final]
at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811)
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) [rt.jar:1.7.0_03]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) [rt.jar:1.7.0_03]
at java.lang.Thread.run(Thread.java:722) [rt.jar:1.7.0_03]
Caused by: java.lang.NoClassDefFoundError: myProj/client/services/MyService
at java.lang.ClassLoader.defineClass1(Native Method) [rt.jar:1.7.0_03]
at java.lang.ClassLoader.defineClass(ClassLoader.java:791) [rt.jar:1.7.0_03]
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) [rt.jar:1.7.0_03]
at org.jboss.modules.ModuleClassLoader.doDefineOrLoadClass(ModuleClassLoader.java:327)
at org.jboss.modules.ModuleClassLoader.defineClass(ModuleClassLoader.java:391)
... 21 more
Caused by: java.lang.ClassNotFoundException: myProj.client.services.MyService from [Module "deployment.myEar.ear.gwt-UI.war:main" from Service Module Loader]
at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:190)
at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:468)
at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:456)
at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:398)
at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:120)
... 26 more

15:28:24,700 INFO  [org.jboss.weld.ClassLoading] (MSC service thread 1-6) WELD-000119 Not generating any bean definitions from myProj.server.MyServiceImpl because of underlying class loading error
15:28:24,700 INFO  [org.jboss.weld.ClassLoading] (MSC service thread 1-6) catching: org.jboss.weld.resources.spi.ResourceLoadingException: java.lang.ClassNotFoundException: myProj.server.MyServiceImpl from [Module "deployment.myEar.ear.gwt-UI.war:main" from Service Module Loader]
at org.jboss.as.weld.WeldModuleResourceLoader.classForName(WeldModuleResourceLoader.java:74) [jboss-as-weld-7.1.1.Final.jar:7.1.1.Final]
at org.jboss.weld.bootstrap.BeanDeployer.loadClass(BeanDeployer.java:107) [weld-core-1.1.5.AS71.Final.jar:2012-10-12 10:00]
at org.jboss.weld.bootstrap.BeanDeployer.addClass(BeanDeployer.java:77) [weld-core-1.1.5.AS71.Final.jar:2012-10-12 10:00]
at org.jboss.weld.bootstrap.BeanDeployer.addClasses(BeanDeployer.java:135) [weld-core-1.1.5.AS71.Final.jar:2012-10-12 10:00]
at org.jboss.weld.bootstrap.BeanDeployment.createBeans(BeanDeployment.java:184) [weld-core-1.1.5.AS71.Final.jar:2012-10-12 10:00]
at org.jboss.weld.bootstrap.WeldBootstrap.deployBeans(WeldBootstrap.java:349) [weld-core-1.1.5.AS71.Final.jar:2012-10-12 10:00]
at org.jboss.as.weld.WeldContainer.start(WeldContainer.java:82) [jboss-as-weld-7.1.1.Final.jar:7.1.1.Final]
at org.jboss.as.weld.services.WeldService.start(WeldService.java:76) [jboss-as-weld-7.1.1.Final.jar:7.1.1.Final]
at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811)
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) [rt.jar:1.7.0_03]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) [rt.jar:1.7.0_03]
at java.lang.Thread.run(Thread.java:722) [rt.jar:1.7.0_03]
Caused by: java.lang.ClassNotFoundException: myProj.server.MyServiceImpl from [Module "deployment.myEar.ear.gwt-UI.war:main" from Service Module Loader]
at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:190)
at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:468)
at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:456)
at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:398)
at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:120)
at org.jboss.as.weld.WeldModuleResourceLoader.classForName(WeldModuleResourceLoader.java:68) [jboss-as-weld-7.1.1.Final.jar:7.1.1.Final]
... 12 more

任何人都有一个错误的线索?

1 个答案:

答案 0 :(得分:1)

感谢您的输入。 我现在想出了问题。

是一个愚蠢的错误。在maven配置中,我设置了client-Package中的所有Classes都不应该包含在打包中,因为它们被编译为JS。这包括我的服务界面...... 我将它移动到一个新的包共享,并包含在gwt.xml中。

还将gwt-user和gwt-dev更改为提供的maven范围,将gwt-servlet更改为运行时。

使用此配置,可以使用: - )