SPRING 调用远程接口出错
EJB项目中的接口和实现类
package dao;
import javax.ejb.Remote;
import Entity.Person;
import Entity.StudentClass;
@Remote
public interface PersonDaoRemote {
public void save(Person p);
public void saveStudent(StudentClass sc);
}
package dao;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import Entity.Person;
import Entity.Student;
import Entity.StudentClass;
-------------------------------------------------------
@Stateless
public class PersonDao implements PersonDaoRemote {
@PersistenceContext(name="pu")
EntityManager em;
public void save(Person p) {
em.persist(p);
}
public void saveStudent(StudentClass sc){
em.persist(sc);
}
}
-----------------------------------------------------------------------------------------
客户端项目中的配置
applicationContext.xml
<bean id="persondao" class="org.springframework.ejb.access.SimpleRemoteStatelessSessionProxyFactoryBean" lazy-init="true">
<property name="jndiName" value="PersonDao/remote"></property>
<property name="businessInterface" value="dao.PersonDaoRemote"></property>
<property name="jndiEnvironment">
<map>
<entry key="java.naming.factory.initial" value="org.jnp.interfaces.NamingContextFactory"></entry>
<entry key="java.naming.provider.url" value="jnp://localhost"></entry>
</map>
</property>
</bean>
<bean id="remotePer" class="Servlets.RemotePer">
<property name="persondao">
<ref bean="persondao"/>
</property>
</bean>
-------------------------------------------------------
persondao 作为remotePer的一个属性,通过spring 注入
test.java中测试的时候发生了错误
错误信息如下
Exception in thread "main" org.springframework.remoting.RemoteLookupFailureException: EJB instance [jboss.j2ee:jar=EJBJPA.jar,name=PersonDao,service=EJB3] is not a Remote Stateless Session Bean
at org.springframework.ejb.access.AbstractRemoteSlsbInvokerInterceptor.newSessionBeanInstance(AbstractRemoteSlsbInvokerInterceptor.java:228)
at org.springframework.ejb.access.SimpleRemoteSlsbInvokerInterceptor.getSessionBeanInstance(SimpleRemoteSlsbInvokerInterceptor.java:141)
at org.springframework.ejb.access.SimstemException.html" title="class in javax.transaction">SystemException</A></CODE> - Thrown if the transaction manager
encounters an unexpected error condition.
请高手指点一下阿!!! 急急急。