我是亚马逊AWS服务的新手.我想知道是否有办法运行EC2的实例(例如,Amazon Linux AMI),然后将两个环境连接到此实例.
特别是,我想在单个EC2实例上运行PHP和Tomcat环境.
问题是,每次我在Elastic Beanstalk中创建一个新环境时,它似乎也会创建一个新的EC2实例.我在这里错过了什么吗?
我很感激任何暗示.
我在AWS上有64位Tomcat 7服务器,默认设置.我使用Elastic Beanstalk来管理我的实例.有时,当我部署新版本时,它不起作用并向我显示错误:
Responses from [i-2a7fe91f] were received, but the commands failed.
事情是它发生了一半时间,而不是所有时间.当我收到此错误时,我终止环境并创建一个具有相同WAR文件的新环境,它工作正常!但是,我想知道是否有人知道真正发生了什么.
这是我认为相关的日志文件的一部分:
2013-05-23 17:12:02,555 [INFO] (20168 MainThread) [command.py-122] [root command execute] Executing command: Infra-WriteApplication2 - AWSEBAutoScalingGroup
2013-05-23 17:12:11,401 [INFO] (20168 MainThread) [command.py-130] [root command execute] Command returned: (code: 1, stdout: Error occurred during build:
, stderr: None)
2013-05-23 17:12:11,432 [DEBUG] (20168 MainThread) [commandWrapper.py-60] [root commandWrapper main] Command result: {'status': 'FAILURE', 'results': [{'status': 'FAILURE', 'config_set': u'Infra-WriteApplication2', 'returncode': 1, 'events': [], 'msg': 'Error occurred during build: \n'}], 'api_version': '1.0'}
Run Code Online (Sandbox Code Playgroud) 我需要调用一个cpp函数
void myFunc(float **array2D, int rows, int cols)
{
}
Run Code Online (Sandbox Code Playgroud)
在objective-c对象中.基本上,当我创建NSArray对象时,数组是在我的objective-c代码中创建的.现在,问题是如何将此数组传递给我的cpp函数.
我对这些混合c ++/objective-c的东西有点新,所以任何提示都会受到高度赞赏.
谢谢
在此之后,我想扩展log4j自定义转换器,以将shiro用户名添加到日志中。这是我的代码:
@Plugin(name = "shiro", type = "Converter")
@ConverterKeys({"susr", "shiro"})
public class ShiroUserConverter extends LogEventPatternConverter {
private static final ShiroUserConverter INSTANCE = new ShiroUserConverter();
private ShiroUserConverter()
{
this("shiro", "shiro"); // not sure why!
}
protected ShiroUserConverter(String name, String style) {
super(name, style);
}
public static ShiroUserConverter newInstance(final String[] options) {
return INSTANCE;
}
@Override
public void format(LogEvent arg0, StringBuilder arg1) {
// TODO Auto-generated method stub
Subject currentUser = SecurityUtils.getSubject();
if ( currentUser != null && currentUser.getPrincipal() …Run Code Online (Sandbox Code Playgroud) 我有一个简单的数据库事务,如下面的代码.第一个查询应该正常工作,而第二个查询应该抛出异常,因此事务不应该通过!
问题是,运行此代码后,第一个查询似乎在我的表中插入了一行,就好像它不是事务性的.该代码确实抛出异常并myCon.rollback();执行,但无论如何都会在表中插入新行.
我不确定我究竟缺少什么,任何提示都会受到高度赞赏.
- 编辑:问题是我使用默认的MyISAM引擎作为我的表.我把它改成了InnoDB,问题解决了.
Connection myCon = null;
try
{
Class.forName("com.mysql.jdbc.Driver");
myCon = DriverManager.getConnection (dbUrl, dbUser, dbPass);
myCon.setAutoCommit(false); // the intention is to do a transaction
Statement stmt = myCon.createStatement();
String query = "INSERT INTO tbltest(f1) VALUES (1);";
stmt.executeUpdate(query);
query = "INSERT INTO"; // a malformed query
stmt.executeUpdate(query);
con.commit();
}
catch(Exception e)
{
System.err.println(e.toString());
myCon.rollback();
}
finally
{
myCon.close();
}
Run Code Online (Sandbox Code Playgroud) 我正在调用外部Web服务来获取json对象.此对象具有属性"value",有时是String,有时是字符串数组.
public class MyClass {
// ... other variables
private String value;
public String getValue() {
return value;
}
@JsonProperty("value")
public void setValue(String value) {
this.value = value;
}
}
Run Code Online (Sandbox Code Playgroud)
目前,我收到一个错误org.codehaus.jackson.map.JsonMappingException: Can not deserialize instance of java.lang.String out of START_ARRAY token抱怨此字段.我想知道是否有人可以给我一个关于value在我班级中定义的正确方法的暗示.
这是我必须处理的示例json的一部分:
{
"id": 12016907001,
"type": "Create",
"value": "normal",
"field_name": "priority"
},
{
"id": 12016907011,
"type": "Create",
"value": [
"sample",
"another"
],
"field_name": "tags"
}
Run Code Online (Sandbox Code Playgroud)
谢谢.
- 编辑
我将值的类型更改为Object,它解决了我的问题.但是,我仍然想知道是否有更好的方法来处理这种情况.
java ×3
amazon-ec2 ×2
c++ ×1
jackson ×1
jdbc ×1
json ×1
log4j ×1
nsarray ×1
objective-c ×1
tomcat7 ×1
transactions ×1
vaadin ×1