[jboss-user] [EJB 3.0] - Problem with EJB Injection in Servlet
sarabjit
do-not-reply at jboss.com
Thu Aug 13 07:46:04 EDT 2009
Hey Guys,
I know there is another similar thread but i couldn't find an answer there. It might be because am really new to EJB so well, please bear with me.
I have a war and an ejb.jar which i package in an ear. I have 2 questions
1. Am not able to access the ejb from the servlet. Can someone tell me what all configurations are needed in which all descriptors.
2. I've put shared libraries directly under the ear but they are not visible to my war. How can i fix that?
My ear structure is
EAR
|->Meta-inf
|->application.xml (defines the two ejb and war modules)
|->jboss-app.xml (empty)
|->my war.war
|->WEB-INF
|->web.xml (no declaration of ejb here)
|->myejb.jar
|->META-INF
|->jboss.xml (which is basically empty - just usual xml markup)
|->ejb-jar.xml(which is empty too)
|->all shared libraries
I have a servlet in my war
TestServelet.java
public class TestServlet extends HttpServlet {
@EJB
MySessionBean mybean;
@Override
protected void doPost(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
system.out.println(mybean);
}
}
I have an interface in myejb.jar
MySessionBean.java
public interface MySessionBean{
void myFunc();
}
MySessionBeanImpl.java
public class MySessionBeanImpl Implements MySessionBean{
public void myFunc(){
system.out.println("Bean Called");
}
}
Am using jboss 4.2.3. Servelet gives me an npe at system.out so the injection isn't working.
Any help on this would be really awesome.
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4249394#4249394
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4249394
More information about the jboss-user
mailing list