You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by xiangqiuzhao <xi...@gmail.com> on 2011/07/13 17:24:59 UTC
why camel-context.xml can't find in my j2ee project?
i import camel-mina components into myeclipse as a maven project. and write a
test Class like this:
public class SocketTest {
public static void main(String args[]) throws Exception {
CamelContext context = new DefaultCamelContext();
context.addRoutes(new RouteBuilder() {
public void configure() throws Exception {
from("mina:tcp://localhost:9999?textline=true&sync=true")
.choice()
.when(body().isNotNull())
.convertBodyTo(String.class)
.process(new SampleTextProcessor());
}
});
context.start();
Thread.sleep(1000000);
context.stop();
}
}
the project directory tree like this:
http://camel.465427.n5.nabble.com/file/n4583039/2011-07-13_231800.jpg
the camel-context.xml:
<bean id="sampleTextProcessor"
class="com.sunyard.bpsp.channel.test.SampleTextProcessor">
</bean>
it's running very fine,but when i create new j2ee project in myeclipse, and
copy some dependencies jars into project, and create the same test class and
camel-context.xml in the similar place. but exception like this:
Exception in thread "main" org.apache.camel.FailedToCreateRouteException:
Failed to create route route1 at: >>> Choice[[When[{body is not null} ->
[convertBodyTo[java.lang.String], process[ref:sampleTextProcessor]]]]] <<<
in route: Route[[From[mina:tcp://localhost:9999?textline=true&sync=tru...
because of registry entry called sampleTextProcessor must be specified on:
process[ref:sampleTextProcessor]
at
org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:815)
at
org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:165)
at
org.apache.camel.impl.DefaultCamelContext.startRoute(DefaultCamelContext.java:706)
at
org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:1643)
at
org.apache.camel.impl.DefaultCamelContext.doStartCamel(DefaultCamelContext.java:1432)
at
org.apache.camel.impl.DefaultCamelContext.doStart(DefaultCamelContext.java:1336)
at org.apache.camel.impl.ServiceSupport.start(ServiceSupport.java:67)
at org.apache.camel.impl.ServiceSupport.start(ServiceSupport.java:54)
at
org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:1314)
at
com.sunyard.bpsp.channel.test.FileCopierWithCamel.main(FileCopierWithCamel.java:25)
Caused by: java.lang.IllegalArgumentException: registry entry called
sampleTextProcessor must be specified on: process[ref:sampleTextProcessor]
at org.apache.camel.util.ObjectHelper.notNull(ObjectHelper.java:293)
at
org.apache.camel.model.ProcessDefinition.createProcessor(ProcessDefinition.java:89)
at
org.apache.camel.model.ProcessorDefinition.createOutputsProcessor(ProcessorDefinition.java:368)
at
org.apache.camel.model.ProcessorDefinition.createOutputsProcessor(ProcessorDefinition.java:136)
at
org.apache.camel.impl.DefaultRouteContext.createProcessor(DefaultRouteContext.java:106)
at
org.apache.camel.model.ProcessorDefinition.createChildProcessor(ProcessorDefinition.java:155)
at
org.apache.camel.model.ExpressionNode.createFilterProcessor(ExpressionNode.java:100)
at
org.apache.camel.model.WhenDefinition.createProcessor(WhenDefinition.java:69)
at
org.apache.camel.model.ChoiceDefinition.createProcessor(ChoiceDefinition.java:71)
at
org.apache.camel.model.ProcessorDefinition.makeProcessor(ProcessorDefinition.java:410)
at
org.apache.camel.model.ProcessorDefinition.addRoutes(ProcessorDefinition.java:181)
at
org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:812)
how the camel-context.xml be found?
--
View this message in context: http://camel.465427.n5.nabble.com/why-camel-context-xml-can-t-find-in-my-j2ee-project-tp4583039p4583039.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: why camel-context.xml can't find in my j2ee project?
Posted by Willem Jiang <wi...@gmail.com>.
You may need to use spring context listener to load the camel-context.xml.
On 7/13/11 11:24 PM, xiangqiuzhao wrote:
> i import camel-mina components into myeclipse as a maven project. and write a
> test Class like this:
>
> public class SocketTest {
> public static void main(String args[]) throws Exception {
> CamelContext context = new DefaultCamelContext();
> context.addRoutes(new RouteBuilder() {
> public void configure() throws Exception {
> from("mina:tcp://localhost:9999?textline=true&sync=true")
> .choice()
> .when(body().isNotNull())
> .convertBodyTo(String.class)
> .process(new SampleTextProcessor());
> }
> });
> context.start();
> Thread.sleep(1000000);
> context.stop();
> }
> }
>
>
> the project directory tree like this:
>
> http://camel.465427.n5.nabble.com/file/n4583039/2011-07-13_231800.jpg
>
> the camel-context.xml:
> <bean id="sampleTextProcessor"
> class="com.sunyard.bpsp.channel.test.SampleTextProcessor">
> </bean>
>
>
> it's running very fine,but when i create new j2ee project in myeclipse, and
> copy some dependencies jars into project, and create the same test class and
> camel-context.xml in the similar place. but exception like this:
>
> Exception in thread "main" org.apache.camel.FailedToCreateRouteException:
> Failed to create route route1 at:>>> Choice[[When[{body is not null} ->
> [convertBodyTo[java.lang.String], process[ref:sampleTextProcessor]]]]]<<<
> in route: Route[[From[mina:tcp://localhost:9999?textline=true&sync=tru...
> because of registry entry called sampleTextProcessor must be specified on:
> process[ref:sampleTextProcessor]
> at
> org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:815)
> at
> org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:165)
> at
> org.apache.camel.impl.DefaultCamelContext.startRoute(DefaultCamelContext.java:706)
> at
> org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:1643)
> at
> org.apache.camel.impl.DefaultCamelContext.doStartCamel(DefaultCamelContext.java:1432)
> at
> org.apache.camel.impl.DefaultCamelContext.doStart(DefaultCamelContext.java:1336)
> at org.apache.camel.impl.ServiceSupport.start(ServiceSupport.java:67)
> at org.apache.camel.impl.ServiceSupport.start(ServiceSupport.java:54)
> at
> org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:1314)
> at
> com.sunyard.bpsp.channel.test.FileCopierWithCamel.main(FileCopierWithCamel.java:25)
> Caused by: java.lang.IllegalArgumentException: registry entry called
> sampleTextProcessor must be specified on: process[ref:sampleTextProcessor]
> at org.apache.camel.util.ObjectHelper.notNull(ObjectHelper.java:293)
> at
> org.apache.camel.model.ProcessDefinition.createProcessor(ProcessDefinition.java:89)
> at
> org.apache.camel.model.ProcessorDefinition.createOutputsProcessor(ProcessorDefinition.java:368)
> at
> org.apache.camel.model.ProcessorDefinition.createOutputsProcessor(ProcessorDefinition.java:136)
> at
> org.apache.camel.impl.DefaultRouteContext.createProcessor(DefaultRouteContext.java:106)
> at
> org.apache.camel.model.ProcessorDefinition.createChildProcessor(ProcessorDefinition.java:155)
> at
> org.apache.camel.model.ExpressionNode.createFilterProcessor(ExpressionNode.java:100)
> at
> org.apache.camel.model.WhenDefinition.createProcessor(WhenDefinition.java:69)
> at
> org.apache.camel.model.ChoiceDefinition.createProcessor(ChoiceDefinition.java:71)
> at
> org.apache.camel.model.ProcessorDefinition.makeProcessor(ProcessorDefinition.java:410)
> at
> org.apache.camel.model.ProcessorDefinition.addRoutes(ProcessorDefinition.java:181)
> at
> org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:812)
>
> how the camel-context.xml be found?
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/why-camel-context-xml-can-t-find-in-my-j2ee-project-tp4583039p4583039.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
--
Willem
----------------------------------
FuseSource
Web: http://www.fusesource.com
Blog: http://willemjiang.blogspot.com (English)
http://jnn.javaeye.com (Chinese)
Twitter: willemjiang
Weibo: willemjiang
Re: why camel-context.xml can't find in my j2ee project?
Posted by Claus Ibsen <cl...@gmail.com>.
The camel-context.xml file should be in src/main/resources and not
src/main/java.
On Wed, Jul 13, 2011 at 5:24 PM, xiangqiuzhao <xi...@gmail.com> wrote:
> i import camel-mina components into myeclipse as a maven project. and write a
> test Class like this:
>
> public class SocketTest {
> public static void main(String args[]) throws Exception {
> CamelContext context = new DefaultCamelContext();
> context.addRoutes(new RouteBuilder() {
> public void configure() throws Exception {
> from("mina:tcp://localhost:9999?textline=true&sync=true")
> .choice()
> .when(body().isNotNull())
> .convertBodyTo(String.class)
> .process(new SampleTextProcessor());
> }
> });
> context.start();
> Thread.sleep(1000000);
> context.stop();
> }
> }
>
>
> the project directory tree like this:
>
> http://camel.465427.n5.nabble.com/file/n4583039/2011-07-13_231800.jpg
>
> the camel-context.xml:
> <bean id="sampleTextProcessor"
> class="com.sunyard.bpsp.channel.test.SampleTextProcessor">
> </bean>
>
>
> it's running very fine,but when i create new j2ee project in myeclipse, and
> copy some dependencies jars into project, and create the same test class and
> camel-context.xml in the similar place. but exception like this:
>
> Exception in thread "main" org.apache.camel.FailedToCreateRouteException:
> Failed to create route route1 at: >>> Choice[[When[{body is not null} ->
> [convertBodyTo[java.lang.String], process[ref:sampleTextProcessor]]]]] <<<
> in route: Route[[From[mina:tcp://localhost:9999?textline=true&sync=tru...
> because of registry entry called sampleTextProcessor must be specified on:
> process[ref:sampleTextProcessor]
> at
> org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:815)
> at
> org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:165)
> at
> org.apache.camel.impl.DefaultCamelContext.startRoute(DefaultCamelContext.java:706)
> at
> org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:1643)
> at
> org.apache.camel.impl.DefaultCamelContext.doStartCamel(DefaultCamelContext.java:1432)
> at
> org.apache.camel.impl.DefaultCamelContext.doStart(DefaultCamelContext.java:1336)
> at org.apache.camel.impl.ServiceSupport.start(ServiceSupport.java:67)
> at org.apache.camel.impl.ServiceSupport.start(ServiceSupport.java:54)
> at
> org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:1314)
> at
> com.sunyard.bpsp.channel.test.FileCopierWithCamel.main(FileCopierWithCamel.java:25)
> Caused by: java.lang.IllegalArgumentException: registry entry called
> sampleTextProcessor must be specified on: process[ref:sampleTextProcessor]
> at org.apache.camel.util.ObjectHelper.notNull(ObjectHelper.java:293)
> at
> org.apache.camel.model.ProcessDefinition.createProcessor(ProcessDefinition.java:89)
> at
> org.apache.camel.model.ProcessorDefinition.createOutputsProcessor(ProcessorDefinition.java:368)
> at
> org.apache.camel.model.ProcessorDefinition.createOutputsProcessor(ProcessorDefinition.java:136)
> at
> org.apache.camel.impl.DefaultRouteContext.createProcessor(DefaultRouteContext.java:106)
> at
> org.apache.camel.model.ProcessorDefinition.createChildProcessor(ProcessorDefinition.java:155)
> at
> org.apache.camel.model.ExpressionNode.createFilterProcessor(ExpressionNode.java:100)
> at
> org.apache.camel.model.WhenDefinition.createProcessor(WhenDefinition.java:69)
> at
> org.apache.camel.model.ChoiceDefinition.createProcessor(ChoiceDefinition.java:71)
> at
> org.apache.camel.model.ProcessorDefinition.makeProcessor(ProcessorDefinition.java:410)
> at
> org.apache.camel.model.ProcessorDefinition.addRoutes(ProcessorDefinition.java:181)
> at
> org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:812)
>
> how the camel-context.xml be found?
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/why-camel-context-xml-can-t-find-in-my-j2ee-project-tp4583039p4583039.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
--
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/
Re: why camel-context.xml can't find in my j2ee project?
Posted by xiangqiuzhao <xi...@gmail.com>.
not a .ear file, just a main program, run as java application.and classpath
is the jars copied from all camel-core and camel-mina dependency in
WEB-INF/lib .
but the same main program is running fine in mina maven project. i don't
know what's the difference?
--
View this message in context: http://camel.465427.n5.nabble.com/why-camel-context-xml-can-t-find-in-my-j2ee-project-tp4583039p4594303.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: why camel-context.xml can't find in my j2ee project?
Posted by Claus Ibsen <cl...@gmail.com>.
On Thu, Jul 14, 2011 at 6:56 AM, xiangqiuzhao <xi...@gmail.com> wrote:
> i means it's successful in camel-mina maven project, but exception in my j2ee
> project.
>
By J2EE project you mean that you assemble a .ear file?
If so you would need to have the .ear file bootstrap Spring so it can
load the camel-context.xml file.
Google how to do this as its not a Camel specific feature/issue
If you do not need J2EE, then you may consider using a .war file. They
are much easier to work with and use.
All you need is a web.xml file to bootstrap Spring and there you go. A
.war file can also be deployed in JEE servers.
See
http://camel.apache.org/tutorial-on-using-camel-in-a-web-application.html
> in camel-mina project the camel-context.xml at
> camel-mina\target\test-classes. and in camel-mina project i have not use
> spring to load the context file. why in my j2ee project it's fail?
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/why-camel-context-xml-can-t-find-in-my-j2ee-project-tp4583039p4585338.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
--
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/
Re: why camel-context.xml can't find in my j2ee project?
Posted by xiangqiuzhao <xi...@gmail.com>.
i means it's successful in camel-mina maven project, but exception in my j2ee
project.
in camel-mina project the camel-context.xml at
camel-mina\target\test-classes. and in camel-mina project i have not use
spring to load the context file. why in my j2ee project it's fail?
--
View this message in context: http://camel.465427.n5.nabble.com/why-camel-context-xml-can-t-find-in-my-j2ee-project-tp4583039p4585338.html
Sent from the Camel - Users mailing list archive at Nabble.com.