Custom Schedulers and Servlets not resolving from Bundle | Community
Skip to main content
__96
Level 4
February 15, 2016
Solved

Custom Schedulers and Servlets not resolving from Bundle

  • February 15, 2016
  • 5 replies
  • 1334 views

I had a requirement to create separate project bundle by collecting some of the classes from the already built bundle. I pulled up all the java files and created a new bundle, and deleted from files from the previous bundle. Now both the bundles are installing successfully(active) but the schedulers and servlets in my new bundle are not getting resolved.

The classes of schedulers and servlets are inside package :

com.mycompany.wcm.softwaredelivery.servlet   ------    All servlets reside here

com.mycompany.wcm.softwaredelivery.schedulers  ---- All schedulers reside here

In my pom.xml I made the changes as  below :

<plugin> <groupId>org.apache.felix</groupId> <artifactId>maven-bundle-plugin</artifactId> <extensions>true</extensions> <configuration> <instructions> <Bundle-SymbolicName>com.mycompany.softwaredelivery-bundle</Bundle-SymbolicName> <Export-Package>com.mycompany.wcm.softwaredelivery.*,com.mycompany.wcm.softwaredelivery.servlet.*,com.mycompany.wcm.softwaredelivery.schedulers.*</Export-Package> <Import-Package>!com.google.gson,!com.sun.*,!javax.jms.*,!org.apache.avalon.*,!org.apache.bsf.*,!org.apache.commons.net.*,!org.apache.commons.httpclient.*,!org.apache.commons.logging.*,!org.apache.log.*,!org.exolab.*,!sun.awt.*,!sun.security.*,*</Import-Package> <Embed-Dependency>gson;scope=compile</Embed-Dependency> <Embed-Directory>OSGI-INF/lib</Embed-Directory> <_exportcontents> javax.xml.soap.*,javax.xml.rpc.*,javax.xml.namespace.*,javax.xml.messaging.*,org.apache.axis.configuration.*;version=1.0.0 </_exportcontents> </instructions> </configuration> </plugin>

Any Idea why I they are struggling to resolve. I am checking my servlets in http://localhost:4503/system/console/servletresolver and checking my scheduler list at http://localhost:4503/system/console/status-slingscheduler. Earlier everything was working fine.

Note : I changed the package name in the new bundle. 

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by __96

This issue got fixed. I don't know the real reason but I shutdown my machine and the next day I started it again and tried to build the bundle again and it gives error saying 

@SlingServlet : Component is defined to generate metatype information, however no properties have been defined; in case no properties are wanted, consider to use 'metatype=false'

I then changed all the servlets metatype to false which didnot have any @properties defined in them. Now it was the same code that was working previously with metatype = true in previous bundle. And yes one more thing in my pom.xml I added this I think after which the build started failing and started giving compile time errors 

<plugin> <groupId>org.apache.felix</groupId> <artifactId>maven-scr-plugin</artifactId> <executions> <execution> <id>generate-scr-descriptor</id> <goals> <goal>scr</goal> </goals> </execution> </executions> <configuration> <outputDirectory>src/main/resources</outputDirectory> </configuration> </plugin>        

Adding this also gave error asking for version in below entry to be more than 1.9.0 

<dependency> <groupId>org.apache.felix</groupId> <artifactId>org.apache.felix.scr.annotations</artifactId> <version>1.6.0</version> <scope>provided</scope> </dependency>

So I changed the version in above to 1.9.6 and then it gave error which I described above. Now my servlets and schedulers I can see listed in the bundle when I expand that in felix.

 

Thanks a lot. Hope this might help someone facing the same issue.

Samir

5 replies

Jitendra_S_Toma
Level 10
February 15, 2016

Just a guess, it could be a bundle cross dependency issue. Your new bundle might depend on old bundle, but new bundle could not find dependency his life cycle (start, resolved etc.).

You could try following things:

  • Try re-starting new bundle manually once. It may get resolved. 
  • Expand new bundle and find if there are some missing dependency which are marked in RED.

Jitendra

__96
__96Author
Level 4
February 15, 2016

Jitendra S.Tomar wrote...

Just a guess, it could be a bundle cross dependency issue. Your new bundle might depend on old bundle, but new bundle could not find dependency his life cycle (start, resolved etc.).

You could try following things:

  • Try re-starting new bundle manually once. It may get resolved. 
  • Expand new bundle and find if there are some missing dependency which are marked in RED.

Jitendra

 

As I said its installed and active. I restarted the instance as well. Tried clearing /var/classes also. Bundle is resolved and infact other handler classes of that bundle are working fine. Only schedulers and servlets are not getting resolved.

Thanks,

Samir

smacdonald2008
Level 10
February 15, 2016

For the schedule r bundle not active, see what java packages cannot be located. They will be red.post them.

__96
__96Author
Level 4
February 15, 2016

smacdonald2008 wrote...

For the schedule r bundle not active, see what java packages cannot be located. They will be red.post them.

 

Hi,

No nothing is in red I checked that a lot of times. One more thing which I observed is that in the bundles where servlets are working fine there servlets are listed on expanding bundles like Service PID : <servlet name> . But in my bundle no such entry is there if I expand that in felix. Dont know why this is happening.

Regards,

Samir

__96
__96AuthorAccepted solution
Level 4
February 16, 2016

This issue got fixed. I don't know the real reason but I shutdown my machine and the next day I started it again and tried to build the bundle again and it gives error saying 

@SlingServlet : Component is defined to generate metatype information, however no properties have been defined; in case no properties are wanted, consider to use 'metatype=false'

I then changed all the servlets metatype to false which didnot have any @properties defined in them. Now it was the same code that was working previously with metatype = true in previous bundle. And yes one more thing in my pom.xml I added this I think after which the build started failing and started giving compile time errors 

<plugin> <groupId>org.apache.felix</groupId> <artifactId>maven-scr-plugin</artifactId> <executions> <execution> <id>generate-scr-descriptor</id> <goals> <goal>scr</goal> </goals> </execution> </executions> <configuration> <outputDirectory>src/main/resources</outputDirectory> </configuration> </plugin>        

Adding this also gave error asking for version in below entry to be more than 1.9.0 

<dependency> <groupId>org.apache.felix</groupId> <artifactId>org.apache.felix.scr.annotations</artifactId> <version>1.6.0</version> <scope>provided</scope> </dependency>

So I changed the version in above to 1.9.6 and then it gave error which I described above. Now my servlets and schedulers I can see listed in the bundle when I expand that in felix.

 

Thanks a lot. Hope this might help someone facing the same issue.

Samir