Advertisement

01.15.2008 at 08:26AM PST, ID: 23084400 | Points: 500
[x]
Attachment Details

EJB3 Client with JBoss error: java.lang.NoSuchFieldError: TRACE

Tags: EJB3 Client with JBoss 4.2
I'm trying to use EBJ3 to manage a table in my database, when I created a 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.

1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
// 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();
		}
    }
}
Start your free trial to view this solution
Question Stats
Zone: Programming
Question Asked By: exprotein
Question Asked On: 01.15.2008
Participating Experts: 1
Points: 500
Views: 0
Translate:
Loading Advertisement...
01.15.2008 at 10:26PM PST, ID: 20669598

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
01.16.2008 at 04:36AM PST, ID: 20671184

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
01.16.2008 at 06:44AM PST, ID: 20672264

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
01.16.2008 at 07:41AM PST, ID: 20672769

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
01.16.2008 at 08:03AM PST, ID: 20673012

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
01.16.2008 at 09:48AM PST, ID: 20674144

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
01.16.2008 at 08:17PM PST, ID: 20678643

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
01.16.2008 at 08:22PM PST, ID: 20678662

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
01.17.2008 at 12:45AM PST, ID: 20679646

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
01.17.2008 at 01:11AM PST, ID: 20679738

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
01.17.2008 at 07:19AM PST, ID: 20682076

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
Loading Advertisement...
20080236-EE-VQP-29 / EE_QW_2_20070628