Link to home
Start Free TrialLog in
Avatar of viola123
viola123

asked on

how to solve java.lang.NoClassDefFoundError: javax/ejb/EJBObject?

Hi all,
i am new to JDeveloper and J2ee.
i opened an application in Jdeveloper 11, and complie it, it is fine. run it, i got error java.lang.NoClassDefFoundError: javax/ejb/EJBObject

what library i missing?

thanks a lot

Loading libraries
Exception in thread "main" java.lang.NoClassDefFoundError: javax/ejb/EJBObject
	at java.lang.ClassLoader.defineClass1(Native Method)
	at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
	at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
	at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
	at java.net.URLClassLoader.access$000(URLClassLoader.java:56)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
	at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
	at au.com.ords.commission.client.CommissionMain.<init>(CommissionMain.java:83)
	at au.com.ords.commission.client.CommissionMain.main(CommissionMain.java:992)
Caused by: java.lang.ClassNotFoundException: javax.ejb.EJBObject
	at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
	at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
	... 14 more
Library directory not found.Process exited with exit code 1.

Open in new window

SOLUTION
Avatar of Mick Barry
Mick Barry
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of viola123
viola123

ASKER

hi all,
i already put j2ee.jar into the libraries and classpath before i run it. i am new to jdeveloper. so i want to make sure if my setting is correct or not:
the library settings is under project propertise-->libraries and classpath-->classpath entries: there listed the libraries the application uses.
if i am correct, then the j2ee.jar is in there already.

thanks a lot
it seems you are running application server in jdeveloper;i think go application server properties and add this jar file and then restart the app server in jdeveloper.
hi, i am new to Jdevloper, could you pls let me know how to add this file to application server?
which server are you running
Are you sure the jar has been added (and is not just available)
we are using apache tomcat6.0
but i am running this application on my local machine, it is an desktopGUI j2ee app
EJB wont work in tomcat
hi objects:
i am totoally new to Jdeveloper and j2ee, i try to open/complie/run/debug this existing application in Jdeveloper, it complies fine. but it is failed when running. if you know how to make sure the library is added into the project, pls let me know how to do it /how to check it in JDeveloper?

thanks a lot
chaituu:
sorry, we use Jboss for this application
check whether j2ee.jar exists in jboss/default/lib folder
check your run profile settings
objects:
where is the run profile settings?
actually it is  jboss-j2ee.jar should be placed  in jboss/default/lib folder

if you are running jboss in jdevloper check this link.

http://www.oracle.com/technology/products/jdev/howtos/appservers/deploy_to_jboss.html
from memory its in project properties
objects:
in project properties-->run/debug/profile-->run configurations: default

what i gonna do next?
chaituu:
i found i don't have jboss installed, OMG! I need to download it. i am currently using java jdk1.6.0. this application is using j2sdk 1.4.2, j2ee 1.3.1, jboss 3.2.3, log 4j 1.2.8
which jboss version i should download?

thanks a lot
why do you need jboss? I thought this was a standalone application
objects:
actually i know nothing about this project and no one knows about this project in my team. it is a very old project. in the functional specification, says j2sdk 1.4.2, j2ee 1.3.1, jboss 3.2.3, log 4j 1.2.8 are used to build this system.
i only know how to run it. like what i said before, it is a desktopGUI project. it is installed on user's local machine and run by a batch file.
now we have a bug which is java.lang.out of memory. and i guess that's because the heap size is not enough, so i tried
java –Xms256M –Xmx512M -jar comtrac.jar
but i still get that out of memory error. so i have to open this project and try to debug it in JDeveloper.
honestly, i don't know  if i need JBoss or not.
i am newbie to Java.

doesn't sound like you need it

sounds more like it needs profiling

whats the error you're getting btw?
objects:
we use this application to upload file and export it to a specified folder. it was working very well but suddenly failed when you upload the file even you use the one which was uploaded successfully.

pls have a look at the img.

step3b.JPG
can you post a screen cap of the project libraries dialog in jdeveloper
object:
see the attachments
    private void btnImportActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnImportActionPerformed
        if ((selectedAllocationHeader != null) && 
            (selectedAllocationHeader.getPostingID() == null || 
             selectedAllocationHeader.getPostingID().intValue() == 0))
        {    
            modeHeader = GUIHelper.IMPORT;

            int maxBankLines = 15;
            int blankLineCount = 0;

            adjustReversalList = new Vector(10);

            // Open a csv file
            final String FILE_EXT = new String("csv");

            javax.swing.JFileChooser fileChooser = new javax.swing.JFileChooser();
            au.com.ords.commission.client.util.file.BasicFileFilter filter = new au.com.ords.commission.client.util.file.BasicFileFilter(FILE_EXT);

            fileChooser.addChoosableFileFilter(filter);
            // don't show all file option
            fileChooser.setAcceptAllFileFilterUsed(false);

            // set current directory to Imports
            java.io.File currentDirectory = null;
            try
            {
                currentDirectory = new java.io.File(GUIHelper.getSystemProperty("DefaultImportDirectory"));
            }
            catch (NullPointerException nex)
            {
                currentDirectory = null;
            }
            if (currentDirectory == null || !currentDirectory.exists())
            {
                currentDirectory = new java.io.File(System.getProperty("user.home"));
            }

            fileChooser.setCurrentDirectory(currentDirectory);
            int retVal = fileChooser.showOpenDialog(this);

            if (retVal == javax.swing.JFileChooser.APPROVE_OPTION)
            {
                //got a file name user has chosen
                String fileName = fileChooser.getSelectedFile().getAbsolutePath();

                if (!fileName.toLowerCase().endsWith("." + FILE_EXT))
                {
                    fileName += "." + FILE_EXT;
                }

                this.setCursor(new java.awt.Cursor(java.awt.Cursor.WAIT_CURSOR));

                try
                {
                    java.text.DecimalFormat formatter = new java.text.DecimalFormat("#");

                    java.io.FileReader fis = new java.io.FileReader(fileName);
                    java.io.LineNumberReader lis = new java.io.LineNumberReader(fis);

                    this.getGSTStatus();
                    String headerStatus = this.getHeaderStatus();

                    // read the file
                    // first line is the header
                    String line = lis.readLine();

                    // if second line is a list of classes, skip that as well
                    while (line != null)
                    {
                        //if it is a blank line, ignore it;
                        //but 15 blank lines in row, the program thinks the import file is ended
                        String tempLine = line;

                        if (tempLine.replaceAll(",", "").trim().length() == 0)  //blank line
                        {
                            blankLineCount ++;
                            if (blankLineCount > 15)
                            {
                                break;
                            }
                        }
                        else
                        {
                            blankLineCount = 0;

                            // process the line
                            Object[] row = this.processCSVLine(line);
                            AllocationView allocation = new AllocationView();

                            // Go through the whole line to pick up imported data
                            // only 7 columns of the imported data
                            allocation.setTransTypeRef(((String)row[0]).trim().toUpperCase());

                            allocation.setClientRef(((String)row[1]).trim().toUpperCase());

                            // will throw NumberFormatException if entry no a number of format #0.00
                            Double allocationAmount = null;

                            String tempAmount = (String)row[2];

                            //System.out.println("Original = " + tempAmount);
                            tempAmount = tempAmount.replaceAll(",", "");    // for case of #,###,000.00
                            tempAmount = tempAmount.replaceAll("\\$", "");    // for amounts with '$'
                            //System.out.println("Processed = " + tempAmount);
                            allocationAmount = new Double(tempAmount);

                            allocation.setAllocationAmount(allocationAmount);

                            if (allocationAmount != null)
                            {
                                getGST(allocationAmount, gstStatus);
                                allocation.setGST(new Double(GST));
                                allocation.setGrossCommission(new Double(grossCommission));
                                allocation.setNetCommission(new Double(netCommission));
                            }

                            String tempFaceValue = ((String)row[3]).trim();
                            //System.out.println("Original FV = " + tempFaceValue);
                            tempFaceValue = tempFaceValue.replaceAll(",", "");    // for case of #,###,000.00
                            tempFaceValue = tempFaceValue.replaceAll("\\$", "");  // remove any $
                            //System.out.println("Processed FV = " + tempFaceValue);
                            if (tempFaceValue.equals(""))
                            {
                                // face value not assigned, set to zero
                                allocation.setFaceValue(new Double(0));
                            }
                            else
                            {
                                // will throw NumberFormatException if entry not a number of format #0.00
                                allocation.setFaceValue(new Double(tempFaceValue));
                            }

                            if (row.length > 4)
                            {
                                if (((String)row[4]).equals(""))
                                    allocation.setProductRef(null);
                                else
                                    allocation.setProductRef(((String)row[4]).trim().toUpperCase());
                            }
                            else
                                allocation.setProductRef(null);

                            if (row.length > 5)
                            {
                                if (((String)row[5]).equals(""))
                                    allocation.setClient(null);
                                else
                                    allocation.setClient(((String)row[5]).toUpperCase());
                            }
                            else
                                allocation.setClient(null);

                            if (row.length > 6)
                            {
                                if (((String)row[6]).equals(""))
                                    allocation.setAdvisor(null);
                                else
                                    allocation.setAdvisor(((String)row[6]).toUpperCase());
                            }
                            else
                                allocation.setAdvisor(null);

                            allocation.setAllocationStatus(headerStatus);

                            adjustReversalList.add(allocation);
                            maxPosition ++;

                        }
                        // read another line
                        line = lis.readLine();
                    }

                    lis.close();
                    fis.close();

                    //Read the whole ClientRef table from DB
                    //Read the whole transTypeRef table from DB
                    //Read the productRef table from DB
                    //get a session bean instance
                    if (allocationSession == null)
                    {
                        try
                        {
***************Exception occurs here***********************
                            GUIHelper.getAllocationEJBInterface();
*******************************************
                        }
                        catch (Exception oEx)
                        {
                            javax.swing.JOptionPane.showMessageDialog(this, "Failed to create Allocation EJBInterface, the Allocation will not work.", "Allocation Error", javax.swing.JOptionPane.ERROR_MESSAGE);
                        }
                        allocationSession = (AllocationManager) GUIHelper.ejbInterface.get("allocation");
                    }

                    Hashtable tableClientRef = null;
                    Hashtable tableProductRef = null;
                    Hashtable tableTransTypeRef = null;

                    try
                    {
                        tableClientRef  = allocationSession.searchClientReferenceBySQL(null);

                        String condition = " AND PRODUCTREFERENCE.PRODUCTPROVIDER_ID = " + providerID;
                        tableProductRef  = allocationSession.searchProductReferenceBySQL(condition);

                        condition = " AND TRANSACTIONTYPEREFERENCE.PRODUCTPROVIDER_ID = " + providerID;
                        tableTransTypeRef  = allocationSession.searchTransTypeReferenceBySQL(condition);
                    }
                    catch (FinderException fe)
                    {
                        userLog.info(this.getClass().getName() + " -- FinderException = " + fe.getMessage());
                        showError("Allocation Error", "Unable to find data.", fe);
                    }
                    catch (RemoteException re)
                    {
                        userLog.info(this.getClass().getName() + " -- RemoteException = " + re.getMessage());
                        showError("Allocation Error", "Unable to contact Application Server.", re);
                    }
                    catch (Exception oEx)
                    {
                        showError("Allocation Error", "Allocation Error.", oEx);
                    }

                    //Match ClientRef, ProductRef, and transRef
                    if (adjustReversalList.size() != 0)
                    {
                        for (int i = 0; i < adjustReversalList.size(); i++)
                        {
                            AllocationView allocation = (AllocationView)adjustReversalList.elementAt(i);

                            String tmpTransTypeRef = allocation.getTransTypeRef().trim();
                            String tmpTransTypeRef2 = providerID + "|" +
                                                      allocation.getTransTypeRef().trim().toUpperCase();

                            String tmpClientRef = allocation.getClientRef().trim();
                            String tmpClientRef2 = providerID + "|" +
                                                   allocation.getClientRef().trim().toUpperCase();
                            String tmpClientRef3 = GUIHelper.ORDML + "|" +
                                                   allocation.getClientRef().trim().toUpperCase();

                            String tmpProductRef = allocation.getProductRef();
                            //In the import file, the productRef can be empty
                            String tmpProductRef2 = null;
                            if (tmpProductRef != null)
                                tmpProductRef2 = providerID + "|" + tmpProductRef.trim().toUpperCase();
                            else
                                tmpProductRef2 = providerID + "|";

                            if (tableClientRef.get(tmpClientRef2) != null)
                            {
                                //System.out.println("tmpClientRef2="+tmpClientRef2);
                                Vector details = (Vector)tableClientRef.get(tmpClientRef2);
                                allocation.setClientID((Long)details.elementAt(0));
                                allocation.setClientLastName((String)details.elementAt(1));
                                allocation.setClientFirstName((String)details.elementAt(2));
                                allocation.setDesignation((String)details.elementAt(3));
                                allocation.setAdvCode((String)details.elementAt(4));
                                allocation.setAdvLastName((String)details.elementAt(5));
                                allocation.setAdvFirstName((String)details.elementAt(6));
                            }
                            else if (tableClientRef.get(tmpClientRef3) != null)
                            {
                                //System.out.println("tmpClientRef3="+tmpClientRef3);
                                Vector details = (Vector)tableClientRef.get(tmpClientRef3);
                                allocation.setClientID((Long)details.elementAt(0));
                                allocation.setClientLastName((String)details.elementAt(1));
                                allocation.setClientFirstName((String)details.elementAt(2));
                                allocation.setDesignation((String)details.elementAt(3));
                                allocation.setAdvCode((String)details.elementAt(4));
                                allocation.setAdvLastName((String)details.elementAt(5));
                                allocation.setAdvFirstName((String)details.elementAt(6));
                            }
                            else if (tableClientRef.get(tmpClientRef) != null)
                            {
                                //System.out.println("tmpClientRef="+tmpClientRef);
                                Vector details = (Vector)tableClientRef.get(tmpClientRef);
                                allocation.setClientID((Long)details.elementAt(0));
                                allocation.setClientLastName((String)details.elementAt(1));
                                allocation.setClientFirstName((String)details.elementAt(2));
                                allocation.setDesignation((String)details.elementAt(3));
                                allocation.setAdvCode((String)details.elementAt(4));
                                allocation.setAdvLastName((String)details.elementAt(5));
                                allocation.setAdvFirstName((String)details.elementAt(6));
                            }
                            else
                            {
                                allocation.setClientID(new Long(0));
                                allocation.setClientLastName("");
                                allocation.setClientFirstName("");
                                allocation.setDesignation("");
                                allocation.setAdvCode("");
                                allocation.setAdvLastName("");
                                allocation.setAdvFirstName("");
                            }

                            if (tableProductRef.get(tmpProductRef2) != null)
                            {
                                //System.out.println("tmpProductRef2="+tmpProductRef2);
                                Vector details = (Vector)tableProductRef.get(tmpProductRef2);
                                allocation.setProductID((Long)details.elementAt(0));
                                allocation.setProductCode((String)details.elementAt(1));
                            }
                            else
                            {
                                allocation.setProductID(new Long(0));
                                allocation.setProductCode("");
                            }

                            if (tableTransTypeRef.get(tmpTransTypeRef2) != null)
                            {
                                //System.out.println("tmpTransTypeRef2="+tmpTransTypeRef2);
                                Vector details = (Vector)tableTransTypeRef.get(tmpTransTypeRef2);
                                allocation.setTransactionTypeID((Long)details.elementAt(0));
                                allocation.setTransTypeCode((String)details.elementAt(1));
                            }
                            else
                            {
                                allocation.setTransactionTypeID(new Long(0));
                                allocation.setTransTypeCode("");
                            }
                        }

                        gstStatus = cboGSTStatus.getSelectedItem().toString();

                        //Fill the adjustReversalList to the current Header on the screen
                        int totalRow = fillAdjustReversalList(gstStatus, adjustReversalList);
                        fillTotals();

                        //Save the Header and all imported details
                        if (processAllocationHeader(iStatRow) == GUIHelper.OK)
                        {
                            iStatRow = iStatRow + totalRow;
                            maxExceptionPosition = iStatRow - 1;
                            maxPosition = iStatRow - 1;

                            //if no line is selected, highlight 1st line
                            if (allocationDataTable.getSelectedRow() < 0)
                            {
                                currentPosition = 0;
                                getSelectedAllocation(currentPosition);
                            }
                        }
                        else
                        {
                            clearUpTotals();
                            fillTotals();
                            allocationDataTable.setDataTableContents(null,allocationTableHeading);
                            javax.swing.JOptionPane.showMessageDialog(this,"Error happened during Importing, please check your import file");
                        }
                    }
                    this.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.DEFAULT_CURSOR));
                }
                catch (java.io.FileNotFoundException oEx)
                {
                    this.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.DEFAULT_CURSOR));
                    System.out.println("FileNotFoundException: " + oEx.getMessage());
                    showError("Allocation Error", "FileNotFoundException", oEx);
                }
                catch (java.io.IOException oEx)
                {
                    this.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.DEFAULT_CURSOR));
                    System.out.println("IOException: " + oEx.getMessage());
                    showError("Allocation Error", "IOException", oEx);
                }
                catch (Exception oEx)
                {
                    javax.swing.JOptionPane.showMessageDialog(this, "Something wrong in the Import file", "Allocation Import Error", javax.swing.JOptionPane.ERROR_MESSAGE);
                    this.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.DEFAULT_CURSOR));
                    oEx.printStackTrace();
                    System.out.println("Exception: " + oEx.getMessage());
                    showError("Allocation Error", "Exception", oEx);
                    
                }
            }
            modeHeader = GUIHelper.SEARCH;
        }
        else if (selectedAllocationHeader == null)
            javax.swing.JOptionPane.showMessageDialog(this, msgSelectHeader);
        else if (selectedAllocationHeader.getPostingID().intValue() != 0)
            javax.swing.JOptionPane.showMessageDialog(this, msgLockHeader);
    }//GEN-LAST:event_btnImportActionPerformed

Open in new window

lib.JPG
hi object,
i will be back tomorrow morning.

see u tomorrow
hi object,
do you have any suggestion?

thanks
Whats he GUIHelper class?
hi objects:
it is a big class file, do you want me to send it to you? or show u here?
GUIHelper is a static class file. the method of getAllocationEJBInterface is attched
    public static void getAllocationEJBInterface() throws Exception {
        AllocationManager session = null;
        
        try {
            /** Creates a JNDI naming context for
             * location objects */
            Context context = new InitialContext(GUIHelper.getEnvironment());
            
            /** Asks the context to locate an object named "AllocationManager" and expects the
             * object to implement the AllocationManagerHome interface
             **/
            System.out.println("Prepare to call Session Bean AllocationManagerHome via Jboss ");
            AllocationManagerHome home = (AllocationManagerHome)PortableRemoteObject.narrow(context.lookup("commission/AllocationManager"), AllocationManagerHome.class);
            
            /** Asks the Home interface to create a new session bean */
            System.out.println("Create the Allocation Session Bean AllocationManager");
            session = (AllocationManager)home.create();
            
        }
        catch (NamingException ex) {
            throw new NamingException("Naming Exception occured when tried to get the commission/AllocationManager");
        }
        catch (RemoteException ex) {
            throw new RemoteException("Remote Exception occured when tried to get the commission/AllocationManager");
        }
        catch (CreateException ex) {
            throw new CreateException("Failed to create Allocation Session Bean");
        }
        
        ejbInterface.put("allocation", session);
    }

Open in new window

hi objects,
i already have that jar jbossall-client.jar in library. pls reference the thread 33043430 above.
thanks a lot
sorry missed it in there

how exactly are you currently running it?
1. now i try to run it in JDeveloper. i show you the contents of run/debug/profile-->run configurations: default,
to make sure the settings are correct. pls look at the attachment.

2. as i met the error java.lang.NoClassDefFoundError: javax/ejb/EJBObject when i try to run it. so currently, i right click the Main.java to run it from there. it starts the application but i got database problem. when i try to search a product, it executes a sql and return to me by saying there is an invalid identifier xxx. BUT I checked the table, that field does exist. so i think it is a database connection problem.
in my application folder META-INF--> oracle-ds.xml , it defines the database connection like the following:
<datasources>
    <local-tx-datasource>
        <jndi-name>OracleDS2</jndi-name>
        <connection-url>jdbc:oracle:thin:@xx.xxx.x.xxx:xxxx:COMTRAC</connection-url>
       <driver-class>oracle.jdbc.driver.OracleDriver</driver-class>
        <user-name>xxx</user-name>
        <password>xxx</password>
       <exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleExceptionSorter</exception-sorter-class-name>
<min-pool-size>0</min-pool-size>
        <max-pool-size>80</max-pool-size>
        <blocking-timeout-millis>5000</blocking-timeout-millis>
        <idle-timeout-minutes>5</idle-timeout-minutes>
        <prepared-statement-cache-size>0</prepared-statement-cache-size>
    </local-tx-datasource>
</datasources>

i am wondering if i still need to define the database connection in application level or somewhere?

thanks a lot
profile.JPG
starting to get beyond where I can help you without know a lot more about the application

That run configuration looks like it relies on the jars manifest to locate dependant jars

Re the database I don't know enough about how the database is being used to help with that
hi,
the run configuration is i set, i don't know that's the correct setting, should i use main.java instead of the commtrac.jar?
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
thanks a lot!!