[JBoss Seam] - [1.3.0 Alpha]not-null property references a null or transien
by enzhao
My environment: JBoss As 4.2.0 GA, Seam 1.3.0 CVS June 14th, 2007
Here the backing bean:
| @Stateful
| @Scope(CONVERSATION)
| @Name("foodNutrients")
| public class FoodNutrientsAction implements Serializable, FoodNutrients {
|
| private static final long serialVersionUID = 366209327813983835L;
|
| @PersistenceContext(type=PersistenceContextType.EXTENDED)
| private EntityManager em;
|
| @DataModel
| private List<FoodWeight> weightUnits;
|
| public void cancel() {
| // TODO Auto-generated method stub
| }
|
| @Remove @Destroy
| public void destroy() {
| // TODO Auto-generated method stub
| }
|
| @Factory("weightUnits")
| public void findWeightUnits() {
| String query = "select w from FoodWeight w where w.food.ndbNo = :foodId";
| this.weightUnits = em.createQuery(query).setParameter("foodId",
| "01001").getResultList();
| }
| }
|
Here the relevant part in the food-nutrients.xhtml:
| <ui:define name="body">
| <h:messages globalOnly="true" styleClass="message" />
| <rich:panel>
| <f:facet name="header">weight units loading test</f:facet>
| <h:dataTable value="#{weightUnits}" var="unit">
| <h:column>
| <f:facet name="header">
| <h:outputText value="Unit" />
| </f:facet>
| <h:outputText value="#{unit.msreDesc}" />
| </h:column>
| </h:dataTable>
| </rich:panel>
| </ui:define>
|
Here is the relevant code in the entity class:
| @Entity
| @Name("foodWeight")
| @Scope(CONVERSATION)
| @Table(name = "weight")
| public class FoodWeight implements Serializable {
|
| @Embeddable
| public static class Id implements Serializable {
| private String foodId;
| private String seq;
|
| public Id(String foodId, String seq) {
| this.foodId = foodId;
| this.seq = seq;
| }
|
| public Id() {}
|
| @Column(name = "NDB_No", nullable = false, length = 5)
| public String getFoodId() {
| return foodId;
| }
|
| @Column(name = "Seq", nullable = false, length = 2)
| public String getSeq() {
| return seq;
| }
|
| public boolean equals(Object other) {
| if (this == other) return true;
| if (!(other instanceof Id)) return false;
|
| final Id pk = (Id) other;
|
| return pk.foodId.equals(this.foodId) && pk.seq.equals(this.seq);
| }
|
| public int hashCode() {
| int result;
| result = this.foodId.hashCode();
| result = 7 * result + this.seq.hashCode();
| return result;
| }
|
| public void setFoodId(String foodId) {
| this.foodId = foodId;
| }
|
| public void setSeq(String seq) {
| this.seq = seq;
| }
| }
|
| private Id id;
|
| private Food food;
|
| private String seq;
|
| private String msreDesc;
|
| //other fields....
|
| public FoodWeight() {}
|
| public FoodWeight(Food food, String seq, BigDecimal amount,
| String msreDesc, BigDecimal gmWgt) {
| // set fields
| this.food = food;
| this.seq = seq;
| this.amount = amount;
| this.msreDesc = msreDesc;
| this.gmWgt = gmWgt;
|
| // set identifier values
| this.id.foodId = food.getNdbNo();
| this.id.seq = seq;
|
| // Guarantee referential integrity
| food.getWeights().add(this);
| }
|
| /**
| * @return the food.
| */
| @ManyToOne(targetEntity = Food.class) //@OnDelete(action = OnDeleteAction.CASCADE)
| @JoinColumn(name = "NDB_No", insertable = false, updatable = false, nullable = false)
| public Food getFood() {
| return food;
| }
|
| public void setFood(Food food) {
| this.food = food;
| }
|
| /**
| * @return the composite primary key of this class
| */
| @EmbeddedId
| public Id getId() {
| return id;
| }
|
| public void setId(Id id) {
| this.id = id;
| }
|
| /**
| * @return Description (for example, cup, diced, and 1-inch pieces)
| */
| @Column(name = "Msre_Desc", nullable = false, length = 80)
| public String getMsreDesc() {
| return msreDesc;
| }
|
| public void setMsreDesc(String msreDesc) {
| msreDesc = msreDesc;
| }
|
| /**
| * @return Sequence number
| */
| @Column(name = "Seq", insertable = false, updatable = false, nullable = false, length = 2)
| public String getSeq() {
| return seq;
| }
|
| public void setSeq(String seq) {
| this.seq = seq;
| }
|
| // other getters and setters
|
| /* (non-Javadoc)
| * @see java.lang.Object#hashCode()
| */
| @Override
| public int hashCode() {
| final int prime = 31;
| int result = 1;
| result = prime * result
| + ((amount == null) ? 0 : amount.hashCode());
| result = prime * result + ((food == null) ? 0 : food.hashCode());
| result = prime * result + ((gmWgt == null) ? 0 : gmWgt.hashCode());
| result = prime * result
| + ((msreDesc == null) ? 0 : msreDesc.hashCode());
| result = prime * result + ((seq == null) ? 0 : seq.hashCode());
| return result;
| }
|
| /* (non-Javadoc)
| * @see java.lang.Object#equals(java.lang.Object)
| */
| @Override
| public boolean equals(Object obj) {
| if (this == obj) return true;
| if (obj == null) return false;
| if (!(obj instanceof FoodWeight)) return false;
| final FoodWeight other = (FoodWeight) obj;
| if (amount == null) {
| if (other.getAmount() != null) return false;
| } else if (!amount.equals(other.getAmount())) return false;
| if (food == null) {
| if (other.getFood() != null) return false;
| } else if (!food.equals(other.getFood())) return false;
| if (gmWgt == null) {
| if (other.getGmWgt() != null) return false;
| } else if (!gmWgt.equals(other.getGmWgt())) return false;
| if (msreDesc == null) {
| if (other.getMsreDesc() != null) return false;
| } else if (!msreDesc.equals(other.getMsreDesc())) return false;
| if (seq == null) {
| if (other.getSeq() != null) return false;
| } else if (!seq.equals(other.getSeq())) return false;
| return true;
| }
| }
|
|
When I was trying to load the food-nutrients.xhtml, I always got this exception:
Exception during request processing:
Caused by java.lang.IllegalStateException with message: "Could not commit transaction"
...
Caused by javax.transaction.RollbackException with message: "[com.arjuna.ats.internal.jta.transaction.arjunacore.commitwhenaborted] [com.arjuna.ats.internal.jta.transaction.arjunacore.commitwhenaborted] Can't commit because the transaction is in aborted state"
...
Caused by javax.persistence.PersistenceException with message: "org.hibernate.PropertyValueException: not-null property references a null or transient value: org.ningning.eatsmart.entity.FoodWeight.msreDesc"
...
Caused by org.hibernate.PropertyValueException with message: "not-null property references a null or transient value: org.ningning.eatsmart.entity.FoodWeight.msreDesc"
org.hibernate.engine.Nullability.checkNullability(Nullability.java:72)
org.hibernate.event.def.DefaultFlushEntityEventListener.scheduleUpdate(DefaultFlushEntityEventListener.java:263)
org.hibernate.event.def.DefaultFlushEntityEventListener.onFlushEntity(DefaultFlushEntityEventListener.java:121)
org.hibernate.event.def.AbstractFlushingEventListener.flushEntities(AbstractFlushingEventListener.java:196)
org.hibernate.event.def.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:76)
org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:26)
org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:338)
org.hibernate.ejb.AbstractEntityManagerImpl$1.beforeCompletion(AbstractEntityManagerImpl.java:515)
com.arjuna.ats.internal.jta.resources.arjunacore.SynchronizationImple.beforeCompletion(SynchronizationImple.java:114)
com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator.beforeCompletion(TwoPhaseCoordinator.java:249)
com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator.end(TwoPhaseCoordinator.java:88)
com.arjuna.ats.arjuna.AtomicAction.commit(AtomicAction.java:177)
com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple.commitAndDisassociate(TransactionImple.java:1256)
com.arjuna.ats.internal.jta.transaction.arjunacore.BaseTransaction.commit(BaseTransaction.java:135)
com.arjuna.ats.jbossatx.BaseTransactionManagerDelegate.commit(BaseTransactionManagerDelegate.java:87)
org.jboss.tm.usertx.client.ServerVMClientUserTransaction.commit(ServerVMClientUserTransaction.java:140)
org.jboss.seam.transaction.UTTransaction.commit(UTTransaction.java:35)
org.jboss.seam.jsf.AbstractSeamPhaseListener.commitOrRollback(AbstractSeamPhaseListener.java:285)
org.jboss.seam.jsf.TransactionalSeamPhaseListener.handleTransactionsAfterPhase(TransactionalSeamPhaseListener.java:45)
org.jboss.seam.jsf.SeamPhaseListener.afterPhase(SeamPhaseListener.java:106)
com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:280)
com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:144)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:245)
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
org.jboss.seam.web.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:70)
org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:81)
org.jboss.seam.web.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:56)
org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:62)
org.jboss.seam.web.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:56)
org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:47)
org.jboss.seam.web.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:56)
org.ajax4jsf.framework.ajax.xmlfilter.BaseFilter.doFilter(BaseFilter.java:293)
org.jboss.seam.web.AbstractAjax4jsfFilter.doFilter(AbstractAjax4jsfFilter.java:35)
org.jboss.seam.web.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:56)
org.jboss.seam.debug.hot.HotDeployFilter.doFilter(HotDeployFilter.java:64)
org.jboss.seam.web.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:56)
org.jboss.seam.web.SeamFilter.doFilter(SeamFilter.java:127)
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
org.ajax4jsf.framework.ajax.xmlfilter.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:127)
org.ajax4jsf.framework.ajax.xmlfilter.BaseFilter.doFilter(BaseFilter.java:277)
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:433)
org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:156)
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:241)
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:580)
org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
java.lang.Thread.run(Thread.java:619)
I wrote the code according to the example 1.11 described in user manual, mine is a simplified version, just want to see if the FoodWeight can be loaded correctly given a foodId. I read the user manual and Michael Yuan's Seam book in order to get a clue, but failed to figure out what was wrong. I tried to let entityManager first load a food entity and then use food.getFoodWeights(), that worked perfectly. But I desparately want to know why the code above does not work and how to correctly use this way of data fetching with Seam......Any enlightenment would be highly appreciated!
Regards,
Ellen
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4056425#4056425
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4056425
18Â years, 10Â months
[Clustering/JBoss] - Hot Farm deployment during client requests
by jmp
Hi there,
I have 2 JBOSS AS 4.2 in clustering environement with farm deployment enabled.
If i deploy my ear while client is requesting i have a cluster invocation failed during deployment.
This is my client code :
Properties properties = new Properties();
| properties.put("java.naming.factory.initial","org.jnp.interfaces.NamingContextFactory");
| properties.put("java.naming.factory.url.pkgs","org.jboss.naming:org.jnp.interfaces");
| properties.put("java.naming.provider.url","server1:1099;server2:1099");
|
| Context context = new InitialContext(properties);
| MyBeanRemote beanRemote = (MyBeanRemote)context.lookup("myapp/MyBeanRemote/remote");
|
| for (int j=0;j<100000;j++){
| //I deploy my ear during this loop
| beanRemote.sampleMethod();
| }
Have you got an idea ?
Is it possible to deploy an ear without affect clients requests ?
Regards,
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4056418#4056418
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4056418
18Â years, 10Â months
[JBoss Messaging] - Re: Single MDB Instance Required
by mirabis
please ignor the above post. Some xml tags are deleted. the following is the correct one:
i am developing an Event Driven architecture using j2ee (MDB) on JBoss. In this Architecture the incoming business events (raw events) will be fetched by a MDB, wich forward the raw events to Event Stream Processor. My Problem is that JBoss instantiate multiple instances of my MDB. It means the same event will be delivered repeatedly. I just tried to force JBoss to limit the number of MDB instances. But it was useless. My jboss.xml look like this:
| <?xml version="1.0"?>
| <!DOCTYPE jboss PUBLIC
| "-//JBoss//DTD JBOSS 3.2//EN"
| "http://www.jboss.org/j2ee/dtd/jboss_3_2.dtd">
| <!-- The jboss.xml descriptor for the jrmp-comp.jar ejb unit -->
| <jboss>
| <enterprise-beans>
| <message-driven>
| <ejb-name>EventInputAdapterBean</ejb-name>
| <destination-jndi-name>topic/rawEventTopic</destination-jndi-name>
| <configuration-name>Standard Message Driven Bean</configuration-name>
|
| <invoker-bindings>
| <invoker>
| <invoker-proxy-binding-name>event-message-driven-bean</invoker-proxy-binding-name>
| </invoker>
| </invoker-bindings>
| </message-driven>
| <message-driven>
| <ejb-name>ComplexEventInputAdapterBean</ejb-name>
| <destination-jndi-name>topic/complexEventTopic</destination-jndi-name>
| <configuration-name>Standard Message Driven Bean</configuration-name>
| <invoker-bindings>
| <invoker>
| <invoker-proxy-binding-name>event-message-driven-bean</invoker-proxy-binding-name>
| </invoker>
| </invoker-bindings>
| </message-driven>
| </enterprise-beans>
|
| <invoker-proxy-bindings>
| <invoker-proxy-binding>
| <name>event-message-driven-bean</name>
| <invoker-mbean>default</invoker-mbean>
| <proxy-factory>org.jboss.ejb.plugins.jms.JMSContainerInvoker</proxy-factory>
| <proxy-factory-config>
| <JMSProviderAdapterJNDI>DefaultJMSProvider</JMSProviderAdapterJNDI>
| <ServerSessionPoolFactoryJNDI>StdJMSPool</ServerSessionPoolFactoryJNDI>
| <MaximumSize>1</MaximumSize>
| <MaxMessages>1</MaxMessages>
| <MDBConfig>
| <ReconnectIntervalSec>10</ReconnectIntervalSec>
| <DLQConfig>
| <DestinationQueue>queue/DLQ</DestinationQueue>
| <MaxTimesRedelivered>10</MaxTimesRedelivered>
| <TimeToLive>0</TimeToLive>
| </DLQConfig>
| </MDBConfig>
| </proxy-factory-config>
| </invoker-proxy-binding>
| </invoker-proxy-bindings>
|
| </jboss>
|
i also made some changes in conf/jbossstandard.xml. The referenced configuration "Standard Message Driven Bean" like following:
| <container-configuration>
| <container-name>Standard Message Driven Bean</container-name>
| <call-logging>false</call-logging>
| <invoker-proxy-binding-name>message-driven-bean</invoker-proxy-binding-name>
| <container-interceptors>
| <interceptor>org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor</interceptor>
| <interceptor>org.jboss.ejb.plugins.LogInterceptor</interceptor>
| <interceptor>org.jboss.ejb.plugins.RunAsSecurityInterceptor</interceptor>
| <!-- CMT -->
| <interceptor transaction="Container">org.jboss.ejb.plugins.TxInterceptorCMT</interceptor>
| <interceptor transaction="Container">org.jboss.ejb.plugins.CallValidationInterceptor</interceptor>
| <interceptor transaction="Container">org.jboss.ejb.plugins.MessageDrivenInstanceInterceptor</interceptor>
| <!-- BMT -->
| <interceptor transaction="Bean">org.jboss.ejb.plugins.MessageDrivenInstanceInterceptor</interceptor>
| <interceptor transaction="Bean">org.jboss.ejb.plugins.MessageDrivenTxInterceptorBMT</interceptor>
| <interceptor transaction="Bean">org.jboss.ejb.plugins.CallValidationInterceptor</interceptor>
| <interceptor>org.jboss.resource.connectionmanager.CachedConnectionInterceptor</interceptor>
| </container-interceptors>
| <instance-pool>org.jboss.ejb.plugins.MessageDrivenInstancePool</instance-pool>
| <instance-cache></instance-cache>
| <persistence-manager></persistence-manager>
| <container-pool-conf>
| <MaximumSize>1</MaximumSize>
| <strictMaximumSize>true</strictMaximumSize>
|
| </container-pool-conf>
| </container-configuration>
|
|
can you please tell me, what my mistake is.
thanks
Saeed
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4056415#4056415
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4056415
18Â years, 10Â months