I'm trying to use EBJ3 to manage a table in my database, when I ran my test 
client, I always received this: 

Exception in thread "main" java.lang.NoSuchFieldError: TRACE
  |     at 
org.jboss.logging.Log4jLoggerPlugin.isTraceEnabled(Log4jLoggerPlugin.java:85)
  |     at org.jboss.logging.Logger.isTraceEnabled(Logger.java:122)
  |     at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:660)
  |     at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:627)
  |     at javax.naming.InitialContext.lookup(InitialContext.java:392)
  |     at TestEJBClient.main(TestEJBClient.java:31)

Although I have created two properties files and referenced all the jar in the 
JBOSS_HOME/client directory... I'm stuck
Anyone  please help! I need to do this urgently.

Below is all the code:

// Table ADMIN: 
  | //    Username nvarchar(20) PK
  | //    Password nvarchar(20)
  |  
  | **** Entity bean: Admin ****
  | @Entity
  | @Table(name = "Admin", schema = "dbo", catalog = "TungaRestaurant", 
uniqueConstraints = {})
  | public class Admin implements java.io.Serializable {
  |     private String username;
  |     private String password;
  |  
  |     public Admin(String username, String password) {
  |             this.username = username;
  |             this.password = password;
  |     }
  |  
  |     @Id
  |     @Column(name = "Username", unique = true, nullable = false, insertable 
= true, updatable = true, length = 20)
  |     public String getUsername() {
  |             return this.username;
  |     }
  |     public void setUsername(String username) {
  |             this.username = username;
  |     }
  |  
  |     @Column(name = "Password", unique = false, nullable = false, insertable 
= true, updatable = true, length = 20)
  |     public String getPassword() {
  |             return this.password;
  |     }
  |     public void setPassword(String password) {
  |             this.password = password;
  |     }
  | }
  |  
  | *** Session Bean to manage Admin Entity: AdminBean ***
  | @Stateless
  | public class AdminBean implements Serializable, AdminMan, AdminBeanLocal, 
AdminBeanRemote {
  |     @PersistenceContext
  |     EntityManager em;
  |     public int delete(Admin admin) {
  |             return delete (admin.getUsername());
  |     }
  |  
  |     public int delete(String usr) {
  |             int retVal = 0;
  |             Admin admin = em.find(Admin.class, usr);
  |             try
  |             {
  |                     em.remove(admin);
  |             }
  |             catch (Exception ex)
  |             {
  |                     retVal = -1;
  |             }               
  |             return retVal;
  |     }
  |  
  |     public Admin findAdmin(String usr) {
  |             return em.find(Admin.class, usr);
  |     }
  |  
  |     public int save(Admin admin) {
  |             int retVal = 0;
  |             try {
  |                     Admin dbadmin = em.find(Admin.class, 
admin.getUsername());
  |                     if (dbadmin == null)
  |                             em.persist(admin);
  |                     else
  |                     {
  |                             dbadmin.setPassword(admin.getPassword());
  |                             em.flush();
  |                     }
  |             } catch (Exception ex) {
  |                     retVal = -1;
  |             }
  |             return retVal;
  |     }
  | }
  |  
  | *** Interface AdminMan ****
  | public interface AdminMan {
  |     /*
  |      * Return an the Admin with username
  |      * @param String username
  |      * @return a tunga.ejb.Admins object
  |      */
  |     public Admin findAdmin(String usr);
  |     
  |     /*
  |      * Save the Admin's information to database, if the Admin is existed, 
the info
  |      * will be update, if not, a new Admin will be inserted to database.
  |      * @param tunga.ejb.Admin the Admin object that holds information
  |      * @return 0 if ok, <0 if not
  |      */
  |     public int save(Admin admin);
  |     
  |     /*
  |      * Delete the Admin from the database
  |      * @param tunga.ejb.Admin the Admin object that holds information
  |      * @return 0 if ok, <0 if not
  |      */
  |     public int delete(Admin admin);
  |     
  |     /*
  |      * Delete the Admin from the database
  |      * @param int the Admin's username
  |      * @return 0 if ok, <0 if not
  |      */
  |     public int delete(String usr);
  | }
  |  
  | *********************************
  | The Client:
  |  
  | **** File: jndi.properties ****
  | java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
  | java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
  | java.naming.provider.url=localhost:1099
  |  
  | ***** File: log4j.properties *****
  | log4j.appender.stdout=org.apache.log4j.ConsoleAppender
  | log4j.appender.stdout.Target=System.out
  | log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
  | log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - 
%m%n
  | log4j.rootLogger=debug, stdout
  |  
  | **** Class test Client
  | public class TestEJBClient {
  |     public static void main(String[] args) {
  |             Context context;
  |             try             
  |             {
  |                     context = new InitialContext();
  |                     AdminMan adminMan = 
(AdminMan)context.lookup("AdminBean");
  |  
  |                     Admin admin = new Admin("admin","123");
  |                     adminMan.save(admin);
  |  
  |             } catch (NamingException e)
  |             {
  |                     e.printStackTrace();
  |             }
  |     }
  | }

View the original post : 
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4120274#4120274

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4120274
_______________________________________________
jboss-user mailing list
jboss-user@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/jboss-user

Reply via email to