开发者

EJB3 Injection failed on JBoss AS 5.1 Error: ClassLoaders of value and target are not equal [duplicate]

开发者 https://www.devze.com 2023-03-28 09:41 出处:网络
This question already has answers here: EJB 3.1 Dependency Injection Failed (2 answers) Closed 2 years ago.
This question already has answers here: EJB 3.1 Dependency Injection Failed (2 answers) Closed 2 years ago.

I'm trying to inject a SLSB into a servlet but got the following error:

ERROR [org.jboss.injection.lang.reflect.FieldBeanProperty] (HDScanner) failed to set value Proxy to jboss.j2ee:ear=contact.ear,jar=contact-ejb.jar,name=ContactServiceBean,service=EJB3 implementing [interface com.test.contactservice.ContactService] on field private com.test.contactservice.ContactServiceBean com.test.contactmanager.controller.ContactController.cBean; Reason: ClassLoaders of value and target are not equal

Here is the annotation on the EJB:

@Stateless(name="ContactServiceBean")
@Local
public cl开发者_运维技巧ass ContactServiceBean implements ContactService {

The servlet has the following annotation:

@EJB(mappedName="contact/ContactServiceBean/local")
private ContactServiceBean cBean;

My web.xml uses 2.5 schema:

<web-app version="2.5"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee      http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">

Could someone please take a look? Any suggestion would be much appreciated.


@AntonioP: I thought packaging the EJB into the war only works in EJB3.1. I believe it's not supported in JBoss 5.1.

I've tried renaming the mappedName as you suggested but got NameNotFoundException. I forgot to mention in my original post that the EJB is bounded to the following entry in Global JNDI:

[org.jboss.ejb3.proxy.impl.jndiregistrar.JndiSessionRegistrarBase] (HDScanner) Binding the following Entries in Global JNDI:

    contact/ContactServiceBean/local - EJB3.x Default Local Business Interface
    contact/ContactServiceBean/local-com.test.contactservice.ContactService - EJB3.x Local Business Interface

My EAR has the following directory structure:

contact.ear
 |
 ___META-INF
      |
      ___application.xml
 |
 ___contact.war
 |
 ___contact-ejb.jar

Thanks.


Are the servlet and SSLB in the same jar or war? They need to be. Also check

@EJB(mappedName="contact/ContactServiceBean/local")

Try with

@EJB(mappedName="com/test/contact/ContactServiceBean/local") 

or just ContactServiceBean/local

Check this post http://community.jboss.org/message/8196#8196

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号