Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6752835
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T13:05:27+00:00 2026-05-26T13:05:27+00:00

I have a hello-world style java ee application using maven3 glassfish3 and javaee6. I

  • 0

I have a hello-world style java ee application using maven3 glassfish3 and javaee6.

I have a simple session bean:

package com.mytest.beans;

import com.mytest.interfaces.HelloBeanRemote;
import javax.ejb.Stateless;

@Stateless
public class HelloBean implements HelloBeanRemote{

    @Override
    public String sayHello() {
        return "well hello there";
    }
}

it exposes a remote interface. this interface is in the same module but a different package.

package com.mytest.interfaces;

import javax.ejb.Remote;

@Remote
public interface HelloBeanRemote {

    public String sayHello();

}

I am using the maven-ejb-plugin to create an ejb-client artifact which my client module depends on.

I wrote this simple app-client

package com.mytest;

import com.mytest.interfaces.HelloBeanRemote;
import java.awt.Container;
import javax.ejb.EJB;
import javax.swing.JButton;
import javax.swing.JFrame;

/**
 * Enterprise Application Client main class.
 *
 */
public class Main {

    @EJB
    private static HelloBeanRemote hb;

    public static void main( String[] args ) {
        JFrame frame = new JFrame();
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        Container pane = frame.getContentPane();
        JButton button = new JButton("i have not been pushed");
        pane.add(button);
        frame.pack();
        frame.setVisible(true);
        try {
            Thread.sleep(5000);
        } catch (InterruptedException ex) {
        }
        button.setText(hb.sayHello());
    }
}

this worked for me as expected. however when I changed my app-client to this:

package com.mytest;

import com.mytest.interfaces.HelloBeanRemote;
import java.awt.Container;
import javax.ejb.EJB;
import javax.swing.JButton;
import javax.swing.JFrame;

/**
 * Enterprise Application Client main class.
 *
 */
public class Main {

    public static void main( String[] args ) {
        JFrame frame = new JFrame();
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        Container pane = frame.getContentPane();
        MyButton button = new MyButton("i have not been pushed");
        pane.add(button);

        frame.pack();
        frame.setVisible(true);
    }
}

…

package com.mytest;

import com.mytest.interfaces.HelloBeanRemote;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.ejb.EJB;
import javax.swing.JButton;


public class MyButton extends JButton implements ActionListener{

    @EJB
    private HelloBeanRemote hb;

    public MyButton(String string){
        super(string);
        addActionListener(this);
    }

    @Override
    public void actionPerformed(ActionEvent e) {
        setText(hb.sayHello());
    }

}

this will not work as expected when I click the button.

Can someone please enlighten me!

Thank you so much.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T13:05:28+00:00Added an answer on May 26, 2026 at 1:05 pm

    The glassfish development guide says:

    Annotation is supported for the main class and the optional callback
    handler class in application clients.

    So, either you inject the beans in the main class, and build some sort of singleton registry where all the classes will get a reference to the EJBs, or you use JNDI to get a reference to a bean, or you use some dependency injection framework (Spring, Guice, etc.) which will have its own injection rules and will use the registry or JNDI as a factory for the EJB references.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple Hello World style .air application. How do I turn it
I am learning java ee right now. I have successfully implemented a hello-world style
I have finally created a very simple Hello World style PHP Extension dll on
In my hello world application, i have a button and a text field set
I have a simple PHP app that prints 'hello world'. When I run it
I have this simple hello world version of a google map api javascript v3
I've implemented a simple Observer pattern in a hello world style app. I've got
So I have a tag like [code style=php]<?php echo Hello world!; ?>[/code] A user
Does anyone have a hello world sample or tutorial for creating an Eclipse plugin
I have created a Hello World web part. When I pressed F5 in Visual

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.