Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Virgo » Setting a Bundle cosuming Spring AOP(Spring AOP configuration)
Setting a Bundle cosuming Spring AOP [message #731325] Fri, 30 September 2011 16:24 Go to next message
Carlos Salinas is currently offline Carlos SalinasFriend
Messages: 32
Registered: March 2011
Location: Avd. de la Argentina 132,...
Member
Hello,

i have a Spring powered Web bundle, there is a bean as follow:

<bean id="workbench" class="com.thingtrack.konekti.view.Workbench" scope="prototype">
   <property name="advisor">
	<ref bean="workbenchAdvisor" />
   </property>
</bean>


I want to use Spring AOP to build the logging service, developing a Aspect that cosumes the LogService OSGi service. Configured as follow:

<!-- Logging Aspect Configuration -->
	<bean id="konektiLoggingAspect" class="com.thingtrack.konekti.view.logging.KonektiLogAspect">
 <property name="logService">
   <ref bean="logService" />
 </property>

<aop:config>
 
   <aop:pointcut expression="execution(* com.thingtrack.konekti.view..*.*(..))" id="loggingPointcut"/>

   <aop:aspect id="loggingAspect" ref=konektiLoggingAspect>
      <aop:before pointcut-ref="loggingPointcut" method="logEntry" />
      <aop:after pointcut-ref="loggingPointcut" method="logExit" />
      <aop:after-returning pointcut-ref="loggingPointcut" method="logExitAfterReturn" />
   </aop:aspect>
</aop:config>


In the MANIFEST.MF the Import-Package has the following value:
...
 org.springframework.aop,
 org.springframework.aop.framework,
 org.springframework.beans.factory,
 org.springframework.context.weaving,
...


I also added the following tag:
<context:load-time-weaver aspectj-weaving="on"/>

(as it is explained the post thread
http://www.eclipse.org/forums/index.php/t/191773/)

BUT i always obtein the same failure when one instance of this prototyped bean is about to be created:

...
javax.servlet.ServletException: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'workbench' defined in URL [bundleentry://155.fwk1687192366/META-INF/spring/bundle-context.xml]: Initialization of bean failed; nested exception is java.lang.NoClassDefFoundError: Could not initialize class $Proxy256
	com.vaadin.terminal.gwt.server.AbstractApplicationServlet.handleServiceException(AbstractApplicationServlet.java:999)
	com.vaadin.terminal.gwt.server.AbstractApplicationServlet.service(AbstractApplicationServlet.java:548)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:848)

root cause

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'workbench' defined in URL [bundleentry://155.fwk1687192366/META-INF/spring/bundle-context.xml]: Initialization of bean failed; nested exception is java.lang.NoClassDefFoundError: Could not initialize class $Proxy256
	org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:527)
	org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
	org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:310)
	org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
	org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1075)
	com.vaadin.terminal.gwt.server.SpringApplicationOSGiServlet.getNewApplication(SpringApplicationOSGiServlet.java:102)
	com.vaadin.terminal.gwt.server.AbstractApplicationServlet.createApplication(AbstractApplicationServlet.java:973)
	com.vaadin.terminal.gwt.server.AbstractApplicationServlet.findApplicationInstance(AbstractApplicationServlet.java:801)
	com.vaadin.terminal.gwt.server.AbstractApplicationServlet.service(AbstractApplicationServlet.java:456)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:848)

...


I use VirgoRT 3.0.0.REALESE

Thanks
Re: Setting a Bundle cosuming Spring AOP [message #731367 is a reply to message #731325] Fri, 30 September 2011 18:30 Go to previous messageGo to next message
Dmitry Sklyut is currently offline Dmitry SklyutFriend
Messages: 278
Registered: January 2010
Senior Member
Try to replace all individual import packages with a single

Import-Library: org.springframework.spring;version="[3.0.5.RELEASE,3.0.5.RELEASE]"


This will rulle out any missing classes from spring. You could be missing imports for "org.aopalliance.aop.*" packages or something deeper in spring that is used by factories to create aspects.

If you get it working with library import, start stripping away bundles and go with Import-Bundle

At minimum you will need:
Import-Bundle: com.springsource.org.aopalliance;version="[1.0.0,1.0.0]",
 org.springframework.aop;version="[3.0.5.RELEASE,3.0.5.RELEASE]",
 org.springframework.asm;version="[3.0.5.RELEASE,3.0.5.RELEASE]",
 org.springframework.beans;version="[3.0.5.RELEASE,3.0.5.RELEASE]",
 org.springframework.core;version="[3.0.5.RELEASE,3.0.5.RELEASE]"
 org.springframework.context;version="[3.0.5.RELEASE,3.0.5.RELEASE]"



You might need to add ".aspects" and ".context-support". With web app you will also need the ".web" and ".web.servlet".

Regards,
Dmitry
Re: Setting a Bundle cosuming Spring AOP [message #734116 is a reply to message #731367] Thu, 06 October 2011 17:59 Go to previous message
Carlos Salinas is currently offline Carlos SalinasFriend
Messages: 32
Registered: March 2011
Location: Avd. de la Argentina 132,...
Member
Hi Dmitry,

thank you for reply. Finall it worked, but i had to configure more things in application-context to allow have the logging aspects ina common bundle.

I posted a workaround in another thread.
Previous Topic:Multiple OSGI Service instance
Next Topic:Mysterious service problem
Goto Forum:
  


Current Time: Mon Dec 22 07:52:12 GMT 2014

Powered by FUDForum. Page generated in 0.08591 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software