为 Spring Portlet 获取异常“无法启动服务 jboss.module.service”

Posted

技术标签:

【中文标题】为 Spring Portlet 获取异常“无法启动服务 jboss.module.service”【英文标题】:Getting an exception "Failed to start service jboss.module.service" for spring portlets 【发布时间】:2012-05-16 20:35:00 【问题描述】:

感谢您的宝贵时间

我们正在使用 liferay 6 - jboss 7 的版本,这是在尝试避免在每个 spring mvc3 portlet war 中包含包含 spring jar 的 lib 文件夹时出现的错误异常。因为同一组 spring 依赖 jar 被添加到所有 portlet 并一直在部署,它实际上增加了负载。为了摆脱这种情况,在模块中创建了一个文件夹 [结构类似于 jboss/modules/com/spring/main/--jar 文件--] 并添加了所有公共库。

这是module.xml

<module xmlns="urn:jboss:module:1.0" name="com.spring">
  <resources>
    <resource-root path="org.springframework.aop-3.1.1.RELEASE.jar"/> 
    <resource-root path="org.springframework.asm-3.1.1.RELEASE.jar"/>
    <resource-root path="org.springframework.aspects-3.1.1.RELEASE.jar"/>
    <resource-root path="org.springframework.beans-3.1.1.RELEASE.jar"/>
    <resource-root path="org.springframework.context-3.1.1.RELEASE.jar"/>
    <resource-root path="org.springframework.context.support-3.1.1.RELEASE.jar"/>
    <resource-root path="org.springframework.core-3.1.1.RELEASE.jar"/>
    <resource-root path="org.springframework.expression-3.1.1.RELEASE.jar"/>
    <resource-root path="org.springframework.instrument-3.1.1.RELEASE.jar"/>
    <resource-root path="org.springframework.instrument.tomcat-3.1.1.RELEASE.jar"/>
    <resource-root path="org.springframework.jdbc-3.1.1.RELEASE.jar"/>
    <resource-root path="org.springframework.jms-3.1.1.RELEASE.jar"/>
    <resource-root path="org.springframework.orm-3.1.1.RELEASE.jar"/>
    <resource-root path="org.springframework.oxm-3.1.1.RELEASE.jar"/>
    <resource-root path="org.springframework.test-3.1.1.RELEASE.jar"/>
    <resource-root path="org.springframework.transaction-3.1.1.RELEASE.jar"/>
    <resource-root path="org.springframework.web-3.1.1.RELEASE.jar"/>
    <resource-root path="org.springframework.web.portlet-3.1.1.RELEASE.jar"/>
    <resource-root path="org.springframework.web.servlet-3.1.1.RELEASE.jar"/>
    <resource-root path="org.springframework.web.struts-3.1.1.RELEASE.jar"/>
    <resource-root path="standard.jar"/>
    <resource-root path="util-java.jar"/>
    <resource-root path="util-taglib.jar"/>
    <resource-root path="util-bridges.jar"/>
    <resource-root path="commons-logging.jar"/>
    <resource-root path="ext-oneprm-liferay-portal-ext-util-bridges.jar"/>
    <resource-root path="ext-oneprm-liferay-portal-ext-util-java.jar"/>
    <resource-root path="ext-oneprm-liferay-portal-ext-util-taglib.jar"/>

  </resources>

</module> 

以及 portlet 中的 jboss-deployement-structure.xml

<?xml version="1.0"?>

<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.0">
    <deployment>
        <dependencies>
            <module name="com.liferay.portal"></module>
            <module name="org.jboss.modules"></module>
        </dependencies>
    </deployment>
</jboss-deployment-structure> 

这是我们现在遇到的错误 .. 我在 portlet 中是否还遗漏了任何要提及的内容?任何人都可以帮助我...提前谢谢!

20:38:41,812 INFO  [org.jboss.as.server.controller] (DeploymentScanner-threads - 1) Deployment of "sample-spring-template-portlet.war" was rolled back with failure message "Failed services" => "jboss.module.service.\"deployment.sample-spring-template-portlet.war\".main" => "org.jboss.msc.service.StartException in service jboss.module.service.\"deployment.sample-spring-template-portlet.war\".main: Failed to load module: deployment.sample-spring-template-portlet.war:main"
20:38:42,140 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-4) Stopped deployment sample-spring-template-portlet.war in 323ms
20:38:42,140 ERROR [org.jboss.as.deployment] (DeploymentScanner-threads - 2) "Composite operation failed and was rolled back. Steps that failed:" => "Operation step-2" => "Failed services" => "jboss.module.service.\"deployment.sample-spring-template-portlet.war\".main" => "org.jboss.msc.service.StartException in service jboss.module.service.\"deployment.sample-spring-template-portlet.war\".main: Failed to load module: deployment.sample-spring-template-portlet.war:main"
20:51:35,192 INFO  [stdout] (com.liferay.portal.kernel.deploy.auto.AutoDeployScanner) 20:51:35,192 INFO  [AutoDeployDir:167] Processing sample-spring-template-portlet-6.1.0.1.war
20:51:35,192 INFO  [stdout] (com.liferay.portal.kernel.deploy.auto.AutoDeployScanner) 20:51:35,192 INFO  [PortletAutoDeployListener:71] Copying portlets for C:\apps\Liferay\JBOSS\Liferay-6.1.0\deploy\sample-spring-template-portlet-6.1.0.1.war
20:51:35,567 INFO  [stdout] (com.liferay.portal.kernel.deploy.auto.AutoDeployScanner)   Expanding: C:\apps\Liferay\JBOSS\Liferay-6.1.0\deploy\sample-spring-template-portlet-6.1.0.1.war into C:\DOCUME~1\SESA23~1\LOCALS~1\Temp\20120507205135567
20:51:36,302 INFO  [stdout] (com.liferay.portal.kernel.deploy.auto.AutoDeployScanner)   Copying 1 file to C:\DOCUME~1\SESA23~1\LOCALS~1\Temp\20120507205135567\WEB-INF
20:51:36,958 INFO  [stdout] (com.liferay.portal.kernel.deploy.auto.AutoDeployScanner)   Copying 1 file to C:\DOCUME~1\SESA23~1\LOCALS~1\Temp\20120507205135567\WEB-INF\classes
20:51:36,958 INFO  [stdout] (com.liferay.portal.kernel.deploy.auto.AutoDeployScanner)   Copying 1 file to C:\DOCUME~1\SESA23~1\LOCALS~1\Temp\20120507205135567\WEB-INF\classes
20:51:37,552 INFO  [stdout] (com.liferay.portal.kernel.deploy.auto.AutoDeployScanner)   Copying 1 file to C:\DOCUME~1\SESA23~1\LOCALS~1\Temp\20120507205135567\WEB-INF\jsp
20:51:38,223 INFO  [stdout] (com.liferay.portal.kernel.deploy.auto.AutoDeployScanner)   Copying 16 files to C:\apps\Liferay\JBOSS\Liferay-6.1.0\jboss-7.0.2\standalone\deployments\sample-spring-template-portlet.war
20:51:38,411 INFO  [stdout] (com.liferay.portal.kernel.deploy.auto.AutoDeployScanner)   Copying 1 file to C:\apps\Liferay\JBOSS\Liferay-6.1.0\jboss-7.0.2\standalone\deployments\sample-spring-template-portlet.war
20:51:38,427 INFO  [stdout] (com.liferay.portal.kernel.deploy.auto.AutoDeployScanner)   Deleting directory C:\DOCUME~1\SESA23~1\LOCALS~1\Temp\20120507205135567
20:51:38,489 INFO  [stdout] (com.liferay.portal.kernel.deploy.auto.AutoDeployScanner) 20:51:38,489 INFO  [PortletAutoDeployListener:81] Portlets for C:\apps\Liferay\JBOSS\Liferay-6.1.0\deploy\sample-spring-template-portlet-6.1.0.1.war copied successfully. Deployment will start in a few seconds.
20:51:38,630 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-3) Starting deployment of "sample-spring-template-portlet.war"
20:51:39,192 INFO  [org.jboss.as.jpa] (MSC service thread 1-3) added javax.persistence.api dependency to sample-spring-template-portlet.war
20:51:39,677 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-4) MSC00001: Failed to start service jboss.deployment.unit."sample-spring-template-portlet.war".INSTALL: org.jboss.msc.service.StartException in service jboss.deployment.unit."sample-spring-template-portlet.war".INSTALL: Failed to process phase INSTALL of deployment "sample-spring-template-portlet.war"
        at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:121)
        at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1824)
        at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1759)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) [:1.7.0_03]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) [:1.7.0_03]
        at java.lang.Thread.run(Thread.java:722) [:1.7.0_03]
Caused by: java.lang.RuntimeException: Failed to load class org.springframework.web.servlet.ViewRendererServlet
        at org.jboss.as.ee.component.deployers.EEClassConfigurationProcessor$1.compute(EEClassConfigurationProcessor.java:141)
        at org.jboss.as.ee.component.deployers.EEClassConfigurationProcessor$1.compute(EEClassConfigurationProcessor.java:122)
        at org.jboss.as.ee.component.LazyValue.get(LazyValue.java:40)
        at org.jboss.as.ee.component.EEApplicationDescription.getClassConfiguration(EEApplicationDescription.java:183)
        at org.jboss.as.ee.component.ComponentDescription.createConfiguration(ComponentDescription.java:153)
        at org.jboss.as.ee.component.deployers.EEModuleConfigurationProcessor.deploy(EEModuleConfigurationProcessor.java:70)
        at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:115)
        ... 5 more
Caused by: java.lang.ClassNotFoundException: org.springframework.web.servlet.ViewRendererServlet from [Module "deployment.sample-spring-template-portlet.war:main" from Service Module Loader]
        at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:191)
        at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:361)
        at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:333)
        at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:310)
        at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:103)
        at java.lang.Class.forName0(Native Method) [:1.7.0_03]
        at java.lang.Class.forName(Class.java:264) [:1.7.0_03]
        at org.jboss.as.ee.component.deployers.EEClassConfigurationProcessor$1.compute(EEClassConfigurationProcessor.java:139)
        ... 11 more

20:51:39,958 INFO  [org.jboss.as.server.controller] (DeploymentScanner-threads - 1) Deployment of "sample-spring-template-portlet.war" was rolled back with failure message "Failed services" => "jboss.deployment.unit.\"sample-spring-template-portlet.war\".INSTALL" => "org.jboss.msc.service.StartException in service jboss.deployment.unit.\"sample-spring-template-portlet.war\".INSTALL: Failed to process phase INSTALL of deployment \"sample-spring-template-portlet.war\"","Services with missing/unavailable dependencies" => ["jboss.naming.context.java.module.sample-spring-template-portlet.sample-spring-template-portlet.ValidatorFactory missing [ jboss.naming.context.java.module.sample-spring-template-portlet.sample-spring-template-portlet ]","jboss.naming.context.java.module.sample-spring-template-portlet.sample-spring-template-portlet.Validator missing [ jboss.naming.context.java.module.sample-spring-template-portlet.sample-spring-template-portlet ]"]
20:51:40,349 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-3) Stopped deployment sample-spring-template-portlet.war in 398ms
20:51:40,364 ERROR [org.jboss.as.deployment] (DeploymentScanner-threads - 2) "Composite operation failed and was rolled back. Steps that failed:" => "Operation step-2" => "Failed services" => "jboss.deployment.unit.\"sample-spring-template-portlet.war\".INSTALL" => "org.jboss.msc.service.StartException in service jboss.deployment.unit.\"sample-spring-template-portlet.war\".INSTALL: Failed to process phase INSTALL of deployment \"sample-spring-template-portlet.war\"","Services with missing/unavailable dependencies" => ["jboss.naming.context.java.module.sample-spring-template-portlet.sample-spring-template-portlet.ValidatorFactory missing [ jboss.naming.context.java.module.sample-spring-template-portlet.sample-spring-template-portlet ]","jboss.naming.context.java.module.sample-spring-template-portlet.sample-spring-template-portlet.Validator missing [ jboss.naming.context.java.module.sample-spring-template-portlet.sample-spring-template-portlet ]"]

【问题讨论】:

【参考方案1】:

您的jboss-deployment-structure.xml 我认为不正确。尝试删除您拥有的两个模块并为com.spring 添加一个。

<?xml version="1.0"?>

<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.0">
    <deployment>
        <dependencies>
            <module name="com.spring"/>
        </dependencies>
    </deployment>
</jboss-deployment-structure> 

【讨论】:

【参考方案2】:

去掉这两个模块名

<module name="com.liferay.portal"></module>
<module name="org.jboss.modules"></module>

...并替换为

<module name="com.spring"/>

【讨论】:

以上是关于为 Spring Portlet 获取异常“无法启动服务 jboss.module.service”的主要内容,如果未能解决你的问题,请参考以下文章

Spring 和 Portlet 环境中的 Web 服务

为 Liferay 开发 portlet 的限制/缺点 [关闭]

当我尝试在我的 tomcat 服务器上运行 liferay portlet 时出现异常

以编程方式获取在 Liferay 7.2 中部署的 Portlet 列表

在 WebSphere Portal Portlet 中获取来自自定义 @proceesAction 的响应

如何将值从 ajax 传递到 portlet 页面