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!

Similar Messages

  • Why the preloader doesn't work in IE 8 but works in FireFox?

    Why the preloader doesn't work in IE 8 but works in FireFox?
    Please see the attached files.  Thanks in advance.

    Why doesn't the preloader work in IE8?
    What's "virtual sandbox"?

  • How to use documentbeforesaved method? And why my code doesn't work in template files?

    Can someone help me with these two codes?
    ----Beginning of code 1-------------
    Private WithEvents App As Word.Application
    Private Sub Document_Open()
    Set App = Word.Application
    End Sub
    Private Sub App_DocumentBeforeSave(ByVal Doc As Document, SaveAsUI As Boolean, Cancel As Boolean)
    MsgBox("BeforeSave")
    End Sub
    --------------End of the code----------------
    Beginning of code 2--------------- Code 2 is from https://msdn.microsoft.com/en-us/library/office/ff838299(v=office.15).aspx
    Public WithEvents appWord as Word.Application 
    Private Sub appWord_DocumentBeforeSave _ 
     (ByVal Doc As Document, _ 
     SaveAsUI As Boolean, _ 
     Cancel As Boolean) 
     Dim intResponse As Integer 
    Private Sub App_DocumentBeforeSave(ByVal Doc As Document, SaveAsUI As Boolean, Cancel As Boolean)
    MsgBox("BeforeSave")
    End Sub
    In the first code, they have:
    Private Sub Document_Open()
    Set App = Word.Application
    End Sub
     I test these two codes in "This document" object, and I find out the first code works but the second code are not!
    Why second code doesn't work?
    Extra question: I am using microsoft 2013. I insert this code into a macro-enabled template. But when I am about to save my file I am expecting these code works. However, they didn't work!
    Thank you for solving these problem for me!

    Hello,
    Please note that the code snippet 2 in your post is different from the code snippet in the MSDN document. Also please read the comments of the MSDN code sample:
    This example prompts the user for a   yes or no response before saving any document.
    This code must be placed in a   class module, and an instance of the class must be correctly initialized to   see this example work; see
    Using Events with the Application Object for   directions on how to accomplish this.
    Public WithEvents appWord   as Word.Application
    Private Sub   appWord_DocumentBeforeSave _
     (ByVal Doc As Document, _
     SaveAsUI As Boolean, _
     Cancel As Boolean)
     Dim intResponse As Integer
     intResponse = MsgBox("Do you really   want to " _
     & "save the document?", _
     vbYesNo)
     If intResponse = vbNo Then Cancel = True
    End Sub
    So the problem in your code snippet 2 is that you didn't put it into a class module and initialize the class module. If you just put it into ThisDocument, you have to initialize the word application object.
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Hi , please tell me why my ipod doesn't work ... when i conect it to my pc nothing happen .. and i can turn on my ipod .. why ? please help me

    hi , please tell me why my ipod doesn't work ... when i conect it to my pc nothing happen .. and i can turn on my ipod .. why ? please help me

    Go to
    http://bt.custhelp.com/app/answers/detail/a_id/47531
    and follow the instructions
    This was put up by BT several months ago as part of the advance notification that the Yahoo service through them was closing

  • Why the imsg doesn't work without a sim card with iOS 7???

    Why the imsg doesn't work without a sim card with iOS 7???

    If it worked for you using iOS 6, then it appears iOS 7 has made some changes.  Was it working before?

  • Hi there, i have a ipod nano general 7, just used one year. Now can't charge battery. When charging, the icon shows full power, but disconnect it. It becomes dark, no power. Why, the battery doesn't work ?

    I've a ipod nano general 7, I've just used it one year. Now, I can't charge the battery. When charging, the icon shows full power. But when I disconnect, the ipod becomes dark, no power is keeped. Why, the battery doesn't work ? the life of my ipod's battery is too short ? 

    Howdy tamsg,
    Welcome to Apple Support Communities.
    The article linked below provides a lot of great troubleshooting tips that can help you resolve the issue with your iPod nano charging or displaying a blank black screen.
    iPod nano (7th generation): Hardware troubleshooting - Apple Support
    So long,
    -Jason

  • Why this statement doesn't work?

    I have two table job and job_status,I use Page Process try to insert records to job_status, but the select query doesn't work, it display all the job in job table didn't filtered out the job matching the query, do someone know why? Any suggestion will be appreciated!
    DECLARE
    BEGIN
    FOR x IN (
    SELECT
    JOB_SEQ,
    PRIMARY
    FROM JOB
    WHERE ((RUN_DATES like '%'||:P6_WDAY||'%')
    or (RUN_DATES like '%'||:P6_DD ||'%')
    or (RUN_DATES like ''|| 0 ||'')))
    LOOP
    INSERT INTO JOB_STATUS(JOB_SEQ, OPERATOR,RUN_DATE) VALUES
    (x.JOB_SEQ,x.PRIMARY,to_date(:P6_DATE,'YYYYMMDD'));
    END LOOP;
    END;

    ops wrong typed
    try
    DECLARE
    BEGIN
    FOR x IN (
    SELECT
    JOB_SEQ,
    PRIMARY
    FROM JOB WHERE
    ((RUN_DATES like CHR(39)||'%'||:P6_WDAY||'%'||CHR(39))
    or (RUN_DATES like CHR(39)||'%'||:P6_DD ||'%'||CHR(39))
    or (RUN_DATES like ''|| 0 ||'')))
    LOOP
    INSERT INTO JOB_STATUS(JOB_SEQ, OPERATOR,RUN_DATE) VALUES
    (x.JOB_SEQ,x.PRIMARY,to_date(:P6_DATE,'YYYYMMDD'));
    END LOOP;
    END;

  • Why this example doesn't work ?

    for example below:
    html code:
    <applet code=LunarPhasesRB.class width="200" height="200">
        </applet>when i run it on IE , i get below result:
    failed to loading java program.
    why it doesn't work on IE ?
    who can help me ?
    thanks !

    thanks a lot!
    left of web browser appear below info:
    small application program LunarPhasesRB notinited
    what does it mean ?
    if i click "Click to activate and use this control".
    another err:
    failed to loading java program.
    who can help me ?

  • Why FileUtils::CopyFile doesn't work with blank space?

    Hi all,
    If I have a destination directory with blank space inside, looks like: "C:\Users\Pattrick James\Documents" for Windows or "Macintosh HD:Users:Pattrick James:Documents" for Mac.
    Then I want to copy a file to that directory, use FileUtils::CopyFile(src, des). Why it doesn't work?
    Can someone please help me to resolve this issue without change my path?

    Sorry, it works fine. It happens because the permission of the directory.

  • Why Detect Displays doesn't work anymore?

    I use my PB to watch movies using my TV and the S-Video to RCA cable, but since the last upgrade 10.4.6 the Detect Displays option (in display menu bar AND preference pane) doesn't work.
    The TV shows a dimmed image of what's suppose to show and sometimes it appears vertically distorted.
    I disconnected the S-Video cable and restarted the PB but it still shows that "something" is connected to the s-video port.
    Which files should I delete to "reset" video preferences?
    UPDATE: PRAM reset didn't work...
    Thanks in advance

    Well, the cable can't be the problem, because the computer is "stuck" with a two monitor configuration, even without the cable plugged in, that's why im guessing there's some kind of switch (i hope) that i can reset so the mother board stops thinking i have another display plugged.... the second problem is that if i plug the s-video to rca cable (that came with the laptop) i can't get a clear tv signal from it... it's distorted.... i'll probably open up the computer and check the s-video port... wish me luck.

  • Why the style doesn't work?

    It's my very second test using Flex.
    quote:
    &lt;mx:Application ...&gt;
    &lt;mx:Style&gt;
    Text{
    backgroundColor:#FFFFFF;
    &lt;/mx:Style&gt;
    &lt;mx:HBox&gt;
    &lt;mx:Text /&gt;
    &lt;/mx:HBox&gt; ...
    &lt;/mx:Application&gt;
    This code doesn't work. I'd like to set my text control's
    background to white. Why is it wrong?
    Thanks.

    Because mx:Text does not have a backgroundColor
    style/property.
    Tracy

  • Sound doesn't work(only in firefox). why? sound doesn't work(only in firefox). why? (adobe flash player doesn't work even thought it's installed)

    sound doesn't work (only in firefox). adobe flash player doesn't work correctly, thought it's installed. can't solve the problem. i need Sound.
    == This happened ==
    Every time Firefox opened
    == don't know

    What does the Adobe test page say?
    http://www.adobe.com/software/flash/about/
    Start Firefox in [[Safe Mode]] to check if one of your add-ons is causing your problem (switch to the DEFAULT theme: Tools > Add-ons > Themes).
    See [[Troubleshooting extensions and themes]] and [[Troubleshooting plugins]]
    If it does work in Safe-mode then disable all your extensions and then try to find which is causing it by enabling one at a time until the problem reappears.
    You can use "Disable all add-ons" on the ''Safe mode'' start window.
    You have to close and restart Firefox after each change via "File > Exit" (on Mac: "Firefox > Quit")
    See also [[No sound in Firefox]] and [[Video or audio does not play]]

  • Why my genius doesn't work ?

    Hi
    I want to share my music library to my phone and i created a genius.When i choose a music it said you have to update.I did  but steel doesn't work.
    Could you help me about it?

    Unfortunately, that did not work for me. I just got an iPod touch and while the Genius feature works in iTunes, it is not available on the iPod, even after several syncs and Genius updates. The sync process itself also takes forever even when nothing changed on either the iPod or the computer. Very frustrating. Another odd thing is that iTunes syncs Podcasts to the device that have not been selected in the device setup page ...

  • Why markupDocumentViewer.fullZoom doesn't work on Fennec 4

    Hi,
    I tried to use gBrowser.selectedBrowser.markupDocumentViewer.fullZoom to do page zoom on Fennec 4 accroding https://developer.mozilla.org/en/Full_page_zoom., but it doesn't work. Could you help me solve this problem or put some sample code?
    Thanks,
    newmore

    The "gBrowser" (tabbrowser) object does not exist in Fennec. Also, you cannot access the markupDocumentViewer object from the parent process in Fennec; you will need to use a "frame script" running in the content process.
    For many more details, see: https://wiki.mozilla.org/Mobile/Fennec/Extensions
    For some example code that uses markupDocumentViewer in a Fennec add-on, see:
    http://hg.mozilla.org/users/mbrubeck_mozilla.com/biggertext/file/tip
    And if you have any questions, you can try the #mobile channel on [http://irc.mozilla.org irc.mozilla.org]. (If you don't get a response, be patient - most people on this channel are only around during North America business hours.)

  • HT204053 Why my iCloud doesn't work it says that the maximum number of free account have been activated on this phone

    My iCloud doesn't work even tho I have my the password and the username still it's says that I can't

    Welcome to the Apple Community.
    Unfortunately once all the 3 iCloud accounts have been created on your mobile device, you cannot create any more regardless of what you do. You will need to re-use one of the accounts that you have already created or create your new account on another device or computer.

Maybe you are looking for