|
From: Julien <ju...@ni...> - 2004-06-22 19:11:07
|
Hello all,
like i told you i'm interested in implementing a servlet Monitor for Hermes.
I began to write a simple servlet to just send an ebxml message using fixed parameters.
I have several questions:
- is the code I wrote the correct way to use the hermes api (code included below) ? Is there something missing in the building of this minimal ebxml message?
Would the Command object be of any use? How to use it?
- does someone has an idea what the error stack i get is due to (included after the code) ? (java.lang.LinkageError: loader constraints violated when linking javax/activation/DataHandler class)
thx!
Julien.
-----------------------------------------------------------------------------
Code:
-----------------------------------------------------------------------------
package ESIAL.GUI;
import java.io.IOException;
import java.io.PrintWriter;
import java.lang.String;
import java.lang.StringBuffer;
import java.net.URL;
import java.util.Date;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.xml.soap.SOAPException;
import hk.hku.cecid.phoenix.message.handler.Request;
import hk.hku.cecid.phoenix.message.handler.RequestException;
import hk.hku.cecid.phoenix.message.handler.ApplicationContext;
import hk.hku.cecid.phoenix.message.handler.NoMessageListenerImpl;
import hk.hku.cecid.phoenix.message.packaging.EbxmlMessage;
public class HermesMonitor extends HttpServlet {
private Request req;
private EbxmlMessage ebxmlm;
private String fromPartyId;
private String toPartyId;
private String cpaId;
private String conversationId;
private String service;
private String action;
private String messageId;
private String timestamp;
private String transportType;
private String retryInterval;
private int numRetry;
/* a StringBuffer to build the reponse before sending */
private StringBuffer sb;
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException {
fromPartyId = "http://localhost:8080/msh";
toPartyId = "http://localhost:8080/msh";
cpaId = "CPA2002";
conversationId = "Item_No_128";
service = "http://www.cecid.hku.hk/ebxml/service";
action = "Order";
messageId = "Julien";
timestamp = new Date().toString();
transportType = "HTTP";
retryInterval = "30000";
numRetry = 2;
try {
ebxmlm = new EbxmlMessage();
ebxmlm.addMessageHeader(fromPartyId, toPartyId, cpaId,
conversationId, service, action, messageId, timestamp);
} catch (SOAPException x) {
x.printStackTrace();
}
ApplicationContext ac = new ApplicationContext(cpaId,
conversationId, service, action);
NoMessageListenerImpl nmli = new NoMessageListenerImpl();
try {
req = new Request(ac, new URL(toPartyId), nmli, transportType,
numRetry, retryInterval);
} catch(RequestException x) {
x.printStackTrace();
}
try {
req.send(ebxmlm);
} catch(RequestException x) {
x.printStackTrace();
}
/* Builds the response */
sb = new StringBuffer();
sb.append("<html>\n");
sb.append("<head>\n");
sb.append("</head>\n");
sb.append("<body>\n");
sb.append("<h1>Hermes Monitor</h1>\n");
sb.append("</body>\n");
sb.append("</html>\n");
/* Displays the response */
PrintWriter out = response.getWriter();
out.println(sb.toString());
}
}
-----------------------------------------------------------------------------
Stack:
-----------------------------------------------------------------------------
Starting service Tomcat-Apache
Apache Tomcat/4.0.3
Info: using property file in /usr/local/jakarta-tomcat-4.0.3/msh_client.properties.xml
java.lang.LinkageError: loader constraints violated when linking javax/activation/DataHandler class
at com.sun.xml.messaging.saaj.soap.MessageImpl.<init>(MessageImpl.java:124)
at com.sun.xml.messaging.saaj.soap.MessageFactoryImpl.createMessage(MessageFactoryImpl.java:32)
at hk.hku.cecid.phoenix.message.packaging.EbxmlMessage.<clinit>(Unknown Source)
at hk.hku.cecid.phoenix.message.handler.MessageServer.getMessageFromFile(Unknown Source)
at hk.hku.cecid.phoenix.message.handler.MessageServer.getMessageFromFile(Unknown Source)
at hk.hku.cecid.phoenix.message.handler.Command.readObject(Unknown Source)
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:324)
at java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:838)
at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1746)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1646)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1274)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:324)
at hk.hku.cecid.phoenix.message.handler.MessageServiceHandler.doPost(Unknown Source)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:243)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:190)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.valves.CertificatesValve.invoke(CertificatesValve.java:246)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2343)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:170)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:468)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.connector.http.HttpProcessor.process(HttpProcessor.java:1012)
at org.apache.catalina.connector.http.HttpProcessor.run(HttpProcessor.java:1107)
at java.lang.Thread.run(Thread.java:534)
On Sat, 19 Jun 2004 14:37:09 +0200
Ronald van Kuijk <rv...@ab...> wrote:
> Patrick Yee wrote:
>
> >
> >>> - is it possible to build a servlet client for Hermes keeping all
> >>> the features that are managed by a regular java application? In
> >>> other words is there something a Hermes client like "Monitor" can't
> >>> do with servlets? (authentication using the existing authentication
> >>> file system, etc...)
> >>>
> >>
> >>
> >> Not yet, but there is some thinking going on to make these things
> >> possible in the future
> >>
> >>
> >>
> > If Julien means can we write "Monitor" as a servlet, then I guess it
> > is possible. Of course, our assumption is, the information which is
> > currently captured interactively using Java Swing, like keystore
> > location, password, etc, shall be managed by the servlet in other
> > ways. One possible way is by pre-configuration.
>
> Yes, I agree. Some other person on this list (won't mention any names
> Sacha ;-) ) likes to have a xml-rpc implementation. Since I made the
> monitor part rather flexible (see the 'WebAdmin and other contrib'
> thread this would not be to difficult now. Just find the time somewhere.
> One thing I like to do there is move the Command object internal into
> Hermes and not expose it to the outside world. Each monitor is then
> responsible for mapping a request into a Command object. e.g.
> - an xml structure can have all command elements in tags
> - a jms monitor gets the command elements from jms headers
> - a servlet monitor gets it from request parameters
>
> This is exactely what I was proposing on the other thread by splitting
> the use of the one servlet into separate things. Each implementation of
> a monitor is then also responsible for their own authentication (which I
> hope will one day be based on the principal from the servlet/j2ee engine
>
> Ronald
>
>
|