Tigase服务端集成问题总结

eclipse jdk8中导入JPEGImageEncoder报错:
java.lang.ClassNotFoundException: com.sun.image.codec.jpeg.JPEGCodec

//import com.sun.image.codec.jpeg.JPEGCodec;
//import com.sun.image.codec.jpeg.JPEGImageEncoder;
private static void writeFile(Image image, int width, int height, String thumbnailFile) throws Exception {
		if (image == null)
			return;
		BufferedImage tag = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
		tag.getGraphics().drawImage(image, 0, 0, width, height, null);
		FileOutputStream out = null;
		try {
			out = new FileOutputStream(thumbnailFile);
			ImageIO.write(tag, JPEG, new File(thumbnailFile));
//			JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out);
//			encoder.encode(tag);
		} catch (Exception e) {
			e.printStackTrace();
			throw new Exception(e);
		} finally {
			if (out != null) {
				out.close();
			}
		}

	}

JPEGImageEncoder在jdk1.7之后已经废弃,此类在eclipse自带的jdk中可以找到,下面说解决方案。
jdk1.7后,使用ImageIo代替此类。

public static void saveImage(BufferedImage dstImage, String dstName) throws IOException {  
    String formatName = dstName.substring(dstName.lastIndexOf(".") + 1);  
    //FileOutputStream out = new FileOutputStream(dstName);  
    //JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out);  
    //encoder.encode(dstImage);  
    ImageIO.write(dstImage, /*"GIF"*/ formatName /* format desired */ , new File(dstName) /* target */ );  
}  

参考
程序包com.sun.image.codec.jpeg不存在
java.lang.ClassNotFoundException: com.sun.image.codec.jpeg.JPEGCodec
https://stackoverflow.com/questions/8015291/how-to-replace-com-sun-image-codec-jpeg-jpegimageencoder-in-this-code

MongoDB##

Windows系统 MongoDB 各个64位版本下载地址
http://dl.mongodb.org/dl/win32/x86_64

AbstractXMPPConnection: Connection closed with error
   org.jivesoftware.smack.SmackException: Parser got END_DOCUMENT event. This could happen e.g. if the server closed the connection without sending a closing stream element
   at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.parsePackets(XMPPTCPConnection.java:1166)
   at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.access$300(XMPPTCPConnection.java:948)
   at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader$1.run(XMPPTCPConnection.java:963)
   at java.lang.Thread.run(Thread.java:818)

smack4.1.6连接tigase7.1.0时报错,下面这个问题是缺少jar包引起的(确认账号密码正确的前提下),导入smack-sasl-provided-4.1.6.jar 包即可 jar包下载地址

connectionClosedOnError:连接异常 arg0=Parser got END_DOCUMENT event. This could happen e.g. if the server closed the connection without sending a closing stream element

05-15 09:29:21.994 28250-29746/com.im.text D/XMPP_SMACK: SENT: <response xmlns='urn:ietf:params:xml:ns:xmpp-sasl'>Yz1iaXdzLHI9KnhkIiM4RW9JQ3g8VlslLXsmZEVINXc1S3EjU1JqQnw2YjIzOTVlMC05YzRjLTQyMTUtYjQ1OC1jYjViYmE5N2Y4ODcscD1BK3IxQ2xNczQ3dWhkTXphOHRIOTFxVWdVNVE9</response>
05-15 09:29:21.999 28250-29747/com.im.text D/XMPP_SMACK: RECV: <failure xmlns="urn:ietf:params:xml:ns:xmpp-sasl"><not-authorized/></failure>
05-15 09:29:22.000 28250-29728/com.im.text W/System.err: org.jivesoftware.smack.sasl.SASLErrorException: SASLError using SCRAM-SHA-1: not-authorized
05-15 09:29:22.000 28250-29728/com.im.text W/System.err:     at org.jivesoftware.smack.SASLAuthentication.authenticationFailed(SASLAuthentication.java:365)
05-15 09:29:22.000 28250-29728/com.im.text W/System.err:     at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.parsePackets(XMPPTCPConnection.java:1044)
05-15 09:29:22.000 28250-29728/com.im.text W/System.err:     at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.access$300(XMPPTCPConnection.java:948)
05-15 09:29:22.000 28250-29728/com.im.text W/System.err:     at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader$1.run(XMPPTCPConnection.java:963)
05-15 09:29:22.000 28250-29728/com.im.text W/System.err:     at java.lang.Thread.run(Thread.java:818)
05-15 09:29:22.001 28250-29728/com.im.text E/XmppService: SASLError using SCRAM-SHA-1: not-authorized

https://stackoverflow.com/questions/29755230/smack-4-1-sasl-authentication-error/29769292#29769292

https://stackoverflow.com/questions/30125363/samck-4-1-error-while-connecting-to-openfire-server-org-jivesoftware-smack-sasl
https://blog.csdn.net/coding_me/article/details/39524137
https://blog.csdn.net/love254443233/article/details/7906918
https://blog.csdn.net/u012519664/article/details/44516757
https://blog.csdn.net/lynnchurch/article/details/38641551
https://blog.csdn.net/lesaqiu/article/details/50208563
https://bbs.csdn.net/topics/391043128
https://discourse.igniterealtime.org/t/asmack-4-1-sasl-authentication-failed-no-known-authentication-mechanisims/72755

tigase服务端修改消息路由的域名,
即本来是发送给 [email protected]的消息,在服务端将其修改为发送给[email protected]
修改tigase.xmpp.XMPPDomBuilderHandler.java

private Element newElement( String name, String cdata, StringBuilder[] attnames,
															StringBuilder[] attvals ) {
		++elements_number_limit_count;
		
		System.out.println("newElement: name="+name+" cdata="+cdata);
		if (attnames != null) {
			for (int i = 0; i < attnames.length; ++i) {
				// Exit the loop as soon as we reach end of attributes set
				if (attnames[i] == null) {
					System.out.println("newElement attnames["+i+"] is null");
					continue;
				}else {
					System.out.println("newElement: attnames["+i+"]="+attnames[i]);
					if(name != null && name.equals(Message.ELEM_NAME)) {
						System.out.println("newElement: attnames[i]="+attnames[i]);
						System.out.println("newElement: attnames[i].toString()="+attnames[i].toString());
						if(attnames[i].toString().equals("to") && attvals[i] != null) {
							String msgTo = attvals[i].toString();
							System.out.println("newElement before msgTo:"+msgTo);
							String account = msgTo.substring(0, msgTo.lastIndexOf("@"));
							attvals[i] = new StringBuilder(account+"@192.168.10.130");
							System.out.println("newElement after attvals[i]:"+attvals[i]);

						}
					}
				}
			}
		}
		if (attvals != null) {
			for (int i = 0; i < attvals.length; ++i) {

				// Exit the loop as soon as we reach end of attributes set
				if (attvals[i] == null) {
					System.out.println("newElement attvals["+i+"] is null");
					continue;
				}else {
					System.out.println("newElement: attvals["+i+"]="+attvals[i]);
				}
			}
		}
		Element el = customFactory.elementInstance( name, cdata, attnames, attvals );
		if ( elements_number_limit_count > elements_number_limit ){
			throw new XMPPParserException( "Too many elements for staza, possible DoS attack."															 + "Current service " + service.getClass() + " limit of elements: " + elements_number_limit );
		}
		return el;
	}

init.properties读取过程
系统启动过程中,tigase.conf.ConfiguratorAbstract.java parseArgs方法会读取init.properties配置文件,然后将配置文件中的配置以map格式存储到系统内容中
获取时以System.getProperty(key)方式来获取 配置中的内容

猜你喜欢

转载自blog.csdn.net/w690333243/article/details/80077333