Results 1 to 5 of 5

Thread: Not able to create RmiProxyFactoryBean

  1. #1
    Join Date
    Feb 2012
    Posts
    12

    Default Not able to create RmiProxyFactoryBean

    Hi friends,

    I am trying to implement the example on page: http://codetojoy.blogspot.in/2007/12...r-i-heart.html

    in RAD(eclipse). I am able to Run the server program properly but when I trying to run the client program I am getting BeanCreationException when trying to inject RmiProxyFactoryBean object.

    Can anyone please help?

  2. #2
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,629

    Default

    Post code and stacktrace. When doing so use [ code][/code ] tags.
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

  3. #3
    Join Date
    Feb 2012
    Posts
    12

    Default

    Quote Originally Posted by Marten Deinum View Post
    Post code and stacktrace. When doing so use [ code][/code ] tags.

    Here are the service side classes:

    Code:
    package com.service;
    
    public class MathServiceImpl implements MathService {
    
    	@Override
    	public int add(int a, int b) {
    		// TODO Auto-generated method stub
    		return a+b;
    	}
    
    	@Override
    	public int pro(int a, int b) {
    		// TODO Auto-generated method stub
    		return a*b;
    	}
    
    }

    Code:
    package com.service;
    
    import org.springframework.context.ApplicationContext;
    
    public class MathServiceStart {
    
    	public static void main(String[] args) {
    		try {
    
    			ApplicationContext ctx = new ClassPathXmlApplicationContext(
    					"MathService.xml");
    
    		} catch (Exception e) {
    			System.out.println("Inside catch");
    			e.printStackTrace();
    		}
    
    	}
    
    }
    Service XML (MathService.xml)

    Code:
    	<bean id="mathService" class="com.service.MathServiceImpl" />
    	<bean
    		class="org.springframework.remoting.rmi.RmiServiceExporter">
    		
    		<property name="serviceName" value="MathService"/>
    		<property name="service" ref="mathService"/>
    		<property name="serviceInterface" value="com.service.MathService"/>
    		<property name="registryPort" value="9911"/>
    	</bean>
    CLIENT side codes

    Code:
    package com.math.caller;
    
    
    public class MathCaller {
    	
    	private MathService ms;
    
    	public MathService getMs() {
    		return ms;
    	}
    
    	public void setMs(MathService ms) {
    		this.ms = ms;
    	}
    	
    	public void add() {
    		System.out.println(ms.add(10, 20));
    	}
    	
    	public void pro() {
    		System.out.println(ms.pro(5, 25));
    	}
    	
    }
    Code:
    package com.math.caller;
    
    import org.springframework.context.ApplicationContext;
    import org.springframework.context.support.ClassPathXmlApplicationContext;
    
    public class MathCallerClient {
    	
    	public static void main(String[] args) {
    		ApplicationContext bf = new ClassPathXmlApplicationContext("client.xml");
    		MathCaller mc = (MathCaller) bf.getBean("mathCaller");
    		
    		mc.add();
    		mc.pro();
    	}
    
    }

    Client side XML

    Code:
    	<bean id="MathService"
    		class="org.springframework.remoting.rmi.RmiProxyFactoryBean">
    		
    		<property name="serviceUrl" value="rmi://localhost:9911/MathService"/>
    		<property name="serviceInerface" value="com.math.caller.MathService"></property>
    	</bean>
    
    	<bean id="mathCaller" class="com.math.caller.MathCaller">
    		<property name="ms" ref="MathService" />
    	</bean>
    When I am executing MathServiceStart class I am getting no error or exception. But when I am executing to access the RMI service I am getting the following exception.


    Code:
    23 Feb, 2012 7:39:25 AM org.springframework.context.support.AbstractApplicationContext prepareRefresh
    INFO: Refreshing org.springframework.context.support.ClassPathXmlApplicationContext@61b383e9: display name [org.springframework.context.support.ClassPathXmlApplicationContext@61b383e9]; startup date [Thu Feb 23 07:39:25 IST 2012]; root of context hierarchy
    23 Feb, 2012 7:39:25 AM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
    INFO: Loading XML bean definitions from class path resource [client.xml]
    23 Feb, 2012 7:39:25 AM org.springframework.context.support.AbstractApplicationContext obtainFreshBeanFactory
    INFO: Bean factory for application context [org.springframework.context.support.ClassPathXmlApplicationContext@61b383e9]: org.springframework.beans.factory.support.DefaultListableBeanFactory@651dba45
    23 Feb, 2012 7:39:25 AM org.springframework.beans.factory.support.DefaultListableBeanFactory preInstantiateSingletons
    INFO: Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@651dba45: defining beans [MathService,mathCaller]; root of factory hierarchy
    23 Feb, 2012 7:39:25 AM org.springframework.beans.factory.support.DefaultSingletonBeanRegistry destroySingletons
    INFO: Destroying singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@651dba45: defining beans [MathService,mathCaller]; root of factory hierarchy
    Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'MathService' defined in class path resource [client.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'serviceInerface' of bean class [org.springframework.remoting.rmi.RmiProxyFactoryBean]: Bean property 'serviceInerface' is not writable or has an invalid setter method. Did you mean 'serviceInterface'?
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1279)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1010)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:472)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
    	at java.security.AccessController.doPrivileged(Native Method)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
    	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)
    	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
    	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:423)
    	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:728)
    	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:380)
    	at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
    	at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83)
    	at com.math.caller.MathCallerClient.main(MathCallerClient.java:9)
    Caused by: org.springframework.beans.NotWritablePropertyException: Invalid property 'serviceInerface' of bean class [org.springframework.remoting.rmi.RmiProxyFactoryBean]: Bean property 'serviceInerface' is not writable or has an invalid setter method. Did you mean 'serviceInterface'?
    	at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:801)
    	at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:651)
    	at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:78)
    	at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:59)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1276)
    	... 16 more

    Following are my file structures for Client clientproject.jpg and
    Service serverside.jpg

  4. #4
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,629

    Default

    Have you read the stacktrace?

    Code:
    Invalid property 'serviceInerface' of bean class [org.springframework.remoting.rmi.RmiProxyFactoryBean]: Bean property 'serviceInerface' is not writable or has an invalid setter method. Did you mean 'serviceInterface'?
    Context
    Code:
    <bean id="MathService"
    		class="org.springframework.remoting.rmi.RmiProxyFactoryBean">
    		
    		<property name="serviceUrl" value="rmi://localhost:9911/MathService"/>
    		<property name="serviceInerface" value="com.math.caller.MathService"></property>
    	</bean>
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

  5. #5
    Join Date
    Feb 2012
    Posts
    12

    Default

    OMG!!! sorry I'll try it today. Thanks a lot.

Posting Permissions

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