Ejb 3 Dependency Injection and Deployment

Dear all,
I have two project. one is ejb_jar and another is ear.
both deploy in same weblogic server with separate package.
But i can't use DI with separate package.
Why i can't use DI with separate package. it dosen't support?
Or my code is wrong?
///// session bean
@Stateless(name = "SessionEJB", mappedName = "stars21_web-Model-SessionEJB")
@Remote
@Local
public class SessionEJBBean implements SessionEJB, SessionEJBLocal
///// client injection
@EJB
SessionEJB test;
With Regards,
WP

These are my full log
NFO: Cleaning up application state
<Nov 4, 2009 5:23:49 PM SGT> <Error> <Deployer> <BEA-149265> <Failure occurred in the execution of deployment request with ID '1257326626033' for task '6'. Error is: 'weblogic.application.ModuleException: Could not setup environment'
weblogic.application.ModuleException: Could not setup environment
     at weblogic.servlet.internal.WebAppModule.activateContexts(WebAppModule.java:1361)
     at weblogic.servlet.internal.WebAppModule.activate(WebAppModule.java:408)
     at weblogic.application.internal.flow.ModuleStateDriver$2.next(ModuleStateDriver.java:182)
     at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:37)
     at weblogic.application.internal.flow.ModuleStateDriver.activate(ModuleStateDriver.java:48)
     Truncated. see log file for complete stacktrace
weblogic.deployment.EnvironmentException: [J2EE:160200]Error resolving ejb-ref 'sg.com.stee.stars21.testing.Servlet1/registrationAuthorityFacade' from module 'stars21_web-stars21-context-root' of application 'stars21_web'. The ejb-ref does not have an ejb-link and the JNDI name of the target bean has not been specified. Attempts to automatically link the ejb-ref to its target bean failed because no EJBs in the application were found to implement the 'sg.com.stee.stars21.common.facade.RegistrationAuthorityFacade' interface. Please link or map this ejb-ref to its target EJB and ensure the interfaces declared in the ejb-ref are correct.
     at weblogic.deployment.BaseEnvironmentBuilder.autowireEJBRef(BaseEnvironmentBuilder.java:426)
     at weblogic.deployment.EnvironmentBuilder.addEJBReferences(EnvironmentBuilder.java:465)
     at weblogic.servlet.internal.CompEnv.activate(CompEnv.java:157)
     at weblogic.servlet.internal.WebAppServletContext.activate(WebAppServletContext.java:3034)
     at weblogic.servlet.internal.WebAppModule.activateContexts(WebAppModule.java:1359)
     Truncated. see log file for complete stacktrace
>
<Nov 4, 2009 5:23:49 PM SGT> <Error> <Deployer> <BEA-149202> <Encountered an exception while attempting to commit the 9 task for the application 'stars21_web'.>
<Nov 4, 2009 5:23:49 PM SGT> <Warning> <Deployer> <BEA-149004> <Failures were detected while initiating deploy task for application 'stars21_web'.>
<Nov 4, 2009 5:23:49 PM SGT> <Warning> <Deployer> <BEA-149078> <Stack trace for message 149004
weblogic.application.ModuleException: Could not setup environment
     at weblogic.servlet.internal.WebAppModule.activateContexts(WebAppModule.java:1361)
     at weblogic.servlet.internal.WebAppModule.activate(WebAppModule.java:408)
     at weblogic.application.internal.flow.ModuleStateDriver$2.next(ModuleStateDriver.java:182)
     at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:37)
     at weblogic.application.internal.flow.ModuleStateDriver.activate(ModuleStateDriver.java:48)
     Truncated. see log file for complete stacktrace
weblogic.deployment.EnvironmentException: [J2EE:160200]Error resolving ejb-ref 'sg.com.stee.stars21.testing.Servlet1/registrationAuthorityFacade' from module 'stars21_web-stars21-context-root' of application 'stars21_web'. The ejb-ref does not have an ejb-link and the JNDI name of the target bean has not been specified. Attempts to automatically link the ejb-ref to its target bean failed because no EJBs in the application were found to implement the 'sg.com.stee.stars21.common.facade.RegistrationAuthorityFacade' interface. Please link or map this ejb-ref to its target EJB and ensure the interfaces declared in the ejb-ref are correct.
     at weblogic.deployment.BaseEnvironmentBuilder.autowireEJBRef(BaseEnvironmentBuilder.java:426)
     at weblogic.deployment.EnvironmentBuilder.addEJBReferences(EnvironmentBuilder.java:465)
     at weblogic.servlet.internal.CompEnv.activate(CompEnv.java:157)
     at weblogic.servlet.internal.WebAppServletContext.activate(WebAppServletContext.java:3034)
     at weblogic.servlet.internal.WebAppModule.activateContexts(WebAppModule.java:1359)
     Truncated. see log file for complete stacktrace
>
[05:23:49 PM] Weblogic Server Exception: weblogic.application.ModuleException: Could not setup environment
[05:23:49 PM] Caused by: weblogic.deployment.EnvironmentException: [J2EE:160200]Error resolving ejb-ref 'sg.com.stee.stars21.testing.Servlet1/registrationAuthorityFacade' from module 'stars21_web-stars21-context-root' of application 'stars21_web'. The ejb-ref does not have an ejb-link and the JNDI name of the target bean has not been specified. Attempts to automatically link the ejb-ref to its target bean failed because no EJBs in the application were found to implement the 'sg.com.stee.stars21.common.facade.RegistrationAuthorityFacade' interface. Please link or map this ejb-ref to its target EJB and ensure the interfaces declared in the ejb-ref are correct.
[05:23:49 PM] See server logs or server console for more details.
oracle.jdeveloper.deploy.DeployException: oracle.jdeveloper.deploy.DeployException: oracle.jdeveloper.deploy.DeployException: Deployment Failed
oracle.jdeveloper.deploy.DeployException: oracle.jdeveloper.deploy.DeployException: oracle.jdeveloper.deploy.DeployException: Deployment Failed
[05:23:49 PM] #### Deployment incomplete. ####
     at oracle.jdevimpl.deploy.common.Jsr88RemoteDeployer.doDeploymentAction(Jsr88RemoteDeployer.java:341)
     at oracle.jdevimpl.deploy.common.Jsr88RemoteDeployer.deployImpl(Jsr88RemoteDeployer.java:235)
     at oracle.jdeveloper.deploy.common.AbstractDeployer.deploy(AbstractDeployer.java:94)
     at oracle.jdevimpl.deploy.fwk.WrappedDeployer.deployImpl(WrappedDeployer.java:39)
     at oracle.jdeveloper.deploy.common.AbstractDeployer.deploy(AbstractDeployer.java:94)
     at oracle.jdeveloper.deploy.common.BatchDeployer.deployImpl(BatchDeployer.java:82)
     at oracle.jdeveloper.deploy.common.AbstractDeployer.deploy(AbstractDeployer.java:94)
     at oracle.jdevimpl.deploy.fwk.WrappedDeployer.deployImpl(WrappedDeployer.java:39)
     at oracle.jdeveloper.deploy.common.AbstractDeployer.deploy(AbstractDeployer.java:94)
     at oracle.jdevimpl.deploy.fwk.DeploymentManagerImpl.deploy(DeploymentManagerImpl.java:442)
     at oracle.jdeveloper.deploy.DeploymentManager.deploy(DeploymentManager.java:209)
     at oracle.jdevimpl.runner.adrs.AdrsStarter$6$1.run(AdrsStarter.java:1469)
Caused by: oracle.jdeveloper.deploy.DeployException: oracle.jdeveloper.deploy.DeployException: Deployment Failed
     at oracle.jdevimpl.deploy.common.Jsr88DeploymentHelper.redeployApplications(Jsr88DeploymentHelper.java:627)
     at oracle.jdevimpl.deploy.common.Jsr88RemoteDeployer.doDeploymentAction(Jsr88RemoteDeployer.java:315)
     ... 11 more
Caused by: oracle.jdeveloper.deploy.DeployException: Deployment Failed
     at oracle.jdevimpl.deploy.common.Jsr88DeploymentHelper.redeployApplications(Jsr88DeploymentHelper.java:608)
     ... 12 more
#### Cannot run application stars21_web due to error deploying to DefaultServer.
[Application stars21_web stopped and undeployed from Server Instance DefaultServer]

Similar Messages

  • ADFc 11g: EJB Dependency injection

    Hello everyone,
    I'm using a managed bean which references a stateless session EJB 3.0:
    public class MyManagedBean {
      @EJB
      private SessionEJB ejb;
    }If the bean is managed by JSF (ie. is registered in faces-config) then the EJB is injected correctly, but if the EJB is managed by ADF (ie. is registered in adfc-config) then there is no dependency injection. Does anybody know why this is so, and if there is a clean solution to the problem?
    Searching the forum, Duncan Mills recommends a bean managed with faces-config in which the EJBs are injected, and then use managed properties to inject those EJBs in the ADF-managed beans.
    Re: Accessing session beans from a managed bean
    Is there a better/simpler solution?
    Thanks!
    Juan Manuel

    Thank you.
    The link helped.
    The one thing i did was created a remote interface for the ejb, which showed up in jndi and then used spring DI to inject a reference to the EJB from jndi.
    Will using a remote interface (instead of a local interface) cause performance issues?

  • EJB 3.0 Dependency Injection and reentrant Calls on SFSB

    Hi there
    I have a SFSB (Bean A) that injects another SFSB (Bean B) with the @EJB annotation. Now Bean A does reentrant-calls on Bean B, which is ok, because it just asks for the current state.
    This results in a "javax.ejb.EJBTransactionRolledbackException: Illegal attempt to make a reentrant call to a stateful session bean from home: .....; nested exception is: javax.ejb.ConcurrentAccessException: Illegal attempt to make a reentrant call to a stateful session bean: ....."
    Now I added a weblogic-ejb-jar.xml with the section:
    <stateful-session-descriptor>
      <allow-concurrent-calls>true</allow-concurrent-calls>
    </stateful-session-descriptor>to enable reentrant calls on my SFSB. Unfortunatly this leads to problems with the DI, it simply doesnt work anymore!!! The message now is " java.lang.IllegalStateException: Cannot find object BeanBInterface with java:comp/env/ejb/BeanBInterface". Obviously the DI didn't work, the local variable isn't filled anmyore.
    Is this a bug of WLS 10.0 MP1 or a feature? Should I open a bug report? Any tips a welcome!
    Stephan

    There is currently no possiblity in Weblogic 10 server web layer to use Dependency Injection on any other component than the ones defined in web.xml s.a.:
    - servlets
    - listeners
    - filters
    See here:
    http://e-docs.bea.com/wls/docs100/webapp/annotateservlet.html
    A simple POJO class part of the web application (such as a Backing Bean in JSF or an Action in Struts for example) is not benefiting from DI.
    Doesn't this make Weblogic 10 a NON JEE 5 compliant server?
    Why was this restriction imposed?
    And how is one supposed to use DI with a simple POJO class? Why this huge inconvenience?

  • Dependency injection and inheritance

    Given:
    class abstract AbstractFoo
    MyObject obj;
    class ConcreteFoo extends AbstractFoo
    Now, I'd like to declare @EJB on "MyObject obj" but AbstractFoo is extended by other subclasses on the client end (outside the container) and so I don't want them to have any EJB3 dependencies. Is there a way for me to declare, inside ConcreteFoo, that "MyObject obj" should have @EJB associated with it?
    Thanks,
    Gili

    Hi Janeth,
    As you can see, Web Dynpro is not a standar JEE container so itu2019s not possible to use dependency injection from a Web Dynpro layer. You have to use JNDI lookups as usually.
    Perhaps the following link may help you: https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/605ff5f2-e589-2910-3ead-e558376e6f3d
    You can use EJB Web Dynpro models as an alternative.
    Edited by: Sergi Arrufat on Jun 3, 2008 12:27 PM

  • JSF 2.0 ejb dependency injection

    It seams that @EJB annotation does not work everywhere... at least in my case.
    Use case:EAR app
    EJB:based on JavaDB APP schema (jdbc/sample in GFv3)(entities, JPA controllers as session beans)
    WAR:JSF 2.0 app using EJB
    For instance in a converter:
    @FacesConverter(forClass=ro.x64.entity.DiscountCode.class)
    public class DiscountCodeConverter implements Converter {
        @EJB
        DiscountCodeFacade discountCodeFacade;
        public Object getAsObject(FacesContext context, UIComponent component, String value) {
            if (value == null || value.length() == 0) {
                return null;
            Character id = new Character(value.charAt(0));
            return discountCodeFacade.find(id);
        public String getAsString(FacesContext context, UIComponent component, Object value) {
            if (value == null) {
                return null;
            if (value instanceof DiscountCode) {
                DiscountCode o = (DiscountCode) value;
                return o.getDiscountCode() == null ? "" : o.getDiscountCode().toString();
            } else {
                throw new IllegalArgumentException("object " + value + " is of type " + value.getClass().getName() + "; expected type: jpa.entities.DiscountCode");
    } discountCodeFacade is resolved to null.
    ...but same @EJB works in a managed bean.
    So is my code wrong,do I use @EJB improperly or is this a bug?
    Florin POP
    Thank you for your replies

    I even tried to decorate as a CDI Managed Bean my @FacesConverter.
    @Named
    @RequestScoped
    @FacesConverter(forClass=MyClass.class)
    public class MyConverter implements ConverterBut didn't work either. When my application is deployed I can see that my class is managed but injection is not working.
    INFO: Adapting InjectionTarget for org.test.MyConverter in the scope interface javax.enterprise.context.RequestScoped
    A workaround is making a context lookup in your converter constructor:
    MyEJB bean;
    public MyConverter() {
                try {
                    bean = (MyEJB) InitialContext.doLookup("java:global/MyApp/MyEJB");
                } catch (NamingException ex) {
                    Logger.getLogger("Converter").log(Level.SEVERE, null, ex);
        }Hope it helps

  • Dependency Injection and Target Unreachable returned null

    Hello
    I have tried a simple code in jsf 2.
    This is it
    following is jsp
    <h:form>
    <h:inputText value="#{MBTest.thePerson.name}"/>
    <h:commandButton value="submit" action="#{MBTest.action}"/>
    <h:messages/>
    </h:form>
    following is Managed bean MBTest
    @ManagedBean(name="MBTest")
    @RequestScoped
    public class MBTest {
    @ManagedProperty (value="#{thePerson}")
    private Person thePerson = null;
    public MBTest() {
    public Person getThePerson() {
    return thePerson;
    public void setThePerson(Person thePerson) {
    this.thePerson = thePerson;
    public void action() {
    System.out.println(thePerson.getName());
    following is Person class
    public class Person {
    private String name = null;
    private int age = 0;
    public int getAge() {
    return age;
    public void setAge(int age) {
    this.age = age;
    public String getName() {
    return name;
    public void setName(String name) {
    this.name = name;
    But once this executed the page displays (please note that 'thePerson' instance of managed bean is not instantiated, just the managed property has been declared). When the button is pressed it gives me the followuing error
    /index.xhtml @12,60 value="#{MBTest.thePerson.name}": Target Unreachable, 'thePerson' returned null
    Could you please tell me why?
    Off the topic :
    Where is the code tags? I can't find it here.

    as far as I can see, your Person class is not a managed bean. I would expect an annotation @ManagedBean(name="thePerson") on it. If you don't make it a managed bean, JSF does not know it exists.
    If you don't want person to be a managed bean, then simply create an instance yourself in your MBTest class.
    private Person thePerson = new Person();

  • Creating and deploying web services

    Hi,
    I am new to java.
    I have created an EJB in NetBeans 5.5 that contains a web service (From one of the web service tutorials - CalculatorWSApplication).
    The EJB compiles fine and deploys fine.
    I am using the Sun's Server Platform Edition 9.0 Admin Console.
    I created a connector connection pool and a connector resource which uses that pool. Then I created a registry with the Publish URL and the Query URL = http://localhost/services/uddi/v3/protect/publishapi (same as the example on the registry page (except for http instead of https).
    When I try to publish the web service using the registry I just added I get the message: "Bad response: (405Method not allowed"
    As I said, I am very new (started this week) to java and all the java tools so please give me the answer in baby steps, thanks :)
    Justin

    Hi, Saiah
    Thanks for getting back to me.
    I created a servlet with a doPut() method and it ran fine.
    I also downloaded JBoss to see if it'd be easier for me to work with, still need a lot of knowledge for that to be useful :)
    Maybe I'm completely on the wrong path, this is my problem in a nutshell:
    Using NetBeans IDE 5.5 and following the web services tutorial (http://www.netbeans.org/kb/50/quickstart-webservice.html) when I get to the part "Consuming the Web Service" it tells me to call a web service operation ... when I do this I get a dialog box saying "Select Operation to Invoke" with "Available Web Services" beneath that ... in this dialog I should be seeing a list of web services (inc the ones I have created) but it is completely empty.
    Do you have any idea what the problem could be, was I on the right path trying to publish it to the registry?
    Thanks,
    Justin

  • When to use @Resource and when to use @EJB for dependency injection

    Hi,
    When do you use
    @Resource and when do you use @EJB for dependency injection?
    Thanks

    Captain obvious: Use @EJB for injection of EJBs, and @Resource for everything else.
    There was a discussion about this very topic quite recently, perhaps you can find it through the search.

  • EJB 3.0 Dependency Injection in JSF ?

    Hi,
    I have a question about ejb 3.0 dependency injection in a JSF WebApp:
    I Build successfully a Web Module (version 2.5) an EJB Module (version 3.0) and an EAR Module (Version 5.0). The EAR App can be deployed without errors on a Bea WebLogic Server 10.1. All modules are successfully deployed.
    Inside the Web Module there is a Servlet which uses dependency injection to access the session EJB form the EJB Module. This works perfect.
    Next I try to use the same EJB with dependency injection from the JSF Page via a backing bean. But when I try to access my JSP Page I got a Nullpointer Exception.
    It seems that the Dependency Injection in the JSP App did not work?
    Can anybody give me a hint what could be wrong?
    Thanks
    Ralph

    There is currently no possiblity in Weblogic 10 server web layer to use Dependency Injection on any other component than the ones defined in web.xml s.a.:
    - servlets
    - listeners
    - filters
    See here:
    http://e-docs.bea.com/wls/docs100/webapp/annotateservlet.html
    A simple POJO class part of the web application (such as a Backing Bean in JSF or an Action in Struts for example) is not benefiting from DI.
    Doesn't this make Weblogic 10 a NON JEE 5 compliant server?
    Why was this restriction imposed?
    And how is one supposed to use DI with a simple POJO class? Why this huge inconvenience?

  • Dependency inject a EJB 2.x bean with EJB3

    Hi there
    I have an old EJB3 2.x bean deployed on my server, that is registered in JNDI with the name "abc/xyz/ItemLookup_v35".
    Now I wrote a EJB3 SFSB bean and I want to access the old bean using dependency injection. I tried it with the annotation
      @EJB(mappedName = "abc/xyz/ItemLookup_v35")
      private ItemLookupRemote itemRemote;but it wasn't working. How can I explicitly set the JNDI name of an old bean, that I want to lookup for?
    Any help is appreciated!
    Regards,
    Stephan
    Edited by: MasterRefactorer on Jun 27, 2008 7:31 AM

    You can use @EJB to access 2.x Remote views, but the field type has to be the Home interface.
    @EJB(mappedName = "abc/xyz/ItemLookup_v35")
    private ItemLookupHome itemHome;

  • EJB 3.0 Why Dependency Injection doesn't work?

    Hello Every body,
    i have a serious problem with dependency injection with EJB 3.0. I have tried so many time to get the simple sun delivered samples ejb-Applications working in NetBeans IDE, but they don't. After importing in building the projects in NetBeans, i get a NullPointerException while trying to run them. Is there any body who have experience with this? What am i making wrong?
    I searched for an answer since several days in google without any success. I have not found a single satisfactory explanation. I can't explain why even the examples in the java ee tutorials don't work.
    Please, can somebody help? I would very greatful.
    Cheers
    flips
    Here is an example of application (that don't work because the injection failed):
    * This is the business interface for Confirmer enterprise bean.
    @Remote
    public interface Confirmer {
    void sendNotice(String recipient);
    @Stateless
    public class ConfirmerBean implements Confirmer {
    private static final String mailer = "JavaMailer";
    private static Logger logger = Logger.getLogger(
    "confirmer.ejb.ConfirmerBean");
    @Resource(name = "mail/myMailSession")
    private Session session;
    /** Creates a new instance of ConfirmerBean */
    public ConfirmerBean() {
    public void sendNotice(String recipient) {
    try {
    Message message = new MimeMessage(session);
    message.setFrom();
    message.setRecipients(
    Message.RecipientType.TO,
    InternetAddress.parse(recipient, false));
    message.setSubject("Test Message from ConfirmerBean");
    DateFormat dateFormatter = DateFormat.getDateTimeInstance(
    DateFormat.LONG,
    DateFormat.SHORT);
    Date timeStamp = new Date();
    String messageText = "Thank you for your order." + '\n'
    + "We received your order on "
    + dateFormatter.format(timeStamp) + ".";
    message.setText(messageText);
    message.setHeader("X-Mailer", mailer);
    message.setSentDate(timeStamp);
    // Send message
    Transport.send(message);
    logger.info("Mail sent to " + recipient + ".");
    } catch (MessagingException ex) {
    ex.printStackTrace();
    logger.info("Error in ConfirmerBean for " + recipient);
    * @author ie139813
    public class ConfirmerClient {
    @EJB
    private static Confirmer confirmer;
    /** Creates a new instance of ConfirmerClient */
    public ConfirmerClient() {
    * @param args the command line arguments
    public static void main(String[] args) {
    String recipient = null;
    if (args.length == 1) {
    recipient = args[0];
    } else {
    recipient = "[email protected]";
    try {
    confirmer.sendNotice(recipient);
    System.out.println("Message sent to " + recipient + ".");
    System.exit(0);
    } catch (Exception ex) {
    ex.printStackTrace();
    }

    Try rebooting your computer. I had something similar. I rebooted my computer and it finished the update. Good luck!

  • Dependency Injection Problem in EJB 3.0

    Hello.
    I've been trying to get an example of java dependency injection working in JBoss 4.0.5.GA. I've installed it with EJB 3.0 support.
    The problem is that if I try to use the injected resource, I get a null pointer exception.
    The example I'm trying is a very short and simple one. Shouldn't be hard to figure out what is going wrong. Here it goes:
    [root]\src\hello\MessageServlet.java:
    package hello;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.io.*;
    import java.util.List;
    import java.util.ListIterator;
    import javax.naming.InitialContext;
    import javax.annotation.*;
    public class MessageServlet extends HttpServlet {
         @Resource (mappedName="java:/DefaultDS")
         javax.sql.DataSource ejb30DB;
         public void init () throws ServletException {
         public void service(HttpServletRequest request, HttpServletResponse response)
                   throws IOException, ServletException {
              boolean injectedLookingGood = false;
              boolean notInjectedLookingGood = false;
              try {
                   java.sql.Connection conn = ejb30DB.getConnection();
                   conn.close();
                   injectedLookingGood = true;
              } catch(Exception e) {
                   e.printStackTrace();
              try {
                   InitialContext ic = new InitialContext();
                   javax.sql.DataSource ds = (javax.sql.DataSource)ic.lookup("java:/DefaultDS");
                   java.sql.Connection conn = ds.getConnection();
                   conn.close();
                   notInjectedLookingGood = true;
              } catch(Exception e) {
                   e.printStackTrace();
              response.setContentType("text/html");
              ServletOutputStream out = response.getOutputStream();
              out.println("<html>");
              out.println("<head><title>Hello World</title></head>");
              out.println("<body>");
              out.println("<h1>Hello World</h1>");
              out.println("<form action=\"HelloWorld\" method=\"get\">");
              out.print("Injected DataSource is looking ");
              if(injectedLookingGood) {
                   out.println("good <br>");
              else {
                   out.println("bad <br>");
              out.print("Not-Injected DataSource is looking ");
              if(notInjectedLookingGood) {
                   out.println("good <br/>");
              else {
                   out.println("bad <br/>");
              out.println("<input type=\"submit\" value=\"Test Some More\">");
              out.println("</form>");
              out.println("</body>");
              out.println("</html>");
    [root]\etc\META-INF\web.xml:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE web-app
    PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
    "http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">
    <web-app>
    <display-name>HelloWorldWAR</display-name>
    <servlet>
    <display-name>HelloWorld</display-name>
    <servlet-name>HelloWorldServlet</servlet-name>
    <servlet-class>hello.MessageServlet</servlet-class>
    </servlet>
    <servlet-mapping>
    <servlet-name>HelloWorldServlet</servlet-name>
    <url-pattern>/servlet/HelloWorld</url-pattern>
    </servlet-mapping>
    </web-app>
    [root]\etc\META-INF\application.xml:
    <?xml version="1.0" encoding="UTF-8"?>
    <application xmlns="http://java.sun.com/xml/ns/j2ee" version="1.4"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com /xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/application_1_4.xsd">
    <display-name>HelloWorld</display-name>
    <description>Application description</description>
    <module>
    <web>
    <web-uri>web-ejb3.war</web-uri>
    <context-root>HelloWorld</context-root>
    </web>
    </module>
    </application>
    [root]\build.xml:
    <project name="HelloWorld" default="all" basedir=".">
    <!-- Name of project and version -->
    <property name="proj.name" value="HelloWorld"/>
    <property name="proj.version" value="1.0"/>
    <!-- Global properties for thid build -->
    <property name="src.dir" value="${basedir}/src"/>
    <property name="build.dir" value="${basedir}/bin"/>
    <property name="lib.dir" value="${basedir}/lib"/>
    <property name="build.classes.dir" value="${build.dir}/classes"/>
    <property name="build.jar.dir" value="${build.dir}/jar"/>
    <property name="src.etc.dir" value="${basedir}/etc"/>
    <property name="meta-inf.dir" value="${src.etc.dir}/META-INF"/>
    <!-- The build classpath -->
    <path id="build.classpath">
    <fileset dir="${lib.dir}">
    <include name="**/*.jar"/>
    <include name="**/*.zip"/>
    </fileset>
    </path>
    <!-- Useful shortcuts -->
    <patternset id="meta.files">
    <include name="**/*.xml" />
    <include name="**/*.properties"/>
    </patternset>
    <target name="prepare">
    <mkdir dir="${build.dir}"/>
    <mkdir dir="${build.classes.dir}"/>
    <mkdir dir="${build.jar.dir}"/>
    </target>
    <target name="compile" depends="prepare">
    <javac destdir="${build.classes.dir}"
    classpathref="build.classpath"
    debug="on">
    <src path="${src.dir}"/>
    </javac>
    </target>
    <target name="package-web" depends="compile">
    <war warfile="${build.dir}/jar/web-ejb3.war"
    webxml="${meta-inf.dir}/web.xml">
    <classes dir="${build.dir}/classes">
    <include name="**/*Servlet.class"/>
    </classes>
    </war>
    </target>
    <!-- Creates an ear file containing the web client war. -->
    <target name="assemble-app">
    <ear destfile="${build.jar.dir}/HelloWorld.ear" appxml="${meta-inf.dir}/application.xml">
    <fileset dir="${build.dir}/jar"
    includes="*.war"/>
    </ear>
    </target>
    <target name="clean">
    <delete dir="${build.dir}" />
    </target>
    <target name="all">
    <antcall target="clean" />
    <antcall target="package-web" />
    <antcall target="assemble-app" />
    </target>
    </project>
    Any help would be apreciated.
    Thanks in advance,
    Hugo Oliveira
    [email protected]

    Hello Ken.
    I gess dependency injection is unnavailable in servlets as of this moment. I conducted another test using a session bean that injects and tests the DataSource and a servlet calling the session bean via a refference obtained from InitialContext. It worked OK.
    Here's the code:
    [root]/src/hello/MessageHandler.java:
    package hello;
    public interface MessageHandler {
         public boolean testInjection();
    [root]/src/hello/MessageHandlerBean.java:
    package hello;
    import javax.ejb.Stateless;
    import javax.persistence.*;
    import java.util.List;
    import javax.annotation.*;
    @Stateless
    public class MessageHandlerBean implements MessageHandler {
         @Resource (mappedName="java:/DefaultDS")
         private javax.sql.DataSource ds;     
         public boolean testInjection() {
              try {
                   java.sql.Connection conn = ds.getConnection();
                   conn.close();
                   return true;
              } catch(Exception e) {
                   e.printStackTrace();
              return false;
    [root]/src/hello/MessageServlet.java:
    package hello;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.io.*;
    import java.util.List;
    import java.util.ListIterator;
    import javax.naming.InitialContext;
    import javax.annotation.*;
    public class MessageServlet extends HttpServlet {
         public void init () throws ServletException {
         public void service(HttpServletRequest request, HttpServletResponse response)
                   throws IOException, ServletException {
              boolean injectedLookingGood = false;
              try {
                   InitialContext ic = new InitialContext();
                   MessageHandler mh = (MessageHandler)ic.lookup("HelloWorld/MessageHandlerBean/local");
                   injectedLookingGood = mh.testInjection();
              } catch(Exception e) {
                   e.printStackTrace();
              response.setContentType("text/html");
              ServletOutputStream out = response.getOutputStream();
              out.println("<html>");
              out.println("<head><title>Hello World</title></head>");
              out.println("<body>");
              out.println("<h1>Hello World</h1>");
              out.println("<form action=\"HelloWorld\" method=\"get\">");
              out.print("Injected DataSource is looking ");
              if(injectedLookingGood) {
                   out.println("good <br>");
              else {
                   out.println("bad <br>");
              out.println("<input type=\"submit\" value=\"Test Some More\">");
              out.println("</form>");
              out.println("</body>");
              out.println("</html>");
    [root]/etc/META-INF/application.xml:
    <?xml version="1.0" encoding="UTF-8"?>
    <application xmlns="http://java.sun.com/xml/ns/j2ee" version="1.4"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com /xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/application_1_4.xsd">
    <display-name>HelloWorld</display-name>
    <description>Application description</description>
    <module>
    <ejb>HelloWorld.ejb3</ejb>
    </module>
    <module>
    <web>
    <web-uri>web-ejb3.war</web-uri>
    <context-root>HelloWorld</context-root>
    </web>
    </module>
    </application>
    [root]/etc/META-INF/web.xml:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE web-app
    PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
    "http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">
    <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">
    <display-name>HelloWorldWAR</display-name>
    <servlet>
    <display-name>HelloWorld</display-name>
    <servlet-name>HelloWorldServlet</servlet-name>
    <servlet-class>hello.MessageServlet</servlet-class>
    </servlet>
    <servlet-mapping>
    <servlet-name>HelloWorldServlet</servlet-name>
    <url-pattern>/servlet/HelloWorld</url-pattern>
    </servlet-mapping>
    </web-app>
    [root]/build.xml:
    <project name="HelloWorld" default="all" basedir=".">
    <!-- Name of project and version -->
    <property name="proj.name" value="HelloWorld"/>
    <property name="proj.version" value="1.0"/>
    <!-- Global properties for thid build -->
    <property name="src.dir" value="${basedir}/src"/>
    <property name="build.dir" value="${basedir}/bin"/>
    <property name="lib.dir" value="${basedir}/lib"/>
    <property name="build.classes.dir" value="${build.dir}/classes"/>
    <property name="build.jar.dir" value="${build.dir}/jar"/>
    <property name="src.etc.dir" value="${basedir}/etc"/>
    <property name="meta-inf.dir" value="${src.etc.dir}/META-INF"/>
    <!-- The build classpath -->
    <path id="build.classpath">
    <fileset dir="${lib.dir}">
    <include name="**/*.jar"/>
    <include name="**/*.zip"/>
    </fileset>
    </path>
    <!-- Useful shortcuts -->
    <patternset id="meta.files">
    <include name="**/*.xml" />
    <include name="**/*.properties"/>
    </patternset>
    <target name="prepare">
    <mkdir dir="${build.dir}"/>
    <mkdir dir="${build.classes.dir}"/>
    <mkdir dir="${build.jar.dir}"/>
    </target>
    <target name="compile" depends="prepare">
    <javac destdir="${build.classes.dir}"
    classpathref="build.classpath"
    debug="on">
    <src path="${src.dir}"/>
    </javac>
    </target>
    <target name="package-ejb" depends="compile">
    <jar jarfile="${build.jar.dir}/HelloWorld.ejb3">
    <fileset dir="${build.classes.dir}">
    <include name="**/*.class"/>
    </fileset>
    <!--
         <metainf dir="${meta-inf.dir}">
    <include name="persistence.xml"/>
    </metainf>
    -->
    </jar>
    </target>
    <target name="package-web" depends="compile">
    <war warfile="${build.dir}/jar/web-ejb3.war"
    webxml="${meta-inf.dir}/web.xml">
    <!--
    <fileset dir="web">
    <include name="**/*"/>
    </fileset>
    -->
    <!--
    <webinf dir="dd/web">
    <include name="jboss-web.xml"/>
    </webinf>
    -->
    <classes dir="${build.dir}/classes">
    <include name="**/*Servlet.class"/>
    </classes>
    </war>
    </target>
    <!-- Creates an ear file containing the ejb jars and the web client war. -->
    <target name="assemble-app">
    <ear destfile="${build.jar.dir}/HelloWorld.ear" appxml="${meta-inf.dir}/application.xml">
    <fileset dir="${build.dir}/jar"
    includes="*.ejb3,*.war"/>
    </ear>
    <!-- <delete file="${build.dir}/jar/web-ejb3.war"/>
    <delete dir="${build.dir}/classes"/> -->
    </target>
    <target name="clean">
    <delete dir="${build.dir}" />
    </target>
    <target name="all">
    <antcall target="clean" />
    <antcall target="package-ejb" />
    <antcall target="package-web" />
    <antcall target="assemble-app" />
    </target>
    </project>
    Thanks,
    Hugo Oliveira
    [email protected]

  • EJB 3.0 client side dependency injection

    Hi,
    I develop an EJB 3.0 based enterprise application using Sun Java System Application Server. The application includes a Swing based client to be launched via Java WebStart. The client has to access some of the EJBs. Is it possible to use dependency injection on client side (see the @EJB annotation) and if yes how do I set the properties for this?
    The following snipped hopefully explains what I mean. The class FastEntry is a class of the Swing client. My question is how can I get the deviceSessionBean initialized?
    public class FastEntry extends javax.swing.JFrame { 
        @EJB
        private static DeviceSessionRemote deviceSessionBean;Kind regards,
    Matthias

    Hi,
    For callbacks and interceptors, you can look at this page : http://today.java.net/pub/a/today/2005/08/18/ejb3.html
    For sending messages, I'd recommend to use JMS (if in clientSide), or EJB3 Message beans if in server side.
    Hope that helps :)

  • Creating and deploying ejb 3.0 session bean with annotated pojo

    I try to create and deploy a EJB 3.0 stateless session bean (and associated webservice) with the following steps:
    1) Create Interface "Repository"
    package de.xxx.config;
    import java.rmi.Remote;
    import java.rmi.RemoteException;
    import javax.jws.WebMethod;
    import javax.jws.WebService;
    @WebService
    public interface Repository extends Remote {
         @WebMethod(operationName = "findCampaignByChannel")
         public String findCampaignByChannel(String channelName) throws RemoteException;
    2) create dummy "RepositoryImpl"
    package de.xxx.config;
    import java.rmi.RemoteException;
    import javax.ejb.Stateless;
    import javax.jws.WebService;
    @WebService(endpointInterface="de.xxx.config.Repository")
    @Stateless
    public class RepositoryImpl implements Repository {
         public String findCampaignByChannel(String channelName) throws RemoteException {
              return null;
    3) The two class files are packaged into a jar without any further descriptors
    4) The jar is deployed with admin_client into the oc4j instance using the commands:
    -deploy -file <jarfile> -deploymentName <name>
    Result:
    An ear was constructed and started but no session bean or webservice is found (using the console). But according to to the docs a jar file without a ejb-jar.xml should be recognized as a EJB 3.0 ejb-jar file and the necessary steps to create session bean and expose webservice should be done automatically.
    My question:
    Which step do i miss here ?
    Tools used:
    Eclipse 3.2 for the jar file
    SoaSuite 10.1.3.1 for oc4j

    another strange problem.
    i have an APplication server added ( JBOSS ).
    when i create deployment profile (EAR ) application server is showed in the ComboBox .
    But when i create Java Test Client for some EJB and when i check " Connect Remote Application server" there is 2 comboboxes
    J2EE Application
    App Server Connection.
    first combo is ok there is EJB applicaiton
    Secound is empty .. but i Have App Server.
    Another think is that when i create EJB 3.0 its BAD to see J2EE app it must be J EE 5 app or just Java EE app

  • EJB compilation and deployment problems

    Dear fellows
    I have good understanding of EJB development process, but the compilation and deployment process of EJB is very problematic for me. Please write me the complete steps which should include:
    1. Starting from class, interface programs creation
    2. Package creation and accessing it along with class path setting
    3. How and where to compile these classes and interfaces (app server details), JAR
    4.deployment details on any app server like SUN, web logic
    Kind regards
    Shahzad faisal

    Dear fellowsDear Shahzad faisal
    Start with the JEE5 tutorial:
    http://java.sun.com/javaee/5/docs/tutorial/doc/
    Part 3 discusses EJB stuff
    I would recommend going to a few samples, bundled with most of the appservers to see the appserver specific stuff.
    >
    I have good understanding of EJB development process,
    but the compilation and deployment process of EJB is
    very problematic for me. Please write me the complete
    steps which should include:
    1. Starting from class, interface programs creationSo you have the classes and interface implemented.
    Next thing is to create a ejb-jar.xml in which your EJBs are defined (optional for EJB3.0)
    2. Package creation and accessing it along with class
    path settingPackaging all in a jar file is enough for an appserver to find your classes.
    3. How and where to compile these classes and
    interfaces (app server details), JARCompilation usually needs the javx.ejb.* classes, most appservers have a j2ee.jar in which the javax.* classes you need are present.
    in jour jar file you package your classes and deployment descriptor
    4.deployment details on any app server like SUN, web
    logicDeployment to appservers is product specific, see the manual here.
    you may want to add some other , vedor specific, deployment settings which are not ejb specification defined, these go into a vendor specific DD, for Sun for example the sun-ejb-jar.xml.
    >
    Kind regards
    Shahzad faisal

Maybe you are looking for

  • How can I use automator to open terminal change directory run a python script?

    Hi all, I dont really ever use automator - which may be my big problem - and I am trying to make an apllication that seems fairly simple in theroy. I want something that will lunch terminal, cd to the place where my python script lives and then run i

  • Create Inbound Delivery from Outbound Delivery create

    Hi, This is what I am trying to do... 1. Create PO (me21n) 2. Create Outbound Delivery based on PO (VL10g) 3. PGI (this creates a DELVRY03 IDoc) (IDoc is created at this step, no issues so far) 4. Based on the Outbound DELVRY03 IDoc I want to create

  • Not Seeing Roles in CMC

    I have SAP 7.0 SP18 and BOE 3.0 and the integration kit. I had configured the SAP Entitlement system and was making progress on the rest of the config like /crystal/rptadmin. Anyway, I went back in to review my roles and I couldn't see any from my SA

  • Performance Issue on "Planning Manager" program

    Hi, In order management --- the "Planning Manager" request is taking lot of time to run when we create 100,000 lines of sales orders at a time( I mean,this causes the planning manager to run slower). Can you please help me out how can i increase the

  • Where is the camera shake reduction filter on Photoshop Elements?

    I downloaded Photoshop Elements for the sole purpose of using this camera shake reduction filter all over the website, but now cannot find it in the list of available filters.  Help!