[EJB 3.0] - EJB3 Client, exception: java.lang.NoSuchFieldError
by mrducnguyen
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
18 years, 5 months
[JBoss Seam] - Transaction TimeOut and Stateful Session Bean
by rodrigotico
Hello All,
********
This is not a doubt, it's just a report of a problem that I had and solve it after hours!
This is just in case someone pass thru the same error!
********
I have a SFSB on my project that inserts records to my database from a uploaded file.
My session timeout is huge. When I use a file with many records to import (more than 5 minutes making database operations) I get this error:
| 22:15:56,250 WARN [arjLoggerI18N] [com.arjuna.ats.arjuna.coordinator.BasicAction_58] - Abort of action id -3f57fe87:dd1e:478d4a9e:49 invoked while multiple threads active within it.
| 22:15:56,251 WARN [arjLoggerI18N] [com.arjuna.ats.arjuna.coordinator.CheckedAction_2] - CheckedAction::check - atomic action -3f57fe87:dd1e:478d4a9e:49 aborting with 1 threads active!
| 22:15:56,282 ERROR [AssertionFailure] an assertion failure occured (this may indicate a bug in Hibernate, but is more likely due to unsafe use of the session)
| org.hibernate.AssertionFailure: bug adding collection twice
| at org.hibernate.engine.StatefulPersistenceContext.addCollection(StatefulPersistenceContext.java:720)
| at org.hibernate.engine.StatefulPersistenceContext.addInitializedDetachedCollection(StatefulPersistenceContext.java:753)
| at org.hibernate.event.def.ProxyVisitor.reattachCollection(ProxyVisitor.java:65)
| at org.hibernate.event.def.WrapVisitor.processCollection(WrapVisitor.java:45)
| at org.hibernate.event.def.AbstractVisitor.processValue(AbstractVisitor.java:101)
| at org.hibernate.event.def.WrapVisitor.processValue(WrapVisitor.java:98)
| at org.hibernate.event.def.AbstractVisitor.processEntityPropertyValues(AbstractVisitor.java:55)
| at org.hibernate.event.def.DefaultFlushEntityEventListener.wrapCollections(DefaultFlushEntityEventListener.java:192)
| at org.hibernate.event.def.DefaultFlushEntityEventListener.onFlushEntity(DefaultFlushEntityEventListener.java:125)
| at org.hibernate.event.def.AbstractFlushingEventListener.flushEntities(AbstractFlushingEventListener.java:196)
| at org.hibernate.event.def.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:76)
| at org.hibernate.event.def.DefaultAutoFlushEventListener.onAutoFlush(DefaultAutoFlushEventListener.java:35)
| at org.hibernate.impl.SessionImpl.autoFlushIfRequired(SessionImpl.java:969)
| at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1114)
| at org.hibernate.impl.QueryImpl.list(QueryImpl.java:79)
|
I changed the transaction timeout at jboss config and everything worked good:
(/server/default/config/jboss-service.xml)
| <!-- The default was 300 seconds -->
| <attribute name="TransactionTimeout">1000</attribute>
|
Thanks.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4120273#4120273
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4120273
18 years, 5 months