[JBoss Seam] - @Label thoughts?
by texan
I'm wondering if it would be useful to have an @Label tag on a bean attribute, that could be used (with a new JSF component) to display the label of a component. An attempt at applying DRY to an area that has always bugged me. Feel free to tell me that somebody did this ages ago and I should just use that.
| @Label(value="Full Name")
| private String name;
|
| @Label(key="org.whatever.lastName")
| private String lastName;
|
| <my:attrLabel value="#{user.name}" />
Maybe the "value=" wouldn't work on the UI component - I haven't written a component before, so I'm not sure how you'd do this, but the intent is that the component would recognize that the "user.name" attribute had a @Label annotation and would use either the key (from a bundle) or the value from the annotation. If there was no annotation, maybe it would use the attribute name itself, possibly converting the first character to a capital.
Ideally, the h:outputLabel component would support this, so that it could use the "for" attribute and tie in with messages. Maybe there's a way to tie into the "for" mechanism in a custom component...
Anyway, just thinking out loud, really. If I get a little breathing room, I need to create a custom component to learn how things work under the covers, so maybe this is something I'll try.
I'm only posting it here because it sort of fits with Seam's "seamless" approach to things.
FYI, this line of thought came about when I was considering writing an "exportLink" component that would handle exporting a collection (or DataModel) to CSV, Excel, etc. It occurred to me that there's not a clean way (IMHO) to do this because I don't have headings for the results. With the @Label annotation, that would be a freebie. [I've seen the MyFaces example where they're parsing the HTML for an export, but that feels really fragile. Besides, I want to export the entire data set, not just the 10 rows I displayed on the UI.]
Anyway, my "exportLink" tag would probably work with an @Exported annotation on the bean, to indicate which attributes should be exported. I started thinking I'd add a (label = "Full Name") to the @Exported annotation, which led me to think that a full @Label tag would itself be quite useful.
So here I am, circles within circles, babbling away.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3973320#3973320
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3973320
19 years, 7 months
[EJB 3.0] - MDB Problem:=DestinationManager not Registeres => InstanceNo
by MarcReis
Hi,
I have written a very simple MDB for testing purpose. I am running two 4.0.4GA servers clustered. My MDB is part of an ear.
The problem occurs when I start both servers simultaneously, starting sequentially does not produce this error.
The first error message shows up on the "second started server". Not sure why it can?t find the queue...
| 2006-09-21 18:22:42,603 WARN [org.jboss.ejb3.mdb.MDB] Could not find the queue
| destination-jndi-name=queue/mdb
| 2006-09-21 18:22:42,643 WARN [org.jboss.ejb3.mdb.MDB] destination not found: q
| ueue/mdb reason: javax.naming.NameNotFoundException: queue not bound
| 2006-09-21 18:22:42,644 WARN [org.jboss.ejb3.mdb.MDB] creating a new temporary
| destination: queue/mdb
| 2006-09-21 18:22:42,648 WARN [org.jboss.system.ServiceController] Problem star
| ting service jboss.j2ee:ear=CLUSTERINGEAR.ear,jar=CLUSTERINGEJB.jar,name=MDBean
| ,service=EJB3
| javax.management.InstanceNotFoundException: jboss.mq:service=DestinationManager
| is not registered.
| at org.jboss.mx.server.registry.BasicMBeanRegistry.get(BasicMBeanRegist
| ry.java:523)
| at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:653)
| at org.jboss.ejb3.mdb.MDB.createDestination(MDB.java:671)
| at org.jboss.ejb3.mdb.MDB.innerCreateQueue(MDB.java:407)
| at org.jboss.ejb3.mdb.MDB.innerCreate(MDB.java:347)
| at org.jboss.ejb3.mdb.MDB.innerStart(MDB.java:225)
| at org.jboss.ejb3.mdb.MDB.start(MDB.java:214)
| at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
| at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl
| .java:39)
| at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcce
| ssorImpl.java:25)
| at java.lang.reflect.Method.invoke(Method.java:585)
| at org.jboss.ejb3.ServiceDelegateWrapper.startService(ServiceDelegateWr
| apper.java:99)
| at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBean
| Support.java:289)
| at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceM
| BeanSupport.java:245)
| ...
|
Ending with an incomplete deployment:
| ...
| 2006-09-21 18:22:48,638 ERROR [org.jboss.deployment.scanner.URLDeploymentScanne
| r] Incomplete Deployment listing:
|
| --- MBeans waiting for other MBeans ---
| ObjectName: jboss.j2ee:ear=CLUSTERINGEAR.ear,jar=CLUSTERINGEJB.jar,name=MDBean,
| service=EJB3
| State: FAILED
| Reason: javax.management.InstanceNotFoundException: jboss.mq:service=Destinat
| ionManager is not registered.
| ...
|
When I now shut down the "first server" the second keeps throwing this error:
| 2006-09-21 18:32:02,791 WARN [org.jboss.mq.Connection] Connection failure, use
| javax.jms.Connection.setExceptionListener() to handle this error and reconnect
| org.jboss.mq.SpyJMSException: Exiting on IOE; - nested throwable: (java.io.EOFE
| xception)
| at org.jboss.mq.SpyJMSException.getAsJMSException(SpyJMSException.java:
| 78)
| at org.jboss.mq.Connection.asynchFailure(Connection.java:420)
| at org.jboss.mq.il.uil2.UILClientILService.asynchFailure(UILClientILSer
| vice.java:174)
| at org.jboss.mq.il.uil2.SocketManager$ReadTask.handleStop(SocketManager
| .java:440)
| at org.jboss.mq.il.uil2.SocketManager$ReadTask.run(SocketManager.java:3
| 72)
| at java.lang.Thread.run(Thread.java:595)
| Caused by: java.io.EOFException
| at java.io.ObjectInputStream$BlockDataInputStream.readByte(ObjectInputS
| tream.java:2670)
| at java.io.ObjectInputStream.readByte(ObjectInputStream.java:864)
| at org.jboss.mq.il.uil2.SocketManager$ReadTask.run(SocketManager.java:3
| 17)
| ... 1 more
|
|
My MDB Client looks like this:
| public class ClientMDB implements Runnable{
| ...
| private void sendMsg(String msg){
| Queue jmsQueue = null;
| QueueConnectionFactory factory = null;
| QueueConnection qCnct = null;
| QueueSession qSess = null;
| QueueSender qSnd = null;
| ExceptionListener qExcLsnr = new MyMDBExceptionListner();
|
| try{
| time = System.currentTimeMillis();
|
| jmsQueue =(Queue) doLookUp("queue/mdb");
| factory = (QueueConnectionFactory) doLookUp("ConnectionFactory");
|
| qCnct = factory.createQueueConnection();
| qCnct.setExceptionListener(qExcLsnr);
| qSess = qCnct.createQueueSession(false, QueueSession.AUTO_ACKNOWLEDGE);
|
| for(int i=0; i < 2; i++){
| TextMessage txtMsg = qSess.createTextMessage("This is "+Thread.currentThread().getName()+" calling ("+i+")");
| qSnd = qSess.createSender(jmsQueue);
| qSnd.send(txtMsg);
| }
| }catch(Exception e){
| System.out.println(e);
| e.printStackTrace();
| }
| }
|
| private Object doLookUp(String JNDIName){
| doLogin(XXX","xxx");
| try{...
| }catch(Exception e){
| return null;
| }
| }
|
| private void doLogin(String user, String pw){
| ?
| }
| public class MyMDBExceptionListner implements ExceptionListener{
| int cnt = 0;
|
| public void onException(JMSException arg0) {
| // TODO Auto-generated method stub
| cnt++;
| if(cnt>1){
| System.out.println(cnt+" Los of connection to the JMS due to: "+ arg0.getStackTrace().toString());
| }
| }
| }
| }
|
|
and the MDB like this:
| @MessageDriven(activationConfig =
| { @ActivationConfigProperty(propertyName="destinationType",
| propertyValue="javax.jms.Queue"),
| @ActivationConfigProperty(propertyName="destination",
| propertyValue="queue/mdb")})
| public class MDBean implements MessageListener{
|
| public void onMessage(Message arg0) {
| // TODO Auto-generated method stub
| try{
| TextMessage txtMsg = (TextMessage)arg0;
| String message = txtMsg.getText();
|
| System.out.println("I received a message: "+message);
| txtMsg.acknowledge();
|
| }catch(Exception e){
| System.out.println(e);
| e.printStackTrace();
| }
| }
| }
|
|
I am thankful for any help !
Sincerely
Marc
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3973317#3973317
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3973317
19 years, 7 months