[EJB 3.0] - EJB3 Session Facade TransactionRequiredException
by mjrother
I was wondering the best way the handle the following with EJB3. I have a EJB3 Session Bean which acts as a facade for business activities. In a method, I want to check for existing records and report the error prior to attempting to persist an business object. I am looking for the existance of a database record (say user table with a username field). If the record exists, I return an error that already exists. When I try to find the user record, if not there a EJB3TransactionRollbackException is raised with the cause a NoResultException. I trap the exception but when I try to continue and persist the new record, I get a TransactionRequiredException.
User user = null;
// pseudocode
try {
user = em.findById(username);
// throw already exists exception
}
catch (RuntimeException) ex) {
// test cause and try to continue... desired path
}
if (user == null) {
User user = new User(username);
em.persist(user);
}
It appears that once a exception is raised, you cannot continue. How can I perform the database check and still continue?
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3959641#3959641
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3959641
19 years, 9 months
[JBossCache] - Re: PojoCache Weblogic 91 and JConsole issue!!
by sphinxmember
| <bean id="mbeanServer"
| class="org.springframework.jndi.JndiObjectFactoryBean">
| <property name="jndiName"
| value="java:comp/env/jmx/runtime"/>
| </bean>
| <bean id="runtimeMbeanServerConnection"
| class="org.springframework.jmx.support.MBeanServerConnectionFactoryBean">
| <property name="serviceUrl" value="service:jmx:t3://localhost:7001/jndi/weblogic.management.mbeanservers.runtime"/>
| <property name="environment">
| <props>
| <prop key="java.naming.security.principal">weblogic</prop>
| <prop key="java.naming.security.credentials">weblogic</prop>
| <prop key="jmx.remote.protocol.provider.pkgs">
| weblogic.management.remote</prop>
| </props>
| </property>
| </bean>
| <bean id="exporter" class="org.springframework.jmx.export.MBeanExporter">
| <property name="assembler" ref="assembler"/>
| <property name="server" ref="mbeanServer"/>
| <property name="beans">
| <map>
| <entry key="web:name=testBean1" value-ref="ConfigBeanA"></entry>
| <entry key="web:name=testBean2" value-ref="CacheMBean"></entry>
| </map>
| </property>
| <property name="listeners">
| <list>
| <ref bean="consoleAdapter"/>
| </list>
| </property>
| <property name="autodetect" value="true"/>
| <property name="registrationBehavior" value="2"/>
| </bean>
|
| <!-- Bean definition -->
| <!-- The factory bean, which contains a method createInstance -->
|
| <bean id="myFactoryBean" class="examples.JBossCacheServiceImpl">
| <property name="cacheMBean" ref="CacheMBean"/>
| </bean>
|
| <bean id="CacheMBean" class="org.jboss.cache.aop.TreeCacheAop">
| </bean>
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3959637#3959637
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3959637
19 years, 9 months
[JBoss Seam] - Seam Managed Persitance problems
by emsa
Hi,
after some time a have finally had the time to upgrade to jboss-4.0.4-Patch1 and seam-1.0.1.GA (after running old betas and cvs for some time).
But I cannot deploy my app using seam managed persistance, this has worked flawlessly before.
My seam.properties looks like this:
| org.jboss.seam.core.init.managedPersistenceContexts em
| em.persistenceUnitJndiName java:/EntityManagerFactories/myDatabase
|
And when I deploy I get this exception:
| java.lang.IllegalArgumentException: no property for configuration setting: org.jboss.seam.core.init.managedPersistenceContexts
| at org.jboss.seam.Component.initInitializers(Component.java:311)
| at org.jboss.seam.Component.<init>(Component.java:209)
| at org.jboss.seam.Component.<init>(Component.java:159)
| at org.jboss.seam.Component.<init>(Component.java:154)
| at org.jboss.seam.Component.<init>(Component.java:149)
| at org.jboss.seam.init.Initialization.addComponent(Initialization.java:381)
| at org.jboss.seam.init.Initialization.addComponents(Initialization.java:255)
| at org.jboss.seam.init.Initialization.init(Initialization.java:195)
| at org.jboss.seam.servlet.SeamListener.contextInitialized(SeamListener.java:32)
| at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3729)
| at org.apache.catalina.core.StandardContext.start(StandardContext.java:4187)
| at .... <SNIP>
|
| Caused by: java.beans.IntrospectionException: Method not found: isManagedPersistenceContexts
| at java.beans.PropertyDescriptor.<init>(PropertyDescriptor.java:89)
| at java.beans.PropertyDescriptor.<init>(PropertyDescriptor.java:53)
| at org.jboss.seam.Component.initInitializers(Component.java:307)
| ... 98 more
|
Deploying with an empty seam.properties do work.
Have I missed someting - must I make any changes to code or configurations to make seam managed persistance work again?
/Magnus
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3959632#3959632
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3959632
19 years, 9 months