Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

Custom Schedulers and Servlets not resolving from Bundle

Avatar

Level 4

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. 

1 Accepted Solution

Avatar

Correct answer by
Level 4

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

View solution in original post

5 Replies

Avatar

Level 9

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

Avatar

Level 4

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

Avatar

Level 10

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

Avatar

Level 4

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

Avatar

Correct answer by
Level 4

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