PDA

View Full Version : Remote EJB



jonnyS
Mar 21st, 2005, 11:08 AM
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!!!

Chris
Mar 22nd, 2005, 01:39 AM
A detailed explanation of LocalStatelessSessionProxyFactoryBean can be found in:

http://www.javaworld.com/javaworld/jw-02-2005/jw-0214-springejb_p.html

SimpleRemoteStatelessSessionProxyFactoryBean is very similar.

Chris

Chris
Mar 22nd, 2005, 01:44 AM
See also:

http://forum.springframework.org/viewtopic.php?t=4220&highlight=

Chris

Andreas Senft
Mar 22nd, 2005, 03:05 AM
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

jonnyS
Mar 22nd, 2005, 03:33 PM
Here is the config and stack trace.


<bean id="myService" class="org.springframework.ejb.access.SimpleRemoteStatele ssSessionProxyFactoryBean">
<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!

Chris
Mar 22nd, 2005, 04:20 PM
Is it possible that com.test.IService is mis-spelt or not in the classpath?

Chris

jonnyS
Mar 22nd, 2005, 08:02 PM
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!! ;)

Chris
Mar 22nd, 2005, 09:10 PM
This is the source of the class at the root of the stack trace, which I think demonstrates that this is a classpath problem.



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

jonnyS
Mar 23rd, 2005, 01:13 AM
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

Chris
Mar 23rd, 2005, 02:40 PM
This exception handler might have been better written as follows in order to avoid lossing the ClassNotFoundException.



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/projects/spring/secure/Dashboard.jspa

Chris