Announcement Announcement Module
Collapse
No announcement yet.
"Method-not-found-exception" given for DirectChannel-->send method in SI 2.1.3 Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • "Method-not-found-exception" given for DirectChannel-->send method in SI 2.1.3

    ApplicationContext context = new ClassPathXmlApplicationContext("/applicationContextSI.xml",this.getClass());
    DirectChannel inputChannel = new DirectChannel();
    QueueChannel outputChannel = new QueueChannel();
    inputChannel= (DirectChannel) context.getBean("inputChannel",DirectChannel.class );
    MyMessageHandler handler = new MyMessageHandler() ;
    inputChannel.subscribe(handler);
    outputChannel = (QueueChannel) context.getBean("outputChannel",QueueChannel.class );
    //("Class name of the typecast object"+inputChannel.getClass().getName());
    inputChannel.send(new StringMessage<String>(request.getCompanyName()));


    Getting exception for both the subscribe and send method call

  • #2
    Hi!
    Not enough info...
    Isn't your other post a part of this one?

    Comment


    • #3
      Hello ,

      The other one is different. here I am trying to call send method from DirectChannel object and getting method not found exception.

      Comment


      • #4
        to call send method from DirectChannel object and getting method not found exception
        it's very strange...
        Although... What is StringMessage? Spring Integration doesn't have similar class, so your compiler can't find appropriate method from DirectChannel.
        Let me guess: tha same is to MyMessageHandler, who isn't instance of org.springframework.integration.core.MessageHandle r

        Comment


        • #5
          hi,
          StringMessage class is created by me extending from Message<T> class. does that work ? or what is the solution ?

          Comment


          • #6
            StringMessage class is created by me extending from Message<T> class.
            No, it's bad idea.
            You should use MessageBuilder for generic Messages.
            Message in the Spring Integration is immutable object for some internal reason.
            From other side org.springframework.integration.Message is interface.
            Are you sure, that you are using correct one for your extending?
            Nevertheless never mind: don't implement Message on your own at all.

            Comment


            • #7
              Used the following
              inputChannel.send( MessageBuilder.withPayload(request.getCompanyName( ))
              .setHeader("foo", "bar")
              .build());

              but getting following error

              "Error creating bean with name 'org.springframework.integration.selector.PayloadT ypeSelector#0': Unsatisfied dependency expressed through constructor argument with index 0 of type [java.lang.Class[]]: Could not convert constructor argument value of type [[Ljava.lang.String;] to required type [[Ljava.lang.Class;]: Failed to convert value of type 'java.lang.String[]' to required type 'java.lang.Class[]'; nested exception is java.lang.IllegalArgumentException: Cannot find class [org.spring]"

              Comment


              • #8
                It's new issue of your config...
                Show your <payload-type-router>.
                Nevertheless looks like you need to study more about Spring Core and Java at all...

                Comment


                • #9
                  Corrected the configuration file. But still getting the following

                  org.springframework.web.util.NestedServletExceptio n: Request processing failed; nested exception is java.lang.NoSuchMethodError: org.springframework.integration.channel.DirectChan nel.send(Lorg/springframework/integration/Message

                  Yes I am migrated to Java-Spring technology and basically from C++ tech. Given to evaluate ESB(s) to choose among Mule, SI , OSB etc. Gradually I am loosing interest on SI as I the product might be still unstable.

                  Comment


                  • #10
                    .DirectChan nel.send(Lorg/springframework/integration/Message
                    It means that you are trying to invoke this method with array argument...
                    For beginners in the SI we recommend fully start from XML and don't use internal API directly like DirectChannel.send.
                    For this purpose there is a Gateway pattern: http://static.springsource.org/sprin...ingle/#gateway

                    Comment


                    • #11
                      Please show the code where you are calling the send method now that you have presumably changed from using your own implementation of Message.

                      I can assure you that this is not a matter of instability... Let's get to the bottom of the issue in your code.

                      Comment


                      • #12
                        By the way: how do you compile your project?
                        We observe here many compilation errors...

                        Comment


                        • #13
                          I changed the code as following

                          Message<String> message1 =MessageBuilder.withPayload(request.getCompanyName ())
                          .setHeader("foo", "bar")
                          .build() ;
                          Message<String> message2 = MessageBuilder.fromMessage(message1).build();
                          inputChannel.send( message2);


                          but still getting another error

                          "The server encountered an internal error () that prevented it from fulfilling this request.</u></p><p><b>exception</b> <pre>org.springframework.web.util.NestedServletExc eption: Request processing failed; nested exception is java.lang.IncompatibleClassChangeError: Class org.springframework.integration.message.GenericMes sage does not implement the requested interface org.springframework.integration.Message"

                          Kindly help.

                          Comment


                          • #14
                            I build the code using Maven.

                            Comment


                            • #15
                              Let me share the complete code :

                              My application context file

                              <?xml version="1.0" encoding="UTF-8"?>

                              <beans:beans xmlns="http://www.springframework.org/schema/integration"
                              xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                              xmlns:beans="http://www.springframework.org/schema/beans"
                              xsi:schemaLocation="http://www.springframework.org/schema/beans
                              http://www.springframework.org/schem...ring-beans.xsd
                              http://www.springframework.org/schema/integration
                              http://www.springframework.org/schema/integration/spring-integration.xsd">

                              <!--
                              <context:component-scan
                              base-package="org.springframework.integration.MessageCh annel">
                              </context:component-scan>
                              <context:component-scan
                              base-package="org.springframework.integration.core.Poll ableChannel">
                              </context:component-scan>
                              -->
                              <channel id="inputChannel">
                              </channel>

                              <channel id="outputChannel">
                              <queue capacity="100"/>
                              </channel>
                              <!--
                              <payload-type-router input-channel="routingChannel">
                              <mapping type="java.lang.String" channel="inputChannel" />
                              <mapping type="java.lang.String" channel="outputChannel" />
                              </payload-type-router>
                              -->
                              <service-activator id="advicedSa" input-channel="inputChannel" ref="getcompcount"
                              method="getCompanyCountName" output-channel="outputChannel">

                              </service-activator>



                              <beans:bean id="getcompcount"
                              class="com.medq.org.OrganizationBOBean" />


                              </beans:beans>


                              My Code :

                              public GetCompanyCountByNameResponse getCompanyCountByName(GetCompanyCountByNameRequest request) {
                              // return organizationBO.getCompanyCountName(request);
                              ApplicationContext context = new ClassPathXmlApplicationContext("/applicationContextSI.xml",this.getClass());
                              DirectChannel inputChannel = new DirectChannel();
                              QueueChannel outputChannel = new QueueChannel();
                              inputChannel= (DirectChannel) context.getBean("inputChannel",DirectChannel.class );
                              // MyMessageHandler handler = new MyMessageHandler() ;
                              // inputChannel.subscribe(handler);
                              outputChannel = (QueueChannel) context.getBean("outputChannel",QueueChannel.class );
                              // ("Class name of the typecast object"+inputChannel.getClass().getName());
                              // inputChannel.send(new StringMessage<String>(request.getCompanyName()));
                              Message<String> message1 =MessageBuilder.withPayload(request.getCompanyName ())
                              .setHeader("foo", "bar")
                              .build() ;
                              Message<String> message2 = MessageBuilder.fromMessage(message1).build();
                              inputChannel.send( message2);

                              // Message<?> reply = output.receive();

                              GetCompanyCountByNameResponse Resp = JAXB_OBJECT_FACTORY.createGetCompanyCountByNameRes ponse();
                              Resp.setCompanyCount("ff"+outputChannel.receive(0) .getPayload());

                              return Resp ;

                              }

                              Please help.

                              Comment

                              Working...
                              X