If you are using a thread in your bundle, make sure you are properly shutting it down when the bundle is stopped. Preferably waiting for it to stop, otherwise it could be trying to load classes after the bundle has been refreshed, which could lead to such errors.

-> richard

On 3/27/09 12:29 AM, Jeremias Maerki wrote:
Thanks for you feedback, Richard. That clears things up. BTW, I've
stumbled over the NoClassDefFoundError one additional time after moving
to FileInstall from SVN but I can't reproduce the failure anymore. I'll
keep an eye on it.

On 26.03.2009 17:34:19 Richard S. Hall wrote:
On 3/26/09 3:50 AM, Jeremias Maerki wrote:
Hmm, I've just built FileInstall from SVN and the class loading issue
disappeared. Sorry for that part of the noise. However, the
activate->deactivate->activate is still there.

Update stops an active bundle, then restarts it after the update. Then
you typically get a refresh, which also stops an active bundle and
restarts it. Yes, this sucks, but it is spec.

->  richard

On 26.03.2009 12:26:06 Jeremias Maerki wrote:

I'm currently looking at a strange effect that I'm not sure how to deal
with. Maybe someone has an idea:

I'm using the FileInstall 0.9.0 bundle with Felix 1.4.1. I have a bundle
containing an LPR (line printer, port 515) server. Its uses Declarative
Services. When I change something in that bundle I rebuild it and copy
the JAR (same name and version) into the directory observed by
FileInstall. FileInstall notices that and updates the bundle. But when I
then send a print job to the LPR server I get this:

[lpr.service.osgi.LPRServerImpl] INFO Stopping LPR 
server...ch.jm.lpr.service.osgi.lprserveri...@a33ce2
[lpr.service.impl.LPRServerImpl] INFO LPR server shutting down...
[org.apache.felix.fileinstall] ERROR Updated 
C:\Dev\xxxxxxxxx\xxxxxx\load\ch.jm.lpr.service.jar
[lpr.service.osgi.LPRServerImpl] INFO Starting LPR 
server...ch.jm.lpr.service.osgi.lprserveri...@151dcd6
[lpr.service.impl.LPRServerImpl] INFO LPR server is listening at port 515
[lpr.service.osgi.LPRServerImpl] INFO Stopping LPR 
server...ch.jm.lpr.service.osgi.lprserveri...@151dcd6
[lpr.service.osgi.LPRServerImpl] INFO Starting LPR 
server...ch.jm.lpr.service.osgi.lprserveri...@8d2280
[lpr.service.impl.LPRServerImpl] INFO LPR server is listening at port 515
ERROR: JarContent: Unable to open JAR file. (java.util.zip.ZipException: The 
system cannot find the path specified)
java.util.zip.ZipException: The system cannot find the path specified
        at java.util.zip.ZipFile.open(Native Method)
        at java.util.zip.ZipFile.<init>(ZipFile.java:203)
        at java.util.jar.JarFile.<init>(JarFile.java:132)
        at java.util.jar.JarFile.<init>(JarFile.java:97)
        at org.apache.felix.framework.util.JarFileX.<init>(JarFileX.java:36)
        at 
org.apache.felix.framework.util.SecureAction.openJAR(SecureAction.java:515)
        at 
org.apache.felix.framework.cache.JarContent.openJarFile(JarContent.java:471)
        at 
org.apache.felix.framework.cache.JarContent.getEntryAsBytes(JarContent.java:165)
        at 
org.apache.felix.framework.searchpolicy.ContentClassLoader.findClass(ContentClassLoader.java:157)
        at 
org.apache.felix.framework.searchpolicy.ContentClassLoader.loadClassFromModule(ContentClassLoader.java:94)
        at 
org.apache.felix.framework.searchpolicy.ContentLoaderImpl.getClass(ContentLoaderImpl.java:166)
        at 
org.apache.felix.framework.searchpolicy.R4SearchPolicyCore.findClassOrResource(R4SearchPolicyCore.java:471)
        at 
org.apache.felix.framework.searchpolicy.R4SearchPolicyCore.findClass(R4SearchPolicyCore.java:185)
        at 
org.apache.felix.framework.searchpolicy.R4SearchPolicy.findClass(R4SearchPolicy.java:45)
        at 
org.apache.felix.framework.searchpolicy.ContentClassLoader.loadClass(ContentClassLoader.java:118)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
        at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
        at 
ch.jm.lpr.service.impl.LPRServerImpl.handleConnection(LPRServerImpl.java:69)
        at 
ch.jm.lpr.service.impl.LPRServerImpl.access$200(LPRServerImpl.java:21)
        at ch.jm.lpr.service.impl.LPRServerImpl$1.run(LPRServerImpl.java:54)
Exception in thread "LPR Server Thread" java.lang.NoClassDefFoundError: 
ch/jm/lpr/service/impl/LPRServerImpl$2
        at 
ch.jm.lpr.service.impl.LPRServerImpl.handleConnection(LPRServerImpl.java:69)
        at 
ch.jm.lpr.service.impl.LPRServerImpl.access$200(LPRServerImpl.java:21)
        at ch.jm.lpr.service.impl.LPRServerImpl$1.run(LPRServerImpl.java:54)

Debugging, I found that the ModuleImpl's m_contentLoader
(ContentLoaderImpl) has a m_content (JarContent) that displays:
JAR .\felix-cache\bundle28\version23.1\bundle.jar

However, looking at the Felix cache, version23.1 has been removed and
replaced by version24.0. It is as if the refresh was incomplete somehow.
The component works fine when Felix is freshly started. So it looks to
me like the class loader is not replaced and after the update the class
loader tries to load from an inexistent/deleted JAR file.

The component declaration just in case:
<component name="ch.jm.lpr.server">
      <implementation class="ch.jm.lpr.service.osgi.LPRServerImpl"/>
      <property name="service.description" value="JM :: LPR Server"/>
      <property name="service.vendor" value="Jeremias Märki"/>
</component>

Am I missing anything?

BTW, any reason why the update action of FileInstall is logging with
"ERROR" level and not "INFO"?

And another thing you can see above: After the update the LPR server is
started (activate(ComponentContext)) and stopped
(deactivate(ComponentContext)) immediately after that, only to be
reactivated again. I'm seeing the same behaviour (but at startup) with
another component. Any hints?

Thanks a lot,
Jeremias Maerki




Jeremias Maerki


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to