Apache Camel integration with Activiti6 beta4 - spring

I'm trying to use Camel with Activiti6 beta4 using only the UI (activiti-app).
But in the log of the execution of my process model I get the error:
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'myContext' is defined
It seems that the UI is unable to find my applicationContext.xml and/or "myContext" (the camel context inside applicationContext.xml).
My applicationContext.xml is in the /WEB-INF and has this content:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:camel="http://camel.apache.org/schema/spring"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">
<camelContext id="myContext" xmlns="http://camel.apache.org/schema/spring">
<route>
:::::::MY ROUTE::::::
</route>
</camelContext>
</beans>
Would anyone tell me what is missing?
The name and location of "applicationContext.xml" are correct?
TIA,
Wanderlan

I can't speak to using Activiti 6 beta with Camel, but I have it working on th 5.x engine and Activiti Enterprise Edition (with some hacking).
The default Camel Context that is installed is called camelContext, I see you have declared a Camel context called myContext. For some reason that bean has not instantiated or cannot be found.
Try using he default id of camelContext and see if your behavior changes.
Greg

Related

Where is hided <context:annotation-config/> in spring boot?

To work via annotations in Spring need to define:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd"
xmlns:context="http://www.springframework.org/schema/context">
<context:annotation-config/>
</beans>
at
annotation-config.xml
But I created a simplest Spring boot Application (lets say I select lust Web in initialazr)
It works on annotations but there isn't any annotation-config.xml there and nor mentioning of ,
where is hidden?
You only need to add <context:annotation-config /> or <context:component-scan /> (which implies annotation driven config) when using an ApplicationContext implementation that doesn't support annotations out-of-the-box.
When only using XML based configuration you also use one of the XML enabled ApplicationContext implementations, generally that would be XmlWebApplicationContext. With these you would need to instruct the ApplicationContext to enable annotation processing.
When using Java based configuration you generally use an annotation based ApplicationContext, default would be AnnotationConfigWebApplicationContext. Due to its nature of processing Java configuration classes it has annotation processing enabled by default.
Spring Boot uses the latter (it actually uses a specialized subclass for this). Hence you don't need to explicitly enable it.

Spring claiming that identical classnames are different

I'm making my first forays into spring and am getting the following error trying to run on eclipse:
org.springframework.beans.factory.BeanNotOfRequiredTypeException: Bean named 'model' must be of type [com.myCompany.project.Model], but was actually of type [com.myCompany.project.Model]
Code causing the exception:
import com.myCompany.project.Model;
// some code
public Model getModel() {
ClassPathXmlApplicationContext applicationContext =
new ClassPathXmlApplicationContext("client-context.xml");
return applicationContext.getBean("model", Model.class);
}
Spring xml:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:p="http://www.springframework.org/schema/p"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">
<context:annotation-config />
<bean id="model" class="com.myCompany.project.Model" />
</beans>
The client-context.xml is located in project/resources, the code in project/src/main/
I assume this is a classpath issue, but I am at a loss as to what to do to fix it.
Java and Spring are case sensitive. This:
<bean id="model" class="com.myCompany.project.model" />
is not the same as this:
<bean id="model" class="com.myCompany.project.Model" />
I'd think about some better names. Those aren't very insightful.
I don't like the way you're going about this. You shouldn't have a bean that has to access the app context this way. You'll have to post more code to be sure, but you ought to be wiring that model bean into object that wants it, not doing what you're doing.
The only reason for doing what you're proposing is if the bean interacting with the app context is creating using new rather than the Spring bean factory. Since you're just starting with Spring, I would recommend letting Spring handle all dependencies.

Using spring together with jbossws-cxf on jboss 6

I want to use spring together with jbossws-cxf. Is this possible?
First I tried using jbossws-cxf.xml with bean definitions of spring. The warning message [DescriptorDeploymentAspect] Spring not available, skipping check for user provided jbossws-cxf.xml / cxf.xml configuration files. states that the file gets ignored and means that you should install spring in order for it to not get ignored :-) . So I installed spring for jboss..
After installation and running of a simple MathWS together with a simple WS example I get a
[org.jboss.wsf.stack.cxf.client.configuration.JBossWSSpringBusFactory] INITIAL_APP_CONTEXT_CREATION_FAILED_MSG: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.apache.cxf.binding.soap.customEditorConfigurer' defined in URL [vfs:/D:/lifeDevSuite/jboss/jboss-6.0.0.FinalSpring/common/lib/cxf-rt-bindings-soap.jar/META-INF/cxf/cxf-extension-soap.fixml]: Initialization of bean failed; nested exception is org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type 'java.util.ArrayList' to required type 'org.springframework.beans.PropertyEditorRegistrar[]' for property 'propertyEditorRegistrars'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [org.apache.cxf.binding.soap.spring.SoapVersionRegistrar] to required type [org.springframework.beans.PropertyEditorRegistrar] for property 'propertyEditorRegistrars[0]': no matching editors or conversion strategy found
error.
My jbossws-cxf.xml looks like this:
`
<beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:jaxws="http://cxf.apache.org/jaxws"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://cxf.apache.org/jaxws
http://cxf.apache.org/schemas/jaxws.xsd">
<bean id="mathBean" class="com.sample.MathWS">
<constructor-arg value="alabama" />
</bean>
<jaxws:endpoint id="MathWSX" implementor="#mathBean" address="http://localhost:8080/HelloCXF" />
`
I solved the problem. Sadly - I cannot recall how. And please forgive me - but I'm not going back to try and reproduce it :-)
Basically the answer is "yes". To that specific problem, it may have been a namespace problem, e.g. correct would be
<beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:jaxws="http://cxf.apache.org/jaxws"
xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/util
http://www.springframework.org/schema/util/spring-util-2.5.xsd
http://cxf.apache.org/jaxws
http://cxf.apache.org/schemas/jaxws.xsd">
It may have been as well that custom spring libraries were deployed (I think it is recommended using the spring libraries coming with jboss and are deployed dynamically automagically)
It may have been something else alltogether

404 when adding beans in the applicationContext xml file

I'm trying to learn Spring, Hibernate and Webflow.
Why is it that when I add beans to my applicationContext i get a 404 when I run the project.
Here's my context config:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd">
<bean id="roleService" name="roleService" class="ws.Service.RoleServiceImp" />
</beans>
Now when I add another bean, it goes 404. I'm not sure what's wrong. i.e:
<bean id="userService" name="userService" class="ws.Service.UserServiceImp" />
Am I missing something? Any help will be appreciated.
If an Web Spring Application can not start, for example if the context-xml contains a bean that does not exist, or a syntax error, then Spring will not "start" the context.
If you have a spring web application and the application does not start then, the whole spring web request handling stuff does not too. And when you not try to access an web page normally handled by the spring controllers the web server can not found this handler, so the web server says: not found - 404.
that is the answer to your question: "Why is it that when I add beans to my applicationContext i get a 404 when I run the project."
Anyway I believe you are more interested in why the application did not start:
have a look in the logs, there must be a stack trace
if you did not find the problem, with help of the stack trace, then add it to your question (or ask a new one).

Why does my Spring AOP aspect work in my unit test but not my webapp?

I have an aspect working correctly in my unit tests, a log message is printed from the actual method, and afterwards from the aspect applied.
When running my webapp though, I only see the result of the '#afterReturning' advice applied, my method does not execute first.
My config:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.0.xsd">
<aop:aspectj-autoproxy proxy-target-class="true" />
<bean id="loggingAspect" class="com.mypackage.MyAspect" />
</beans>
Any ideas ?
Thanks for your help.
Information you provided in not enough to analyze. So check below things in your web app,
1) Verify that the method you are expecting to be intercepted by your advice, belongs to spring bean class & not some other servlet or other class defined outside spring. If any class is not initialized through spring then aop advice can not be applied to that class.
2) Verify that above aop & advice configs are put in proper context xml for spring. Like in case of spring-mvc, you have to explicitely define the name of your application context xml. And in that application context xml only you have to write aop configurations.
3) Verify if your pointcut is appropriate to find exact class & method for advice.
See if these things are in place.

Resources