delete this tokenn is expired current time is 会影响数据吗

Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. J it only takes a minute:
I have set up hadoop2.2.0 on 3 clusters. Everything is going fine. NodeManager and Datanode are started in each clusters. But, when I run wordcount example, 100% mapping takes place
and it gives following exception:
map 100% reduce 0%
13/11/28 09:57:15 INFO mapreduce.Job: Task Id : attempt_8_0001_r_, Status : FAILED
Container launch failed for container_8_003 : org.apache.hadoop.yarn.exceptions.
YarnException: Unauthorized request to start container.
This token is expired. current time is 8 found 5
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
I have gone through internet to find out solution. But I couldn't find out. Help me out.
This exception occurs when your nodes have different time settings.
Make sure that your all 3 nodes have same time n timezone settings and then restart computer.
This worked for me . Hope this help to you as well !!!!
One of the options would be increasing lifespan of container by setting
yarn.resourcemanager.rm.container-allocation.expiry-interval-ms
which is by default is 10 min
Service-Wide / Advanced
YARN Service Configuration Safety Valve for yarn-site.xml
&property&
&name&yarn.resourcemanager.rm.container-allocation.expiry-interval-ms&/name&
&value&1000000&/value&
&/property&
Beyond just the time settings, make sure the nodes are running NTP or are time-synced reasonably well -
I had the same problem and discovered that one of the node had the wrong YEAR set in date.
Once I put the times within seconds of each other, then the error went away.
Your Answer
Sign up or
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Post as a guest
By posting your answer, you agree to the
Not the answer you're looking for?
Browse other questions tagged
Stack Overflow works best with JavaScript enabled动态加载用户控件,怎么设置控件属性_怎么进行自定义变量的传递?求_是哪位高手动了小弟我的cookie?Spring Security自动登录功能开发经历总结__脚本百事通
稍等,加载中……
^_^请注意,有可能下面的2篇文章才是您想要的内容:
动态加载用户控件,怎么设置控件属性
怎么进行自定义变量的传递?求
是哪位高手动了小弟我的cookie?Spring Security自动登录功能开发经历总结
动态加载用户控件,怎么设置控件属性
动态加载用户控件,如何设置控件属性?&uc7:NewsList
CategoryID= "2 "
TitleLength= "25 "
id= "NewsList1 "
runat= "server "/&
然后这样:
UserControl
(UserControl)LoadControl( "Modules/NewsList.ascx ");
PlaceHolder1.Controls.Clear();
PlaceHolder1.Controls.Add(uc);
加载是加载了,但是属性值怎么弄?------解决方案--------------------UserControl uc = (UserControl)LoadControl( "Modules/NewsList.ascx ");
uc.TitleLength= 25;
PlaceHolder1.Controls.Clear();
PlaceHolder1.Controls.Add(uc);
------解决方案--------------------楼上好快
------解决方案--------------------说了NewsList是你NewsList.ascx的类名,我这里是猜测的,具体是什么要看你的。
因为你必须强制转化成NewsList类才行。
我估计可能你要这样才行
Modules.NewsList uc = (Modules.NewsList)LoadControl( "Modules/NewsList.ascx ");
具体看你的NewsList.ascx的类名和命名空间
------解决方案--------------------MyUserControl uc = LoadControl( "Modules/NewsList.ascx ") as MyUserC
uc.MyProperty =
怎么进行自定义变量的传递?求
如何进行自定义变量的传递?急求【1】我定义了一个存储过程写在数据库中
@stringStr
word=@stringStr
【2】不明白的是(代码中):
textBox.Text的值传递到
@stringStr
【3】下面是引用存储过程(问题是【2】)
queryStr= "wordMean ";
SqlDataAdapter
myDataAdapter=new
SqlDataAdapter(queryStr,con); ------解决方案--------------------string queryStr=String.Format( "wordMean({0}) ",textBox.Text);
------解决方案--------------------调试
把错误报上来. ------解决方案--------------------【4】您不可以去MSDN上看看吗?好好看看上面的DEMO
------解决方案--------------------SqlConnection con=DB.createConnection();
string queryStr=String.Format( "wordMean({0}) ",this.textWord.Text);
SqlDataAdapter myDataAdapter=new SqlDataAdapter( "wordMean ",con);
myDataAdapter.SelectCommand.Parameters.Add( "@stringStr ", SqlDbType.VarChar).Value = this.textWord.T
con.Open();
myDataAdapter.Fill(myDataSet, "myDict ");
con.Close();
dataGrid1.DataSource=myDataSet.Tables[ "myDict "].DefaultV
是哪位高手动了小弟我的cookie?Spring Security自动登录功能开发经历总结
是谁动了我的cookie?Spring Security自动登录功能开发经历总结
在使用Spring Security的remember me模块为云端开源论坛XLineCode开发自动登录模块时,本着用户至上的理念优先采用了PersistentTokenBasedRememberMeServices作为实现根基。通过参考Spring Security的官网推荐书籍Spring Security 3 ,很简单也很顺利的在Spring Security命名空间下配置了该service,本地环境也简单测试通过了该功能,但在上线后接近两个月的时间内,却出现了各种多线程引发的问题而导致自动登录功能失效的情况。
Spring Security的remember me模块的两个实现机制简介:
PersistentTokenBasedRememberMeServices:
使用JdbcTokenRepositoryImpl在数据库创建persistent_logins表。当勾选自动登录时随机产生键值对并将该键值对保存在persistent_logins表及浏览器的cookie中,在浏览器当前会话失效后从下一request中提取cookie键值对,通过对比是否与数据库中的键值对一致来判断该自动功能是否有效。有效则根据该key生成新的token并更新至数据库和浏览器。如根据key未能从数据库找到记录,则不进行登录授权并取消该key在浏览器中对应的cookie。如该key对应的cookie token与数据库得到的token不一致,则该cookie在浏览器中可能已经被黑客攻破,被盗用于信息窃取,因此抛出cookie被盗的异常并根据该用户id删除其在数据库对应的所有键值记录(该用户在多个浏览器登录则有多条记录)。
核心方法processAutoLoginCookie代码如下:
protected UserDetails processAutoLoginCookie(String[] cookieTokens, HttpServletRequest request, HttpServletResponse response) {
if (cookieTokens.length != 2) {
throw new InvalidCookieException("Cookie token did not contain " + 2 +
" tokens, but contained '" + Arrays.asList(cookieTokens) + "'");
final String presentedSeries = cookieTokens[0];
final String presentedToken = cookieTokens[1];
PersistentRememberMeToken token = tokenRepository.getTokenForSeries(presentedSeries);
if (token == null) {
// No series match, so we can't authenticate using this cookie
throw new RememberMeAuthenticationException("No persistent token found for series id: " + presentedSeries);
// We have a match for this user/series combination
if (!presentedToken.equals(token.getTokenValue())) {
// Token doesn't match series value. Delete all logins for this user and throw an exception to warn them.
tokenRepository.removeUserTokens(token.getUsername());
throw new CookieTheftException(messages.getMessage("PersistentTokenBasedRememberMeServices.cookieStolen",
"Invalid remember-me token (Series/token) mismatch. Implies previous cookie theft attack."));
if (token.getDate().getTime() + getTokenValiditySeconds()*1000L & System.currentTimeMillis()) {
throw new RememberMeAuthenticationException("Remember-me login has expired");
// Token also matches, so login is valid. Update the token value, keeping the *same* series number.
if (logger.isDebugEnabled()) {
logger.debug("Refreshing persistent login token for user '" + token.getUsername() + "', series '" +
token.getSeries() + "'");
PersistentRememberMeToken newToken = new PersistentRememberMeToken(token.getUsername(),
token.getSeries(), generateTokenData(), new Date());
tokenRepository.updateToken(newToken.getSeries(), newToken.getTokenValue(), newToken.getDate());
addCookie(newToken, request, response);
} catch (DataAccessException e) {
logger.error("Failed to update token: ", e);
throw new RememberMeAuthenticationException("Autologin failed due to data access problem");
return getUserDetailsService().loadUserByUsername(token.getUsername());
TokenBasedRememberMeServices:
根据用户id和密码生成cookie,同样通过对比判断cookie是否有效。该机制的缺点是用户修改密码后其在其他浏览器中的cookie不会自动更新,需再次登陆生成cookie。另一缺点是密码经过加密后保存在客户端,存在一定风险。
核心方法processAutoLoginCookie代码如下:
protected UserDetails processAutoLoginCookie(String[] cookieTokens, HttpServletRequest request,
HttpServletResponse response) {
if (cookieTokens.length != 3) {
throw new InvalidCookieException("Cookie token did not contain 3" +
" tokens, but contained '" + Arrays.asList(cookieTokens) + "'");
long tokenExpiryT
tokenExpiryTime = new Long(cookieTokens[1]).longValue();
catch (NumberFormatException nfe) {
throw new InvalidCookieException("Cookie token[1] did not contain a valid number (contained '" +
cookieTokens[1] + "')");
if (isTokenExpired(tokenExpiryTime)) {
throw new InvalidCookieException("Cookie token[1] has expired (expired on '"
+ new Date(tokenExpiryTime) + "'; current time is '" + new Date() + "')");
// Check the user exists.
// Defer lookup until after expiry time checked, to possibly avoid expensive database call.
UserDetails userDetails = getUserDetailsService().loadUserByUsername(cookieTokens[0]);
// Check signature of token matches remaining details.
// Must do this after user lookup, as we need the DAO-derived password.
// If efficiency was a major issue, just add in a UserCache implementation,
// but recall that this method is usually only called once per HttpSession - if the token is valid,
// it will cause SecurityContextHolder population, whilst if invalid, will cause the cookie to be cancelled.
String expectedTokenSignature = makeTokenSignature(tokenExpiryTime, userDetails.getUsername(),
userDetails.getPassword());
if (!equals(expectedTokenSignature,cookieTokens[2])) {
throw new InvalidCookieException("Cookie token[2] contained signature '" + cookieTokens[2]
+ "' but expected '" + expectedTokenSignature + "'");
return userD
使用PersistentTokenBasedRememberMeServices遇到的各种情况:
1. 因Spring Security的filter链未作并发控制,所以PersistentTokenBasedRememberMeServices的processAutoLoginCookie在处理自动登录时如服务器负载过大用户多次刷新页面会产生线程A和B同时在运行processAutoLoginCookie的情况。假设A是先于B的请求,而A在未执行tokenRepository.updateToken(newToken.getSeries(), newToken.getTokenValue(), newToken.getDate());时被系统挂起了线程,导致B先于A完成了请求。此时A获得资源后执行完时因A请求已被浏览器取消,故A所产生的新的cookie无法在浏览器中更新,导致该浏览器的下次请求中的cookie与数据库中的token不一致从而抛出Cookie被盗的异常(该情况只在极低的概率下才可能发生)。
2. 跑完PersistentTokenBasedRememberMeServices的processAutoLoginCookie后在业务逻辑中如抛出异常而未被代码或者web.xml中的500配置捕获,则会直接返回500错误给浏览器,此时新生成的cookie不会在浏览器更新,同样会导致cookie被盗的情况。不过一般情况下都会捕获,问题不大。
3. filter配置不当导致拦截了页面加载后触发的ajax或一般业务请求:同上,在发生异常时导致cookie更新失败。
4. 在浏览器请求未返回时直接取消该请求,因该请求在服务器执行完后不能正常设置浏览器的cookie,导致浏览器下次请求再次使用失效的cookie时processAutoLoginCookie发现两边token不一致,抛出cookie被盗异常。这种情况在网络不理想的情况下被用户触发的可能性最大,而Spring Security代码中也没有处理该情况的代码。仅仅因为用户取消请求而抛出cookie被盗的异常并清空该用户在其他浏览器的cookie会造成相当差的用户体验,这也是我决定转为采用TokenBasedRememberMeServices的原因.
使用TokenBasedRememberMeServices则相对简单很多,无需考虑并发的情况,只要cookie匹配就可自动登录。
后话:我在发现该情况后分别尝试了oschina,csdn和iteye的登录机制,发现他们均使用的是TokenBasedRememberMeServices的方式。
如果您想提高自己的技术水平,欢迎加入本站官方1号QQ群:&&,&&2号QQ群:,在群里结识技术精英和交流技术^_^
本站联系邮箱:Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. J it only takes a minute:
I have tried to Login Vtiger from my Android Application.I got Challenge token successfully and concodinate that challenge token with access key(taken from my account preferences). Then convert to MD5 string.
My Challenge URL:
http://mysite/vtigerCRM510-RC/vtigerCRM/webservice.php?operation=getchallenge&username=Manager
Challenge Response:
{"success":true,"result":{"token":"4ff555f87eece","serverTime":,"expireTime":}}
Login URL:
http://mysite/vtigerCRM510-RC/vtigerCRM/webservice.php?operation=login&username=Manager&accesskey=976bbac37c
Login Response:
{"success":false,"error":{"code":"INVALID_AUTH_TOKEN","message":"Specified token is invalid or expired"}}
Also I have a doubt, In Android I used AsyncTask for Http Operation.Two Asynctask used.Fisrt one for get Challenge token and using this token done
second Async task for Login. Is it correct way? My Android code is below.
My Android Code:
public class GetChallengeActivity extends Activity {
private TextView textV
private static final String USER_NAME="Manager";
private static final String ACCESS_KEY="myaccesskey"; //taken from preferences
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
public void postData(View view)
textView=(TextView) findViewById(R.id.resulttext);
ConnectivityManager conmgr=(ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo networkinfo=conmgr.getActiveNetworkInfo();
Log.i(null, "Network Info--&"+networkinfo.toString());
if(networkinfo!=null && networkinfo.isConnected())
//Network Available.
//Toast.makeText(getApplicationContext(), "Network available", Toast.LENGTH_LONG).show();
Log.i(null, "Network Available");
textView.setText("Network Available");
String url="http://mysite/vtigerCRM510-RC/vtigerCRM/webservice.php?operation=getchallenge&username="+USER_NAME+"";
Log.i(null,"Challenge URL--&"+url);
new ServerCommunication().execute(url);
//Network not Available
Log.i(null, "Network Not Available");
Toast.makeText(getApplicationContext(), "Network Not available", Toast.LENGTH_LONG).show();
textView.setText("Network Not Available");
private class ServerCommunication extends AsyncTask&String,String,String&
protected String doInBackground(String... urls) {
Log.i(null, "Doing in Background");
return postToServer(urls[0]);
}catch (IOException e) {
Log.i(null, "Unable to retrieve web page. URL may be invalid.");
return "Unable to retrieve web page. URL may be invalid.";
protected void onPostExecute(String result)
Log.i(null, "onPostExecute");
Log.i(null, result);
textView.setText(result);
private String postToServer(String string) throws IOException{
Log.i(null, "post2Server");
InputStream is =
// Only display the first 500 characters of the retrieved web page content.
int len = 500;
URL url = new URL(string);
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setReadTimeout(10000 /* milliseconds */);
conn.setConnectTimeout(15000 /* milliseconds */);
conn.setRequestMethod("GET");
conn.setDoInput(true);
// Starts the query
conn.connect();
int response = conn.getResponseCode();
is = conn.getInputStream();
// Convert the InputStream into a string
String contentAsString = readIt(is, len);
Log.i(null,contentAsString);
String result="";
JSONObject jsondata=new JSONObject(contentAsString);
String outcomesrf=jsondata.getString("success");
Log.i(null, "OutCome----&"+outcomesrf);
if(outcomesrf=="false")
JSONObject jsonobj2=jsondata.getJSONObject("error");
result=jsonobj2.getString("message");
Log.i(null,"Error--&errorMessage----&"+result);
JSONObject jsonobj3=jsondata.getJSONObject("result");
result=jsonobj3.getString("token");
Log.i(null,"Success--&Token----&"+result);
Log.i(null,"--&MD5Hash("+result+ACCESS_KEY+")");
String generatedkey=MD5_Hash(result+ACCESS_KEY);
Log.i(null,"Key--&"+generatedkey);
String loginurl="http://mysite/vtigerCRM510-RC/vtigerCRM/webservice.php?operation=login&username="+USER_NAME+"&accesskey="+generatedkey+"";
Log.i(null,"Login URL--&"+loginurl);
new LoginCommunication().execute(loginurl);
} catch (JSONException e) {
e.printStackTrace();
Log.i(null,"At Json "+e.toString());
if (is != null) {
is.close();
// Reads an InputStream and converts it to a String.
private class LoginCommunication extends AsyncTask&String,String,String&
protected String doInBackground(String... urls) {
Log.i(null, "Login Posting in Background");
return loginToServer(urls[0]);
}catch (IOException e) {
Log.i(null, "Unable to retrieve web page. URL may be invalid.");
return "Unable to retrieve web page. URL may be invalid.";
protected void onPostExecute(String result)
Log.i(null, "LoginonPostExecute");
Log.i(null, result);
textView.setText(result);
private String loginToServer(String string) throws IOException{
Log.i(null, "loginToServer");
InputStream is =
int len = 500;
URL url = new URL(string);
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setReadTimeout(10000 /* milliseconds */);
conn.setConnectTimeout(15000 /* milliseconds */);
conn.setRequestMethod("POST");
conn.setDoInput(true);
conn.setDoOutput(true);
// Starts the query
conn.connect();
int response = conn.getResponseCode();
is = conn.getInputStream();
// Convert the InputStream into a string
String contentAsString = readIt(is, len);
Log.i(null,contentAsString);
String result1="";
String result2="";
JSONObject jsondata=new JSONObject(contentAsString);
String outcomesrf=jsondata.getString("success");
Log.i(null, "Login OutCome----&"+outcomesrf);
if(outcomesrf=="false")
JSONObject jsonobj2=jsondata.getJSONObject("error");
result1=jsonobj2.getString("message");
Log.i(null,"Error--&errorMessage----&"+result1);
JSONObject jsonobj3=jsondata.getJSONObject("result");
result1=jsonobj3.getString("sessionName");
Log.i(null,"Success--&sessionName----&"+result1);
JSONObject jsonobj4=jsondata.getJSONObject("result");
result2=jsonobj4.getString("userId");
Log.i(null,"Success--&userId----&"+result2);
} catch (JSONException e) {
e.printStackTrace();
Log.i(null,"At Json "+e.toString());
String result="sessionName"+result1+" userId"+result2;
if (is != null) {
is.close();
public String readIt(InputStream stream, int len) throws IOException, UnsupportedEncodingException {
Reader reader =
reader = new InputStreamReader(stream, "UTF-8");
char[] buffer = new char[len];
reader.read(buffer);
return new String(buffer);
public static String MD5_Hash(String s) {
MessageDigest m =
m = MessageDigest.getInstance("MD5");
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
m.update(s.getBytes(),0,s.length());
String hash = new BigInteger(1, m.digest()).toString(16);
1,58373271
In your PostToServer, the accesskey verb should be with a upper k (accessKey)
String loginurl="http://mysite/vtigerCRM510-RC/vtigerCRM/webservice.php?operation=login&username="+USER_NAME+"&accessKey="+generatedkey+"";
Your Answer
Sign up or
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Post as a guest
By posting your answer, you agree to the
Not the answer you're looking for?
Browse other questions tagged
Stack Overflow works best with JavaScript enabled

我要回帖

更多关于 expired time 的文章

 

随机推荐