Results 1 to 4 of 4

Thread: load spring app context with annotations (standalone)

  1. #1

    Default cannot load app context (with referenses to annotated services) (standalone)

    Hi

    I have a web application up and running with annotation based services/components. The web app runs fine.

    Now I am trying to load the same context in a standalone java application.
    Code:
    ClassPathXmlApplicationContext ctx =
    new ClassPathXmlApplicationContext(new String[] {"spring/infrastructure-context.xml", "spring/services-context.xml"});
    ctx.start();
    the configuration is loaded with the error below
    No bean named 'groupDefinitionTagCreator' is defined

    This bean is annotated with @Service("groupDefinitionTagCreator") and not defined in the xml configuration files.

    How do I load my configuration that has annotated services.

    BTW: my configuration works fine when run as a web app.

    I tried to look for any other implementations of ApplicationContext some thing like AnnotationBasedApplicationContext but didnt find any.

    Can somebody guide me how to achieve this?

    // the following is the one that is failing to be initialized.

    Code:
    <!-- Provides support for tagging audited entities -->
    <bean id="tagFactoryService" class="com.workscape.auditing.AuditTagFactoryImpl">
    	<property name="defaultTagCreator" ref="defaultTagCreator" />
    	<property name="tagCreatorMap">
    		<map>
    			<entry key="com.workscape.em.model.GroupDefinition"
     value-ref="groupDefinitionTagCreator" /> // this is referring to a annotate service @Service("groupDefinitionTagCreator")
    ...
    ...
    ...
    		</map>
    	</property>
    </bean>
    Thanks
    Srikanth
    Last edited by smadarapu; Mar 22nd, 2010 at 10:12 AM. Reason: Thought the message was not clear, refined the title.

  2. #2

    Default

    Any body from the Spring developers, can you at least give some idea? Am I doing something completely wrong?
    Last edited by smadarapu; Mar 22nd, 2010 at 02:14 PM.

  3. #3

    Default

    From your previous Spring context configuration snippet, couldn't really make out if you have the annotation config (specifically the component scanning) turned ON.

    From the Spring reference documentation section on :Automatically detecting classes and registering bean definitions" ... you must have the following in your configuration. The AutowiredAnnotationBeanPostProcessor and CommonAnnotationBeanPostProcessor are both included implicitly when you use the component-scan element. That means that the two components are autodetected and wired together - all without any bean configuration metadata provided in XML.

    <context:component-scan base-package="org.example"/>

  4. #4

    Default

    Yes i have the component-scan tag in my config file, i just posted part of my configuration (the problematic one). As I mentioned all the beans are correctly discovered when run inside the webserver. I am trying to load the same configuration from a standalone java app.

    Thanks

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •