Results 1 to 10 of 10

Thread: Remote EJB

  1. #1
    Join Date
    Nov 2004
    Posts
    13

    Default Remote EJB

    Hello,
    I was wondering if anyone has a sample program that uses SimpleRemoteStatelessSessionProxyFactoryBean.

    I'm trying to call a remote EJB from a web app, and I can make things work with Local, but for the Remote I have had no success.

    I get property not writable exception for "buinessInterface" property, when I tried on remote. Could someone point me to the right direction or a samples?

    Thanks!!!

  2. #2
    Join Date
    Sep 2004
    Location
    Christchurch, New Zealand
    Posts
    73

    Default

    A detailed explanation of LocalStatelessSessionProxyFactoryBean can be found in:

    http://www.javaworld.com/javaworld/j...ringejb_p.html

    SimpleRemoteStatelessSessionProxyFactoryBean is very similar.

    Chris

  3. #3
    Join Date
    Sep 2004
    Location
    Christchurch, New Zealand
    Posts
    73

  4. #4
    Join Date
    Aug 2004
    Posts
    2,715

    Default Re: Remote EJB

    Quote Originally Posted by jonnyS
    I get property not writable exception for "buinessInterface" property
    Is this just a typo or did you copy it from your error message?. there is missing an 's' (businessInterface).

    If the provided links do not help, maybe you could just post the stacktrace and the part of your configuration containing the remote access.

    Regards,
    Andreas

  5. #5
    Join Date
    Nov 2004
    Posts
    13

    Default

    Here is the config and stack trace.


    <bean id="myService" class="org.springframework.ejb.access.SimpleRemote StatelessSessionProxyFactoryBean">
    <property name="jndiName">
    <value>IService</value>
    </property>
    <property name="businessInterface">
    <value>com.test.IService</value>
    </property>
    </bean>


    [3/22/05 16:25:23:889 EST] 646201d8 WebGroup E SRVE0026E: [Servlet Error]-[Error creating bean with name myService; defined in class path resource [WEB-INF/applicationContext.xml]: Error setting property values&#59; nested exception is org.springframework.beans.PropertyAccessExceptions Exception: PropertyAccessExceptionsException &#40;1 errors&#41;&#59; nested propertyAccessExceptions are: [org.springframework.beans.TypeMismatchException: Failed to convert property value of type [java.lang.String] to required type [java.lang.Class] for property &#39;businessInterface&#39;&#59; nested exception is java.lang.IllegalArgumentException: Invalid class name: com.test.IService]]: org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'myService' defined in class path resource [WEB-INF/applicationContext.xml]: Error setting property values; nested exception is org.springframework.beans.PropertyAccessExceptions Exception: PropertyAccessExceptionsException (1 errors); nested propertyAccessExceptions are: [org.springframework.beans.TypeMismatchException: Failed to convert property value of type [java.lang.String] to required type [java.lang.Class] for property 'businessInterface'; nested exception is java.lang.IllegalArgumentException: Invalid class name: com.test.IService]
    PropertyAccessExceptionsException (1 errors)
    org.springframework.beans.TypeMismatchException: Failed to convert property value of type [java.lang.String] to required type [java.lang.Class] for property 'businessInterface'; nested exception is java.lang.IllegalArgumentException: Invalid class name: com.testIService
    java.lang.IllegalArgumentException: Invalid class name: com.test.IService
    at org.springframework.beans.propertyeditors.ClassEdi tor.setAsText(ClassEditor.java:44)
    at org.springframework.beans.BeanWrapperImpl.doTypeCo nversionIfNecessary(BeanWrapperImpl.java:934)
    at org.springframework.beans.BeanWrapperImpl.setPrope rtyValue(BeanWrapperImpl.java:768)
    at org.springframework.beans.BeanWrapperImpl.setPrope rtyValue(BeanWrapperImpl.java:674)
    at org.springframework.beans.BeanWrapperImpl.setPrope rtyValue(BeanWrapperImpl.java:815)
    at org.springframework.beans.BeanWrapperImpl.setPrope rtyValues(BeanWrapperImpl.java:842)
    at org.springframework.beans.BeanWrapperImpl.setPrope rtyValues(BeanWrapperImpl.java:831)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.applyPropertyValues(Abs tractAutowireCapableBeanFactory.java:831)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.populateBean(AbstractAu towireCapableBeanFactory.java:648)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.createBean(AbstractAuto wireCapableBeanFactory.java:288)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.createBean(AbstractAuto wireCapableBeanFactory.java:223)
    at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:236)
    at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:159)
    at org.springframework.beans.factory.support.DefaultL istableBeanFactory.preInstantiateSingletons(Defaul tListableBeanFactory.java:255)
    at org.springframework.context.support.AbstractApplic ationContext.refresh(AbstractApplicationContext.ja va:317)


    If you can spot anything, I appreciate much!

    Thank you!

  6. #6
    Join Date
    Sep 2004
    Location
    Christchurch, New Zealand
    Posts
    73

    Default

    Is it possible that com.test.IService is mis-spelt or not in the classpath?

    Chris

  7. #7
    Join Date
    Nov 2004
    Posts
    13

    Default

    I'm pretty sure that the class is in the classpath. I was wondering that since they require class type to be passed to the businessInterface property, I need a concrete object name or something...

    I'll double check with the classpath thou. The error message seems pretty specific, so I wondered. Would there be other things that can be wrong about ?

    Thanks again!!

  8. #8
    Join Date
    Sep 2004
    Location
    Christchurch, New Zealand
    Posts
    73

    Default

    This is the source of the class at the root of the stack trace, which I think demonstrates that this is a classpath problem.

    Code:
    public class ClassEditor extends PropertyEditorSupport &#123;
    
    	public void setAsText&#40;String text&#41; throws IllegalArgumentException &#123;
    		try &#123;
    			setValue&#40;ClassUtils.forName&#40;text&#41;&#41;;
    		&#125;
    		catch &#40;ClassNotFoundException ex&#41; &#123;
    			throw new IllegalArgumentException&#40;"Invalid class name&#58; " + ex.getMessage&#40;&#41;&#41;;
    		&#125;
    	&#125;
    
    	public String getAsText&#40;&#41; &#123;
    		Class clazz = &#40;Class&#41; getValue&#40;&#41;;
    		return &#40;clazz.isArray&#40;&#41; ? clazz.getComponentType&#40;&#41;.getName&#40;&#41; + ClassUtils.ARRAY_SUFFIX &#58; clazz.getName&#40;&#41;&#41;;
    	&#125;
    
    &#125;
    Chris

  9. #9
    Join Date
    Nov 2004
    Posts
    13

    Default

    Thank you Chris for being patient with my errors. You are absolutely right on for the cause of error. One thing I'm quickly learning on Spring (somehow especially when working with EJB), the error message seems misleading very often.

    The source code you posted catches the ClassNotFound exception, but put the error message saying "invalid class name". If it actually threw the ClassNotFound exception or wrap the exception with "ClassNotFound" message, I would've known the problem right off the bat.

    Since it threw IlligalArgument exception, it then becomes even harder to find out the real problem. To me these approach seems to hide a real exception.. but is this considered to be a good practice??


    From next time, I think I'll look at the source first to see what exception is being thrown before posting help !

    Any how, thank you again!!



    :o

  10. #10
    Join Date
    Sep 2004
    Location
    Christchurch, New Zealand
    Posts
    73

    Default

    This exception handler might have been better written as follows in order to avoid lossing the ClassNotFoundException.

    Code:
    			catch &#40;ClassNotFoundException ex&#41; &#123;
                            IllegalArgumentException ex2 = new IllegalArgumentException&#40;"Invalid class name&#58; " + ex.getMessage&#40;&#41;&#41;;
    				ex2.initCause&#40;ex&#41;;
    				throw ex2;
    			&#125;
    You could submit this as a defect in JIRA and it might get fixed.

    http://opensource.atlassian.com/proj...Dashboard.jspa

    Chris

Similar Threads

  1. Replies: 3
    Last Post: Sep 22nd, 2005, 10:14 AM
  2. Replies: 0
    Last Post: Jul 11th, 2005, 05:49 PM
  3. Replies: 4
    Last Post: Jun 25th, 2005, 06:12 PM
  4. SLSB remote pratice.
    By djeang in forum EJB
    Replies: 6
    Last Post: Jun 14th, 2005, 12:41 PM
  5. Replies: 4
    Last Post: Mar 21st, 2005, 06:28 AM

Posting Permissions

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