Common library class (with injection) for different EJB projects

I want to write a utility class named DBUtil
with methods like
bool checkExist(String tableName, String columnName, String value);This class will use a EntityManager reference to have access to a database.
The point is that I would like it to be injected the EntityManager corresponding
to the EJB project where it is used. This is,
if DBUtil is used in project EJB-A with EntityManager-A then DBUtil accesses
EntityManager-A, but it accesses EntityManager-B if used in project EJB-B.
What is the best approach?
I tried DBUtil having a constructor receiving an EntityManager ref.
But I failed to instantiate DBUtil from the default constructor of a SessionBean
in a EJB project. (It is like that default constructor is not used).
Perhaps I have to deepen into SessioBean lifecycle.
Any suggestion will be very appreciated.
JordiBM

I respond to myself:
JordiBM wrote:
I want to write a utility class named DBUtil
with methods like
bool checkExist(String tableName, String columnName, String value);This class will use a EntityManager reference to have access to a database.
The point is that I would like it to be injected the EntityManager corresponding
to the EJB project where it is used. This is,
if DBUtil is used in project EJB-A with EntityManager-A then DBUtil accesses
EntityManager-A, but it accesses EntityManager-B if used in project EJB-B.
What is the best approach?
I tried DBUtil having a constructor receiving an EntityManager ref.
But I failed to instantiate DBUtil from the default constructor of a SessionBean
in a EJB project. (It is like that default constructor is not used).
Yes. The constructor of the SessionBean is not the right place to do that.
The right place is to write a method in the SessionBean class
annotated with @PostConstruct
This method is called after the injection has taken place:
@Stateful
public class MySessionBean {
   @PersistencyContext
   private Entitymanager em; // the EM of *this* project
   private DBUtil myUtil;  // the utility class of many projects
  @PostConstruct
  public void my_init () {
    myUtil = new DBUtil (em); // we pass it this project's EM.
  public void aMethod () {
    // use myUtil
    myUtil.doSomething();
}

Similar Messages

  • Configuring Log4j for a EJB Project.

    Hi,
    I have a weblogic EJB project as a Ear file. The project has no web components (so war file). I want to know which is the ideal way to initialize log4j in this situation.
    I can use listener class thro' weblogic-application.xml. But there is no neat way to passing the log4j.xml thro' parameter from weblogic-applicaiton.xml file.
    If we are using servlet we could use init-parm to passing xml file. I don't want to hard code the xml file location in the listener class.
    What is the best practice to initialize log4j for a EJB project?
    Thanks in advance.
    Anand

    Dan,
    I had a similar problem because I wanted to define my own log4j config regardless of what other portal apps were deployed in the BEA domain or what log4j was the default for the domain. This is what I do:
    1) Put your log4j config file in the WEB-INF classes dir (or I guess it could be in some other place that the CLASSPATH knows of)
    2) Create a servlet that looks like:
    import javax.servlet.*;
    import javax.servlet.http.*;
    import org.apache.log4j.xml.*;
    public class Log4jInitServlet extends HttpServlet {
    private static final long serialVersionUID = 23456;
    public void init(ServletConfig config) throws ServletException {
    super.init(config);
    DOMConfigurator.configure(Thread.currentThread().getContextClassLoader().getResource("myLog4jConfigFile.xml"));
    public void doGet(HttpServletRequest req, HttpServletResponse resp) {
    3) Add the servlet definition in the web.xml and add a <load-on-startup>1</load-on-startup>
    That should do it.
    - Peter

  • Arrays within custom Classes - same array for different instances?

    Hello all,
    I have made a very simple custom class for keeping track of groups of offices for a company.  The class has a Number variable to tell it how many different offices there are, and an Array to store the individual offices by name.  It looks like this.
    class officeCluster
        static var _className:String = "officeCluster";
        // variables
        var numOffices:Number;
        var locationArray:Array = new Array();
        // functions
        function officeCluster()
            trace("officeCluster constructor");
    Very simple!
    Now, it is my understand that when I create different instances of the class, they will each have their own version of "numOffices" and their own version of "locationArray".
    When I run traces of "numOffices", this seems to be true.  For example,
    trace(manufacturingOfficeCluster.numOffices);
    trace(servicesOfficeCluster.numOffices);
    yields
    5
    4
    In the output panel, which is correct.  However, there is trouble with the locationArray.  It seems that as I assign different values to it, regardless of what instance I specify, there is only ONE array- NOT one for each instance.
    In other words,
    trace(manufacturingOfficeCluster.locationArray[1].theLocation);   // theLocation is a String.  The locationArray itself holds Objects.
    trace(servicesOfficeCluster.locationArray[1].theLocation);
    yields
    New Haven, CT
    New Haven, CT
    even though I have defined elsewhere that they are different!
    Is anyone aware of any issues partaining to using Arrays within Class instances?  Any help would be appreciated!
    note:  I've been able to work around this by creating multiple arrays within the class and using a different one for each instance, but this seems very sloppy.

    Unfortunately, the code segment you attached results in:
    12
    12
    in the output panel.   So the problem must lie elsewhere!  Let me give some more detail...
    There are several files involved. The "officeCluster" class file looks like this:
    class officeCluster
         static var _className:String = "officeCluster";
         // variables
         var numOffices:Number;
         var locationArray:Array = new Array();
         // functions
         function officeCluster()
            trace("officeCluster constructor");
    I have two actionscript files which contain object data for the individual offices.  They look like this...
    var servicesOfficeCluster = new officeCluster();
    servicesOfficeCluster.numOffices = 4;
    var newHope:Object = new Object();
    newHope.locationName = "New Hope Office";
    newHope.theLocation = "New Hope, NJ";
    //more data
    servicesOfficeCluster.locationArray[0] = newHope; //array index is incremented with each entry
    //more Objects...
    and like this...
    var manufacturingOfficeCluster = new officeCluster();
    manufacturingOfficeCluster.numOffices = 5;
    var hartford:Object = new Object();
    hartford.locationName = "Hartford Office";
    hartford.theLocation = "Hartford, CT";
    //more data
    manufacturingOfficeCluster.locationArray[0] = hartford; //array index is incremented with each entry
    //more Objects...
    As you can see, the only difference is the name of the officeCluster instance, and of course the Object data itself.  Finally, these are all used by the main file, which looks like this- I have commented out all the code except for our little test -
    import officeCluster;
    #include "manufacturingList.as"
    #include "servicesList.as"
    /*lots of commented code*/
    manufacturingOfficeCluster.locationArray[1].theLocation = "l1";
    servicesOfficeCluster.locationArray[1].theLocation = "l2";
    trace(manufacturingOfficeCluster.locationArray[1].theLocation);
    trace(servicesOfficeCluster.locationArray[1].theLocation);
    Which, unfortunately, still yields
    12
    12
    as output :\  Any ideas?  Is there something wrong with the way I have set up the class file?  Something wrong in the two AS files?  I'm really starting to bang my head against the wall with this one.
    Thanks

  • How do I generate stub classes with wsimport for secured (SSL) WSDL?

    I'm trying to use the wsimport utility from the JWSDP1.6 to generate the stub classes for a web service client. The problem is that the WSDL location is secured on it's server, and when you navigate to it via a browser it asks you to authenticate before it'll show it. I have access to the WSDL, via a username and password, but I have no idea how to send those parameters to it through wsimport. Here's my error message from wsimport:
    [ERROR] Failed to read the WSDL document: https://-removed4companysecurityreasons-.com/ObsidianAdService.asmx?WSDL, because 1) could not find the document
    ; /2) the document could not be read; 3) the root element of the document is not <wsdl:definitions>.
    unknown location
    Can anyone offer me any advice/solutions here?

    I'm not sure we had support for secured web services access in 10.1.2 - try JDeveloper 10.1.3 instead:
    http://www.oracle.com/technology/products/jdev/howtos/1013/wssecure/10gwssecurity_howto.html#CreateSecureProxy

  • I am having trouble with loops for my IT project

    I am not shour if this is the correct place to post my question.I am sorry if this is the wrong place.
    I have been given a school project to do in netbeans. Under the tab labeled "Timestable drill" I wrote code that is is supposted to output the timetable of a number requested by the user after they click on the view button.I tried to do this using a loop.
    My problem is that the program only outputs the requested number multiplyed by 12 whilst it is supposed to out put something like this: for example the number requested by the user is 2
    0*2=0
    1*2=2
    2*2=4
    3*2=6
    4*2=8
    5*2=10
    6*2=12
    7*2=14
    8*2=16
    9*2=18
    10*2=20
    11*2=22
    12*2=48
    Is there something wrong with my code for the loop or should I use a diffrent component for the screen?
    Any help would be useful. Thank you
    this is my code
    * calcBMI.java
    * Created on 09 July 2008, 10:55
    * @author  Owner
    public class calcBMI extends javax.swing.JFrame {
        /** Creates new form calcBMI */
        public calcBMI() {
            initComponents();
        /** This method is called from within the constructor to
         * initialize the form.
         * WARNING: Do NOT modify this code. The content of this method is
         * always regenerated by the Form Editor.
        @SuppressWarnings("unchecked")
        // <editor-fold defaultstate="collapsed" desc="Generated Code">                         
        private void initComponents() {
            Tabs = new javax.swing.JTabbedPane();
            Standard_Calculator = new javax.swing.JPanel();
            Calculatorlbl = new javax.swing.JLabel();
            Screen = new javax.swing.JTextField();
            btn7 = new javax.swing.JButton();
            btn8 = new javax.swing.JButton();
            btn9 = new javax.swing.JButton();
            btn4 = new javax.swing.JButton();
            btn5 = new javax.swing.JButton();
            btn6 = new javax.swing.JButton();
            btn1 = new javax.swing.JButton();
            btn2 = new javax.swing.JButton();
            btn3 = new javax.swing.JButton();
            btn0 = new javax.swing.JButton();
            btnpoint = new javax.swing.JButton();
            btneq = new javax.swing.JButton();
            btnplus = new javax.swing.JButton();
            btnsubtract = new javax.swing.JButton();
            btnmultiply = new javax.swing.JButton();
            btndiv = new javax.swing.JButton();
            btnclear = new javax.swing.JButton();
            BMI_Calculator = new javax.swing.JPanel();
            Scrn = new javax.swing.JTextField();
            BMIlabel = new javax.swing.JLabel();
            weight_btn = new javax.swing.JButton();
            Height_btn = new javax.swing.JButton();
            Clear = new javax.swing.JButton();
            calcBtn = new javax.swing.JButton();
            Tables_Drill = new javax.swing.JPanel();
            jLabel1 = new javax.swing.JLabel();
            jLabel2 = new javax.swing.JLabel();
            timetable = new javax.swing.JTextField();
            Viewbttn = new javax.swing.JButton();
            jScrollPane2 = new javax.swing.JScrollPane();
            viewing_board = new javax.swing.JTextPane();
            jMenuBar1 = new javax.swing.JMenuBar();
            jMenu2 = new javax.swing.JMenu();
            Quit = new javax.swing.JMenuItem();
            jMenu3 = new javax.swing.JMenu();
            jMenu4 = new javax.swing.JMenu();
            jMenuItem1 = new javax.swing.JMenuItem();
            jMenu1 = new javax.swing.JMenu();
            jMenu5 = new javax.swing.JMenu();
            jMenuItem2 = new javax.swing.JMenuItem();
            How_toBMI = new javax.swing.JMenu();
            jMenuItem3 = new javax.swing.JMenuItem();
            jMenuBar2 = new javax.swing.JMenuBar();
            jMenu6 = new javax.swing.JMenu();
            Quit1 = new javax.swing.JMenuItem();
            jMenu7 = new javax.swing.JMenu();
            jMenu8 = new javax.swing.JMenu();
            jMenuItem4 = new javax.swing.JMenuItem();
            jMenu9 = new javax.swing.JMenu();
            jMenu10 = new javax.swing.JMenu();
            jMenuItem5 = new javax.swing.JMenuItem();
            How_toBMI1 = new javax.swing.JMenu();
            jMenuItem6 = new javax.swing.JMenuItem();
            jMenuBar3 = new javax.swing.JMenuBar();
            jMenu11 = new javax.swing.JMenu();
            Quit2 = new javax.swing.JMenuItem();
            jMenu12 = new javax.swing.JMenu();
            jMenu13 = new javax.swing.JMenu();
            jMenuItem7 = new javax.swing.JMenuItem();
            jMenu14 = new javax.swing.JMenu();
            jMenu15 = new javax.swing.JMenu();
            jMenuItem8 = new javax.swing.JMenuItem();
            How_toBMI2 = new javax.swing.JMenu();
            jMenuItem9 = new javax.swing.JMenuItem();
            jMenuBar4 = new javax.swing.JMenuBar();
            jMenu16 = new javax.swing.JMenu();
            Quit3 = new javax.swing.JMenuItem();
            jMenu17 = new javax.swing.JMenu();
            jMenu18 = new javax.swing.JMenu();
            jMenuItem10 = new javax.swing.JMenuItem();
            jMenu19 = new javax.swing.JMenu();
            jMenu20 = new javax.swing.JMenu();
            jMenuItem11 = new javax.swing.JMenuItem();
            How_toBMI3 = new javax.swing.JMenu();
            jMenuItem12 = new javax.swing.JMenuItem();
            jMenuBar5 = new javax.swing.JMenuBar();
            jMenu21 = new javax.swing.JMenu();
            Quit4 = new javax.swing.JMenuItem();
            jMenu22 = new javax.swing.JMenu();
            jMenu23 = new javax.swing.JMenu();
            jMenuItem13 = new javax.swing.JMenuItem();
            jMenu24 = new javax.swing.JMenu();
            jMenu25 = new javax.swing.JMenu();
            jMenuItem14 = new javax.swing.JMenuItem();
            How_toBMI4 = new javax.swing.JMenu();
            jMenuItem15 = new javax.swing.JMenuItem();
            setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
            Calculatorlbl.setBackground(new java.awt.Color(0, 204, 255));
            Calculatorlbl.setFont(new java.awt.Font("Heather", 1, 18));
            Calculatorlbl.setForeground(new java.awt.Color(0, 204, 204));
            Calculatorlbl.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
            Calculatorlbl.setText("CALCULATOR");
            btn7.setBackground(new java.awt.Color(204, 204, 204));
            btn7.setForeground(java.awt.Color.magenta);
            btn7.setText("7");
            btn7.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    btn7ActionPerformed(evt);
            btn8.setBackground(new java.awt.Color(204, 204, 204));
            btn8.setForeground(java.awt.Color.magenta);
            btn8.setText("8");
            btn8.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    btn8ActionPerformed(evt);
            btn9.setBackground(new java.awt.Color(204, 204, 204));
            btn9.setForeground(java.awt.Color.magenta);
            btn9.setText("9");
            btn9.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    btn9ActionPerformed(evt);
            btn4.setBackground(new java.awt.Color(204, 204, 204));
            btn4.setForeground(java.awt.Color.magenta);
            btn4.setText("4");
            btn4.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    btn4ActionPerformed(evt);
            btn5.setBackground(new java.awt.Color(204, 204, 204));
            btn5.setForeground(java.awt.Color.magenta);
            btn5.setText("5");
            btn5.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    btn5ActionPerformed(evt);
            btn6.setBackground(new java.awt.Color(204, 204, 204));
            btn6.setForeground(java.awt.Color.magenta);
            btn6.setText("6");
            btn6.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    btn6ActionPerformed(evt);
            btn1.setBackground(new java.awt.Color(204, 204, 204));
            btn1.setForeground(java.awt.Color.magenta);
            btn1.setText("1");
            btn1.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    btn1ActionPerformed(evt);
            btn2.setBackground(new java.awt.Color(204, 204, 204));
            btn2.setForeground(java.awt.Color.magenta);
            btn2.setText("2");
            btn2.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    btn2ActionPerformed(evt);
            btn3.setBackground(new java.awt.Color(204, 204, 204));
            btn3.setForeground(java.awt.Color.magenta);
            btn3.setText("3");
            btn3.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    btn3ActionPerformed(evt);
            btn0.setBackground(new java.awt.Color(204, 204, 204));
            btn0.setForeground(java.awt.Color.magenta);
            btn0.setText("0");
            btn0.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    btn0ActionPerformed(evt);
            btnpoint.setBackground(new java.awt.Color(204, 204, 204));
            btnpoint.setForeground(java.awt.Color.magenta);
            btnpoint.setText(".");
            btnpoint.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    btnpointActionPerformed(evt);
            btneq.setBackground(new java.awt.Color(204, 204, 204));
            btneq.setForeground(java.awt.Color.magenta);
            btneq.setText("=");
            btneq.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    btneqActionPerformed(evt);
            btnplus.setText("+");
            btnplus.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    btnplusActionPerformed(evt);
            btnsubtract.setText("-");
            btnsubtract.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    btnsubtractActionPerformed(evt);
            btnmultiply.setText("*");
            btnmultiply.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    btnmultiplyActionPerformed(evt);
            btndiv.setText("/");
            btndiv.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    btndivActionPerformed(evt);
            btnclear.setText("C");
            btnclear.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    btnclearActionPerformed(evt);
            javax.swing.GroupLayout Standard_CalculatorLayout = new javax.swing.GroupLayout(Standard_Calculator);
            Standard_Calculator.setLayout(Standard_CalculatorLayout);
            Standard_CalculatorLayout.setHorizontalGroup(
                Standard_CalculatorLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(Standard_CalculatorLayout.createSequentialGroup()
                    .addGroup(Standard_CalculatorLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(Standard_CalculatorLayout.createSequentialGroup()
                            .addGap(45, 45, 45)
                            .addComponent(Calculatorlbl, javax.swing.GroupLayout.PREFERRED_SIZE, 237, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGroup(Standard_CalculatorLayout.createSequentialGroup()
                            .addGap(31, 31, 31)
                            .addGroup(Standard_CalculatorLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addGroup(Standard_CalculatorLayout.createSequentialGroup()
                                    .addGroup(Standard_CalculatorLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                        .addGroup(Standard_CalculatorLayout.createSequentialGroup()
                                            .addComponent(btn7)
                                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                            .addComponent(btn8)
                                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                            .addComponent(btn9))
                                        .addGroup(Standard_CalculatorLayout.createSequentialGroup()
                                            .addComponent(btn4)
                                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                            .addComponent(btn5)
                                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                            .addComponent(btn6))
                                        .addGroup(Standard_CalculatorLayout.createSequentialGroup()
                                            .addComponent(btn1)
                                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                            .addComponent(btn2)
                                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                            .addComponent(btn3))
                                        .addGroup(Standard_CalculatorLayout.createSequentialGroup()
                                            .addComponent(btn0)
                                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                            .addComponent(btnpoint)
                                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                            .addComponent(btneq)))
                                    .addGap(60, 60, 60)
                                    .addGroup(Standard_CalculatorLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                        .addComponent(btnmultiply)
                                        .addGroup(Standard_CalculatorLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                            .addComponent(btnclear)
                                            .addComponent(btndiv))
                                        .addComponent(btnsubtract)
                                        .addComponent(btnplus)))
                                .addComponent(Screen, javax.swing.GroupLayout.PREFERRED_SIZE, 277, javax.swing.GroupLayout.PREFERRED_SIZE))))
                    .addContainerGap(38, Short.MAX_VALUE))
            Standard_CalculatorLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {btnclear, btndiv, btnmultiply, btnplus, btnsubtract});
            Standard_CalculatorLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {btn0, btn1, btn2, btn3, btn4, btn5, btn6, btn7, btn8, btn9, btneq, btnpoint});
            Standard_CalculatorLayout.setVerticalGroup(
                Standard_CalculatorLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(Standard_CalculatorLayout.createSequentialGroup()
                    .addContainerGap()
                    .addComponent(Calculatorlbl, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGap(18, 18, 18)
                    .addComponent(Screen, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGap(18, 18, 18)
                    .addGroup(Standard_CalculatorLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(Standard_CalculatorLayout.createSequentialGroup()
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 4, Short.MAX_VALUE)
                            .addGroup(Standard_CalculatorLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(btn8)
                                .addComponent(btn7)
                                .addComponent(btn9))
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addGroup(Standard_CalculatorLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(btn4)
                                .addComponent(btn5)
                                .addComponent(btn6))
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addGroup(Standard_CalculatorLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(btn1)
                                .addComponent(btn3, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(btn2))
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addGroup(Standard_CalculatorLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(btn0)
                                .addComponent(btnpoint)
                                .addComponent(btneq))
                            .addGap(25, 25, 25))
                        .addGroup(Standard_CalculatorLayout.createSequentialGroup()
                            .addComponent(btnplus, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(btnsubtract)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(btnmultiply, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(btndiv)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(btnclear)))
                    .addGap(37, 37, 37))
            Tabs.addTab("Standard Calculator", Standard_Calculator);
            BMIlabel.setFont(new java.awt.Font("Heather", 1, 18));
            BMIlabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
            BMIlabel.setText("BMI Calculator");
            weight_btn.setText("Weight (Kg)");
            weight_btn.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    weight_btnActionPerformed(evt);
            Height_btn.setText("Height (m)");
            Height_btn.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    Height_btnActionPerformed(evt);
            Clear.setText("Clear");
            Clear.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    ClearActionPerformed(evt);
            calcBtn.setText("Calculate");
            calcBtn.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    calcBtnActionPerformed(evt);
            javax.swing.GroupLayout BMI_CalculatorLayout = new javax.swing.GroupLayout(BMI_Calculator);
            BMI_Calculator.setLayout(BMI_CalculatorLayout);
            BMI_CalculatorLayout.setHorizontalGroup(
                BMI_CalculatorLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(BMI_CalculatorLayout.createSequentialGroup()
                    .addGroup(BMI_CalculatorLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(BMI_CalculatorLayout.createSequentialGroup()
                            .addGap(40, 40, 40)
                            .addGroup(BMI_CalculatorLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                .addComponent(weight_btn)
                                .addComponent(Height_btn))
                            .addGap(66, 66, 66)
                            .addGroup(BMI_CalculatorLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(calcBtn)
                                .addComponent(Clear)))
                        .addGroup(BMI_CalculatorLayout.createSequentialGroup()
                            .addContainerGap()
                            .addComponent(Scrn, javax.swing.GroupLayout.PREFERRED_SIZE, 301, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGroup(BMI_CalculatorLayout.createSequentialGroup()
                            .addGap(29, 29, 29)
                            .addComponent(BMIlabel, javax.swing.GroupLayout.PREFERRED_SIZE, 263, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addContainerGap(35, Short.MAX_VALUE))
            BMI_CalculatorLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {Clear, Height_btn, calcBtn, weight_btn});
            BMI_CalculatorLayout.setVerticalGroup(
                BMI_CalculatorLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(BMI_CalculatorLayout.createSequentialGroup()
                    .addContainerGap()
                    .addComponent(BMIlabel, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGap(9, 9, 9)
                    .addComponent(Scrn, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGap(34, 34, 34)
                    .addGroup(BMI_CalculatorLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(weight_btn)
                        .addComponent(calcBtn))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                    .addGroup(BMI_CalculatorLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(Height_btn)
                        .addComponent(Clear))
                    .addContainerGap(100, Short.MAX_VALUE))
            Tabs.addTab("BMI Calculator", BMI_Calculator);
            jLabel1.setText("Tables drill");
            jLabel2.setText("Timetable ");
            Viewbttn.setText("VIEW");
            Viewbttn.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    ViewbttnActionPerformed(evt);
            jScrollPane2.setViewportView(viewing_board);
            javax.swing.GroupLayout Tables_DrillLayout = new javax.swing.GroupLayout(Tables_Drill);
            Tables_Drill.setLayout(Tables_DrillLayout);
            Tables_DrillLayout.setHorizontalGroup(
                Tables_DrillLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(Tables_DrillLayout.createSequentialGroup()
                    .addGroup(Tables_DrillLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(Tables_DrillLayout.createSequentialGroup()
                            .addContainerGap()
                            .addGroup(Tables_DrillLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, 387, Short.MAX_VALUE)
                                .addGroup(Tables_DrillLayout.createSequentialGroup()
                                    .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 65, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addGap(41, 41, 41)
                                    .addGroup(Tables_DrillLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                        .addComponent(timetable, javax.swing.GroupLayout.PREFERRED_SIZE, 129, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addComponent(Viewbttn, javax.swing.GroupLayout.PREFERRED_SIZE, 84, javax.swing.GroupLayout.PREFERRED_SIZE))
                                    .addGap(152, 152, 152))))
                        .addGroup(Tables_DrillLayout.createSequentialGroup()
                            .addGap(55, 55, 55)
                            .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 256, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addContainerGap())
            Tables_DrillLayout.setVerticalGroup(
                Tables_DrillLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(Tables_DrillLayout.createSequentialGroup()
                    .addContainerGap()
                    .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGap(18, 18, 18)
                    .addGroup(Tables_DrillLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(timetable, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(Viewbttn, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGap(40, 40, 40)
                    .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 84, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addContainerGap(41, Short.MAX_VALUE))
            Tabs.addTab("Tables Drill", Tables_Drill);
            jMenu2.setText("File");
            Quit.setText("Exit");
            Quit.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    QuitActionPerformed(evt);
            jMenu2.add(Quit);
            jMenuBar1.add(jMenu2);
            jMenu3.setText("Edit");
            jMenu4.setText("Clear");
            jMenuItem1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_C, java.awt.event.InputEvent.ALT_MASK));
            jMenuItem1.setText("Screen");
            jMenuItem1.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jMenuItem1ActionPerformed(evt);
            jMenu4.add(jMenuItem1);
            jMenu3.add(jMenu4);
            jMenuBar1.add(jMenu3);
            jMenu1.setText("Help");
            jMenu5.setText("Standard Calculator");
            jMenuItem2.setText("Item");
            jMenu5.add(jMenuItem2);
            jMenu1.add(jMenu5);
            How_toBMI.setText("BMI Calculator");
            How_toBMI.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    How_toBMIActionPerformed(evt);
            jMenuItem3.setText("How to use");
            How_toBMI.add(jMenuItem3);
            jMenu1.add(How_toBMI);
            jMenuBar1.add(jMenu1);
            jMenu6.setText("File");
            Quit1.setText("Exit");
            Quit1.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    QuitActionPerformed(evt);
            jMenu6.add(Quit1);
            jMenuBar2.add(jMenu6);
            jMenu7.setText("Edit");
            jMenu8.setText("Clear");
            jMenuItem4.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_C, java.awt.event.InputEvent.ALT_MASK));
            jMenuItem4.setText("Screen");
            jMenuItem4.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jMenuItem1ActionPerformed(evt);
            jMenu8.add(jMenuItem4);
            jMenu7.add(jMenu8);
            jMenuBar2.add(jMenu7);
            jMenu9.setText("Help");
            jMenu10.setText("Standard Calculator");
            jMenuItem5.setText("Item");
            jMenu10.add(jMenuItem5);
            jMenu9.add(jMenu10);
            How_toBMI1.setText("BMI Calculator");
            How_toBMI1.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    How_toBMIActionPerformed(evt);
            jMenuItem6.setText("How to use");
            How_toBMI1.add(jMenuItem6);
            jMenu9.add(How_toBMI1);
            jMenuBar2.add(jMenu9);
            jMenu11.setText("File")                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          &nbs

    I love when new people think they have to show their entire application when they only have a problem with a little piece.
    If you have a problem with a loop, just post the loop! Why should we need to sift through all your GUI code and other irrelevant nonsense? It's your job to show us the information we need to help you.

  • I need help with TransparentBackgrounds for a school project

    So i had found the transparentBackground class
    * @(#)TransparentBackground.java
    * @author
    * @version 1.00 2010/2/26
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.image.*;
    import java.text.NumberFormat;
    public class TransparentBackground extends JComponent implements ComponentListener, WindowFocusListener, Runnable{
        private JFrame frame;
        private Image background;
         private long _lastUpdate = 0;
         private boolean _refreshRequested = true;
         public Robot rbt;
         public Toolkit tk;
         public Dimension dim;
         public Point pos;
         public Point offset;
         long total;
         long used;
    public TransparentBackground(JFrame frame) {
        this.frame = frame;
        updateBackground();
        frame.addComponentListener(this);
         frame.addWindowFocusListener(this);
        new Thread(this).start();
    public void updateBackground( ) {
        try {
             total = Runtime.getRuntime().totalMemory();
             used  = (Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory())/1024;
             System.out.println("updateBackground() Run: Memory Usage: " + used +" MB");
            rbt = new Robot();
            tk = Toolkit.getDefaultToolkit( );
            dim = tk.getScreenSize( );
            background = rbt.createScreenCapture(
            new Rectangle(0,0,(int)dim.getWidth( ),
                              (int)dim.getHeight( )));
        } catch (Exception ex) {
    public void paintComponent(Graphics g) {
         System.out.println("paintComponent() Run");
        pos = this.getLocationOnScreen();
        offset = new Point(-pos.x,-pos.y);
        g.drawImage(background,offset.x,offset.y,null);
    protected void refresh() {
              if (frame.isVisible() && this.isVisible()) {
                   repaint();
                   _refreshRequested = true;
                   _lastUpdate = System.currentTimeMillis();
              System.out.println("refresh() Run");
    // ComponentListener -------------------------------------------------------
         public void componentHidden(ComponentEvent e) {
         public void componentMoved(ComponentEvent e) {
              repaint();
         public void componentResized(ComponentEvent e) {
              repaint();
         public void componentShown(ComponentEvent e) {
              repaint();
         // WindowFocusListener -----------------------------------------------------
         public void windowGainedFocus(WindowEvent e) {
              refresh();
         public void windowLostFocus(WindowEvent e) {
              refresh();
    public void run() {
              try {
                   while (true) {
                        Thread.sleep(10);
                        long now = System.currentTimeMillis();
                        if (_refreshRequested && ((now - _lastUpdate) > 100)) {
                             if (frame.isVisible()) {
                                  Point location = frame.getLocation();
                                  frame.setLocation(-frame.getWidth(), -frame.getHeight());
                                  updateBackground();
                                  frame.setLocation(location);
                                  refresh();
                             _lastUpdate = now;
                             _refreshRequested = false;
                             System.out.println("run() END------------");
              } catch (InterruptedException e) {
                   e.printStackTrace();
    }In have like 8 - 12 of these "panels" in my program. They are not running simultaneously but each one is created everytime I press a button.
    I have A button ing main class (x) and another class (y)
    Class y
    public JFrame Frame;
    public TransparentBackground Panel;
    class y()
    public void makeMe()
    Frame = new JFrame(" ");
         Panel= new TransparentBackground(Frame);
      ///   ....all the combining
       // and then
       frame.setVisible(true);
    public void hideMe()
         frame.setVisible(false);
    }When press A which has only one instanciation of class y:
    it calls
    y.makeMe()
    and then it when I press it again
    it calls
    y.hideMe()
    and then this same process goes on for like 8 times before it starts to show this
    updateBackground() Run: Memory Usage: 248606 MB
    Exception in thread "Thread-25" java.lang.OutOfMemoryError: Java heap space
        at sun.awt.windows.WRobotPeer.getRGBPixels(WRobotPeer.java:46)
        at java.awt.Robot.createScreenCapture(Robot.java:329)
        at TransparentBackground.updateBackground(TransparentBackground.java:45)
        at TransparentBackground.run(TransparentBackground.java:104)
        at java.lang.Thread.run(Thread.java:619)
    paintComponent() Run
    refresh() Run
    paintComponent() RunBTW: the x and y class are just skeletal classes, but the actual ones I use in the programs are filled with Images and all that good stuff..
    So my ulimate question is..
    Why dose it make that error?
    and i also tried to increase the heap space, but it still showed the same error.
    I am just a newbie, so i would appreciate if the explainations are easier to understand for beginners
    thank you for reading and taking interest

    I don't understand you GUI approach at all: you are making a very basic board game. You need not even do an animation loop as a continuously running process. While I have not gone over your code extensively, what your errors and glimpsing at your code says to me is that you don't have your objects being disposed of because they are running--your "while(true)" loop is not being canceled/stopped.
    You need to make a very basic animation loop and look at making your events happen accordingly. You can easily paint your cards/messages over portions of the playing screen and have them age off with a timer or other triggered events--this removes the need of your while(true) loops and runnable objects.
    On the other hand, you do not need to implement runnable nor have a running animation loop with a basic GUI. When you have your "cards" pop up, they need not be objects that implement runnable either, but just basic GUI components.
    Anyways, I'm just at a loss as to your need to have everything implement runnable.

  • How to manage seasrch directorie​s for different TestStand projects and different users?

    I am working with several others and we share some number of directories and at the same time own different directories for each projects. Problem rises when there are duplicated VI names are created by two users working on two different projects. Search path has to be manually changed to avoid loading a wrong VI. Sometimes user forgets to change and load a duplicated VI name. Is there a better way to manage th search paths?

    LegalEngineer -
    Matt's comments above regarding the SearchDirectories object only apply to TestStand 3.0.
    Under TestStand 2.0.1, you have to manage the settings in the config file Testexec.ini. You can also have read access to the search directories by accessing the .Data.SearchDirectories array property that is returned from Engine.ConfigFile().
    Scott Richardson (NI)
    Scott Richardson
    National Instruments
    Attachments:
    temp.jpg ‏15 KB

  • Co-writing with Garageband for iPad: sharing projects between 2 iPads

    Hello, all,
    I am hoping somebody can help me achieve what something that it strikes me that Garageband on the iPad should be perfect for, but which I just can't seem to figure out!
    I am the guitarist in a band, and hoping to use my iPad to co-write songs with the singer, who lives in another town.
    We can't always get together for writing sessions, but, since we both have iPads, I assumed that I could start projects by making some instrumental recordings on my iPad, and then share the project with the singer to add vocals on their iPad, and that they could then send the track back to me for further editing, adding extra parts to, etc.
    This seems like it would be a great way to develop songs with a co-writer without having to be in the same room -- but I just can't figure out how to do it!
    It seems I can send a sound file to email from my iPad's Garageband, but how would the singer import that file into their iPad's Garageband? Surely it can't be that difficult, but I've read a lot online and there just doesn't seem to be a way to do this.
    Any suggestions or advice would be very gratefully received!

    Hi Zapruder,
    On the 'Help' file on my ipod there'sn a section about uploading the file to SoundCloud. Have you checked it out yet?
    Steverino1

  • EventService lookup from ejb project

    hi
    We want to use the EventService from with in a class which resides in an ejb project of our portal application.
    We used the EventService from within the portal webapp project without problems. With
    Object o = p_context.lookup( "java:comp/env/ejb/EventService" );
    we could lookup the object and narrow it to the EventServiceHome interface. However this does not work within the ejb project.
    We get the error message:
    "javax.naming.NameNotFoundException: While trying to look up comp/env/ejb/EventService in /app/ejb/scp_helpers.jar#EJBTTHelper.; remaining name 'comp/env/ejb/EventService'"
    We tried another name which we found in different depoyment descriptors: p13n_ejb.jar#EventService . No success.
    What name do we have to use or shortly: what are we doing wrong? How could we get the EventService SessionBean from within an ejb project?

    look up the resource-ref in web.xml (and weblogic.xml). Add the same in ejb-jar.xml (and weblogic-ejb-jar.xml). The entries are not exactly the same, but the concept is the same.
    Best regards...
    hi
    We want to use the EventService from with in a class
    which resides in an ejb project of our portal
    application.
    We used the EventService from within the portal
    webapp project without problems. With
    Object o = p_context.lookup(
    "java:comp/env/ejb/EventService" );
    we could lookup the object and narrow it to the
    EventServiceHome interface. However this does not
    work within the ejb project.
    We get the error message:
    "javax.naming.NameNotFoundException: While trying to
    look up comp/env/ejb/EventService in
    /app/ejb/scp_helpers.jar#EJBTTHelper.; remaining name
    'comp/env/ejb/EventService'"
    We tried another name which we found in different
    depoyment descriptors: p13n_ejb.jar#EventService . No
    success.
    What name do we have to use or shortly: what are we
    doing wrong? How could we get the EventService
    SessionBean from within an ejb project?

  • Workshop, ant, and ejb project

    I exported an ant build file from the workshop for an ejb project. I ran
    the build from the command line. I got the following exception:
    java.lang.NoClassDefFoundError: com/bea/ide/Application
    at
    com.bea.wls.build.DeleteModuleTask.execute(DeleteModuleTask.java:32)
    at org.apache.tools.ant.Task.perform(Task.java:319)
    at org.apache.tools.ant.Target.execute(Target.java:309)
    at org.apache.tools.ant.Target.performTasks(Target.java:336)
    at org.apache.tools.ant.Project.executeTarget(Project.java:1306)
    at org.apache.tools.ant.Project.executeTargets(Project.java:1250)
    at org.apache.tools.ant.Main.runBuild(Main.java:610)
    at org.apache.tools.ant.Main.start(Main.java:196)
    at org.apache.tools.ant.Main.main(Main.java:235)
    Any ideas, suggestions, workarounds?
    Your help in this regard is greatly appreciated...

    DESCRIPTION:
    If you have overloaded methods with the same parameter name but the different parameter type and running EJBGen on the bean, all the overloaded methods are not included in the Remote interface.
    Like if you have the following methods:
    1)-public Record getRecord(Integer pRecordId)
    2)-public Record getRecord(Integer pRecordId, String str)
    3)-public Record getRecord(Integer pRecordId, double str)
    running EJBGen on it will include only the method 1 and the method 2 in the remote interface.
    Does this match what you were seeing? (the WLS CR is marked as fixed in 10.0 - patch is requested for 9.2/9.1)

  • EJB project creation in Eclipse

    Hi All,
    i am using Eclipse 3.2 to create an EJB module.
    i created a new EJB project......in it in ejbModule, i created a package and a JAVA class in it...........
    when in the JAVA class, i wrote import javax.ejb.SessionBean; it gave error on javax.ejb saying "javax.ejb cant be resolved"............
    Can anybody suggest how to rectify this error.
    Thanks,
    Rajeev Gupta

    Hi All,
    i created a jar file for my ejb project...........
    Now i imported that jar file in a new java prj, then i am able to instantiate that ejb class in the main method of the new java prj.........
    In the window i can also see all methods of the ejb class.........
    My ejb-jar xml file is having the below content:
    <ejb-jar id="ejb-jar_ID" version="2.1" xmlns="http://java.sun.com/xml/ns/j2ee" 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/ejb-jar_2_1.xsd">
         <description>Hello World EJB description</description>
         <display-name>prjHelloWorldEJB</display-name>
         <enterprise-beans>          
                   <ejb-name>HelloWorldEJB</ejb-name>
                   <ejb-class>pkgHelloWorldEJB.HelloWorldEJB</ejb-class>               
                   <session-type>Stateless</session-type>
                   <transaction-type>Container</transaction-type>          
         </enterprise-beans>
    </ejb-jar>
    Like i declared a function:
    public String strReturn(){
              return "Hello JAVA EJB World";     
    When i called this function by obj.strReturn() then no compilation error was there.
    <b>But when i run this JAVA prj application, it gave error java.lang.NoClassDefFoundError: pkgEJB/ClassEJB
         at pkg.class.main of JAVA prj application</b>.
    Can anybody suggest me what should i do to rectify this situation.
    Thanks,
    Rajeev Gupta

  • EJB project in Eclipse 3.2

    Hi All,
    i am trying to develop a demo EJB project in Eclipse 3.2 so after it i can use it in some other demo project.....i am not developing a adapter module.....i am developing a simple EJB project by implementing SessionBean only.
    now i am facing a problem that     i am not able to see EJB Candidate   in  my EJB-Project, so i am not able to add my class file to ejb-jar xml file........i am also not able to see ejb-j2ee-engine.xml............
    So can anybody help me to rectify this situation.
    Thanks,
    Rajeev Gupta

    Hi Wang,
    i am not developing a adapter module......i am developing just a demo ejb project in Eclipse 3.2 for using it in another java prj.....well my above problem is resolved now...........
    now i am facing the below issue:
    i created a jar file for my ejb project...........then i imported that jar file in a new java prj, then i am able to instantiate that ejb class in the main method of the new java prj.........
    In the window i can also see all methods of the ejb class.........
    My ejb-jar xml file is having the below content:
    <ejb-jar id="ejb-jar_ID" version="2.1" xmlns="http://java.sun.com/xml/ns/j2ee" 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/ejb-jar_2_1.xsd">
    <description>Hello World EJB description</description>
    <display-name>prjHelloWorldEJB</display-name>
    <enterprise-beans>
    <ejb-name>HelloWorldEJB</ejb-name>
    <ejb-class>pkgHelloWorldEJB.HelloWorldEJB</ejb-class>
    <session-type>Stateless</session-type>
    <transaction-type>Container</transaction-type>
    </enterprise-beans>
    </ejb-jar>
    Like i declared a function:
    public String strReturn(){
    return "Hello JAVA EJB World";
    When i called this function by obj.strReturn() then no compilation error was there.
    <b>But when i run this JAVA prj application, it gave error java.lang.NoClassDefFoundError: pkgEJB/ClassEJB
    at pkg.class.main of JAVA prj application.</b>
    Can anybody suggest me what should i do to rectify this situation.
    Thanks,
    Rajeev Gupta

  • EJB project IDE build dos not include properties files

    We have property files also which we want included as part of the build process
    for EJB projects but if we use the IDE build it does not include them. We have
    to therefore export the IDE build and customize it to include *.properties like
    this
    <zip basedir="${dest.path}" zipfile="${ejb.outputJar}" encoding="UTF8"> <!-- JARs
    filenames are encoded UTF8 --> <zipfileset dir="${project.local.directory}" includes="*.properties"
    /> </zip>
    which causes a problem for us because the exported build file is specific to a
    user's local PC and cannot be used in a team environment.
    How can we have the IDE build include all the files within an EJB project i.e.
    include properties files also.

    Hey Jamie,
    Currently there is no support to include other .properties files into
    the internal build. There's a build.properties that you get as part of
    an EJB project which you could place your values into and use that as
    your template for your team based development and check that into your
    source control.
    If you'd really like to get gross and hack Workshop a little bit you
    could modify the default EJB project template to use your .properties
    file for every EJB project you create. This would then splat a copy of
    your .properties file into the root of the EJB project.
    To do that you'd go to {your BEAHOME}\workshop\templates and crack open
    the ejb-project.zip template zip file and merge your settings into the
    existing build.properties file. This has the same
    effect as replacing the .properties file after you've created your
    project only it keeps you from having to perform that step each time.
    The downside of this is that each person on your team would then have to
    update that template zip file in their workshop installation. (I'd make
    sure to backup the original template file before performing this
    activity so you can always go back to the original template).
    Hope this helps,
    -Michael
    Jamie wrote:
    We have property files also which we want included as part of the build process
    for EJB projects but if we use the IDE build it does not include them. We have
    to therefore export the IDE build and customize it to include *.properties like
    this
    <zip basedir="${dest.path}" zipfile="${ejb.outputJar}" encoding="UTF8"> <!-- JARs
    filenames are encoded UTF8 --> <zipfileset dir="${project.local.directory}" includes="*.properties"
    /> </zip>
    which causes a problem for us because the exported build file is specific to a
    user's local PC and cannot be used in a team environment.
    How can we have the IDE build include all the files within an EJB project i.e.
    include properties files also.

  • Two libraries needing different versions of a common library

    I am currently writing an application that utilizes two libraries that depend on a third common library. However, each of the two libraries requires a different version of the third library. Is there any way this can be done?
    I have done some research into writing custom class loaders but I haven't been able to find anything useful in this instance. Any help would be appreciated. Thanks.

    It's not just a feature missing that's the problem.
    If I use one version of the library, one part of the
    program simply doesn't work. If I use the other,
    then the other part of the program refuses to work.The problem you should be trying to solve is why the two libraries won't work with the same (latest) version of the shared library. It indicates that one of them is relying on buggy behavior, and should be fixed.
    Do you have any access to the libraries' source code? You'd be far better off trying to figure out what changed, and how to fix the piece that relied on its old behavior, rather than any sort of hack (and changing package structure to work around a bug is definitely a hack, perhaps moreso than using a custom classloader).
    Finally, what does "doesn't work" mean? Are you unable to compile? Are you able to compile but get incorrect results? Does the program crash?

  • WebLogic 12.1.2 fails when deploying ear with injecting extension and bean with injection of this extension in ejb

    WebLogic 12.1.2 fails when deploying an enterprise application(ear) that contains a ejb in which injected 1) an extension 2)bean with injection of this extension.
    The following exception is thrown:
    Caused By: org.jboss.weld.exceptions.DeploymentException: WELD-001409 Ambiguous dependencies for type [CdiExtension] with qualifiers [@Default] at injection point [[field] @Inject private test.extension.Bean1.extension].
    Possible dependencies [
    [Extension [class test.extension.CdiExtension] with qualifiers [@Default]; zip:/domain1/servers/AdminServer/tmp/_WL_user/test/7x6roh/lib/test-extension-0.0.1-SNAPSHOT.jar!/META-INF/services/javax.enterprise.inject.spi.Extension@1[test.extension.CdiExtension@1115deb],
    Extension [class test.extension.CdiExtension] with qualifiers [@Default]; zip:/domain1/servers/AdminServer/tmp/_WL_user/test/7x6roh/lib/test-extension-0.0.1-SNAPSHOT.jar!/META-INF/services/javax.enterprise.inject.spi.Extension@1[test.extension.CdiExtension@ed791f]]]
        at org.jboss.weld.bootstrap.Validator.validateInjectionPoint(Validator.java:314)
        at org.jboss.weld.bootstrap.Validator.validateInjectionPoint(Validator.java:280)
        at org.jboss.weld.bootstrap.Validator.validateBean(Validator.java:143)
        at org.jboss.weld.bootstrap.Validator.validateRIBean(Validator.java:163)
        at org.jboss.weld.bootstrap.Validator.validateBeans(Validator.java:382)
        at org.jboss.weld.bootstrap.Validator.validateDeployment(Validator.java:367)
        at org.jboss.weld.bootstrap.WeldBootstrap.validateBeans(WeldBootstrap.java:379)
        at com.oracle.injection.provider.weld.WeldInjectionContainer.start(WeldInjectionContainer.java:106)
        at com.oracle.injection.integration.CDIAppDeploymentExtension.initCdi(CDIAppDeploymentExtension.java:70)
        at com.oracle.injection.integration.CDIAppDeploymentExtension.activate(CDIAppDeploymentExtension.java:47)
        at weblogic.application.internal.flow.AppDeploymentExtensionFlow.activate(AppDeploymentExtensionFlow.java:37)
        at weblogic.application.internal.BaseDeployment$2.next(BaseDeployment.java:729)
        at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:42)
        at weblogic.application.internal.BaseDeployment.activate(BaseDeployment.java:258)
        at weblogic.application.internal.EarDeployment.activate(EarDeployment.java:61)
        at weblogic.application.internal.DeploymentStateChecker.activate(DeploymentStateChecker.java:165)
        at weblogic.deploy.internal.targetserver.AppContainerInvoker.activate(AppContainerInvoker.java:80)
    Problem can be easily reproduced by a minimal case:
    test.ear:
    \lib\test-extension-0.0.1-SNAPSHOT.jar
    test-ejb-0.0.1-SNAPSHOT.jar
    where
    test-extension-0.0.1-SNAPSHOT.jar contains:
    CdiExtension.java:
    package test.extension;
    import javax.enterprise.inject.spi.Extension;
    public class CdiExtension implements Extension {
        private String someString = "Some String";
        public String getSomeString() {
            return someString;
    Bean1.java:
    package test.extension;
    import javax.enterprise.context.ApplicationScoped;
    import javax.inject.Inject;
    @ApplicationScoped
    public class Bean1 {
        @Inject
        private CdiExtension extension;
        public String get() {
            return extension.getSomeString();
    test-ejb-0.0.1-SNAPSHOT.jar contains:
    EjbBean.java:
    package test;
    import test.extension.Bean1;
    import test.extension.CdiExtension;
    import javax.ejb.Stateless;
    import javax.inject.Inject;
    @Stateless
    public class EjbBean {
        @Inject
        private CdiExtension extension;
        @Inject
        private Bean1 bean1;
        public String getSomeString() {
            return extension.getSomeString() + "\n" + bean1.get();
    p.s. i seen same problem in community.oracle.com/thread/2577403 , but it happen in "war", not "ear", and seems successfully patched with patch №17424706

    Hi,
    It looks like there is patch exists for this issue.
    Patch 17198187
    Please try to download from the MOS or try to open a ticket with support.
    Regards,
    Kal

Maybe you are looking for

  • CS4 InDesign Auto update Links

    I seem to be having a problem with CS4. When I click the edit original button the image is brought up, change done, Indesign updates. The problem is when I switch back to the image with out clicking edit original and come back to InDesign. It no long

  • Movement Artifacts and the Reduction Thereof

    Heyo! I recently started using Final Cut Express 4.0.1 on a MacBook running Lion, and I ran into a curious error when importing some footage from a borrowed JVC Everio GZ-MS240 camera. The first issue into which I ran was that this camera creates .MO

  • Black and white laser printer for Imac running 8.6 os

    Does anyone know of a laser printer for my older Imac running 8.6 os?

  • SAP XI 3.0 Tutorial

    I know this forum has many requests on a daily basis for tutorials for beginners. Does anyone know online a sample scenario with XI sending an receiving idocs via email? Thanks for the info. Steve Edited by: Stephen Hardeman on Feb 11, 2008 2:39 PM

  • Freehand Crashing

    Yesterday, after working for several hours, I tried to type something and Freehand 11.0 crashed. Not unheard of, so I relaunched the program. Crashed again. And again and again and again. I tried a different file - crash. Every time I try to use the