[JBossWS] - Re: How Do I See the XML?
by flindet
rmartony, here's what I ended up doing to log my full SOAP message. It's based heavily on the example handlers included with JBossWS.
| public class ProtocolHandler extends GenericSOAPHandler
| {
| /**
| * The {@link Logger} used for writing logging messages.
| */
| private static Logger log = Logger.getLogger(ProtocolHandler.class);
|
| /* (non-Javadoc)
| * @see org.jboss.ws.core.jaxws.handler.GenericSOAPHandler#handleOutbound(javax.xml.ws.handler.MessageContext)
| */
| @Override
| public boolean handleOutbound(final MessageContext msgContext)
| {
| if (log.isInfoEnabled())
| {
| return logMessage(msgContext);
| }
| return true;
| }
|
| /* (non-Javadoc)
| * @see org.jboss.ws.core.jaxws.handler.GenericSOAPHandler#handleInbound(javax.xml.ws.handler.MessageContext)
| */
| @Override
| public boolean handleInbound(final MessageContext msgContext)
| {
| if (log.isInfoEnabled())
| {
| return logMessage(msgContext);
| }
| return true;
| }
|
| /**
| * Logs the full SOAP message.
| *
| * @param messageContext The message context containing the SOAP message to be handled.
| * @return True if handler processing should continue, false otherwise.
| * @throws WebServiceException If the SOAP message is malformed.
| */
| private boolean logMessage(final MessageContext messageContext)
| {
| try
| {
| SOAPMessage soapMessage = ((SOAPMessageContext) messageContext).getMessage();
| if (soapMessage.getSOAPBody().getChildElements().hasNext())
| {
| SOAPElement soapElement = (SOAPElement) soapMessage.getSOAPBody().getChildElements().next();
| if (soapElement.getChildElements().hasNext())
| {
| soapElement = (SOAPElement) soapElement.getChildElements().next();
|
| ByteArrayOutputStream xmlStream = new ByteArrayOutputStream();
| soapMessage.writeTo(xmlStream);
| log.info(new String(xmlStream.toByteArray()));
| }
| }
|
| return true;
| }
| catch (SOAPException ex)
| {
| throw new WebServiceException(ex);
| }
| catch (IOException ex)
| {
| throw new WebServiceException(ex);
| }
| }
| }
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4035389#4035389
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4035389
19 years
[JBoss Seam] - Re: How to return to a previous page without conversations
by christian.bauer@jboss.com
- User viewing a contact page
This view.xhtml page needs a page action, e.g. #{myViewer.rememberThis}. In the rememberThis() method you can get the "redirect" component from Seam and call captureCurrentRequest()/captureCurrentView().
- User clicks "Add Note"
This needs to be a call to the "view.xhtml" page, e.g. <s:link action="addNote"/>. In your pages.xml you can then have a navigation rule like this:
| <page view-id="/view.xhtml" action="#{myViewer.rememberThis}">
|
| <navigation>
| <rule if-outcome="addNote">
| <begin-conversation flush-mode="MANUAL"/>
| <redirect view-id="/noteEditor.xhtml"/>
| </rule>
|
The rememberThis() runs again and remembers the "entry point" for your long running conversation. Which is what <begin-conversation> does, it promotes the temporary conversation to a long-running conversation. The "redirect" component is carried on in that same conversation.
- New page and user enters a note
This is a conversational flow, so you stay inside the long running conversation on the /noteEditor.xhtml screen (during validation errors, etc.)
- User clicks save, note saved and contact page reshown
You can get out of your long running conversation by first ending it, and then redirecting to the last remembered location in the "redirect" component. This code could be in your NoteEditor.java bean as the exit code after save (or mapped to the Cancel button in the UI):
|
| public void exitConversation() {
| Conversation currentConversation = Conversation.instance();
| Redirect redirect = (Redirect)Component.getInstance("redirect");
| currentConversation.end();
| // Have a chance here to modify the redirect.setParameters() for the following GET, e.g.
| // strip off the action=(addNote) parameter which would lead me into a circle
| redirect.returnToCapturedView();
| }
|
|
Yes, this is not ideal and we are currently working on a better concept that involves "entry points". Not sure yet how that will exactly look like in code and pages.xml. You also have the case of nested conversations, where you want to exit to the last view shown in the parent conversation. Or a root conversation that was started from another root conversation.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4035386#4035386
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4035386
19 years
[EJB 3.0] - Re: No ManagedConnections available Error
by majohnst
Doing some simple stress testing, I really think my database connection isn't being closed. I am using EJB3. I'm not sure what version, an early RC version probably and jboss 4.0.3.
My servlet code is:
| UserTransaction ut = null;
| try {
| // begin transaction
| InitialContext ctx = new InitialContext();
|
| ut = (UserTransaction)ctx.lookup("java:comp/UserTransaction");
| ut.begin();
|
| ... do webpage code
|
| ut.commit();
|
| catch (Exception e) {
| log.error("error in servlet", e);
| try {
| ut.rollback();
| }
| catch (Exception erb) {
| log.error("could not rollback transaction", erb);
| }
|
| }
| finally {
|
| ut = null;
| }
|
Postrgres is setup to accept 20 connections. My datasource is setup for 10 connections max. I am using JMeter to do the stress testing. I setup JMeter to run 10 threads concurrently and load a series of webpages. Soon after I start the test, I get the error:
| 10:59:45,341 WARN [org.jboss.resource.connectionmanager.JBossManagedConnectionPool:232] Throwable while attempting to get a new connection: null
| org.jboss.resource.JBossResourceException: Could not create connection; - nested throwable: (org.postgresql.util.PSQLException: FATAL: sorry, too many clients already)
| at org.jboss.resource.adapter.jdbc.local.LocalManagedConnectionFactory.createManagedConnection(LocalManagedConnectionFactory.java:164)
| at org.jboss.resource.connectionmanager.InternalManagedConnectionPool.createConnectionEventListener(InternalManagedConnectionPool.java:519)
| at org.jboss.resource.connectionmanager.InternalManagedConnectionPool.getConnection(InternalManagedConnectionPool.java:208)
| at org.jboss.resource.connectionmanager.JBossManagedConnectionPool$BasePool.getConnection(JBossManagedConnectionPool.java:566)
| at org.jboss.resource.connectionmanager.BaseConnectionManager2.getManagedConnection(BaseConnectionManager2.java:410)
| at org.jboss.resource.connectionmanager.TxConnectionManager.getManagedConnection(TxConnectionManager.java:342)
| at org.jboss.resource.connectionmanager.BaseConnectionManager2.allocateConnection(BaseConnectionManager2.java:462)
|
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4035379#4035379
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4035379
19 years