Hi Everyone
HELP! Im currently working on a Masters Project for my Uni and in big trouble. My project involves creating a collaborative system for a concept mapping software. i have already built simple Java IM client using the Smack Api. i want a way to transfer some custom data. I followed the tutorial on sending custom data (using packetextension) here (Use Case 2: The Custom Message):
http://java.sys-con.com/node/232087?page=0,1
http://gemsres.com/story/jun06/232087/source.html
The tutorial is the only one i found but it wasnt too clear (for me anyway). Im programming in netbeans 6.5.1, using smack api ver 3.1.0 and openfire 3.6.4.
i have made some modifications in the code listed to suit my needs. which i will list here.
As mentioned in the tutorial I created a class which implements the PacketExtension and the PacketExtensionProvider (shown under listing 3 of the 2nd link). Once the file was compiled i placed the class files into the **org.jivesoftware.smackx.provider folder **in the smackx.jar file.
The only changes i made to this was that i changed the namespace (ConceptionEx) and the elementName (ConExMsgExtension).
public class ConExMsgExtension implements PacketExtension
{
private String xmlFile = “”;
public static String namespace = “ConceptionEx”;
public static String elementname = “ConExMsgExtension”;
public ConExMsgExtension() {
super();
// TODO Auto-generated constructor stub
}
public void setXmlFile(String file)
{
this.xmlFile = file;
}
public String getXmlFile()
{
return xmlFile;
}
public String getNamespace()
{
return “ConceptionEx”;
}
public String getElementName()
{
return “ConExMsgExtension”;
}
public String toXML()
{
StringBuffer buf = new StringBuffer();
buf.append("<").append(getElementName()).append(" xmlns="").append(getNamespace()).
append("">");
if (getXmlFile() != null)
{
//buf.append("<conf Url="").append(getXmlFile()).append(""/>");
buf.append("<conf Url="").append(getXmlFile()).append(""/>");
}
buf.append("</").append(getElementName()).append(">");
return buf.toString();
}
public static class Provider implements PacketExtensionProvider
{
public Provider()
{ }
public PacketExtension parseExtension(XmlPullParser parser) throws Exception
{
ConExMsgExtension ConExtn = new ConExMsgExtension();
boolean done = false;
while (!done)
{
int eventType = parser.next();
if (eventType == XmlPullParser.START_TAG)
{
if (parser.getName().equals("conf"))
{
ConExtn.setXmlFile(parser.getAttributeValue("", "Url"));
done = true;
}
}
}
return ConExtn;
}
}
}
i also added the following code to be added in the smack.providers file in the smackx.jar file:
ConExMsgExtension ConceptionEx **org.jivesoftware.smackx.provider.ConExMsgExtension$Provider**NOW heres the problem … when im running my client and login i get the following error message. and i dont know for the life of me wht i need to do to correct this.
org.xmlpull.v1.XmlPullParserException: parser must be on START_TAG to read next text (position: TEXT seen …ConExMsgExtension</… @264:52)
at org.xmlpull.mxp1.MXParser.nextText(MXParser.java:1055)
at org.jivesoftware.smack.provider.ProviderManager.initialize(ProviderManager.java :209)
at org.jivesoftware.smack.provider.ProviderManager.(ProviderManager.java:436 )
at org.jivesoftware.smack.provider.ProviderManager.getInstance(ProviderManager.jav a:134)
at org.jivesoftware.smackx.debugger.EnhancedDebuggerWindow.createDebug(EnhancedDeb uggerWindow.java:227)
at org.jivesoftware.smackx.debugger.EnhancedDebuggerWindow.showNewDebugger(Enhance dDebuggerWindow.java:125)
at org.jivesoftware.smackx.debugger.EnhancedDebuggerWindow.addDebugger(EnhancedDeb uggerWindow.java:115)
at org.jivesoftware.smackx.debugger.EnhancedDebugger.(EnhancedDebugger.java: 148)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessor Impl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructor AccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at org.jivesoftware.smack.XMPPConnection.initReaderAndWriter(XMPPConnection.java:1 097)
at org.jivesoftware.smack.XMPPConnection.initConnection(XMPPConnection.java:920)
at org.jivesoftware.smack.XMPPConnection.connectUsingConfiguration(XMPPConnection. java:904)
at org.jivesoftware.smack.XMPPConnection.connect(XMPPConnection.java:1415)
at Project.LoginScreen.login(LoginScreen.java:246)
at Project.LoginScreen.connectBtnActionPerformed(LoginScreen.java:207)
at Project.LoginScreen.access$100(LoginScreen.java:22)
at Project.LoginScreen$2.actionPerformed(LoginScreen.java:146)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1995)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2318)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.ja va:236)
at java.awt.Component.processMouseEvent(Component.java:6216)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3265)
at java.awt.Component.processEvent(Component.java:5981)
at java.awt.Container.processEvent(Container.java:2041)
at java.awt.Component.dispatchEventImpl(Component.java:4583)
at java.awt.Container.dispatchEventImpl(Container.java:2099)
at java.awt.Component.dispatchEvent(Component.java:4413)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4556)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4220)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4150)
at java.awt.Container.dispatchEventImpl(Container.java:2085)
at java.awt.Window.dispatchEventImpl(Window.java:2475)
at java.awt.Component.dispatchEvent(Component.java:4413)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:26 9)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:17 4)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
If anyone can help me i would be **indebted!!! **i have been stuck on it for 2 days and going insane. If there anything else i need to mention plz let me know. My deadline is due in 2 weeks and i have to write a nearly 15000 word dissertation for my project… IF only i could get the coding done!
PLZ HELP!
Thanks in advance
Sreejit