SPRING 调用远程接口出错

litao315367624 2010-05-17 07:16:57
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.
请高手指点一下阿!!! 急急急。
...全文
83 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

67,512

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧