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 9051991
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T13:03:16+00:00 2026-06-16T13:03:16+00:00

I am having difficulty figuring out why my spring bean is not getting injected

  • 0

I am having difficulty figuring out why my spring bean is not getting injected into my CXF web service that is being deployed into jboss.
Here is the scenario:

I have multiple Service classes which implement an Interface

Here is Implementation # 1

@Service("retrieveService")
@Scope("prototype")
@Transactional(propagation=Propagation.REQUIRED)
public class RetrieveService extends BaseService implements IEuclidService 
{
    @Resource
    private EntrLoanRepository entrLoanRepository;


    @Override
    public RetrieveResponse serve(RequestMessage request) 
    {
                    entrLoanRepository.findByEntrLoanId();
    }
}

Here is Implementation # 2

@Service("disableService")
@Scope("prototype")
@Transactional(propagation=Propagation.REQUIRED)
public class DisableService extends BaseService implements IEuclidService 
{
    @Resource
    private EntrLoanRepository entrLoanRepository;

    @Override
    public RetrieveResponse serve(RequestMessage request) 
    {
                EntrLoan entrLoan = new EntrLoan();
                entrLoan.setEndDate( new Date());
                entrLoanRepository.save(entrLoan);
    }
}

I have my cxf web service, into which I am expecting a spring (service) bean to be injected.

@javax.jws.WebService
public class Euclid implements IEuclid {

    private IEuclidService euclidService

    public MyResponse myMethod(MyRequest req)
    {
    <!-- How do I inject an instance of RetrieveService here ???-->
    euclidService.serve();
    }
}

I tried doing this:

euclidService = ctx.getBean("retrieveService", RetrieveService.class);

but I am getting the error message:

     com.sgb.euclid.contracts.RetrieveEnterpriseLnIdRequest@31d908
     ***1 EuclidService is NULL
     *****Instantiating Spring Bean
     org.springframework.beans.factory.BeanNotOfRequiredTypeException: Bean named 'retrieveService' must be of type [com.sgb.euclid.ws.service.RetrieveService], but was actually of type [$Proxy98]
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:360)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
        at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1102)
        at com.sgb.euclid.ws.web.Euclid.retrieve(Euclid.java:79)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.jboss.as.ee.component.ManagedReferenceMethodInterceptorFactory$ManagedReferenceMethodInterceptor.processInvocation(ManagedReferenceMethodInterceptorFactory.java:72)
        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
        at org.jboss.invocation.WeavedInterceptor.processInvocation(WeavedInterceptor.java:53)
        at org.jboss.as.ee.component.interceptors.UserInterceptorFactory$1.processInvocation(UserInterceptorFactory.java:58)
        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
        at org.jboss.invocation.WeavedInterceptor.processInvocation(WeavedInterceptor.java:53)
        at org.jboss.as.ee.component.interceptors.UserInterceptorFactory$1.processInvocation(UserInterceptorFactory.java:58)
        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
        at org.jboss.invocation.InitialInterceptor.processInvocation(InitialInterceptor.java:21)
        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
        at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61)
        at org.jboss.as.ee.component.interceptors.ComponentDispatcherInterceptor.processInvocation(ComponentDispatcherInterceptor.java:53)
        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
        at org.jboss.as.webservices.deployers.WSComponentInstanceAssociationInterceptor.processInvocation(WSComponentInstanceAssociationInterceptor.java:49)
        at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
        at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61)
        at org.jboss.as.ee.component.ViewService$View.invoke(ViewService.java:165)
        at org.jboss.as.webservices.invocation.AbstractInvocationHandler.invoke(AbstractInvocationHandler.java:111)
        at org.jboss.wsf.stack.cxf.JBossWSInvoker.performInvocation(JBossWSInvoker.java:149)
        at org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:96)
        at org.apache.cxf.jaxws.AbstractJAXWSMethodInvoker.invoke(AbstractJAXWSMethodInvoker.java:178)
        at org.apache.cxf.jaxws.JAXWSMethodInvoker.invoke(JAXWSMethodInvoker.java:64)
        at org.jboss.wsf.stack.cxf.JBossWSInvoker.invoke(JBossWSInvoker.java:129)
        at org.apache.cxf.interceptor.ServiceInvokerInterceptor$1.run(ServiceInvokerInterceptor.java:58)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
        at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
        at java.util.concurrent.FutureTask.run(FutureTask.java:138)
        at org.apache.cxf.workqueue.SynchronousExecutor.execute(SynchronousExecutor.java:37)
        at org.apache.cxf.interceptor.ServiceInvokerInterceptor.handleMessage(ServiceInvokerInterceptor.java:107)
        at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:262)
        at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:121)
        at org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:236)
        at org.jboss.wsf.stack.cxf.RequestHandlerImpl.handleHttpRequest(RequestHandlerImpl.java:88)
        at org.jboss.wsf.stack.cxf.transport.ServletHelper.callRequestHandler(ServletHelper.java:156)
        at org.jboss.wsf.stack.cxf.CXFServletExt.invoke(CXFServletExt.java:87)
        at org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(AbstractHTTPServlet.java:221)
        at org.apache.cxf.transport.servlet.AbstractHTTPServlet.doPost(AbstractHTTPServlet.java:141)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:754)
        at org.jboss.wsf.stack.cxf.CXFServletExt.service(CXFServletExt.java:135)
        at org.jboss.wsf.spi.deployment.WSFServlet.service(WSFServlet.java:140)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:295)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:149)
        at org.jboss.as.jpa.interceptor.WebNonTxEmCloserValve.invoke(WebNonTxEmCloserValve.java:50)
        at org.jboss.as.jpa.interceptor.WebNonTxEmCloserValve.invoke(WebNonTxEmCloserValve.java:50)
        at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:169)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:145)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:97)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:102)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:336)
        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
        at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:652)
        at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:919)
        at java.lang.Thread.run(Thread.java:662)

I do not quite understand what “type [$Proxy98]” is. I searched in the logs, but cannot see where it is coming from. I assume this is related to spring??
Eitherway, what am I doing wrong that I am unable to instantiate a spring bean keeping in mind that the beans are not defined in beans.xml, but rather annotated.

I feel I am missing something, but cannot quite put my finger on it.

As I am deploying on jboss, the configuration xmls are a bit different that the examples I am seeing online.
Here is my jboss-cxf.xml:

    <jaxws:endpoint id="POJOEndpoint" 
        implementor="com.sgb.euclid.ws.web.Euclid"
        wsdlLocation="WEB-INF/wsdl/EnterpriseLoanIdentifier.wsdl" 
        address="http://localhost:8080/euclid-ws">
        <jaxws:properties>
            <entry key="schema-validation-enabled" value="true" />
        </jaxws:properties>
        <jaxws:invoker>
            <bean class="org.jboss.wsf.stack.cxf.InvokerJSE" />
        </jaxws:invoker>
    </jaxws:endpoint>

And here is the applicationContext-ws.xml:

    <import resource="applicationContext-core.xml" />
    <import resource="applicationContext-jpa.xml" />

    <!-- setting up packages to scan for components -->
    <context:component-scan base-package="com.sgb.euclid.ws.service" />

    <tx:annotation-driven 
    transaction-manager="transactionManager" />

Here is the corresponding web.xml

<!--  setting up spring configuration to instantiate the spring container  -->
<context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>classpath*:META-INF/spring/applicationContext-ws.xml</param-value>
</context-param>

<servlet>
    <servlet-name>euclid</servlet-name>
    <servlet-class>com.sgb.euclid.ws.web.Euclid</servlet-class>
    <load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
    <servlet-name>euclid</servlet-name>
    <url-pattern>/*</url-pattern>
</servlet-mapping>

I cannot figure out what my mistake is. Any help is appreciated….

  • 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-06-16T13:03:17+00:00Added an answer on June 16, 2026 at 1:03 pm

    The solution seems to be as follows:

    euclidService = ctx.getBean("retrieveService", IEuclidService .class);
    

    or

    euclidService = (IEuclidService) ctx.getBean("retrieveService");
    

    It appears that the getBean can only cast to the interface and not the implementation class. … based on http://forum.springsource.org/showthread.php?71543-Proxy-Type-Conversion-Error

    Another explanation is here:
    Abstract DAO pattern and Spring's "Proxy cannot be cast to …" problem!

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

Sidebar

Related Questions

I'm having difficulty figuring out how to write a module with a form that
I'm having difficulty figuring out why user password hashing is not working. The way
I'm building a multi-thread windows service. I'm having a little difficulty figuring out the
I'm having difficulty figuring out how to deal with different device orientations for one
I'm having difficulty figuring out how to clone my Mercurial repository from my local
I'm trying to learn the MapKit with Monotouch and I'm having difficulty figuring out
I am having some difficulty figuring out how to return the selected item in
I'm having some difficulty figuring out the best ways to pause and resume my
I'm having some difficulty figuring out what is going on and how to fix
I'm having a bit of difficulty figuring out how to use this Regular Expression

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.