Results 1 to 8 of 8

Thread: java.lang.ClassCastException

  1. #1
    Join Date
    Sep 2008
    Location
    Mannheim,Germany
    Posts
    125

    Exclamation 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. #2
    Join Date
    May 2007
    Location
    Netherlands
    Posts
    614

    Default

    Can you add SI.xml to the post?

  3. #3
    Join Date
    Sep 2008
    Location
    Mannheim,Germany
    Posts
    125

    Default

    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>

  4. #4
    Join Date
    May 2007
    Location
    Netherlands
    Posts
    614

    Default

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

  5. #5
    Join Date
    Oct 2005
    Location
    Boston, MA
    Posts
    2,840

    Default

    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).

  6. #6
    Join Date
    Sep 2008
    Location
    Mannheim,Germany
    Posts
    125

    Question

    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 at 09:10 AM.

  7. #7
    Join Date
    Oct 2007
    Location
    Toronto, ON
    Posts
    90

    Default

    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 at 09:03 AM. Reason: fixing format
    Marius Bogoevici,
    Spring Integration Committer

  8. #8
    Join Date
    Sep 2008
    Location
    Mannheim,Germany
    Posts
    125

    Wink

    Quote 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!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •