CWWSS7200E: Unable to create AxisService from ServiceEndpointAddress
Couldn't find anything on the web about any of the above - I hope this helps someone else with the same problem.
CWWSS7200E: Unable to create AxisService from ServiceEndpointAddress
Exception in thread "main" java.lang.NoClassDefFoundError: org/eclipse/core/runtime/IProgressMonitor
at demo.ui.test.EntryPoint.main(EntryPoint.java:18)
Caused by: java.lang.ClassNotFoundException: org.eclipse.core.runtime.IProgressMonitor
//get current user
UserService userService = UserServiceFactory.getUserService();
User user = userService.getCurrentUser();
//prepare query
PersistenceManager pm = PMF.get().getPersistenceManager();
String select_query = "select from " + Order.class.getName();
Query query = pm.newQuery(select_query);
query.setFilter("customer == paramCustomer");
query.declareParameters("com.google.appengine.api.users.User paramCustomer");
//execute query
List<OrderDTO> result= OrderUtils.getOrderDTOList((List<Order>) query.execute(user));
//feck-off --> I'll never get an MVP but I can swear on my blog!
pm.close();
After a long time I'm again here for another post!
I will talk about event handling, focusing at first on .NET way to supply it, and then spending 2 words about the Java style.
What I want to talk about is delegates and how are they used...I know old good Giovacchia has already spoken about them in a previous post (here) but I wanna talk about them again.
Why?
I'm leaving for a while the Java world and walking through the .NET Framework (I have to take some Microsoft Certifications, 2 or maybe 3 exams in just 1 month and a half...sounds crazy but it's my task in the short term): this means I have to study, as for now, 2 book of about 1000 pages each one.
I'm not taking part in the war between Open Source Multi Platforms Java Conding and Mama Microsoft Windows-Platform Framework yet, but in this path toward the MS certifications I will try to catch what's good and what's not in both frameworks.
At a first sight (I'm about at the half of the first book) 2 years of experience in Java programming has helped me a lot, but I stopped a while learning about delegates.
I don't want to explain what actually they are (Giovacchia in his post said it perfectly), let's just say delegates are a kind of function pointers, and you have to subscribe a delegate to a particular event in order to make it running when that event is raised.
Because my memory is so short term (could it be Google's fault?), during the reading I made a simple schema to remember which key words to use when declaring a delegate and rasing your own event.
namespace HereIsMyDelegateNamespace{
. . .
public delegate void MyEventHandler(object o, System.EventArgs ev);
. . .
public class MyClass{
. . .
public event MyEventHandler MyEvent;
. . .
/* this method raises an event */
publlic ReturnType RaisingMethod()
{
System.EventArgs ev = new System.EventArgs();
. . .
MyEvent(this,ev);
. . .
}
}
}
namespace ConsumerNamespace{
public class Consumer{
public static void Main(string[] args)
{
. . .
MyClass m = new MyClass();
m.MyEvent += MyEventHandler(m_MyEvent);
. . .
/* from now on we can call a method
* or make an action which causes MyClass to
* raise the MyEvent event */
m.SomeMethodThatRaisesTheEvent();
. . .
}
public static void m_MyEvent(object o, System.EventArgs ev)
{
. . .
/* handles the event */
}
}
}
You have to remember few things:
And what about Java?
Learning Java I actually never had the need to write down some code to remember how Event Handling works.
Why? There are no delegates, in the sense you need to specify an entire class as the delegate for that event. What does it happen when you need to subscribe to an event?
In that situation Java is more OO then .NET, indeed you only use your Handler Class (such as MouseListener class, but for the common events, e.g. such as Mouse and Keyboard, you have at your disposal tons of ready-to-use classes) to manage the event. In this scenario you call directly by the object that throws the event, an addXXXListener() or removeXXXListener(), and inside your class, in which you surely have an array of potential listeners, when you want to raise the event, you have to iterate manually by calling all the needed methods of the listeners subscribed.
IMHO Java is straightforward to the OOP, but you need more code, and .NET allow you by using delegate and event keywords not to think to the propagation of the event. Moreover, in .NET you won't need to specify an entire class to handle the event, bringing to a more concise code style.
I'm not as experienced in .NET as I'm in Java, so maybe in few weeks I will post the exact opposite kind of opinion, but as for now I'm feeling better using C#, as it seems it has taken the good in Java and brought it to a more powerfull level (I'm refering to the whole framework ofcourse and not to the language itself).
public class MyGUIClass{
private Display _display = null;
public static void main(String[] args)
{
/* main thread */
final Display display = new Display();
/* this allows a future catch of this class */
_display = display;
final Shell shell = new Shell(display);
final Button button = new Button(shell,SWT.PUSH);
button.setText("Run a thread");
button.addSelectionListener(new SelectionListener()
{
public void widgetSelected(SelectionEvent e) {
/* this class starts a new thread */
MyComputationClass mcc = new MyComputationClass ();
mcc.createNewThread(this);
}
public void widgetDefaultSelected(SelectionEvent e) {}
});
}
/* this main class exposes a public method that returns the
current Display class
*/
public Display getDisplay()
{
return _display;
}
public class MyComputationClass{
public void createNewThread(MyGUIClass aGUI)
/* a new thread is running */
/* make intensive computation . . .*/
/* . . . */
if(!aGUI.getDisplay().isDisposed()){
aGUI.getDisplay().asyncExec (new Runnable ()
{
public void run () {
aGUI.doSomeGUIModifications();
}
});
/* . . . */
/* thread is ended up */
}
}
<HTML>
<BODY>
<%
String message = "<p>Hello, this is my first JSP page!!</p>"
String endPage = "<p>Bye bye!</p>"
System.out.println(message);
%>
<p>Above you are reading a wellcome message.</p>
<%=endPage%>
</BODY>
</HTML>
<%@ page import="java.util.Date, java.util.ArrayList" %>
<%@ include file="hello.jsp" %>
<%
String action = request.getParameter("submitted");
if( action.equals("true") )
{
/* saves a variable as a session variabile:
* from now on it is always available */
String name = request.getParameter( "username" );
session.setAttribute( "theName", name );
}
if(session.getAttribute("theName") == null)
{
%>
<FORM METHOD="POST" ACTION="thisPage.jsp">
What's your name? <INPUT TYPE="TEXT" NAME="username" SIZE="20">
<INPUT TYPE="HIDDEN" NAME="submitted" VALUE="true">
<INPUT TYPE="SUBMIT">
</FORM>
<%
}
else
{
out.println("<p>Hello "+ session.getAttribute("theName") +" !!!</p>");
}
%>

import java.awt.GridLayout;
import javax.swing.JFrame;
import javax.swing.JLabel;
public class SwingHelloWorld extends JFrame {
public static void main(String args[]) {
new SwingHelloWorld();
}
SwingHelloWorld() {
JLabel jlbHelloWorld = new JLabel("Just a label");
add(jlbHelloWorld);
setTitle("Example Frame");
setLayout(new GridLayout());
this.setSize(300, 100);
setVisible(true);
}
}
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
public class SWTHelloWorld {
public static void main(String[] args) {
Display display = new Display();
final Shell shell = new Shell(display);
shell.setText("Example Frame");
shell.setSize(300,100);
shell.setLayout(new GridLayout());
/* controls code goes here */
Label label1 = new Label(shell, SWT.BORDER);
label1.setText("Just a label");
label1.setSize(100,20);
shell.open();
while(!shell.isDisposed())
{
if(!display.readAndDispatch())
{
display.sleep();
}
}
display.dispose();
}
}
| Swing | SWT |
|---|---|
![]() | ![]() |
String dir = System.getProperty("user.dir");java.io.File currentDir = new java.io.File("");
String dir = currentDir.getAbsolutePath();InputStream in = MyClass.class.getResourceAsStream("MyImage.gif");Sometimes anyway you have only a string that contains your XML data (maybe got from an HTTP request or a webservice), and you just want to deserialize it into a Document object:private Document parseXmlFromFile(String filePath){
try {//get the factory
DocumentBuilderFactory dbf =
DocumentBuilderFactory.newInstance();//Using factory get an instance of document builder
DocumentBuilder db = dbf.newDocumentBuilder();
//parse using builder to get DOM representation
//of the XML file
return db.parse(filePath);
}catch(IOException ioe) {
ioe.printStackTrace();
}
}
private Document deserialize(String xml)
try{
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
dbf.setIgnoringComments(true);
dbf.setIgnoringElementContentWhitespace(true); DocumentBuilder db = dbf.newDocumentBuilder();
StringReader reader = new StringReader(xml);
InputSource source = new InputSource(reader);
return db.parse(source);
}
catch(Exception e){
e.printStackTrace();
}
}
private String serialize(Document document){
try {
OutputFormat format = new OutputFormat(document);
StringWriter stringOut = new StringWriter();
XMLSerializer serial = new XMLSerializer(stringOut, format);
serial.asDOMSerializer();
serial.serialize(document.getDocumentElement());
return stringOut.toString();
} catch (Exception e) {
e.printStackTrace();
}
}
public String transform(Document xml, String urlSchema){
try{
TransformerFactory tFactory = TransformerFactory.newInstance();
Transformer transformer =
tFactory.newTransformer(new StreamSource(urlSchema));
StringWriter writer = new StringWriter();
transformer.transform(new DOMSource(xml),
new StreamResult(writer));
return writer.toString();
}
catch(Exception e){
e.printStackTrace();
}
}
public boolean validate(String xml, String schemaURL) {
try {
String schemaLang = "http://www.w3.org/2001/XMLSchema";
SchemaFactory factory = SchemaFactory.newInstance(schemaLang);
Schema schema = factory.newSchema(new StreamSource(schemaURL));
Validator validator = schema.newValidator();
StringReader reader = new StringReader(xml);
validator.validate(new StreamSource(reader));
return true;
} catch (Exception e) {
e.printStackTrace();
return false;
}
}