Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5950975
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T17:28:15+00:00 2026-05-22T17:28:15+00:00

As per the following spring doc link I can use @Async annotation to make

  • 0

As per the following spring doc link I can use @Async annotation to make a method call asynchronous. Can I use this facility in Grails from a java src file that I have?

[Update]
This is my java(netty) socket handler class which receives the socket packet.
public class DefaultHandler extends SimpleChannelUpstreamHandler {

private static final Logger LOG = LoggerFactory.getLogger(DefaultHandler.class);

private AggregateSocketData aggregateSocketData;

@Override
public void messageReceived(ChannelHandlerContext ctx, MessageEvent e)
        throws Exception {
    LOG.trace("In messageRecieved method with event: {}",e);
    IEvent event = Events.dataInEvent(e.getMessage());
    System.out.println(Thread.currentThread().getName());
    aggregateSocketData.receiveSocketData(event);
}


@Override
public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e)
        throws Exception {
    LOG.error("Exception occurred in Default Handler: " ,e.getCause());
}

public AggregateSocketData getAggregateSocketData() {
    return aggregateSocketData;
}

public void setAggregateSocketData(AggregateSocketData aggregateSocketData) {
    this.aggregateSocketData = aggregateSocketData;
}

}

I have made it a bean in grails- conf – resources.xml

<bean id="defaultECM1240Handler" class="com.appcapture.buildingmgr.netty.DefaultHandler"
        scope="prototype">
        <property name="aggregateSocketData" ref="binaryDataAggregatorService"></property>
</bean>

And this is my grails service class whose method I have annotated with @Async

class BinaryDataAggregatorService implements AggregateSocketData {

def rawDataService
static transactional = true

@Async
void receiveSocketData(IEvent event) {
    println Thread.currentThread().name
    log.debug("Going to decode netty packet in receiveSocketData");
    Map decodedPacket = decodePacket((INettyPacket)event.getSource())
    def rawData = saveRawData (decodedPacket);
    log.debug ("Saved raw data, id: ${rawData?.id}")
    rawDataService.saveHTTPData(decodedPacket);
}

}

[Update 2] Here is the stack trace for the method call.
Here is the stack. BinaryDataAggregatorService.receiveSocketData(INettyPacket) line: 20
BinaryDataAggregatorService$$FastClassByCGLIB$$82489f62.invoke(int, Object, Object[]) line: not available
MethodProxy.invoke(Object, Object[]) line: 149
Cglib2AopProxy$CglibMethodInvocation.invokeJoinpoint() line: 688
Cglib2AopProxy$CglibMethodInvocation(ReflectiveMethodInvocation).proceed() line: 150
TransactionInterceptor.invoke(MethodInvocation) line: 110
Cglib2AopProxy$CglibMethodInvocation(ReflectiveMethodInvocation).proceed() line: 172
Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Object, Method, Object[], MethodProxy) line: 621
BinaryDataAggregatorService$$EnhancerByCGLIB$$1c96985c.receiveSocketData(INettyPacket) line: not available
DefaultHandler.handlePacket(INettyPacket) line: 50

[Update 3]
The grails stack trace on setting the task:annotation-driven element.

011-05-26 17:38:03,109 [main] ERROR context.GrailsContextLoader  - Error executing bootstraps: Error creating bean with name 'defaultECM1240Handler' defined in URL [file:./grails-app/conf/spring/resources.xml]: Cannot resolve reference to bean 'binaryDataAggregatorService' while setting bean property 'aggregateSocketData'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'binaryDataAggregatorService': Invocation of init method failed; nested exception is org.springframework.aop.framework.AopConfigException: Could not generate CGLIB subclass of class [class $Proxy12]: Common causes of this problem include using a final class or a non-visible class; nested exception is java.lang.IllegalArgumentException: Cannot subclass final class class $Proxy12
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'defaultECM1240Handler' defined in URL [file:./grails-app/conf/spring/resources.xml]: Cannot resolve reference to bean 'binaryDataAggregatorService' while setting bean property 'aggregateSocketData'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'binaryDataAggregatorService': Invocation of init method failed; nested exception is org.springframework.aop.framework.AopConfigException: Could not generate CGLIB subclass of class [class $Proxy12]: Common causes of this problem include using a final class or a non-visible class; nested exception is java.lang.IllegalArgumentException: Cannot subclass final class class $Proxy12

Thanks,
Abraham

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T17:28:15+00:00Added an answer on May 22, 2026 at 5:28 pm

    If it is a spring bean – yes, you can. For that you have to annotate it with @Service and have a <context:component-scan base-package="com.foo.bar" />

    But to make it easier, you can use a groovy class placed in the grails-app/services – it will be a spring bean automatically

    In order to make @Async work, you need <task:annotation-driven/> in the xml config.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

On Linux, how can I (programmatically) retrieve the following counters on a per-interface basis
The samples and documentation in question can be found here: http://static.springsource.org/spring-flex/docs/1.5.0.M1/ The reference doc
As per this question and this question, I'm getting the following error: Unable to
Can you tell me what's wrong in this code? I'm using Spring MVC to
I have installed GDB 7.0 and python per the following instructions . In the
The following query returns the total amount of orders, per week, for the past
I have the following query that retrieve the number of users per country; SELECT
Following code iterates through many data-rows, calcs some score per row and then sorts
Per this helpful article I have confirmed I have a connection pool leak in
When i try to use spring 2.5.x DispatcherPortlet with liferay to use Ajax, i

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.