Importing javax.ejb problems

Hi,
I have started learning EJB using netbeans 6.5 running on a mac os X 10.5.6. When i am trying to import javax.ejb and error stating that package javax.ejb does not exist.
From a search on the net i have learned that on windows os it is a problem of class paths. I don't know how to solve this problem on mac.
Thanks
Ray

Here is what I have done recently:
I tried it in Eclipse, which also isn't able to find javax.ejb and java.ejb
What is going wrong? It seems like j2ee.jar doesn't provide these libraries.
Thank you.

Similar Messages

  • Import javax.ejb.EJBHome; cannot resolve symbol

    Hi i wonder if anyone can help me. I have read alot of the posts regarding this issue and have tried everything to do with the paths and environmental variables and even reinstalled everything.
    import javax.ejb.EJBHome; cannot resolve symbol
    This is the problem i keep getting and here are the paths that i set:
    SET PATH=c:\j2sdkee1.3\bin;c:\jdk1.3.1_01\bin;c:\jakarta-ant-1.3\bin
    SET ANT_HOME=c:\jakarta-ant-1.3
    SET JAVA_HOME=c:\jdk1.3.1_01
    SET J2EE_HOME=c:\j2sdkee1.3
    SET CLASSPATH=c:\j2sdkee1.3\lib\j2ee.jar;c:\jakarta-ant-1.3\lib\ant.jar;c:\jdk1.3.1_01\lib\tools.jar
    What am i doing wrong???

    Im not sure, everything looks ok to me, but here is what i tried:
    I wrote this little test class, and compiled it
    import javax.ejb.EJBHome;
    public class test
    public test()
    I got the same error you did (or similar)
    D:\>javac test.java
    test.java:1: package javax.ejb does not exist
    import javax.ejb.EJBHome;
    ^
    1 error
    then I added the j2ee.jar to my classpath and everything worked fine.
    here are my env vars:
    JAVA_HOME=d:\dev\jdk
    J2EE_HOME=d:\dev\j2sdkee
    CLASSPATH=...;%J2EE_HOME%\lib\j2ee.jar
    If I were you I would double check all the paths you have set up then try a simple case like the one above. If your running NT/2000 make sure the JAVA_HOME, J2EE_HOME and CLASSPATH are system variables not user variables. Another thing you can try is adding the j2ee.jar to the classpath with the -classpath compiler switch.
    javac -classpath %CLASSPATH%;d:\dev\j2sdkee\lib\j2ee.jar test.java
    Other than those things I'm not sure
    Good Luck

  • Could not import javax.ejb.* package

    On compiling my EJB program the following errors appears
    C:\bea\wlserver6.0sp1\samples\examples\ejb\basic\ValidateBean>javac ValidateBean
    .java
    ValidateBean.java:3: Package javax.ejb not found in import.
    import javax.ejb.*;
    ^
    ValidateBean.java:4: Class javax.ejb.CreateException not found in import.
    import javax.ejb.CreateException;
    ^
    ValidateBean.java:5: Class javax.ejb.SessionBean not found in import.
    import javax.ejb.SessionBean;
    ^
    ValidateBean.java:6: Class javax.ejb.SessionContext not found in import.
    import javax.ejb.SessionContext;
    ^
    ValidateBean.java:7: Class javax.naming.InitialContext not found in import.
    import javax.naming.InitialContext;
    ^
    ValidateBean.java:8: Class javax.naming.NamingException not found in import.
    import javax.naming.NamingException;
    ^
    ValidateBean.java:9: Package javax.sql not found in import.
    import javax.sql.*;
    ^
    ValidateBean.java:15: Interface javax.ejb.SessionBean of class examples.ejb.basi
    c.ValidateBean.ValidateBean not found.
    public class ValidateBean implements SessionBean {
    ^
    8 errors
    for these errors do i have to install any other package and
    what are the classpath settings required.
    and in which *.jar file, these classes and packages are available

    javax.ejb.* is in j2ee.jar
    if you use weblogic6.0, you need download ejb20.jar from http://www.weblogic.com
    if you use weblogic6.1 ,you need't this file.

  • Import javax.ejb cannot be resolved

    Hi,
    There are some libraries missing in the following code.
    package era.budget;
    import javax.ejb.*;
    import era.budget.BudgetVO;
    public class BudgetItemVO implements java.io.Serializable
         private Integer itemId;
         private BudgetVO budget;
         private int type;
         private String itemDetails;
         private int amount;
    // -------------- BEGIN GET/SET METHODS --------------
    public BudgetItemVO(Integer id)
              this.itemId = id;
         public BudgetItemVO()
         public Integer getItemId()
              return itemId;
    public BudgetVO getBudget()
              return budget;
         public void setBudget(BudgetVO budget)
              this.budget=budget;
    public int getType()
              return type;
         public void setType(int id)
         this.type=id;
    public String getItemDetails()
              return this.itemDetails;
    public void setItemDetails(String details)
              this.itemDetails=details;
    public int getAmount()
              return this.amount;
    public void setAmount(int amount)
    this.amount=amount;
    As aresult of these missing libraries there are some compilation errors..Some of the errors are as follows
         1)The import javax.ejb cannot be resolved     
         2)EntityBean cannot be resolved to a type     
    3)EntityContext cannot be resolved to a type     
    4)EJBLocalObject cannot be resolved to a type     
    Thanx & Regards
    Maria.

    try: in your project properties choose 'Java Build Path' and add javaee.jar (from J2EE_HOME\lib) as external jar

  • Import javax.ejb.*

    Hello,
    i was able to import javax.ejb.*
    i did
    set classpath=c:\j2sdkee1.3.1\lib\j2ee.jar
    then compiled my file, i also need a class file which is in the c:\pro\project3
    called Item.class
    i'm getting an error where i'm doing
    public Item
    it say, can't fine class Item.
    how can i use j2ee.jar and also use Item.class
    thanks alot

    set classpath=c:\j2sdkee1.3.1\lib\j2ee.jar;c:\pro\project3

  • Import javax.ejb errors when compiling

    Hi,
    when I am compiling my EJBs, (I am using Eclipse 2.1.1 , but I got the same thing using Bluej) I am getting errors that point to my import statements such as:
    import javax.ejb.SessionBean;
    do I need to install some jar files anywhere and configure my classpath? in order to be able to use EJBs?
    many thanks
    yan

    thanks,
    I already have j2ee installed and I have the j2ee.jar file in my classpath
    I was wondering if it was something more specific than this
    yan

  • Import javax.swing problems

    hey
    I am new to java and have recently downloaded j2sdk1.4.2_04. I am trying to create a simple graphical application. However, It doesnt seem to import the javax.swing.* libraries. I understand that there is the src.zip in the directory, so I unzipped it but it still doesn't read the package. I read elsewhere on this forum that you should set the path to src.zip. I have tried that and it also doesnt work. My current path is:
    PATH=C:\j2sdk1.4.2_04\lib\src.zip;C:\j2sdk1.4.2_04\bin
    Is there an error in this, or what else should I try? All suggestions greatly appreciated.

    There's no need to set your classpath when importing any of the standard packages that are provided by the JDK. Perhaps you could post a (small) code sample and the compiler error you are getting.

  • The import javax.ejb cannot be resolved

    Hi all,
    I have a bean working fine when deployed as jar on weblogic but it gives the above error when deployed as ear. Deployment goes ok but when I try to use it I get the error.
    Anybody has any idea of what the problem could be?
    Thanks,
    A.

    I figured out that if I include j2ee.jar in the ear file and the entry j2ee.jar in the Class-Path of the manifest file inside the jar then everything works, but I can't understand why...do I ALWAYS need to include j2ee.jar for every aplication that I deploy?
    A.

  • BMP question : got javax.ejb.EJBException error Object state not saved

    Could anybody please help me? I could not figure out what i did wrong.
    I got the javax.ejb.EJBException error: Object state not saved
    when i test the getname() method for findByPrimaryKey() and findAll() methods.
    Here is my code:
    package org.school.idxc;
    import javax.sql.*;
    import javax.naming.*;
    import javax.ejb.*;
    import javax.sql.*;
    import java.sql.Connection;
    import java.sql.PreparedStatement;
    import java.sql.ResultSet;
    import java.sql.SQLException;
    import java.sql.Statement;
    import java.util.ArrayList;
    import java.util.Collection;
    import java.util.Enumeration;
    import java.util.Vector;
    * Bean implementation class for Enterprise Bean: status
    public class statusBean implements javax.ejb.EntityBean {
         private javax.ejb.EntityContext myEntityCtx;
         private int id;
         private String name;
         private DataSource ds;
         private String dbname = "jdbc/idxc";
         private Connection con;
         * ejbActivate
    public void ejbActivate() {
         * ejbLoad
         public void ejbLoad() {
         System.out.println("Entering EJBLoad");
         try
         Integer primaryKey = (Integer) myEntityCtx.getPrimaryKey();
         String sqlstmt = "select id, name from from status where id =?";
         con = ds.getConnection();
         PreparedStatement stmt = con.prepareStatement(sqlstmt);
         stmt.setInt (1,primaryKey.intValue());
         ResultSet rs = stmt.executeQuery();
         if (rs.next())
              this.id = rs.getInt(1);
              this.name = rs.getString (2).trim();
              stmt.close();
         } // if
         else
              stmt.close();
              throw new NoSuchEntityException ("Invalid id " + id);
         }// else
              } // try
         catch (SQLException e)
         System.out.println("EJBLOad : " + e.getMessage());
              } // catch
         finally
         try
              if (con != null)
              con.close();
              }// try
         catch (SQLException e)
              System.out.println("EJBLOad finally" + e.getMessage());
              } // catch
              }// finally
         * ejbPassivate
         public void ejbPassivate() {
         * ejbRemove
         public void ejbRemove() throws javax.ejb.RemoveException {
         System.out.println ("Entering ejb Removed");
         try
         String sqlstmt = "delete from status where id=" + id;
         con = ds.getConnection();
         Statement stmt = con.createStatement();
         stmt.executeUpdate(sqlstmt);
         stmt.close();
         }// try
         catch (SQLException e)
         System.out.println("Ejb Remove" + e.getMessage());     
         } // catch
         finally
         try
              if (con!=null)
                   con.close();
         }// try
         catch (SQLException e)
              System.out.println ("EJBRemoved " + e.getMessage());
         } // catch
         } // finally
         * ejbStore
         public void ejbStore() {
         System.out.println("Entering the ejbStore");
         try
    String sqlstmt = "update status set id=" + id + ",name='" + name + "' where id=" + id;
         con = ds.getConnection();
         Statement stmt = con.createStatement();
         if (stmt.executeUpdate(sqlstmt) != 1)
              throw new EJBException ("Object state not saved");
    stmt.close();     
         } // try
         catch (SQLException e)
              System.out.println ("EJBStore : " + e.getMessage());
         }// catch
         finally
         try
              if (con != null)
              con.close();
         } // try
         catch(SQLException e)
              System.out.println ("EJBStore finally " + e.getMessage());
         } // catch
         } // finally
         * getEntityContext
         public javax.ejb.EntityContext getEntityContext() {
              return myEntityCtx;
         * setEntityContext
         public void setEntityContext(javax.ejb.EntityContext ctx) {
              myEntityCtx = ctx;
              try
              InitialContext initial = new InitialContext();
              ds = (DataSource)initial.lookup(dbname);
    } // try
              catch (NamingException e)
              throw new EJBException ("set Entity context : Invalid database");     
              }// catch
         * unsetEntityContext
         public void unsetEntityContext() {
              myEntityCtx = null;
         * ejbCreate
         public Integer ejbCreate(Integer key, String name) throws javax.ejb.CreateException {
    this.id = key.intValue();
    this.name = name;
              System.out.println ("Entering ejbCreated!!!");
              try
              String sqlstmt = "insert into status(id,name) values (" + id + ",'" + (name == null ? "" : name) + "')";
              con = ds.getConnection();
              Statement stmt = con.createStatement();
              stmt.executeUpdate(sqlstmt);
              stmt.close();
              }// try
              catch (SQLException e)
              System.out.println("EJBCreate : SQLEXception ");     
              }// catch
              finally
              try
              if (con!=null)
                   con.close();
              }// try
              catch (SQLException e)
              System.out.println ("EJB Created Finally : SQLException");
              e.getMessage();
              } // catch
              }// finally
              this.id = key.intValue();
              this.name = name;
              return key ;
         * ejbPostCreate
         public void ejbPostCreate(Integer id, String name) throws javax.ejb.CreateException {
         * ejbFindByPrimaryKey
         public Integer ejbFindByPrimaryKey(
              Integer key) throws javax.ejb.FinderException {
              try
              String sqlstmt = "select id from status where id=" + key.intValue();
              con = ds.getConnection();
              Statement stmt = con.createStatement();
    ResultSet rs = stmt.executeQuery(sqlstmt);
              if (!rs.next())
              throw new ObjectNotFoundException();     
              } // if
              rs.close();
              stmt.close();
              } // try
              catch (SQLException e)
              System.out.println ("EJBFindBYPrimaryKey " + e.getMessage());     
              } // catch
              finally
              try
              if (con!=null)
                   con.close();
              }// try
              catch (SQLException e)
              System.out.println ("EJB Find by primary key" + e.getMessage());
              }// catch
              }// finally
              return key;
         * @return Returns the name.
         public String getName() {
              return this.name;
         * @return Returns id
         public int getId() {
              return this.id;
         * @param name The name to set.
         public void setName(String xname) {
              this.name = xname;
         * ejbFindByLastnameContaining
         public Enumeration ejbFindAllNamne () throws javax.ejb.FinderException
         try
         String sqlstmt = "select id from status order by id";
         con = ds.getConnection();
         Statement s = con.createStatement();
         ResultSet rs = s.executeQuery(sqlstmt);
         Vector keys = new Vector();
         while (rs.next())
              keys.add(new Integer(rs.getInt(1)));
         }// while
         rs.close();
         s.close();
         con.close();
         return keys.elements();
         } // try
         catch (SQLException e)
              throw new FinderException (e.toString());
         } // catch
    }

    Hi,
    if you look at your error message you will see the problem. In your code you've missed to implement
    public void ejbPassivate {}
    so your code looks like this
    import java.lang.Object;
    import javax.ejb.SessionBean;
    import javax.ejb.SessionContext;
    import java.rmi.RemoteException;
    import java.lang.Math;
    import java.util.Random;
    import java.io.*;
    /** * Title: * Description: * Copyright: Copyright (c) 2001 * Company: * @author * @version 1.0 */
    public class DiceEJB implements SessionBean, Serializable
         public int[] Roll()
              Random rng = new Random();
              int[] diceArray = new int[5];
              for(int i =0; i < diceArray.length;i++)
                   diceArray[i] = (Math.abs (rng.nextInt()) % 6) +1;
              return diceArray;
         public DiceEJB(){}
         public void ejbCreate() {}
         public void ejbRemove() {}
         public void ejbActivate() {}
         public void ejbPassivate() {}
         public void setSessionContext (SessionContext sc)
         private void writeObject(ObjectOutputStream oos) throws IOException
              oos.defaultWriteObject();
         private void readObject(ObjectInputStream ois) throws ClassNotFoundException, IOException
              ois.defaultReadObject();
    bye

  • Status=STATUS_NO_TRANSACTION; - nested throwable: (javax.ejb.EJBException:

    Hi,
    I'm stuck on this problem since 10 days now. Please Please help.
    I'm using Jboss 4.0.5GA and ejb 2.0 While executing the last query after running the ejbStore() of the bean, it breaks,
    The error is below :
    Executing SQL: UPDATE arinpchg SET modified_date=?, doc_num=?, printing_status=? WHERE trx_num=?
    2007-11-29 15:52:55,593 TRACE [org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMP1xFieldBridge.au.com.cams.cims.ar.ejb.Charge#modifiedDate] param: i=1, type=TIMESTAMP, value=2007-11-29 15:52:53.14
    2007-11-29 15:52:55,593 TRACE [org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMP1xFieldBridge.au.com.cams.cims.ar.ejb.Charge#docNum] param: i=2, type=VARCHAR, value=INV297217
    2007-11-29 15:52:55,593 TRACE [org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMP1xFieldBridge.au.com.cams.cims.ar.ejb.Charge#printingStatus] param: i=3, type=INTEGER, value=1
    2007-11-29 15:52:55,593 TRACE [org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMP1xFieldBridge.au.com.cams.cims.ar.ejb.Charge#trxNum] param: i=4, type=VARCHAR, value=ARTRX395716
    2007-11-29 15:52:55,734 ERROR [org.jboss.ejb.plugins.LogInterceptor] TransactionRolledbackException in method: public abstract au.com.cams.cims.ar.data.PendingChargeResponse au.com.cams.cims.business.ejb.PendingChargeManager.processPendingCharges(au.com.cams.cims.ar.data.PendingChargeRequest,au.com.cams.cims.core.data.DUser) throws au.com.cams.cims.core.util.StoredProcedureFailedException,au.com.cams.cims.core.util.UpdateFailedException,java.rmi.RemoteException, causedBy:
    org.jboss.tm.JBossRollbackException: Unable to commit, tx=TransactionImpl:XidImpl[FormatId=257, GlobalId=MEL-LAP-XP-66/59, BranchQual=, localId=59] status=STATUS_NO_TRANSACTION; - nested throwable: (javax.ejb.EJBException: Update failed. Expected one affected row: rowsAffected=0, id=au.com.cams.cims.ar.data.ChargePK@839418b6)
    at org.jboss.tm.TransactionImpl.commit(TransactionImpl.java:372)
         at org.jboss.ejb.plugins.TxInterceptorCMT.endTransaction(TxInterceptorCMT.java:501)
         at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:361)
         at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:181)
         at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:168)
         at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:205)
         at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInterceptor.java:136)
         at org.jboss.ejb.SessionContainer.internalInvoke(SessionContainer.java:648)
         at org.jboss.ejb.Container.invoke(Container.java:954)
         at sun.reflect.GeneratedMethodAccessor108.invoke(Unknown Source)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:585)
         at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
         at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
         at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
         at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
         at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
         at org.jboss.invocation.local.LocalInvoker$MBeanServerAction.invoke(LocalInvoker.java:169)
         at org.jboss.invocation.local.LocalInvoker.invoke(LocalInvoker.java:118)
         at org.jboss.invocation.InvokerInterceptor.invokeLocal(InvokerInterceptor.java:209)
         at org.jboss.invocation.InvokerInterceptor.invoke(InvokerInterceptor.java:195)
         at org.jboss.proxy.TransactionInterceptor.invoke(TransactionInterceptor.java:61)
         at org.jboss.proxy.SecurityInterceptor.invoke(SecurityInterceptor.java:70)
         at org.jboss.proxy.ejb.StatelessSessionInterceptor.invoke(StatelessSessionInterceptor.java:112)
         at org.jboss.proxy.ClientContainer.invoke(ClientContainer.java:100)
         at $Proxy508.processPendingCharges(Unknown Source)
         at au.com.cams.cims.ar.cmd.PendingChargeManagerCmdBean.doProcessPendingCharges(Unknown Source)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:585)
         at au.com.cams.cims.core.cmd.AbstractCmdBean.execute(Unknown Source)
         at au.com.cams.cims.core.sys.CIMSCommandBeanManager.doCommandBeanExecute(Unknown Source)
         at au.com.cams.cims.core.sys.CIMSCommandBeanManager.execute(Unknown Source)
         at au.com.singtech.saf.MainServlet.doPost(Unknown Source)
         at au.com.singtech.saf.MainServlet.doGet(Unknown Source)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:697)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
         at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
         at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
         at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
         at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:175)
         at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74)
         at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
         at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
         at org.jboss.web.tomcat.tc5.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:156)
         at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
         at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
         at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
         at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
         at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
         at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
         at java.lang.Thread.run(Thread.java:595)
    Caused by: javax.ejb.EJBException: Update failed. Expected one affected row: rowsAffected=0, id=au.com.cams.cims.ar.data.ChargePK@839418b6
         at org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreEntityCommand.execute(JDBCStoreEntityCommand.java:169)
         at org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.storeEntity(JDBCStoreManager.java:666)
         at org.jboss.ejb.plugins.CMPPersistenceManager.storeEntity(CMPPersistenceManager.java:428)
         at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.storeEntity(CachedConnectionInterceptor.java:273)
         at org.jboss.ejb.EntityContainer.storeEntity(EntityContainer.java:756)
         at org.jboss.ejb.GlobalTxEntityMap$2.synchronize(GlobalTxEntityMap.java:149)
         at org.jboss.ejb.GlobalTxEntityMap$GlobalTxSynchronization.synchronize(GlobalTxEntityMap.java:295)
         at org.jboss.ejb.GlobalTxEntityMap$GlobalTxSynchronization.beforeCompletion(GlobalTxEntityMap.java:345)
         at org.jboss.tm.TransactionImpl.doBeforeCompletion(TransactionImpl.java:1491)
         at org.jboss.tm.TransactionImpl.beforePrepare(TransactionImpl.java:1110)
         at org.jboss.tm.TransactionImpl.commit(TransactionImpl.java:324)
    My entityBean:
    * Copyright 2000 by Sing Technologies Pty. Ltd.,
    * Level 11, 269 Wickham Street, Fortitude Valley, Qld 4006, Australia
    * All rights reserved.
    * This software is the confidential and proprietary information
    * of Sing Technologies Pty. Ltd. ("Confidential Information"). You
    * shall not disclose such Confidential Information and shall use
    * it only in accordance with the terms of the license agreement
    * you entered into with Sing Technologies.
    package au.com.cams.cims.ar.ejb;
    import java.sql.*;
    import javax.ejb.*;
    import au.com.cams.cims.ar.data.*;
    import au.com.cams.cims.core.data.*;
    import au.com.cams.cims.core.util.*;
    import au.com.cams.cims.core.ejb.*;
    import au.com.cams.cims.core.app.*;
    import org.apache.log4j.*;
    import javax.naming.*;
    import javax.rmi.*;
    import java.util.*;
    import java.rmi.RemoteException;
    * @stereotype EntityBean
    * @persistence Container
    * @homeInterface au.com.cams.cims.ar.ejb.ChargeHome
    * @remoteInterface au.com.cams.cims.ar.ejb.Charge
    * @primaryKey au.com.cams.cims.ar.ejb.ChargePK
    public class ChargeBean implements EntityBean {
         static private Logger log = Logger.getLogger(ChargeBean.class.getName());
    private static final String datasource = "java:ds/cims";
    private static final String chargeLineRef = "java:comp/env/ejb/au.com.cams.cims.ar.ejb.ChargeLineHome";
    // Used by the isModified extension
    private transient boolean isDirty;
    public boolean isModified() {
    return isDirty;
    /** @field Key VARCHAR(20) CIMSSchema.dbo.arinpchg.trx_num */
    public String trxNum;
    /** @field VARCHAR(20) CIMSSchema.dbo.arinpchg.apply_to_num */
    public String applyToNum;
    /** @field VARCHAR(20) CIMSSchema.dbo.arinpchg.terms_code */
    public String termsCode;
    /** @field VARCHAR(20) CIMSSchema.dbo.arinpchg.fin_chg_code */
    public String finChgCode;
    /** @field VARCHAR(20) CIMSSchema.dbo.arinpchg.shipping_code */
    public String shippingCode;
    /** @field VARCHAR(20) CIMSSchema.dbo.arinpchg.posting_code */
    public String postingCode;
    /** @field VARCHAR(20) CIMSSchema.dbo.arinpchg.tax_code */
    public String taxCode;
    /** @field TIMESTAMP(23) CIMSSchema.dbo.arinpchg.aging_date */
    public Timestamp agingDate;
    /** @field TIMESTAMP(23) CIMSSchema.dbo.arinpchg.due_date */
    public Timestamp dueDate;
    /** @field FLOAT(15) CIMSSchema.dbo.arinpchg.gross_amount */
    public Double grossAmount;
    /** @field FLOAT(15) CIMSSchema.dbo.arinpchg.tax_amount */
    public Double taxAmount;
    /** @field FLOAT(15) CIMSSchema.dbo.arinpchg.tax_included_amount */
    public Double taxIncludedAmount;
    /** @field FLOAT(15) CIMSSchema.dbo.arinpchg.freight_amount */
    public Double freightAmount;
    /** @field FLOAT(15) CIMSSchema.dbo.arinpchg.tax_on_freight_amount */
    public Double taxOnFreightAmount;
    /** @field FLOAT(15) CIMSSchema.dbo.arinpchg.net_amount */
    public Double netAmount;
    /** @field FLOAT(15) CIMSSchema.dbo.arinpchg.paid_amount */
    public Double paidAmount;
    /** @field FLOAT(15) CIMSSchema.dbo.arinpchg.due_amount */
    public Double dueAmount;
    /** @field INTEGER(10) CIMSSchema.dbo.arinpchg.trx_type */
    public Integer trxType;
    /** @field VARCHAR(20) CIMSSchema.dbo.arinpchg.doc_num */
    public String docNum;
    /** @field TIMESTAMP(23) CIMSSchema.dbo.arinpchg.doc_date */
    public Timestamp docDate;
    /** @field TIMESTAMP(23) CIMSSchema.dbo.arinpchg.apply_date */
    public Timestamp applyDate;
    /** @field VARCHAR(20) CIMSSchema.dbo.arinpchg.debtor_num */
    public String debtorNum;
    /** @field INTEGER(10) CIMSSchema.dbo.arinppyt.trx_status */
    public Integer trxStatus;
    /** @field INTEGER(10) CIMSSchema.dbo.arinppyt.approval_status */
    public Integer approvalStatus;
    /** @field INTEGER(10) CIMSSchema.dbo.arinpchg.printing_status */
    public Integer printingStatus;
    /** @field INTEGER(10) CIMSSchema.dbo.arinpchg.posting_status */
    public Integer postingStatus;
    /** @field INTEGER(10) CIMSSchema.dbo.arinpchg.hold_status */
    public Integer holdStatus;
    /** @field VARCHAR(50) CIMSSchema.dbo.arinpchg.hold_reason */
    public String holdReason;
    /** @field VARCHAR(2000) CIMSSchema.dbo.arinpchg.notes */
    public String notes;
    /** @field VARCHAR(200) CIMSSchema.dbo.arinpchg.message */
    public String message;
    /** @field INTEGER(10) CIMSSchema.dbo.arinpchg.next_sequence_id */
    public Integer nextSequenceId;
    /** @field VARCHAR(100) CIMSSchema.dbo.arinpchg.billing_addressee */
    public String billingAddressee;
    /** @field VARCHAR(50) CIMSSchema.dbo.arinpchg.billing_job_position */
    public String billingJobPosition;
    /** @field VARCHAR(50) CIMSSchema.dbo.arinpchg.billing_addr1 */
    public String billingAddr1;
    /** @field VARCHAR(50) CIMSSchema.dbo.arinpchg.billing_addr2 */
    public String billingAddr2;
    /** @field VARCHAR(50) CIMSSchema.dbo.arinpchg.billing_addr3 */
    public String billingAddr3;
    /** @field VARCHAR(50) CIMSSchema.dbo.arinpchg.billing_locality */
    public String billingLocality;
    /** @field VARCHAR(20) CIMSSchema.dbo.arinpchg.billing_state */
    public String billingState;
    /** @field VARCHAR(20) CIMSSchema.dbo.arinpchg.billing_postcode */
    public String billingPostcode;
    /** @field VARCHAR(20) CIMSSchema.dbo.arinpchg.billing_country */
    public String billingCountry;
    /** @field VARCHAR(30) CIMSSchema.dbo.arinpchg.billing_phone_home */
    public String billingPhoneHome;
    /** @field VARCHAR(30) CIMSSchema.dbo.arinpchg.billing_phone_business */
    public String billingPhoneBusiness;
    /** @field VARCHAR(30) CIMSSchema.dbo.arinpchg.billing_phone_mobile */
    public String billingPhoneMobile;
    /** @field VARCHAR(30) CIMSSchema.dbo.arinpchg.billing_phone_car */
    public String billingPhoneCar;
    /** @field VARCHAR(30) CIMSSchema.dbo.arinpchg.billing_fax_home */
    public String billingFaxHome;
    /** @field VARCHAR(30) CIMSSchema.dbo.arinpchg.billing_fax_business */
    public String billingFaxBusiness;
    /** @field VARCHAR(100) CIMSSchema.dbo.arinpchg.billing_email */
    public String billingEmail;
    /** @field VARCHAR(100) CIMSSchema.dbo.arinpchg.billing_email2 */
    public String billingEmail2;
    /** @field VARCHAR(100) CIMSSchema.dbo.arinpchg.billing_website */
    public String billingWebsite;
    /** @field VARCHAR(100) CIMSSchema.dbo.arinpchg.shipping_addressee */
    public String shippingAddressee;
    /** @field VARCHAR(50) CIMSSchema.dbo.arinpchg.shipping_job_position */
    public String shippingJobPosition;
    /** @field VARCHAR(50) CIMSSchema.dbo.arinpchg.shipping_addr1 */
    public String shippingAddr1;
    /** @field VARCHAR(50) CIMSSchema.dbo.arinpchg.shipping_addr2 */
    public String shippingAddr2;
    /** @field VARCHAR(50) CIMSSchema.dbo.arinpchg.shipping_addr3 */
    public String shippingAddr3;
    /** @field VARCHAR(50) CIMSSchema.dbo.arinpchg.shipping_locality */
    public String shippingLocality;
    /** @field VARCHAR(20) CIMSSchema.dbo.arinpchg.shipping_state */
    public String shippingState;
    /** @field VARCHAR(20) CIMSSchema.dbo.arinpchg.shipping_postcode */
    public String shippingPostcode;
    /** @field VARCHAR(20) CIMSSchema.dbo.arinpchg.shipping_country */
    public String shippingCountry;
    /** @field VARCHAR(30) CIMSSchema.dbo.arinpchg.shipping_phone_home */
    public String shippingPhoneHome;
    /** @field VARCHAR(30) CIMSSchema.dbo.arinpchg.shipping_phone_business */
    public String shippingPhoneBusiness;
    /** @field VARCHAR(30) CIMSSchema.dbo.arinpchg.shipping_phone_mobile */
    public String shippingPhoneMobile;
    /** @field VARCHAR(30) CIMSSchema.dbo.arinpchg.shipping_phone_car */
    public String shippingPhoneCar;
    /** @field VARCHAR(30) CIMSSchema.dbo.arinpchg.shipping_fax_home */
    public String shippingFaxHome;
    /** @field VARCHAR(30) CIMSSchema.dbo.arinpchg.shipping_fax_business */
    public String shippingFaxBusiness;
    /** @field VARCHAR(100) CIMSSchema.dbo.arinpchg.shipping_email */
    public String shippingEmail;
    /** @field VARCHAR(100) CIMSSchema.dbo.arinpchg.shipping_email2 */
    public String shippingEmail2;
    /** @field VARCHAR(100) CIMSSchema.dbo.arinpchg.shipping_website */
    public String shippingWebsite;
    /** @field TIMESTAMP(23) CIMSSchema.dbo.arinpchg.created_date */
    public Timestamp createdDate;
    /** @field VARCHAR(30) CIMSSchema.dbo.arinpchg.created_by */
    public String createdBy;
    /** @field TIMESTAMP(23) CIMSSchema.dbo.arinpchg.modified_date */
    public Timestamp modifiedDate;
    /** @field VARCHAR(30) CIMSSchema.dbo.arinpchg.modified_by */
    public String modifiedBy;
    /** @field VARCHAR(20) CIMSSchema.dbo.arinpchg.print_job_num *//*
    public String printJobNum;*/
    * The container assigned reference to the entity
    private EntityContext context;
    * Sets the context of the bean
    * @param ec
    public void setEntityContext(EntityContext ec) {
    context = ec;
    // to do: code goes here.
    * Clears the context of the bean
    public void unsetEntityContext() {
    this.context = null;
    // to do: code goes here.
    * This method is called when the container picks this entity object
    * and assigns it to a specific entity object. Insert code here to
    * acquire any additional resources that it needs when it is in the
    * ready state.
    public void ejbActivate() {
    * This method is called when the container diassociates the bean
    * from the entity object identity and puts the instance back into
    * the pool of available instances. Insert code to release any
    * resources that should not be held while the instance is in the
    * pool.
    public void ejbPassivate() {
    * The container invokes this method on the bean whenever it
    * becomes necessary to synchronize the bean's state with the
    * state in the database. This method is called after the container
    * has loaded the bean's state from the database.
    public void ejbLoad() {
              System.out.println("#### VJ: ChargeBean.ejbLoad()");
    * The container invokes this method on the bean whenever it
    * becomes necessary to synchronize the state in the database
    * with the state of the bean. This method is called before the
    * container extracts the fields and writes them into the database.
    public void ejbStore() {
              System.out.println("#### VJ: ChargeBean.ejbStore()");
    this.isDirty = false;
    updateTotals();
              System.out.println("#### VJ: ChargeBean.context.getPrimaryKey(): " + context.getPrimaryKey().toString());
              System.out.println("#### VJ: ChargeBean.trxNum: " + trxNum);
    * The container invokes this method in response to a client-invoked
    * remove request. Insert code to implement any actions before the
    * bean is removed from the database.
    public void ejbRemove() throws RemoveException {
    public ChargePK ejbCreate(DCharge charge, DUser user)
    throws CreateException {
         System.out.println("#### VJ: ChargeBean.ejbCreate(DCharge, DUser)");
    Connection con = null;
    ChargePK key = new ChargePK();
    if (charge == null)
    throw new CreateException("charge cannot be null");
    if (user == null)
    throw new CreateException("user cannot be null");
    try {
    // set the pk
    con = DatabaseUtilities.getConnection(log, datasource);
    this.trxNum = AppJDBCHelper.getNextTrxNum(con);
    key.trxNum = this.trxNum;
    // set other attributes
    setAttributes(charge);
    // set mod history
    this.createdDate = new Timestamp(new java.util.Date().getTime());
    this.createdBy = user.getUsername();
    this.modifiedDate = new Timestamp(new java.util.Date().getTime());
    this.modifiedBy = user.getUsername();
    } catch (GetNextIdFailedException gnife) {
    log.error("ejbCreate", gnife);
    throw new CreateException(gnife.getMessage());
    } catch (NullPointerException ex1) {
    ex1.printStackTrace();
    log.warn("ejbCreate(): " + ex1);
    throw new CreateException("ejbCreate(): " + ex1);
    } finally {
    if (con != null) DatabaseUtilities.close(con, log, "ejbCreate()");
         //System.out.println("#### VJ: ChargeBean.ejbCreate(DCharge, DUser) context.getPrimaryKey(): " + context.getPrimaryKey().toString());
         System.out.println("#### VJ: ChargeBean.ejbCreate(DCharge, DUser) (ChargeBean) trxNum: " + trxNum);
         System.out.println("#### VJ: ChargeBean.ejbCreate(DCharge, DUser) (ChargePK) key.trxNum: " + key.trxNum);
         System.out.println("#### VJ: ChargeBean.ejbCreate(DCharge, DUser) (DCharge): " + charge.getTrxNum());
    return (key);
    * The container invokes this method after invoking the ejbCreate
    * method with the same arguments.
    * @param charge
    * @param user
    public void ejbPostCreate(DCharge charge, DUser user) {
              System.out.println("#### VJ: ChargeBean.ejbPostCreate(DCharge, DUser)");
    updateTotals();
    isDirty = false;
              System.out.println("#### VJ: ChargeBean.ejbPostCreate(DCharge, DUser) context.getPrimaryKey(): " + context.getPrimaryKey().toString());
              System.out.println("#### VJ: ChargeBean.ejbPostCreate(DCharge, DUser) (ChargeBean) trxNum: " + trxNum);
              System.out.println("#### VJ: ChargeBean.ejbPostCreate(DCharge, DUser) (DCharge): " + charge.getTrxNum());
    * @exception ReadFailedException
    * @return
    public DCharge getDetails()
    throws ReadFailedException {
    DCharge charge = new DCharge();
    try {
    updateTotals();
    charge.setTrxNum(this.trxNum);
    getAttributes(charge);
    DModificationHistory history = new DModificationHistory();
    history.setCreatedDate(this.createdDate);
    history.setCreatedBy(this.createdBy);
    history.setModifiedDate(this.modifiedDate);
    history.setModifiedBy(this.modifiedBy);
    charge.setModificationHistory(history);
    } catch (InvalidDataException ex1) {
    log.warn("getDetails(): " + ex1);
    throw new ReadFailedException("getDetails(): " + ex1.toString());
    } catch (NullPointerException ex2) {
    log.warn("getDetails(): " + ex2);
    throw new ReadFailedException("getDetails(): " + ex2.toString());
    return (charge);
    * @exception ReadFailedException
    * @return
    public DCharge getAllDetails()
    throws ReadFailedException {
    DCharge charge = null;
    try {
    // get non dependant object data
    charge = getDetails();
    // declare and init search home ejbs
    Context ctx = new InitialContext();
    // used for searching
    ChargePK chargePK = new ChargePK();
    chargePK.trxNum = this.trxNum;
                   System.out.println("#### VJ: ChargeBean.getAllDetails() chargePK.trxNum(): " + chargePK.trxNum);
                   System.out.println("#### VJ: ChargeBean.getAllDetails() charge.getTrxNum(): " + charge.getTrxNum());
    // load the charge line items
    try {
    Object obj = ctx.lookup("java:comp/env/ejb/au.com.cams.cims.ar.ejb.ChargeLineSearchHome");
    ChargeLineSearchHome chargeLineSearchHome = (ChargeLineSearchHome) PortableRemoteObject.narrow(obj, ChargeLineSearchHome.class);
    ChargeLineSearch chargeLineSearch = chargeLineSearchHome.create();
    System.out.println("ChargePK: " + chargePK.trxNum);
    charge.setLineItems(chargeLineSearch.searchByCharge(chargePK));
    } catch (NamingException ne) {
    log.warn("getAllDetails(): couldn't lookup ChargeLineSearchHome " + ne.toString());
    } catch (InvalidDataException ide) {
    log.warn("getAllDetails(): couldn't set ChargeLineSearchHome " + ide.toString());
    } catch (SearchFailedException sfe) {
    log.warn("getAllDetails(): search failed " + sfe.toString());
    } catch (CreateException ce) {
    log.warn("getAllDetails(): couldn't create ChargeLineSearchHome " + ce.toString());
    } catch (RemoteException re) {
    log.warn("getAllDetails(): " + re.toString());
    } catch (NamingException ex) {
    log.warn("getAllDetails(): couldn't get an initial context " + ex.toString());
    throw new ReadFailedException("getAllDetails(): " + ex.toString());
    return charge;
    * @param charge
    * @param user
    * @exception UpdateFailedException
    public void setDetails(DCharge charge, DUser user)
    throws UpdateFailedException {
              System.out.println("#### VJ: ChargeBean.setDetails(DCharge, DUser)");
    try {
    // set other attributes
    setAttributes(charge);
    updateTotals();
    // set mod history
    this.modifiedDate = new Timestamp(new java.util.Date().getTime());
    this.modifiedBy = user.getUsername();
    } catch (NullPointerException ex1) {
    log.warn("setDetails(): " + ex1);
    throw new UpdateFailedException("setDetails(): " + ex1.toString());
    * Increments the next sequenceId and returns the current sequenceId (before incrememt)
    * @exception java.rmi.RemoteException
    * @exception UpdateFailedException
    public Integer incNextSequenceId()
    throws UpdateFailedException {
    Integer nextId = null;
    try {
    int current = this.nextSequenceId.intValue();
    // make a copy of the existing id
    nextId = new Integer(current);
    // now inc it
    this.nextSequenceId = new Integer(++current);
    } catch (EJBException e) {
    log.error("incNextSequenceId(): couldn't inc next sequenceId: " + e.toString());
    throw new UpdateFailedException(e.getMessage());
    return nextId;
    * Used by setDetails, ejbCreate.
    * @param member
    protected void setAttributes(DCharge charge) {
              System.out.println("#### VJ: ChargeBean.setAttributes(DCharge)");
         this.isDirty = true;
    ARTransactionManager mgr = null;
    try {
    Context ctx = new InitialContext();
    Object obj = ctx.lookup("java:comp/env/ejb/au.com.cams.cims.ar.ejb.ARTransactionManagerHome");
    ARTransactionManagerHome mgrHome = (ARTransactionManagerHome) PortableRemoteObject.narrow(obj, ARTransactionManagerHome.class);
    mgr = mgrHome.create();
    } catch (NamingException ne) {
    log.warn("setAttributes(): couldn't lookup ARTransactionManagerHome " + ne.toString());
    throw new EJBException(ne.toString());
    } catch (CreateException ce) {
    log.warn("setAttributes(): couldn't create ARTransactionManagerHome " + ce.toString());
    throw new EJBException(ce.toString());
    } catch (RemoteException ex) {
    log.error(ex.toString());
    throw new EJBException(ex.toString());
    try {
    TaxCode tc = mgr.getTaxCode(charge.getTaxCode());
    TaxAmounts amounts = ARUtilities.calculateTax(charge.getFreightAmount(), tc);
    this.taxOnFreightAmount = new Double(amounts.getAmountTax().doubleValue() - amounts.getAmountTaxIncluded().doubleValue());
    } catch (ReadFailedException rfe) {
    log.error("ReadFailedException reading tax code : " + charge.getTaxCode(), rfe);
    throw new EJBException(rfe.toString());
    } catch (RecordNotFoundException rnfe) {
    log.error("RecordNotFoundException reading tax code : " + charge.getTaxCode(), rnfe);
    throw new EJBException(rnfe.toString());
    } catch (RemoteException ex) {
    log.error(ex.toString());
    throw new EJBException(ex.toString());
              System.out.println("#### VJ: ChargeBean.setAttributes(DCharge) prior setters");
    this.applyToNum = charge.getApplyToNum();
    this.termsCode = charge.getTermsCode();
    this.finChgCode = charge.getFinanceChargeCode();
    this.shippingCode = charge.getShippingCode();
    this.postingCode = charge.getPostingCode();
    this.taxCode = charge.getTaxCode();
    this.agingDate = new Timestamp(charge.getAgingDate().getTime());
    this.dueDate = new Timestamp(charge.getDueDate().getTime());
    this.grossAmount = charge.getGrossAmount();
    this.taxAmount = charge.getTaxAmount();
    this.taxIncludedAmount = charge.getTaxIncludedAmount();
    this.freightAmount = charge.getFreightAmount();
    this.netAmount = charge.getNetAmount();
    this.paidAmount = charge.getPaidAmount();
    this.dueAmount = charge.getDueAmount();
    this.trxType = charge.getTrxType();
    this.docNum = charge.getDocNum();
    this.docDate = new Timestamp(charge.getDocDate().getTime());
    this.applyDate = new Timestamp(charge.getApplyDate().getTime());
    this.debtorNum = charge.getDebtorNum();
    this.trxStatus = charge.getTrxStatus();
    this.approvalStatus = charge.getApprovalStatus();
    this.printingStatus = charge.getPrintingStatus();
    this.postingStatus = charge.getPostingStatus();
    this.holdStatus = charge.getHoldStatus();
    this.holdReason = charge.getHoldReason();
    this.notes = charge.getNotes();
    this.message = charge.getMessage();
    this.nextSequenceId = charge.getNextSequenceId();
    DAddress billingAddress = charge.getBillingAddress();
    if (billingAddress != null) {
    this.billingAddressee = billingAddress.getAddressee();
    this.billingJobPosition = billingAddress.getPosition();
    this.billingAddr1 = billingAddress.getAddress1();
    this.billing

    I've solved this problem using JDBC.
    Thanks
    Smile
    Message was edited by:
    nsqsmile

  • Javax.ejb Error

    Hi all,
    I am m using this code in my portal application:import javax.ejb.CreateException; trying to  connect to a DataSource, but my NWDS keeps showing the red mark near the code: Javax.ejb cannot be resolved. I added j2ee.jar to my config and to classpath my NWDS but nothing seems to work.
    I am using NWDS 7.0.10.
    Points will be awarded.
    Thanx
    Sara

    HI Sara,
    I could see some problem at the line where we are triming it may vary from the Datasource , dunno how it will behave in case of LDAP as datasource.The above code will deft work but can be problem as in my scenraio u i removed the first 27 character and then it gave me the user id .
    till then you can try not sure
    IUserContext iuc = request.getUser();
    String logonUserid = iuc.getLogonUid();
    String eMail = iuc.getEmail();
    String logonName = iuc.getDisplayName();
    Also for this you have to create a Portal request object. Please add this code also for getting the request object.
    IPortalComponentRequest request =(IPortalComponentRequest) this.getRequest();
    In case i get some special method will let know.
    Thanx
    Pankaj

  • Javax.ejb.EJBException: Transaction aborted

    Hello everyone, I am new in javaEE6. When i try to develop and simple example i meet this error but i can't find which code line cause it. I use JSF EJB3.1 EclipseLink JPA 2.0 in Glassfish v3 and developed in Netbean6.8. Here is my Stack trace .
    Caused by: javax.ejb.EJBException: Transaction aborted
         at com.sun.ejb.containers.BaseContainer.completeNewTx(BaseContainer.java:4997)
         at com.sun.ejb.containers.BaseContainer.postInvokeTx(BaseContainer.java:4756)
         at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:1955)
         at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:1906)
         at com.sun.ejb.containers.EJBLocalObjectInvocationHandler.invoke(EJBLocalObjectInvocationHandler.java:198)
         at com.sun.ejb.containers.EJBLocalObjectInvocationHandlerDelegate.invoke(EJBLocalObjectInvocationHandlerDelegate.java:84)
         at $Proxy158.createUsers(Unknown Source)
         at home.tuan.bussiness.__EJB31_Generated__UsersEJB__Intf____Bean__.createUsers(Unknown Source)
         at home.tuan.controller.UsersController.doCreateUser(UsersController.java:40)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:597)
         at com.sun.el.parser.AstValue.invoke(AstValue.java:234)
         at com.sun.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:297)
         at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:98)
         at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:88)
         ... 32 more
    Caused by: javax.transaction.RollbackException: Transaction marked for rollback.
         at com.sun.enterprise.transaction.JavaEETransactionImpl.commit(JavaEETransactionImpl.java:450)
         at com.sun.enterprise.transaction.JavaEETransactionManagerSimplified.commit(JavaEETransactionManagerSimplified.java:837)
         at com.sun.ejb.containers.BaseContainer.completeNewTx(BaseContainer.java:4991)
         ... 48 more
    Caused by: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.0.0.v20091127-r5931): org.eclipse.persistence.exceptions.DatabaseException
    Internal Exception: java.sql.SQLSyntaxErrorException: Syntax error: Encountered "." at line 1, column 29.
    Error Code: -1
    Call: INSERT INTO ChatDatabase.dbo.Users (UserName, Pass) VALUES (?, ?)
         bind => [er, w]
    Query: InsertObjectQuery(home.tuan.model.Users@825299)My Entity is:
    package home.tuan.model;
    import java.io.Serializable;
    import javax.persistence.Column;
    import javax.persistence.Entity;
    import javax.persistence.Id;
    import javax.persistence.NamedQueries;
    import javax.persistence.NamedQuery;
    import javax.persistence.Table;
    * @author minhtuan
    @Entity
    @Table(name = "Users", catalog = "ChatDatabase", schema = "dbo")
    public class Users implements Serializable {
        private static final long serialVersionUID = 1L;
        @Id  
        @Column(name = "UserName")
        private String userName;
        @Column(name = "Pass")
        private String pass;
        public Users() {
        public Users(String userName, String pass) {
            this.userName = userName;
            this.pass = pass;
        public String getUserName() {
            return userName;
        public void setUserName(String userName) {
            this.userName = userName;
        public String getPass() {
            return pass;
        public void setPass(String pass) {
            this.pass = pass;
    }My session bean is:
    package home.tuan.bussiness;
    import home.tuan.model.Users;
    import java.util.ArrayList;
    import java.util.List;
    import javax.ejb.Stateless;
    import javax.persistence.EntityManager;
    import javax.persistence.PersistenceContext;
    import javax.persistence.Query;
    * @author minhtuan
    @Stateless
    public class UsersEJB {
      @PersistenceContext(unitName="MavenTestPU")
      private EntityManager em ;
      public Users createUsers(Users newUser){
          em.persist(newUser);
          return newUser;
    }My controller class is:
    package home.tuan.controller;
    import home.tuan.bussiness.UsersEJB;
    import home.tuan.model.Users;
    import java.util.ArrayList;
    import java.util.List;
    import javax.ejb.EJB;
    import javax.faces.bean.ManagedBean;
    import javax.faces.bean.RequestScoped;
    import javax.persistence.EntityTransaction;
    import javax.persistence.Persistence;
    import javax.transaction.UserTransaction;
    * @author minhtuan
    @ManagedBean(name="UsersController")
    @RequestScoped
    public class UsersController {
        /** Creates a new instance of UsersController */
        @EJB
        UsersEJB userEJB;
        Users newUser = new Users();
        List<Users> listUsers = new ArrayList<Users>();
        public String doNewUser(){
            return "index.jsp";
        public String doCreateUser(){
            System.out.println("Den day rui");
            System.out.println(newUser.getUserName());
            System.out.println(newUser.getPass());
            newUser = userEJB.createUsers(newUser);
            return "index.jsp";
        public List<Users> getListUsers() {
            return listUsers;
        public void setListUsers(List<Users> listUsers) {
            this.listUsers = listUsers;
        public Users getNewUser() {
            return newUser;
        public void setNewUser(Users newUser) {
            this.newUser = newUser;
    }And my persistence.xml is:
    <persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
      <persistence-unit name="MavenTestPU" transaction-type="JTA">
        <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
        <class>home.tuan.model.Users</class>
        <properties>
            <!--
          <property name="javax.persistence.jdbc.url" value="jdbc:sqlserver://localhost:1433;databaseName=ChatDatabase"/>
          <property name="javax.persistence.jdbc.password" value="12345"/>
          <property name="javax.persistence.jdbc.driver" value="com.microsoft.sqlserver.jdbc.SQLServerDriver"/>
          <property name="javax.persistence.jdbc.user" value="sa"/>
          -->
           <property name="eclipselink.target-database" value="SQLSERVER"/>
           <property name="eclipselink.jdbc.driver" value="com.microsoft.sqlserver.jdbc.SQLServerDriver"/>
           <property name="eclipselink.jdbc.url" value="jdbc:sqlserver://localhost:1433;databaseName=ChatDatabase"/>
                <!--<property name="eclipselink.jdbc.driver" value="org.apache.derby.jdbc.EmbeddedDriver"/>-->
                <!--<property name="eclipselink.jdbc.url" value="jdbc:derby:chapter10DB;create=true"/>-->
           <property name="eclipselink.jdbc.user" value="sa"/>
           <property name="eclipselink.jdbc.password" value="12345"/>
                <!--property name="eclipselink.ddl-generation" value="update"/-->
                <!--property name="eclipselink.ddl-generation" value="drop-and-create-tables"/-->
           <property name="eclipselink.logging.level" value="INFO"/>
        </properties>
      </persistence-unit>
    </persistence>Thanks in advance
    Edited by: ActiveDean on Dec 24, 2009 4:38 PM

    You need to step through a debugger and find the source of your problem as something is clearly going wrong and causing the transaction to roll back. That is all that message tells us.
    m

  • How do I include javax.ejb.EJB in a Web Project?

    Hi,
    I have set up an application with two projects. One is called EJBModel and the other is UserInterface. In my UserInterface project, I am writing a bean class and I want it to access the controller beans created in EJBModel. I created a private type for the controller bean and used the @EJB annotation. When I try to import javax.ejb.EJB I get an error saying it is not found. Other javax packages popup on the list of available imports, but not ejb. How do I include it in the UserInterface project?
    Thanks in advance...

    Yeah your right...let me further explain what I'm doing.
    I'm creating a web application using the Model-View-Controller design pattern. Model represents data, View represents data display, and Controller is control. I created the EJBModel project in my web app to contain the model aspect. So it has entity objects and beans to access/manipulate the data. Then I created the UserInterface project to store the web interface - mostly jsps. In the UserInterace project, I need a managed bean that calls methods from the beans created in the EJBModel project. I can do this using the @EJB annotation and creating an instance of the class, but since the files are in separate projects that can't see each other and JDeveloper shows an error because it can't find the necessary file. It is best practice to create two projects to keep both elements distinct.
    So I wanted to know the best way to access the files stored in separate projects within the same application.

  • Javax.ejb.Inject not found

    I'm working with jdeveloper 10.1.3 in S.O. XP
    build a proyect template JSP,EJB3,TOPLINK
    import javax.ejb.Inject;
    Error: Inject not found
    Tanks

    Add EJB 3.0 Library to project libraries.

  • Javax.ejb.EJBException: nested exception is: java.rmi.RemoteException:

    package library.client;
    import javax.naming.InitialContext;
    import java.awt.BorderLayout;
    import java.awt.Color;
    import java.awt.FlowLayout;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.lang.reflect.Method;
    import java.sql.ResultSet;
    import javax.ejb.*;
    import javax.naming.*;
    import javax.swing.*;
    import library.common.*;
    @SuppressWarnings("serial")
    public class LibraryClient extends JFrame implements ActionListener {
      private static LibraryInterface li;
      private JTextField book_author = new JTextField(10);
      private JTextField book_title = new JTextField(10);
      private JTextField book_isbn = new JTextField(10);
      private JLabel author_label = new JLabel("Podaj autora:");
      private JLabel book_title_label = new JLabel("Podaj tytul ksiazki");
      private JLabel isbn_label = new JLabel("Podaj ISBN");
      private JTextArea display_books = new JTextArea(20,50);
      private JButton search = new JButton("Search");
      private ResultSet resultset;
      public LibraryClient() {
        this("DEFAULT_CONTEXT");
    private JPanel createPanel1(){
          JPanel panel = new JPanel();
          panel.add(author_label);
          panel.add(book_author);
          panel.add(book_title_label);
          panel.add(book_title);
          panel.add(isbn_label);
          panel.add(book_isbn);
          panel.add(search);
          ////search.setActionCommand("ISBN");
          search.addActionListener(this);
          return panel;
    private JPanel createPanel2(){
          JPanel panel = new JPanel();
          panel.add(display_books);
          return panel;
    private JPanel createPanels(){
         JPanel panel = new JPanel();
        //Use default FlowLayout.
        panel.setLayout(new BorderLayout());
        panel.add(createPanel1(), BorderLayout.NORTH);
        panel.add(createPanel2(), BorderLayout.SOUTH);
        return panel;
      public  LibraryClient(String appType) {
        init(appType);
        JFrame frame = new JFrame("Library");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    //    /final Table table = new Table();
        frame.setContentPane(createPanels());
        frame.pack();
    //    /f.setLocationRelativeTo(null);
        frame.setVisible(true);
      public void actionPerformed(ActionEvent e) {
             try {
                  display_books.setText("");
                  display_books.setText("Wyszukane Ksiazki\n");
                  if(!book_author.getText().equals("")){
                       resultset=li.getBookByAuthor(book_author.getText());
                  }else if(!book_title.getText().equals("")){
                       resultset=li.getBookByName(book_title.getText());
                  }else if(!book_isbn.getText().equals("")){
                       resultset=li.getBookByISBN(book_isbn.getText());
                  }else {
                       System.out.println("Before->resultset=li.getAllBooks()");
                       resultset=li.getAllBooks();
                       System.out.println("After->resultset=li.getAllBooks()");
                  while(resultset.next()){
                       System.out.println("in while resultset.next()"); 
                       String name = resultset.getString("name");
                         String author =resultset.getString("author");
                         String isbn = resultset.getString("ISBN");
                         display_books.append("\n"+ name + " " + author +" "+ isbn);
             } catch(Exception exc) { exc.printStackTrace(); }
      private void init(String type) {
        if (type.equals("JAVA_APP")) li = new library.ejb.LibraryBean();
        else if (type.equals("JAVA_CLIENT")) {
          try {
            InitialContext ic = new InitialContext();
            li = (LibraryInterface) ic.lookup("library.common.LibraryInterface");
          } catch (NamingException e) {
            e.printStackTrace();
      public static void main(String[] args) {
        if (args.length >= 1) new LibraryClient(args[0]);
        else new LibraryClient();
    }it throws the exception when it gets to
    any of the functions
    resultset=li.getBookByAuthor(book_author.getText());
    resultset=li.getBookByName(book_title.getText());
    resultset=li.getBookByISBN(book_isbn.getText());
    resultset=li.getAllBooks();
    Please help
    Thank You

    Hi,
    I also get the same error.have you got the solution,fi so explain me how to rectify the error
    Regards
    SamyMohan

Maybe you are looking for

  • Links to files not working in Safari 5.1

    I have an HTML document on my hard drive that links to various TextEdit files on my computer. It's a great shortcut tool. I click a link, and it instantly opens up the file in TextEdit. However, I just upgraded to Safari 5.1, and now when I click the

  • AS2/AIR 1.5 open pdf problem

    I have a flash SWF that I run as a AIR 1.5 desktop  app. I want the user to be able to open a pdf file to print it. As  it is now, I have flash call their browser to open the local PDF with a  open url http://myfile.pdf.  This works fine if their bro

  • Help with an SR520

    About a decade ago I took the CCNA course but not the certification , so I have a good level of knowledge. I do IT support for a non profit and we acquired an SR520. We chose it because we want to set up 3 to 5 VPN's allowing a few folks to work from

  • BPC75NW: Query on write-back BAdI

    Hi, I have a requirement wherein for 2 set of input schedules that are based on same APPSET and APPLICATION, have different ABAP logic to be built through write-back BAdI. I try to built a second BAdI to put in the logic for second set of input sched

  • Lockbox processing - customer invoice

    Hi Gurus, i have a query on Lockbox processing of an invoice created using F-22 tcode. How will we tell the system that this particular invoice ( or say particular customer ) is going to pay this amount to a lockbox maintained in the system? I have m