VMware {code} Community
hanish
Contributor
Contributor
Jump to solution

java.lang.ClassNotFoundException: com.vmware.vise.usersession.UserSessionService

I want to use the UserSessionService class from my java service project which the UI project uses via proxy.

My budle-context.xml contains

   <bean name="TestInterfaceImpl" class="com.acme.TestInterfaceImpl">

      <constructor-arg ref="userSessionService"/>

   </bean>

and bundle-context-osgi.xml contains

<osgi:service id="TestInterface" ref="TestInterfaceImpl" interface="com.acme.TestInterface" />

<osgi:reference id="userSessionService" interface="com.vmware.vise.usersession.UserSessionService"/>

I'm getting following error

Caused by: java.lang.ClassNotFoundException: com.vmware.vise.usersession.UserSessionService

      at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:513)

      at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:429)

      at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:417)

      at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:107)

      at org.eclipse.virgo.kernel.userregion.internal.equinox.KernelBundleClassLoader.loadClass(KernelBundleClassLoader.java:134)

I even tried adding the vsphere-client-lib.jar to server/pickup folder. Still same error.

EDIT: The top level error I'm getting is

Start failed for bundle '<my bundle name>' version '1.0.0'. org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userSessionService': Initialization of bean failed; nested exception is org.springframework.beans.TypeMismatchException: Failed to convert property value of type 'java.lang.String' to required type 'java.lang.Class[]' for property 'interfaces'; nested exception is java.lang.IllegalArgumentException: Cannot find class [com.vmware.vise.usersession.UserSessionService]

0 Kudos
1 Solution

Accepted Solutions
laurentsd
VMware Employee
VMware Employee
Jump to solution

See this entry in docs/FAQ.html, it looks like you didn't add com.vmware.vise.usersession in the list of Import-Packages in your bundle's MANIFEST.MF.

How to solve most ClassNotFoundException or similar errors?

In most cases a ClassNotFoundException, or similar "not found" error, is caused by incorrect or missing packages in your bundle manifest's Import-Packages. For instance if your java service uses any API from the SDK packagecom.vmware.vise.data.query, that package must be listed in its manifest (this is how Virgo handles dynamic dependencies between libraries). We recommend to use a tool like bundlor to generate the manifest with your build, this will avoid many errors!

If the "not found" error still happens when calling a remote web service from your java plugin, another thing to try is to add the missing package in the MANIFEST of the UI plugin making the initial call to your java plugin. For instance if you get a popup with the error Provider com.ctc.wstx.stax.WstxInputFactory not found you should add com.ctc.wstx.stax to the Import-Packages of your UI plugin's MANIFEST (in addition to your Java plugin).

View solution in original post

0 Kudos
2 Replies
laurentsd
VMware Employee
VMware Employee
Jump to solution

See this entry in docs/FAQ.html, it looks like you didn't add com.vmware.vise.usersession in the list of Import-Packages in your bundle's MANIFEST.MF.

How to solve most ClassNotFoundException or similar errors?

In most cases a ClassNotFoundException, or similar "not found" error, is caused by incorrect or missing packages in your bundle manifest's Import-Packages. For instance if your java service uses any API from the SDK packagecom.vmware.vise.data.query, that package must be listed in its manifest (this is how Virgo handles dynamic dependencies between libraries). We recommend to use a tool like bundlor to generate the manifest with your build, this will avoid many errors!

If the "not found" error still happens when calling a remote web service from your java plugin, another thing to try is to add the missing package in the MANIFEST of the UI plugin making the initial call to your java plugin. For instance if you get a popup with the error Provider com.ctc.wstx.stax.WstxInputFactory not found you should add com.ctc.wstx.stax to the Import-Packages of your UI plugin's MANIFEST (in addition to your Java plugin).

0 Kudos
hanish
Contributor
Contributor
Jump to solution

Thanks for the response and it worked! My bad, I forgot about FAQ doc. Thanks again! Smiley Happy

0 Kudos