Unable to integrate Factory Pattern along with Spring-Swagger - spring-mvc

I have implemented factory pattern using ServiceLocatorFactoryBean by following this reference.
It is working fine.
I am using swagger-springMVC (SpringFox), It is also working fine.
But, when I am trying to use factory pattern along with swagger then It is throwing below exceptions,
Could not autowire field: org.test.MyProject.MyFactory org.test.MyProject.controller.MyController.myFactory; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [org.test.MyProject.MyFactory] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {#org.springframework.beans.factory.annotation.Autowired(required=true)}
org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:561)
I have tried in all possible ways by following several resources but unable to find a solution. Can anyone please help me resolve this issue?

You need to provide a proper root path in your ComponentScan path. I have faced same kind of issue; after I fixed the ComponentScan path, it is working now as expected.

Related

Configure multiple content stores in Alfresco?

I followed the step given in below link to configure multiple content stores in Alfresco 5.0.d.
http://docs.alfresco.com/5.0/concepts/store-config-fullexample.html
Alfresco instance is not able to start and gives the exeption,
Cannot resolve reference to bean 'storeSelectorContentStore' while setting bean property 'store';
nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: Invalid bean definition with name 'storeSelectorContentStore' defined in file [/opt/alfresco-5.0.d/tomcat/shared/classes/alfresco/extension/content-store-selector-context.xml]:
I also tried the method stated in below link,
https://community.alfresco.com/docs/DOC-5156-content-store-configuration
This gives a different error, alfresco dir root not defined even though it's defined in the properties file.
This is an enterprise only feature. This is why you are getting this error on Community.
Marcus is right about this being an Enterprise only feature, but you could develop your own. It shouldn't be too much of a hassle.
Also, have you tried using this extension, I suspect it has everything you need and is maintained by a well know Alfresco contributor?
https://github.com/Acosix/alfresco-simple-content-stores

How should I add environment properties to my JUnit5 Spring MVC integration test?

I'm writing integration tests using MockMvcBuilders.webAppContextSetup() in JUnit 5.
I'm extending with Sam Brannen's SpringExtension and a MockitoExtension. (Really, I'm using the composed SpringJUnitJupiterWebConfig)
I get this output when running the tests (edited):
java.lang.IllegalStateException: Failed to load ApplicationContext
BeanDefinitionStoreException: Failed to process import candidates for configuration class [com.example.myapp.config.SomeConfig];
Could not resolve placeholder 'someEnvVar' in string value "classpath:/com/example/myapp/config/${someEnvVar}/custom.properties"
(This is in an internal company library on which my application depends.)
Seems clear that I need to set the environment property before the container starts up. But I'm struggling to discover how to hook into that with JUnit5.
I want to add PropertySources to the environment, I assume, but to get the environment, I have to get the application context, and in so doing, it instantiates, erroring out before I can do anything with it.
I tried creating my own extension and getting a handle to the environment during the BeforeAllCallback.
I'm getting the feeling that I'm going about it all wrong and I'm missing something fundamental.
I just needed to use the #TestPropertySource annotation on my test class.

Cannot resolve reference to bean '__dwrConfiguration'

Iam new to Spring MVC with DWR, Iam facing a problem to integrating the Annotation based spring 3.1 and DWR integrating.
while running my application I got an Exception like:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dwrController': Cannot resolve reference to bean '_dwrConfiguration' while setting bean property 'configurators' with key [0]; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named '_dwrConfiguration' is defined.
Please help me what does it means.?
on which conditions we get this type of Exceptions.?
commons-logging-1.1.3,dwr.jar,org.springframework.aop-3.1.0.M1.jar.
i have some doubts regarding DWR configurations,*emphasized text*can any one please help me out.
1.What are the dwr/engine.js and dwr/util.js files, and what they do. where do i found, and where do I configure in my spring application. I referred several tutorials, but i didn't get clarify those tutorials, can any one clarify me briefly.
Thanks in advance.

CDI on GlassFish 3.1.1 b12 generates error "WELD-001408 Unsatisfied dependencies"

I'm trying to evaluate CDI on Glassfish 3.1 and even though I have accomplished to make it work well, when I'm trying to split my code in separate deployment modules I get a weird error. More specifically:
I have two classes bundled in the same utility project (let's say the CommonLib.jar); the classnames are UserDatabase and UserDatabaseEntityManager and their definitions are as below (in the PS at the end of this message).
I also have an EAR with an EJB3.1 module in it.
When I choose to deploy the CommonLib.jar as a "Bundled Library" of the EAR, then I get the following error:
Error occurred during deployment: Exception while loading the app : WELD-001408 Unsatisfied dependencies for type [EntityManager] with qualifiers [#UserDatabase] at injection point [[field] #UserDatabase #Inject com.test.TestEJB.itemPersistenceEm]. Please see server.log for more details.
Same error as above I get also when I deploy the CommonLib.jar as a shared library (jar file copied under $glasshfish_installation_path/domains/domain1/lib)
BUT, if I choose to just have the two classes (UserDatabase and UserDatabaseEntityManager) in the EJB project (thus they are compiled within the EJB module), then the injection works fine.
Am I facing a classloader issue? Any ideas how I can get past this issue?
Just a guess, because I faced a very similar problem with Glassfish and CDI a few days ago: Do you have a beans.xml in every JAR, i.e. in the CommonLib.jar and the EJB JAR, so that CDI scans both of them?
My problem resulted from the fact that I thought placing a beans.xml into the EAR would be sufficient, which is not the case.
Sounds like you're running into some of the Glassfish CDI integration issues we've found while working on Seam 3. It could be a couple of them, so you'll have to take a look at see which one it may be. Try testing on JBoss AS7 or Apache TomEE and see if you still have problems.

which jar contains org.springframework.util.MultiValueMap in spring2.5?

I am using spring2.5. and trying to implement a custom CommonsMultipartResolver for ajax upload.
After I submited form, I got following error:
org.springframework.web.util.NestedServletExceptio n: Handler processing failed; nested exception is java.lang.NoSuchMethodError: org.springframework.web.multipart.commons.CommonsF ileUploadSupport$MultipartParsingResult.getMultipa rtFiles()Lorg/springframework/util/MultiValueMap;
It seems that I need class org.springframework.util.MultiValueMap. But I can not find it anywhere in spring2.5.
Can you tell me which jar contains it?
thanks
It supposed to be in org.springframework.core...jar file, but such class does not exist in Spring 2.5
http://static.springsource.org/spring/docs/2.5.0/api/org/springframework/util/package-summary.html
It was added only in Spring 3.0.x
http://static.springsource.org/spring/docs/3.0.x/javadoc-api/org/springframework/util/package-tree.html
I think you may be mixing versions of spring jars, since the 2.5 version returns a regular Map as parameters to the getMultiPartFiles() method (javadoc). The 3.0.x version uses MultiValueMap (javadoc).
It's not the map type that is missing, but the method. Check that you are using spring-web version that matches the rest of your spring dependencies.

Resources