如何在OSGi中找到类未找到问题的根本原因?

时间:2014-07-09 11:29:03

标签: java osgi classloader equinox osgi-bundle

我想尝试一些修复ClassNotFound问题的步骤。我正在使用Equinox / OSGI。 例如,即时通讯

   java.lang.ClassNotFoundException: org.wso2.carbon.tomcat.ext.servlet.DelegationServlet
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1714)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1559)
    at org.apache.catalina.core.DefaultInstanceManager.loadClass(DefaultInstanceManager.java:532)
    at org.apache.catalina.core.DefaultInstanceManager.loadClassMaybePrivileged(DefaultInstanceManager.java:514)
    at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:133)

我试过,ss,ls -c,diag,b命令..但是找不到任何有用的信息。我把那些命令的输出..

任何人都可以告诉我,我怎样才能解决这些OSgi问题?如何找出导致此类问题的根本原因..

#osgi> p org.wso2.carbon.tomcat.ext.servlet
org.wso2.carbon.tomcat.ext.servlet; version="4.2.0"<org.wso2.carbon.tomcat.ext_4.2.0 [421]>

#osgi> diag 421
reference:file:../plugins/org.wso2.carbon.tomcat.ext_4.2.0.jar [421]
  No unresolved constraints.

#osgi> b 421
org.wso2.carbon.tomcat.ext_4.2.0 [421]
  Id=421, Status=ACTIVE      Data Root=C:\Projects\scartch\chunk13\08_07_new\wso2am-1.7.1\repository\components\default\configuration\org.eclipse.osgi
\bundles\421\data
  "No registered services."
  Services in use:
    {org.wso2.carbon.user.core.service.RealmService, org.wso2.carbon.user.api.UserRealmService}={service.id=136}
    {org.wso2.carbon.tomcat.api.CarbonTomcatService}={service.id=130}
    {org.wso2.carbon.base.api.ServerConfigurationService}={service.id=103}
    {org.wso2.carbon.registry.core.service.RegistryService, org.wso2.carbon.registry.api.RegistryService}={service.id=143}
  Exported packages
    org.wso2.carbon.tomcat.ext.service; version="4.2.0"[exported]
    org.wso2.carbon.tomcat.ext.scan; version="4.2.0"[exported]
    org.wso2.carbon.tomcat.ext.valves; version="4.2.0"[exported]
    org.wso2.carbon.tomcat.ext.saas; version="4.2.0"[exported]
    org.wso2.carbon.tomcat.ext.utils; version="4.2.0"[exported]
    org.wso2.carbon.tomcat.ext.filter; version="4.2.0"[exported]
    org.wso2.carbon.tomcat.ext.realms; version="4.2.0"[exported]
    org.wso2.carbon.tomcat.ext.transport; version="4.2.0"[exported]
    org.wso2.carbon.tomcat.ext.servlet; version="4.2.0"[exported]
    org.wso2.carbon.tomcat.ext.transport.statistics; version="4.2.0"[exported]
  Imported packages
    org.wso2.carbon.utils.multitenancy; version="4.2.0"<org.wso2.carbon.utils_4.2.0 [454]>
    org.wso2.carbon.utils; version="4.2.0"<org.wso2.carbon.utils_4.2.0 [454]>
    org.wso2.carbon.user.core.tenant; version="4.2.0"<org.wso2.carbon.user.core_4.2.0 [449]>
    org.wso2.carbon.user.core.service; version="4.2.0"<org.wso2.carbon.user.core_4.2.0 [449]>
    org.wso2.carbon.user.api; version="1.0.1"<org.wso2.carbon.user.api_4.2.0 [448]>
    org.wso2.carbon.tomcat.api; version="4.2.0"<org.wso2.carbon.tomcat_4.2.0 [420]>
    org.wso2.carbon.tomcat; version="4.2.0"<org.wso2.carbon.tomcat_4.2.0 [420]>
    org.wso2.carbon.registry.core.service; version="1.0.1"<org.wso2.carbon.registry.core_4.2.0 [344]>
    org.wso2.carbon.registry.core.ghostregistry; version="1.0.1"<org.wso2.carbon.registry.core_4.2.0 [344]>
    org.wso2.carbon.registry.api; version="1.0.1"<org.wso2.carbon.registry.api_4.2.0 [341]>
    org.wso2.carbon.core.session; version="4.2.0"<org.wso2.carbon.core_4.2.0 [197]>
    org.wso2.carbon.core; version="4.2.0"<org.wso2.carbon.core_4.2.0 [197]>
    org.wso2.carbon.context; version="4.2.0"<org.wso2.carbon.utils_4.2.0 [454]>
    org.wso2.carbon.base.api; version="1.0.0"<org.wso2.carbon.base_4.2.0 [189]>
    org.wso2.carbon.base; version="1.0.0"<org.wso2.carbon.base_4.2.0 [189]>
    org.osgi.service.component; version="1.2.0"<org.eclipse.osgi.services_3.3.100.v20120522-1822 [132]>
    org.eclipse.osgi.framework.adaptor; version="0.0.0"<org.eclipse.osgi_3.8.1.v20120830-144521 [0]>
    org.eclipse.equinox.http.servlet; version="1.1.0"<org.eclipse.equinox.http.servlet_1.1.300.v20120522-1841 [102]>
    org.apache.tomcat.util.scan; version="1.7.0"<tomcat_7.0.34.wso2v1 [494]>
    org.apache.tomcat.util.res; version="1.7.0"<tomcat_7.0.34.wso2v1 [494]>
    org.apache.tomcat.util.file; version="1.7.0"<tomcat_7.0.34.wso2v1 [494]>
    org.apache.tomcat; version="1.7.0"<tomcat_7.0.34.wso2v1 [494]>
    org.apache.juli.logging; version="7.0.34"<tribes_7.0.34.wso2v1 [496]>
    org.apache.coyote; version="1.7.0"<org.wso2.carbon.tomcat.patch_4.2.0 [423]>
    org.apache.commons.logging; version="1.1.1"<org.wso2.carbon.logging_4.2.0 [287]>
    org.apache.catalina.valves; version="1.7.0"<tomcat_7.0.34.wso2v1 [494]>
    org.apache.catalina.startup; version="1.7.0"<tomcat_7.0.34.wso2v1 [494]>
    org.apache.catalina.realm; version="1.7.0"<tomcat_7.0.34.wso2v1 [494]>
    org.apache.catalina.ha; version="1.7.0"<tomcat-ha_7.0.34.wso2v1 [495]>
    org.apache.catalina.core; version="1.7.0"<tomcat_7.0.34.wso2v1 [494]>
    org.apache.catalina.connector; version="1.7.0"<tomcat_7.0.34.wso2v1 [494]>
    org.apache.catalina; version="1.7.0"<tomcat_7.0.34.wso2v1 [494]>
    org.apache.axis2.clustering; version="1.6.1.wso2v10"<axis2_1.6.1.wso2v10 [13]>
    javax.servlet.http; version="2.6.0"<javax.servlet_3.0.0.v201112011016 [57]>
    javax.servlet; version="2.6.0"<javax.servlet_3.0.0.v201112011016 [57]>
  No fragment bundles
  Named class space
    org.wso2.carbon.tomcat.ext; bundle-version="4.2.0"[provided]
  No required bundles


#osgi> ls -c 421
Components in bundle org.wso2.carbon.tomcat.ext:
ID      Component details
139     Component[
        name = tomcat.ext.service.comp
        factory = null
        autoenable = true
        immediate = true
        implementation = org.wso2.carbon.tomcat.ext.internal.CarbonRealmServiceComponent
        state = Unsatisfied
        properties = {service.pid=tomcat.ext.service.comp}
        serviceFactory = false
        serviceInterface = null
        references = {
                Reference[name = user.realm.provider, interface = org.wso2.carbon.user.core.service.RealmService, policy = dynamic, cardinality = 1..1
, target = null, bind = setRealmService, unbind = unsetRealmService]
                Reference[name = registry.service.provider, interface = org.wso2.carbon.registry.core.service.RegistryService, policy = dynamic, cardi
nality = 1..1, target = null, bind = setRegistryService, unbind = unsetRegistryService]
        }
        located in bundle = org.wso2.carbon.tomcat.ext_4.2.0 [421]
]
Dynamic information :
  The component is satisfied
  All component references are satisfied
  Component configurations :
    Configuration properties:
      service.pid = tomcat.ext.service.comp
      component.name = tomcat.ext.service.comp
      component.id = 138
    Instances:
      org.eclipse.equinox.internal.ds.impl.ComponentInstanceImpl@68c19d85
        Bound References:
        String[org.wso2.carbon.registry.core.service.RegistryService,org.wso2.carbon.registry.api.RegistryService]
                -> org.wso2.carbon.registry.core.jdbc.EmbeddedRegistryService@7f4cbc7d
        String[org.wso2.carbon.user.core.service.RealmService,org.wso2.carbon.user.api.UserRealmService]
                -> org.wso2.carbon.user.core.common.DefaultRealmService@6eaf3d6

140     Component[
        name = tomcat.service.comp
        factory = null
        autoenable = true
        immediate = true
        implementation = org.wso2.carbon.tomcat.ext.internal.CarbonTomcatServiceComponent
        state = Unsatisfied
        properties = {service.pid=tomcat.service.comp}
        serviceFactory = false
        serviceInterface = null
        references = {
                Reference[name = server.configuration.service, interface = org.wso2.carbon.base.api.ServerConfigurationService, policy = dynamic, card
inality = 1..1, target = null, bind = setServerConfigurationService, unbind = unsetServerConfigurationService]
                Reference[name = tomcat.service.provider, interface = org.wso2.carbon.tomcat.api.CarbonTomcatService, policy = dynamic, cardinality =
1..1, target = null, bind = setCarbonTomcatService, unbind = unsetCarbonTomcatService]
        }
        located in bundle = org.wso2.carbon.tomcat.ext_4.2.0 [421]
]
Dynamic information :
  The component is satisfied
  All component references are satisfied
  Component configurations :
    Configuration properties:
      service.pid = tomcat.service.comp
      component.name = tomcat.service.comp
      component.id = 139
    Instances:
      org.eclipse.equinox.internal.ds.impl.ComponentInstanceImpl@2b2e6a26
        Bound References:
        String[org.wso2.carbon.base.api.ServerConfigurationService]
                -> org.wso2.carbon.base.ServerConfiguration@4c309c86
        String[org.wso2.carbon.tomcat.api.CarbonTomcatService]
                -> org.wso2.carbon.tomcat.internal.CarbonTomcat@b74487e

1 个答案:

答案 0 :(得分:1)

您诊断出了提供课程的插件。查看请求者也可能有所帮助。

一般情况下,OSGi类加载很难解决。不兼容的库版本和重复的库是ClassNotFoundException最常见的原因。因此,在崩溃期间查找配置更改可能会给您一些提示。

堆栈跟踪是否完整?如果没有你可以粘贴整个堆栈,可能会有帮助。