Announcement Announcement Module
Collapse
No announcement yet.
java.lang.ClassCastException Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • java.lang.ClassCastException

    Hi, I get the following exception.What should I do to solve this error??Please help.I wonder whts with the "QueueChannel" in the exception??

    Main Method:

    Code:
    ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("SI.xml", GidSI.class);
    
    // Compose the XML message according to the server's schema
    String requestXml =
    "<hr:CompanyRequest xmlns:hr=\"http://mycompany.com/hr/schemas\">" +
    "<hr:Company>"+
    "<hr:CompanyName>TestRequest</hr:CompanyName>"+
    "</hr:Company>"+
    "</hr:CompanyRequest>";
    
    // Create the Message object
    // In this case the service expects a SoapAction header
    Message<String> message = MessageBuilder.withPayload(requestXml)
    	.setHeader(AbstractWebServiceOutboundGateway.SOAP_ACTION_PROPERTY_KEY, "http://mycompany.com/hr/schemas")
    		.build();
    // Send the Message to the handler's input channel
    ((MessageChannel)context.getBean("sendChannel")).send(message);
    	}
    }
    Exception:

    Code:
    Exception in thread "main" java.lang.ClassCastException: org.springframework.integration.channel.QueueChannel
    	at org.springframework.integration.bus.DefaultMessageBus.registerChannels(DefaultMessageBus.java:152)
    	at org.springframework.integration.bus.DefaultMessageBus.onApplicationEvent(DefaultMessageBus.java:407)
    	at org.springframework.context.event.SimpleApplicationEventMulticaster$1.run(SimpleApplicationEventMulticaster.java:78)
    	at org.springframework.core.task.SyncTaskExecutor.execute(SyncTaskExecutor.java:49)
    	at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:76)
    	at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:274)
    	at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:736)
    	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:383)
    	at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:197)
    	at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:172)
    	at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:158)
    	at org.springframework.integration.rc.GidSI.main(GidSI.java:22)
    

  • #2
    Can you add SI.xml to the post?

    Comment


    • #3
      SI.xml

      Code:
      <message-bus/>
      <channel id="sendChannel"/>
      <ws:outbound-gateway id="WebServiceGateway"
      				         request-channel="sendChannel" 
      				         reply-channel="WebServiceReceiveChannel"
      				    uri="http://localhost:8080/Trial1/companyservice"/>
      
      	
      <jms:outbound-gateway request-channel="WebServiceReceiveChannel" connection-factory="connectionFactory" jms-queue="HelloQueue"/>
          
      <beans:bean id="connectionFactory" class="org.springframework.jms.connection.SingleConnectionFactory">
      		<beans:property name="targetConnectionFactory">
      			<beans:bean class="org.apache.activemq.ActiveMQConnectionFactory">
      				<beans:property name="brokerURL" value="tcp://localhost:61616"/>		
      			</beans:bean>
      		</beans:property>
      	</beans:bean>
      	
      <beans:bean id="HelloQueue" class="org.apache.activemq.command.ActiveMQQueue">
      <beans:constructor-arg value="HelloQueueWorlds" />
      </beans:bean>

      Comment


      • #4
        Hmmm that error doesn't look too good. Can you create a JIRA issue for this?

        Comment


        • #5
          Before you post an issue on JIRA, can you describe what version you are using?

          The first thing I noticed (also based on other questions you've been raising) is that the configuration is for RC1 (with the 'ws' namespace's 'outbound-gateway' element). However, that stack trace is clearly not RC1 (there is no DefaultMessageBus for example).

          Comment


          • #6
            I was using M6 before and latter I tried to change the same code with RCI.May be would be the problem with jars m6 and RC1 together. After tht I created a fresh project and tried to run the same code with RCI jars alone and this ClassCastException disappeared but I have the below Exception (as taked b4)still when using jms outbound gateway
            Code:
            HTTP ERROR: 500
            
            javax.jms.JMSException: Failed to build body from bytes. Reason: java.io.IOException: org.springframework.integration.message.GenericMessage
            RequestURI=/admin/message.jsp
            
            javax.el.ELException: javax.jms.JMSException: Failed to build body from bytes. Reason: java.io.IOException: org.springframework.integration.message.GenericMessage
            I dont understand this exception cos I tried to check what class it returns and it gave me the below Class. Im using these two packages:
            Code:
            import org.springframework.integration.core.Message;
            import org.springframework.integration.core.MessageChannel;
            Code:
            Message<String> message = MessageBuilder.withPayload(requestXml)
            			.setHeader(AbstractWebServiceOutboundGateway.SOAP_ACTION_PROPERTY_KEY, "http://mycompany.com/hr/schemas").build();
            
            System.out.println(message.getClass());
            Returned Class:
            Code:
            class org.springframework.integration.message.GenericMessage
            Last edited by ashleyvijay; Nov 6th, 2008, 09:10 AM.

            Comment


            • #7
              I was using M6 before and latter I tried to change the same code with RCI.May be would be the problem with jars m6 and RC1 together. After tht I created a fresh project and tried to run the same code with RCI jars alone and this ClassCastException disappeared but I have the below Exception (as taked b4)still when using jms outbound gateway
              Well, in this case using two versions of the same library in the same project is definitely not a good idea ...
              Last edited by mbogoevici; Nov 6th, 2008, 09:03 AM. Reason: fixing format

              Comment


              • #8
                Originally posted by mbogoevici View Post
                Well, in this case using two versions of the same library in the same project is definitely not a good idea ...
                Yes I totally agree with u!

                Comment

                Working...
                X