[JBoss Seam] - EntityManger-per-user-session...
by bkyrlach
Okay...
Everywhere I read, everyone says that this is bad. In fact, it's labeled as an anti-pattern in the Hibernate documentation. However, I still can't help but think that this is an appropriate usage when talking about Seam as the application framework. The only reasons I can find after some searching on Google why this is an anti-pattern is the following...
1) EntityManager is not thread-safe.
Rebuttal: em is not thread safe, but the new feature in Seam 1.1.0 of synchronizing calls to SFSB's means that if you wrap the em in a session scoped seam component, then for our purposes it should be threadsafe.
2) EntityManager uses more memory the longer user session exists because it keeps references to attached objects.
Rebuttal: This is actually true, but doesn't that make sense for a Seam component. I mean using Hibernate without Seam, you have to reattach your entities all the time, because you're presentation layer is always passing id's instead of objects. With Seams contextual bijection, you're always dealing with objects. So, the old way... (assuming updating an already persistent entity)
Activity activity = em.find(Activity.class, activityId);
//update activity
//activity is persisted at the end of the method call because it's
//attached from the finder method.
The new way without using EntityManager-per-user-session...
@In
Activity activity;
...
...
activity = em.merge(activity);
//activity is persisted when you called merge, and was already
//updated because it was injected.
And the way you would do it with the EntityManager-per-session
@In
Activity activity;
...
...
//no code nessecary assuming the updated activity was injected
//and the instance was already attached.
So, please share your thoughts on this. I need to know why EntityManger-per-session is such a bad idea, or if it does truly make sense when dealing with the idea of a Seam component.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3983814#3983814
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3983814
19Â years, 6Â months
[JBossWS] - org.jboss.remoting.CannotConnectException: Can not connect h
by jgilbert
I am trying to call a secured web service from a SLSB. I have injected the port using @Resource but get a connection exception because the credentials are not set. I have come up with a workaround to propagate the credentials (see below). But I would like to know if there is a standards based way to propagate credentials to the jaxrpc stub.
Do I just need to wait for the full JaxWS implementation in JBossWS 2.0?
@Stateless
| @RolesAllowed(value = { "User" })
| @SecurityDomain("portal")
| public class AuthorizationCallbackServiceAdapterBean implements AuthorizationCallbackServiceLocal {
|
| @Resource(mappedName = "jbossws-client/service/AuthorizationCallbackService")
| protected AuthorizationCallbackService_PortType port;
|
| public void authorizationResponse(Long paymentId, Boolean status) {
| try {
| Stub stub = (Stub) port;
| stub._setProperty(Stub.USERNAME_PROPERTY, SecurityAssociation.getCallerPrincipal().getName());
| stub._setProperty(Stub.PASSWORD_PROPERTY, SecurityAssociation.getCredential());
|
| port.authorizationResponse(paymentId, status);
|
| } catch (Exception e) {
| throw new RuntimeException(e);
| }
| }
| }
|
Calling SecurityAssociation and setting the properties on the stub is the prioritary workaround that i would like to avoid.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3983812#3983812
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3983812
19Â years, 6Â months
[JBoss Messaging] - JMS Unknown Destination Error
by danielkalcevich
I am trying to add a ObjectMessage to my JMS Queue and am getting an unknown destination exception. I am able to connect to the Queue on startup though. Any ideas what could be causing the error?
I am on JBoss 4.0.5-GA and am using a MessageProducer to attempt and sent the message to the Destination.
Daniel
-----
Error:
org.quartz.JobExecutionException: javax.jms.JMSException: Unknown Destination Type [See nested exception: javax.jms.JMSE
xception: Unknown Destination Type]
at com.firstam.mlsdatachecker.quartz.BatchSchedulerJob.executeInternal(BatchSchedulerJob.java:108)
at org.springframework.scheduling.quartz.QuartzJobBean.execute(QuartzJobBean.java:79)
at org.quartz.core.JobRunShell.run(JobRunShell.java:203)
at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:520)
* Nested Exception (Underlying Cause) ---------------
javax.jms.JMSException: Unknown Destination Type
at org.exolab.jms.message.MessageHeader.setJMSDestination(MessageHeader.java:194)
at org.exolab.jms.message.MessageImpl.setJMSDestination(MessageImpl.java:301)
at org.jboss.mq.SpyMessageProducer.send(SpyMessageProducer.java:257)
at org.jboss.mq.SpyMessageProducer.send(SpyMessageProducer.java:206)
at com.firstam.mlsdatachecker.jms.JMSConnector.sendObjectMessage(JMSConnector.java:229)
at com.firstam.mlsdatachecker.quartz.BatchSchedulerJob.executeInternal(BatchSchedulerJob.java:97)
at org.springframework.scheduling.quartz.QuartzJobBean.execute(QuartzJobBean.java:79)
at org.quartz.core.JobRunShell.run(JobRunShell.java:203)
at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:520)
------
Queue Definition:
<mbean code="org.jboss.mq.server.jmx.Queue"
| name="jboss.mq.destination:service=Queue,name=BatchProcess">
| <depends optional-attribute-name="DestinationManager">jboss.mq:service=DestinationManager</depends>
| <depends optional-attribute-name="SecurityManager">jboss.mq:service=SecurityManager</depends>
| <attribute name="MessageCounterHistoryDayLimit">-1</attribute>
| <attribute name="SecurityConf">
| <security>
| <role name="mdc_user" read="true" write="true"/>
| </security>
| </attribute>
| </mbean>
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3983810#3983810
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3983810
19Â years, 6Â months