[EJB 3.0] - Em does not rollback
by vphagura
Folks,
I have the following code;
@Enitity
| public class Cruise
| {
| private Collection<Reservation> reservations;
| ...
| @OneToMany(cascade = CascadeType.ALL, mappedBy="cartridge")
| public Collection<Reservation> getReservations() {
| return reservations;
| }
|
| public void setReservations(Collection<Reservation> reservations) {
| this.reservations= reservations;
| }
| ...
| }
|
| @Enitity
| public class Reservation
| {
| private Cruise cruise;
| ...
| @ManyToOne(cascade = {CascadeType.ALL})
| @JoinColumn(name="cruiseId", nullable=true)
| public Cruise getCruise() {
| return cruise ;
| }
|
| public void setCruise(Cruise cruise ) {
| this.cruise = cruise;
| }
| ...
| }
|
| @Stateless
| public class PersistBean
| {
|
| /** Injected EntityManger */
| @PersistenceContext( unitName="eg")
| protected EntityManager em = null;
|
| ...
|
| public void persist( Set reservations, Curise cruise )
| {
| .....
| Iterator it = reservations.iterator();
| while( it.hasNext() )
| {
| Reservation r = (Reservation)it.next();
| r.setCruise( cruise );
| em.persist( r );
| }
| ......
| }
|
| ....
| }
Now, I'm trying to write just 4 reservations. And, on the 4th one I get a db error about a contraint being voilated! I find that the first 3 records are writen to the Reservation table.
My point is that, if my persist() method is running in a transaction, which I believe it is, then the first 3 records should have been rolledback, following an error on the 4th record!!!!
Please help! Any help will be appreciated. Thx in adv!
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4070762#4070762
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4070762
18Â years, 8Â months
[Security & JAAS/JBoss] - Re: rough start with JBossPDP
by anil.saldhanaï¼ jboss.com
What you provide to the PDP construction is a configuration file(which internally lists the locations of your policy/policy sets). Look at page 4 of the user guide for an example of the configuration file.
| <ns:jbosspdp>
| <ns:Policies>
| <ns:PolicySet>
| <ns:Location>test/policies/interop/xacml-policySet.xml</ns:Location>
| <ns:Policy>
| <ns:Location>test/policies/interop/xacml-policy2.xml</ns:Location>
| </ns:Policy>
| <ns:Policy>
| <ns:Location>test/policies/interop/xacml-policy3.xml</ns:Location>
| </ns:Policy>
| <ns:Policy>
| <ns:Location>test/policies/interop/xacml-policy4.xml</ns:Location>
| </ns:Policy>
| <ns:Policy>
| <ns:Location>test/policies/interop/xacml-policy5.xml</ns:Location>
| </ns:Policy>
| </ns:PolicySet>
| </ns:Policies>
| <ns:Locators>
| <ns:Locator>
| </ns:Locator>
| </ns:Locators>
| </ns:jbosspdp>
|
I will need to clean up the user guide and make it more intuitive and descriptive (this is a beta release). For the GA release, I will get the user guide better. :)
If you download the source jar, there are multiple junit tests that you can look at.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4070755#4070755
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4070755
18Â years, 8Â months
[Messaging, JMS & JBossMQ] - Quartz Classpath issues. How to configure.
by jfrankman
I am trying to use the quartz scheduler that comes with JBoss. I have created a simple job that logs a message every few minutes. Now that I have this working, I want to call a job that requires Hibernate and Java Persistence. When I do this I get errors because the persistence.xml file is not found in META-INF folder. I beleive this is a class path issue. Here is the error I am getting:
12:36:00,034 INFO [Ejb3Configuration] Could not find any META-INF/persistence.xml file in the classpath
| 12:36:00,034 WARN [UserSuppliedConnectionProvider] No connection properties specified - the user must supply JDBC connections
| 12:36:00,034 ERROR [JobRunShell] Job default.job.0.1186166057839 threw an unhandled Exception:
| javax.ejb.EJBTransactionRolledbackException: javax.persistence.PersistenceException: org.hibernate.HibernateException: Hibernate Dialect must be explicitly set
| at org.jboss.ejb3.tx.Ejb3TxPolicy.handleInCallerTx(Ejb3TxPolicy.java:93)
| at org.jboss.aspects.tx.TxPolicy.invokeInCallerTx(TxPolicy.java:130)
| at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:195)
| at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
| at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:62)
| at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
| at org.jboss.ejb3.mdb.MessagingContainer.localInvoke(MessagingContainer.java:245)
| at org.jboss.ejb3.mdb.inflow.MessageInflowLocalProxy.delivery(MessageInflowLocalProxy.java:268)
| at org.jboss.ejb3.mdb.inflow.MessageInflowLocalProxy.invoke(MessageInflowLocalProxy.java:138)
| at $Proxy133.execute(Unknown Source)
| at org.jboss.resource.adapter.quartz.inflow.QuartzJob.execute(QuartzJob.java:57)
| at org.quartz.core.JobRunShell.run(JobRunShell.java:203)
| at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:520)
| Caused by: javax.persistence.PersistenceException: org.hibernate.HibernateException: Hibernate Dialect must be explicitly set
| at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:698)
| at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:121)
| at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:51)
| at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:33)
| at com.idfbins.nexus.batch.GISDataBatch.init(GISDataBatch.java:42)
| at com.idfbins.nexus.batch.GISDataBatch.assignLocationsCoordinates(GISDataBatch.java:55)
| at com.idfbins.nexus.batch.ExecuteGISBatch.execute(ExecuteGISBatch.java:34)
| 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 org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:112)
| at org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:166)
| at org.jboss.ejb3.interceptor.EJB3InterceptorsInterceptor.invoke(EJB3InterceptorsInterceptor.java:63)
| at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
| at org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor.invoke(TransactionScopedEntityManagerInterceptor.java:54)
| at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
| at org.jboss.ejb3.AllowedOperationsInterceptor.invoke(AllowedOperationsInterceptor.java:46)
| at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
| at org.jboss.aspects.tx.TxPolicy.invokeInCallerTx(TxPolicy.java:126)
| ... 11 more
| Caused by: org.hibernate.HibernateException: Hibernate Dialect must be explicitly set
| at org.hibernate.dialect.DialectFactory.determineDialect(DialectFactory.java:57)
| at org.hibernate.dialect.DialectFactory.buildDialect(DialectFactory.java:39)
| at org.hibernate.cfg.SettingsFactory.determineDialect(SettingsFactory.java:409)
| at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:119)
| at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:1933)
| at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1216)
| at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:691)
| ... 30 more
|
Here is my setting the the ejb-jar.xml:
<message-driven>
| <ejb-name>GISBatch</ejb-name>
| <ejb-class>com.idfbins.nexus.batch.ExecuteGISBatch</ejb-class>
| <messaging-type>org.quartz.Job</messaging-type>
| <transaction-type>Container</transaction-type>
| <activation-config>
| <activation-config-property>
| <activation-config-property-name>
| cronTrigger
| </activation-config-property-name>
| <activation-config-property-value>
| <![CDATA[0 */2 * * * ?]]>
| </activation-config-property-value>
| </activation-config-property>
| </activation-config>
| </message-driven>
Here is my JBoss.xml:
<?xml version="1.0" encoding="UTF-8"?>
| <jboss>
| <enterprise-beans>
| <message-driven>
| <ejb-name>QuartzTst2</ejb-name>
| <resource-adapter-name>quartz-ra.rar</resource-adapter-name>
| </message-driven>
| <message-driven>
| <ejb-name>GISBatch</ejb-name>
| <resource-adapter-name>quartz-ra.rar</resource-adapter-name>
| </message-driven>
|
| </enterprise-beans>
| </jboss>
|
Here is the class that gets scheduled. It is located inside and EAR deployed on JBoss:
package com.idfbins.nexus.batch;
|
| import javax.ejb.EJBException;
| import javax.ejb.MessageDrivenContext;
| import javax.jms.Message;
|
| import org.jboss.logging.Logger;
| import org.quartz.JobExecutionContext;
| import org.quartz.JobExecutionException;
|
| public class ExecuteGISBatch {
|
| /**
| * @param args
| */
| /*
| public static void main(String[] args) {
| // TODO Auto-generated method stub
| GISDataBatch batch = new GISDataBatch();
| batch.assignLocationsCoordinates();
| }
| */
|
| private static final Logger log = Logger.getLogger(QuartzTst2.class);
|
| public void execute(JobExecutionContext jobExecutionContext)
| throws JobExecutionException {
| log.info("Executing GIS Batch");
| log.info("class path="+System.getProperty(
| "java.class.path"
| ));
|
| GISDataBatch batch = new GISDataBatch();
| batch.assignLocationsCoordinates();
| }
|
| /**
| * *
| *
| * @see javax.ejb.MessageDrivenBean#ejbRemove() *
| * @throws EJBException
| */
| public void ejbRemove() throws EJBException {
| }
|
| /**
| * *
| *
| * @see javax.ejb.MessageDrivenBean#setMessageDrivenContext(javax.ejb.MessageDrivenContext) *
| * @param context *
| * @throws EJBException
| */
| public void setMessageDrivenContext(MessageDrivenContext context)
| throws EJBException {
| }
|
| /**
| * *
| *
| * @see javax.jms.MessageListener#onMessage(javax.jms.Message) *
| * @param message
| */
| public void onMessage(Message message) {
| }
|
| public void ejbCreate() {
| log.info("GIS Batch job created");
| }
|
| }
I have read that if I set the Quartz property: useClassLoaderOfInitializer to true then it will use the JBoss class loader and everything should be on the classpath. If this is correct, I just need to know where to update or create the quartz.properties file. If I am incorrect I need to find a way to make sure that when the job is run that everything in my EAR is in the classpath. What is the best way to do this?
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4070750#4070750
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4070750
18Â years, 8Â months