lizongbo at 618119.com 工作,生活,Android,前端,Linode,Ubuntu,nginx,java,apache,tomcat,Resin,mina,Hessian,XMPP,RPC

2014年09月15日

在Linode VPS上安装配置Apache James 3.0

Filed under: Java,Linux — 标签:, , — admin @ 14:50

在Linode VPS上安装配置Apache James 3.0,服务器是Linode的VPS,操作系统是Ubuntu 14.04 64位
1.先下载

http://mirrors.ibiblio.org/apache//james/apache-james/3.0beta4/apache-james-3.0-beta4-app.tar.gz

来自:http://james.apache.org/download.cgi#Apache_James_Server

root@618119.com:/usr/local/app# wget http://mirrors.ibiblio.org/apache//james/apache-james/3.0beta4/apache-james-3.0-beta4-app.tar.gz

2.解压:

root@618119.com:/usr/local/app# tar -zxvf ./apache-james-3.0-beta4-app.tar.gz

3.修改配置文件:
进入/usr/local/app/apache-james-3.0-beta4/conf 目录。
先把配置文件模板复制一份成配置文件

root@618119.com:/usr/local/app/apache-james-3.0-beta4/conf# cp ./dnsservice-template.conf ./dnsservice.conf
root@618119.com:/usr/local/app/apache-james-3.0-beta4/conf# cp ./domainlist-template.conf ./domainlist.conf
root@618119.com:/usr/local/app/apache-james-3.0-beta4/conf# cp ./smtpserver-template.conf ./smtpserver.conf

然后分别编辑这三个文件。
dns server 增加
<server>8.8.8.8</server>
<server>114.114.114.114</server>

domainlist.conf修改为:
<!– XML based implementation for DomainList –>
<domainlist class=”org.apache.james.domainlist.xml.XMLDomainList”]] >
<domainnames>
<domainname>mail.lizongbo.com</domainname>
<domainname>lizongbo.com</domainname>
</domainnames>
<autodetect>true</autodetect>
<autodetectIP>true</autodetectIP>
<defaultDomain>mail.lizongbo.com</defaultDomain>
</domainlist>

(实际发现这个没效果,还是通过命令加域名比较靠谱)
smtpserver.conf
增加如下配置:
<authRequired>announce</authRequired>
<verifyIdentity>true</verifyIdentity>

4.由于服务器用的jdk版本较高,会触发一个bug。

因此需要下载 http://jaxb.java.net/2.1.13/JAXB2_20100510.jar 提取jaxb-impl.jar 放到 james 的lib目录下面:
quickli-nb:lib lizongbo$ scp ./jaxb-impl.jar root@lizongbo.com:/usr/local/app/apache-james-3.0-beta4/lib

参考:
http://james.apache.org/server/3/install.html

5.运行测试

启动还是出错
于是下载最新的SNAPSHOT版本:

http://repository.apache.org/content/repositories/snapshots/org/apache/james/james-server-app/3.0.0-beta5-SNAPSHOT/james-server-app-3.0.0-beta5-20140913.003752-643-app.tar.gz

参考:http://stackoverflow.com/questions/16154201/start-apache-james-with-jdk-1-7

root@618119.com:/usr/local/app# wget http://repository.apache.org/content/repositories/snapshots/org/apache/james/james-server-app/3.0.0-beta5-SNAPSHOT/james-server-app-3.0.0-beta5-20140913.003752-643-app.tar.gz

root@618119.com:/usr/local/app# tar -zxvf ./james-server-app-3.0.0-beta5-20140913.003752-643-app.tar.gz

把改好的配置同步过去

root@618119.com:/usr/local/app# cp /usr/local/app/apache-james-3.0-beta4/conf/dnsservice.conf  /usr/local/app/james-server-app-3.0.0-beta5-SNAPSHOT/conf
root@618119.com:/usr/local/app# cp /usr/local/app/apache-james-3.0-beta4/conf/domainlist.conf /usr/local/app/james-server-app-3.0.0-beta5-SNAPSHOT/conf
root@618119.com:/usr/local/app# cp /usr/local/app/apache-james-3.0-beta4/conf/smtpserver.conf /usr/local/app/james-server-app-3.0.0-beta5-SNAPSHOT/conf

此时不需要更新jaxb也能正常启动了。

root@618119.com:/usr/local/app/james-server-app-3.0.0-beta5-SNAPSHOT/bin# ./james start
Starting Apache James :: Server :: App…
./james: 1: eval: /usr/local/app/james-server-app-3.0.0-beta5-SNAPSHOT/bin/./wrapper-linux-x86-32: not found
root@618119.com:/usr/local/app/james-server-app-3.0.0-beta5-SNAPSHOT/bin# sudo apt-get install libc6 libc6-dev

6.通过命令来加东西

root@618119.com:/usr/local/app/james-server-app-3.0.0-beta5-SNAPSHOT/bin# ./james-cli.sh  -h 127.0.0.1 -p 9999 adddomain email.lizongbo.com
adddomain command executed sucessfully in 262 ms.

root@618119.com:/usr/local/app/james-server-app-3.0.0-beta5-SNAPSHOT/bin# ./james-cli.sh  -h 127.0.0.1 -p 9999 listdomains
email.lizongbo.com
localhost.
96.126.96.170
127.0.0.1

listdomains command executed sucessfully in 3571 ms.

root@618119.com:/usr/local/app/james-server-app-3.0.0-beta5-SNAPSHOT/bin# ./james-cli.sh  -h 127.0.0.1 -p 9999 adddomain mail.lizongbo.com
adddomain command executed sucessfully in 253 ms.

root@618119.com:/usr/local/app/james-server-app-3.0.0-beta5-SNAPSHOT/bin# ./james-cli.sh  -h 127.0.0.1 -p 9999 listdomains
email.lizongbo.com
mail.lizongbo.com
localhost.
96.126.96.170
127.0.0.1

listdomains command executed sucessfully in 165 ms.

7.先添加域名,再添加测试账号

root@618119.com:/usr/local/app/james-server-app-3.0.0-beta5-SNAPSHOT/bin# ./james-cli.sh  -h 127.0.0.1 -p 9999 adduser postmaster 618119
Error while execute command:
Given Username needs to contain a @domainpart
root@618119.com:/usr/local/app/james-server-app-3.0.0-beta5-SNAPSHOT/bin# ./james-cli.sh  -h 127.0.0.1 -p 9999 adduser postmaster@mail.lizongbo.com 618119
adduser command executed sucessfully in 171 ms.

root@618119.com:/usr/local/app/james-server-app-3.0.0-beta5-SNAPSHOT/bin# ./james-cli.sh  -h 127.0.0.1 -p 9999 adduser admin@mail.lizongbo.com lizongbo
adduser command executed sucessfully in 164 ms.

root@618119.com:/usr/local/app/james-server-app-3.0.0-beta5-SNAPSHOT/bin# ./james-cli.sh  -h 127.0.0.1 -p 9999 listusers
admin@mail.lizongbo.com
postmaster@mail.lizongbo.com

8.配置wrapper.conf,替换 wrapper-linux-x86-32。

root@618119.com:/usr/local/app/james-server-app-3.0.0-beta5-SNAPSHOT/bin# vi ../conf/wrapper.conf
(指定了java 启动命令来源:)
wrapper.java.command=/usr/local/app/jdk/bin/java

root@618119.com:/usr/local/app/james-server-app-3.0.0-beta5-SNAPSHOT/bin# cp ./wrapper-linux-x86-64  ./wrapper-linux-x86-32
root@618119.com:/usr/local/app/james-server-app-3.0.0-beta5-SNAPSHOT/bin# ./wrapper-linux-x86-32

不替换的话,启动会报错,因为服务器是64位的:

root@618119.com:/usr/local/app/james-server-app-3.0.0-beta5-SNAPSHOT/bin# ./james start
Starting Apache James :: Server :: App…
./james: 1: eval: /usr/local/app/james-server-app-3.0.0-beta5-SNAPSHOT/bin/./wrapper-linux-x86-32: not found

9.然后再安装成系统服务:

root@618119.com:/usr/local/app/james-server-app-3.0.0-beta5-SNAPSHOT# ln -s /usr/local/app/james-server-app-3.0.0-beta5-SNAPSHOT/bin/james /etc/init.d/james
root@618119.com:/usr/local/app/james-server-app-3.0.0-beta5-SNAPSHOT# ls /etc/init.d/james  -alh
lrwxrwxrwx 1 root root 62 Sep 14 04:38 /etc/init.d/james -> /usr/local/app/james-server-app-3.0.0-beta5-SNAPSHOT/bin/james
root@618119.com:/usr/local/app/james-server-app-3.0.0-beta5-SNAPSHOT# service james start

root@618119.com:/usr/local/app/james-server-app-3.0.0-beta5-SNAPSHOT# service james restart
Stopping Apache James :: Server :: App…
Stopped Apache James :: Server :: App.
Starting Apache James :: Server :: App…

这样就成了系统服务了。

10.再在name.com  添加mx记录,将mail.lizongbo.com 的域名指向运行Apache James的服务器,就可以了。

2013年02月22日

Exception in thread “LWJGL Application” com.badlogic.gdx.utils.GdxRuntimeException: com.badlogic.gdx.utils.GdxRuntimeException: OpenGL is not supported by the video driver.的解决办法

Filed under: Android,Java — 标签:, , , — lizongbo @ 11:25

按照网上的教程,下载最新的libgdx库,

解压:libgdx-nightly-latest.zip.然后运行里面的工程生成工具。

D:\Java\libgdx-nightly-latest>java -jar gdx-setup-ui.jar

导入生成的工程,结果运行出错:

Exception in thread “LWJGL Application” com.badlogic.gdx.utils.GdxRuntimeException: com.badlogic.gdx.utils.GdxRuntimeException: OpenGL is not supported by the video driver.
at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:113)
Caused by: com.badlogic.gdx.utils.GdxRuntimeException: OpenGL is not supported by the video driver.
at com.badlogic.gdx.backends.lwjgl.LwjglGraphics.createDisplayPixelFormat(LwjglGraphics.java:219)
at com.badlogic.gdx.backends.lwjgl.LwjglGraphics.setupDisplay(LwjglGraphics.java:181)
at com.badlogic.gdx.backends.lwjgl.LwjglApplication.mainLoop(LwjglApplication.java:122)
at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:110)
Caused by: org.lwjgl.LWJGLException: Pixel format not accelerated
at org.lwjgl.opengl.WindowsPeerInfo.nChoosePixelFormat(Native Method)
at org.lwjgl.opengl.WindowsPeerInfo.choosePixelFormat(WindowsPeerInfo.java:52)
at org.lwjgl.opengl.WindowsDisplay.createWindow(WindowsDisplay.java:229)
at org.lwjgl.opengl.Display.createWindow(Display.java:303)
at org.lwjgl.opengl.Display.create(Display.java:845)
at org.lwjgl.opengl.Display.create(Display.java:754)
at com.badlogic.gdx.backends.lwjgl.LwjglGraphics.createDisplayPixelFormat(LwjglGraphics.java:216)
… 3 more

遇到这个错误,解决办法很简单,到nvidia官方网站下载对应的opengl驱动即可:

https://developer.nvidia.com/opengl-driver

http://developer.download.nvidia.com/devzone/devcenter/gamegraphics/files/opengl/4.3/306.63_desktop_win8_winvista_win7_64bit_international.exe

网上相关文章和讨论只说了显卡在十年前就支持Opengl了,却没提示用户该检查一下是否安装了显卡的OpenGL驱动。

参考:  http://code.google.com/p/libgdx/issues/detail?id=882

http://stackoverflow.com/questions/10972688/libgdx-exception-in-thread-lwjgl-application

http://code.google.com/p/libgdx/wiki/ProjectSetup

最新的非稳定包的下载地址:

http://libgdx.badlogicgames.com/nightlies/libgdx-nightly-latest.zip

 

 

2011年05月5日

从google的json接口获取地理位置信息的Java代码

Filed under: IP,Java,JavaScript — 标签:, , , , , — lizongbo @ 22:55

从google的json接口获取地理位置信息的Java代码

google 提供了公开的接口,通过,这个接口,根据gps或基站信息或wifi热点信息来获取当前位置的地理信息.
gps信息是经纬度,基站信息是基站的cellid等信息,wifi热点信息是wifi的mac地址是热点名字,信号强度等。
因此可以通过java程序获取相应信息,在LBS项目中可以用上:

api接口定义描述在:

http://code.google.com/p/gears/wiki/GeolocationAPI

Java代码如下:

[code]

package com.lizongbo.geo;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.InetSocketAddress;
import java.net.Proxy;
import java.net.URL;

import com.lizongbo.org.json.JSONArray;
import com.lizongbo.org.json.JSONException;
import com.lizongbo.org.json.JSONObject;

/**
* 从google的json接口获取地理位置信息的代码
*
* @author lizongbo
*
*/
public class GeoTest {

/**
* @param args
* @throws Exception
*/
public static void main(String[] args) throws Exception {
String url = “http://www.google.com/loc/json”;
JSONObject json = new JSONObject();
json.put(“version”, “1.1.0”);
json.put(“host”, “maps.618119.com”);
json.put(“home_mobile_country_code”, 460);// 国家代码
json.put(“home_mobile_network_code”, 0);// 移动运营商代码
json.put(“radio_type”, “gsm”);
json.put(“carrier”, “lizongbo”);
json.put(“request_address”, true);
json.put(“address_language”, “zh_CN”);
JSONArray jsoncells = new JSONArray();
json.put(“cell_towers”, jsoncells);
JSONArray jsonwifis = new JSONArray();
json.put(“wifi_towers”, jsonwifis);
JSONObject jsoncell = new JSONObject();
jsoncell.put(“mobile_country_code”, 460);// 国家代码,mcc
jsoncell.put(“mobile_network_code”, 0);// 移动运营商代码,mnc
jsoncell.put(“location_area_code”, 9364);// 位置区域代码,lac
jsoncell.put(“cell_id”, “3851”);// 移动基站id
// jsoncell.put(“age”, 0);
// jsoncell.put(“signal_strength”, -70);
// jsoncell.put(“timing_advance”, 7777);
jsoncells.put(jsoncell);
JSONObject jsonwifi = new JSONObject();
// jsonwifi.put(“mac_address”, “00-11-22-33-44-55”);
// jsonwifi.put(“signal_strength”, 8);
// jsonwifi.put(“age”, 0);
// jsonwifis.put(jsonwifi);
// jsonwifi = new JSONObject();
jsonwifi.put(“mac_address”, “00-55-44-33-22-11”);//
jsonwifi.put(“ssid”, “TPLINK_618119”);// 无线路由器的名字
jsonwifi.put(“signal_strength”, 8);// 信号强度
jsonwifi.put(“age”, 0);
// jsonwifis.put(jsonwifi);

System.out.println(json.toString());
System.out.println(downloadUrlbyPOST(url, json.toString(), null,
“UTF-8”));

}

public static String downloadUrlbyPOST(String urlStr, String query,
String referer, String encoding) throws Exception {
String line = “”;
StringBuilder sb = new StringBuilder();
HttpURLConnection httpConn = null;
try {
URL url = new URL(urlStr);
System.out.println(urlStr + “?” + query);
Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress(
“proxy.lizongbo.com”, 8080));
proxy = Proxy.NO_PROXY;
httpConn = (HttpURLConnection) url.openConnection(proxy);
httpConn.setDoInput(true);
httpConn.setDoOutput(true);
httpConn.setRequestMethod(“POST”);
if (referer != null) {
httpConn.setRequestProperty(“Referer”, referer);
}
httpConn.setConnectTimeout(5000);
// httpConn.getOutputStream().write(
// java.net.URLEncoder.encode(query, “UTF-8”).getBytes());
httpConn.getOutputStream().write(query.getBytes());
httpConn.getOutputStream().flush();
httpConn.getOutputStream().close();

BufferedReader in = null;
if (httpConn.getResponseCode() != 200) {
System.err.println(“error:” + httpConn.getResponseMessage());
in = new BufferedReader(new InputStreamReader(httpConn
.getErrorStream(), “UTF-8”));
} else {
in = new BufferedReader(new InputStreamReader(httpConn
.getInputStream(), “UTF-8”));
}
while ((line = in.readLine()) != null) {
sb.append(line).append(‘\n’);
}
// 关闭连接
httpConn.disconnect();
return sb.toString();
} catch (Exception e) {
// 关闭连接
httpConn.disconnect();
System.out.println(e.getMessage());
throw e;
}
}
}

[/code]
运行结果如下:
{“address_language”:”zh_CN”,”wifi_towers”:[],”host”:”maps.618119.com”,”radio_type”:”gsm”,”home_mobile_country_code”:9364,”carrier”:”lizongbo”,”home_mobile_network_code”:460,”cell_towers”:[{“mobile_network_code”:0,”cell_id”:”3851″,”mobile_country_code”:460,”location_area_code”:9364}],”request_address”:true,”version”:”1.1.0″}
http://www.google.com/loc/json?{“address_language”:”zh_CN”,”wifi_towers”:[],”host”:”maps.618119.com”,”radio_type”:”gsm”,”home_mobile_country_code”:9364,”carrier”:”lizongbo”,”home_mobile_network_code”:460,”cell_towers”:[{“mobile_network_code”:0,”cell_id”:”3851″,”mobile_country_code”:460,”location_area_code”:9364}],”request_address”:true,”version”:”1.1.0″}
{“location”:{“latitude”:22.522185,”longitude”:113.925618,”address”:{“country”:”中国”,”country_code”:”CN”,”region”:”广东省”,”city”:”深圳市”,”street”:”滨海大道辅路”},”accuracy”:620.0},”access_token”:”2:618119:lizongbo”}

试了一下把无线路由器的mac地址发到 https://www.google.com/loc/json ,google果然返回很准的定位看来google是把我用手机测试定位的时候就把数据采集分析好了,确实强大。

Older Posts »

Powered by WordPress