I'm running Google Apps locally via eclipse. I connect to http://localhost:8888/ and sometimes Eclipse will throw an exception from this line 374 in AccessControlContext.class:
throw new AccessControlException("access denied "+perm, perm);
Here is the stack trace:
Thread [299085#qtp-12256262-2] (Suspended (exception AccessControlException))
AccessControlContext.checkPermission(Permission) line: 374
AccessController.checkPermission(Permission) line: 546
DevAppServerFactory$CustomSecurityManager(SecurityManager).checkPermission(Permission) line: 532
DevAppServerFactory$CustomSecurityManager.checkPermission(Permission) line: 289
DevAppServerFactory$CustomSecurityManager(SecurityManager).checkPackageAccess(String) line: 1512
Launcher$AppClassLoader.loadClass(String, boolean) line: 298
Launcher$AppClassLoader(ClassLoader).loadClass(String) line: 247
ResourceBundle$RBClassLoader.loadClass(String) line: 435
ResourceBundle$Control.newBundle(String, Locale, String, ClassLoader, boolean) line: 2289
ResourceBundle.loadBundle(CacheKey, List<String>, Control, boolean) line: 1364
ResourceBundle.findBundle(CacheKey, List<Locale>, List<String>, int, Control, ResourceBundle) line: 1328
ResourceBundle.findBundle(CacheKey, List<Locale>, List<String>, int, Control, ResourceBundle) line: 1282
ResourceBundle.findBundle(CacheKey, List<Locale>, List<String>, int, Control, ResourceBundle) line: 1282
ResourceBundle.getBundleImpl(String, Locale, ClassLoader, ResourceBundle$Control) line: 1224
ResourceBundle.getBundle(String) line: 705
Level.getLocalizedName() line: 223
SimpleFormatter.format(LogRecord) line: 64
ConsoleHandler(StreamHandler).publish(LogRecord) line: 179
ConsoleHandler.publish(LogRecord) line: 88
Logger.log(LogRecord) line: 478
Logger.doLog(LogRecord) line: 500
Logger.log(Level, String) line: 523
Logger.warning(String) line: 1026
I'm calling just this:
log.warning("string");
and log is initialized like so:
private static final Logger log = Logger.getLogger(MyServletName.class.getName());
What is breaking?
Try using this line instead. I normally use something similar to the following line when I write GAE code:
private static final Logger log = Logger.getLogger(MyServletName.class.getSimpleName());
So, use getSimpleName() instead of getName(). Read java.lang.Class javadoc on getName() and getSimpleName(). The former probably appends an 'L' character to the end of the class type name, while the latter does not possess this (in your situation, undesirable) behaviour.
Also, consider using Guice Injection for the class's Logger object.
Related
I am implementing a RPC function for my C application , and try to programmatically declare a queue which limits maximum number of pending messages, after reading the declaration of amqp_table_entry_t and amqp_field_value_t in amqp.h , here's my minimal code sample :
int default_channel_id = 1;
int passive = 0;
int durable = 1;
int exclusive = 0;
int auto_delete = 0;
amqp_table_entry_t *q_arg_n_elms = malloc(sizeof(amqp_table_entry_t));
*q_arg_n_elms = (amqp_table_entry_t) {.key = amqp_cstring_bytes("x-max-length"),
.value = {.kind = AMQP_FIELD_KIND_U32, .value = {.u32 = 234 }}};
amqp_table_t q_arg_table = {.num_entries=1, .entries=q_arg_n_elms};
amqp_queue_declare( conn, default_channel_id, amqp_cstring_bytes("my_queue_123"),
passive, durable, exclusive, auto_delete, q_arg_table );
amqp_rpc_reply_t _reply = amqp_get_rpc_reply(conn);
The code above always returns AMQP_RESPONSE_LIBRARY_EXCEPTION in the object of amqp_rpc_reply_t, with error message a socket error occurred , I don't see any active connection triggered by this code in web management UI of the RabbitMQ. so I think rabbitmq-c library doesn't establish a connection and just reply with error.
However everything works perfectly when I replace the argument q_arg_table with default amqp_empty_table (which means no argument).
Here are my questions :
Where can I find the code which filter the invalid key of the queue argument ? according to this article , x-max-length should be correct argument key for limiting number of messages in a queue , but I cannot figure out why the library still reports error.
Is there any example that demonstrates how to properly set up amqp_table_t passing in amqp_queue_declare(...) ?
Development environment :
RabbitMQ v3.2.4
rabbitmq-c v0.11.0
Appreciate any feedback , thanks for reading.
[Edit]
According to the server log rabbit#myhostname-sasl.log, RabbitMQ broker accepted a new connection, found decode error on receiving frame, then close connection immediately. I haven't figured out the Erlang implementation but the root cause is likely the decoding error on the table argument when declaring the queue.
131 =CRASH REPORT==== 18-May-2022::16:05:46 ===
132 crasher:
133 initial call: rabbit_reader:init/2
134 pid: <0.23706.1>
135 registered_name: []
136 exception error: no function clause matching
137 rabbit_binary_parser:parse_field_value(<<105,0,0,1,44>>) (src/rabbit_binary_parser.erl, line 53)
138 in function rabbit_binary_parser:parse_table/1 (src/rabbit_binary_parser.erl, line 44)
139 in call from rabbit_framing_amqp_0_9_1:decode_method_fields/2 (src/rabbit_framing_amqp_0_9_1.erl, line 791)
140 in call from rabbit_command_assembler:process/2 (src/rabbit_command_assembler.erl, line 85)
141 in call from rabbit_reader:process_frame/3 (src/rabbit_reader.erl, line 688)
142 in call from rabbit_reader:handle_input/3 (src/rabbit_reader.erl, line 738)
143 in call from rabbit_reader:recvloop/2 (src/rabbit_reader.erl, line 292)
144 in call from rabbit_reader:run/1 (src/rabbit_reader.erl, line 273)
145 ancestors: [<0.23704.1>,rabbit_tcp_client_sup,rabbit_sup,<0.145.0>]
146 messages: [{'EXIT',#Port<0.31561>,normal}]
147 links: [<0.23704.1>]
148 dictionary: [{{channel,1},
149 {<0.23720.1>,{method,rabbit_framing_amqp_0_9_1}}},
150 {{ch_pid,<0.23720.1>},{1,#Ref<0.0.20.156836>}}]
151 trap_exit: true
152 status: running
153 heap_size: 2586
154 stack_size: 27
155 reductions: 2849
156 neighbours:
RabbitMQ may not support unsigned integers as table values.
Instead try using a signed 32 or 64-bit number (e.g., .value = {.kind = AMQP_FIELD_KIND_I32, .value = {.i32 = 234 }}).
Also the RabbitMQ server logs may contain additional debugging information that can help understand errors like this as well as the amqp_error_string2 function can be used to translate error-code into an error-string.
Call to get_execution_role() from notebook instance fails with the error message NoSuchEntityException: An error occurred (NoSuchEntity) when calling the GetRole operation: The user with name <name> cannot be found.
Stack trace:
NoSuchEntityExceptionTraceback (most recent call last)
<ipython-input-1-1e2d3f162cfe> in <module>()
5 sagemaker_session = sagemaker.Session()
6
----> 7 role = get_execution_role()
/home/ec2-user/anaconda3/envs/tensorflow_p27/lib/python2.7/site-packages/sagemaker/session.pyc in get_execution_role(sagemaker_session)
871 if not sagemaker_session:
872 sagemaker_session = Session()
--> 873 arn = sagemaker_session.get_caller_identity_arn()
874
875 if 'role' in arn:
/home/ec2-user/anaconda3/envs/tensorflow_p27/lib/python2.7/site-packages/sagemaker/session.pyc in get_caller_identity_arn(self)
701 # Call IAM to get the role's path
702 role_name = role[role.rfind('/') + 1:]
--> 703 role = self.boto_session.client('iam').get_role(RoleName=role_name)['Role']['Arn']
704
705 return role
/home/ec2-user/anaconda3/envs/tensorflow_p27/lib/python2.7/site-packages/botocore/client.pyc in _api_call(self, *args, **kwargs)
312 "%s() only accepts keyword arguments." % py_operation_name)
313 # The "self" in this scope is referring to the BaseClient.
--> 314 return self._make_api_call(operation_name, kwargs)
315
316 _api_call.__name__ = str(py_operation_name)
/home/ec2-user/anaconda3/envs/tensorflow_p27/lib/python2.7/site-packages/botocore/client.pyc in _make_api_call(self, operation_name, api_params)
610 error_code = parsed_response.get("Error", {}).get("Code")
611 error_class = self.exceptions.from_code(error_code)
--> 612 raise error_class(parsed_response, operation_name)
613 else:
614 return parsed_response
NoSuchEntityException: An error occurred (NoSuchEntity) when calling the GetRole operation: The user with name <name> cannot be found.
However using boto client directly to get info about the role succeeds. This works fine:
response = client.get_role(
RoleName='role-name',
)['Role']['Arn']
Turns out this is some weird bug that goes away if you stop and start the notebook instance.
I have shutdown and run again the notebook and it works.
PD: I have to run again the code to make effect.
I have a Dictionary model defined in Django (1.6.5). One method (called get_topentities) returns the top names in my dictionary (entity names are defined by Entity model):
def get_topentities(self,n):
entities = self.entity_set.select_related().filter(in_dico=True,table_type=0).order_by("rank")[0:n]
return entities
When I call the function (say with n=2), it returns the top 2 elements but I cannot access the second one because of this "not enough arguments to format string" error:
In [5]: d = Dictionary.objects.get(code='USA')
In [6]: top2 = d.get_topentities(2)
In [7]: top2
Out[7]: [<Entity: BARACK OBAMA>, <Entity: GOVERNMENT>]
In [8]: top2[0]
Out[8]: <Entity: BARACK OBAMA>
In [9]: top2[1]
.
.
/usr/local/lib/python2.7/dist-packages/django_pyodbc/compiler.pyc in as_sql(self, with_limits, with_col_aliases)
172 # Lop off ORDER... and the initial "SELECT"
173 inner_select = _remove_order_limit_offset(raw_sql)
--> 174 outer_fields, inner_select = self._alias_columns(inner_select)
175
176 order = _get_order_limit_offset(raw_sql)[0]
/usr/local/lib/python2.7/dist-packages/django_pyodbc/compiler.pyc in _alias_columns(self, sql)
339
340 # store the expanded paren string
--> 341 parens[key] = buf% parens
342 #cannot use {} because IBM's DB2 uses {} as quotes
343 paren_buf[paren_depth] += '(%(' + key + ')s)'
TypeError: not enough arguments for format string
In [10]:
My server backend is MSSQL and I'm using pyodbc as the database driver. If I try the same on a PC with engine sqlserver_ado, it works. Can someone help?
Regards,
Patrick
I have tried to insert PaginationRecallComponent (http://bakery.cakephp.org/articles/Zaphod/2012/03/27/paginationrecall_for_cakephp_2_x), in
App -> Controller -> Component -> PaginationRecallComponent.php
UserController:
public $components = array('PaginationRecall');
Why I received the following error:
Strict (2048): Declaration of PaginationRecallComponent::initialize() should be compatible with Component::initialize(Controller $controller) [APP/Controller/Component/PaginationRecallComponent.php, line 46]
Code Context
App::load() - CORE/Cake/Core/App.php, line 567
App::load() - CORE/Cake/Core/App.php, line 567
spl_autoload_call - [internal], line ??
class_exists - [internal], line ??
ComponentCollection::load() - CORE/Cake/Controller/ComponentCollection.php, line 110
ComponentCollection::init() - CORE/Cake/Controller/ComponentCollection.php, line 53
Controller::constructClasses() - CORE/Cake/Controller/Controller.php, line 652
Dispatcher::_invoke() - CORE/Cake/Routing/Dispatcher.php, line 183
Dispatcher::dispatch() - CORE/Cake/Routing/Dispatcher.php, line 162
[main] - APP/webroot/index.php, line 97
CakePHP 2.4.2
You get this error because the signature of the initialize method in the PaginationRecallComponent class is different from the one in its parent class.
If you look at the code you will see that in Cake/Controller/Component.php the signature is:
public function initialize(Controller $controller)
whereas in the PaginationRecallComponent it is:
function initialize(&$controller)
In the first case the $controller parameter must be an instance of Controller, whereas in the second case there is no such constraint. To get rid of the error you simply have to add this constraint to the signature of the initialize method of the PaginationRecallComponent.
I can't seem to start my development environment for gae on eclipse anymore. Once I start it it goes to the debug view with source not found for the PolicyUtil.getKeyStore with an illegalarguementexception. Has anyone else had this problem? I've tried deleting my run configs but no luck.
Any help is much appreciated. Here's the stack trace:
{Daemon Thread [Thread-1] (Suspended (exception IllegalArgumentException))
PolicyUtil.getKeyStore(URL, String, String, String, String, Debug) line: 65
PolicyFile.init(URL, PolicyFile$PolicyInfo) line: 635
PolicyFile.access$400(PolicyFile, URL, PolicyFile$PolicyInfo) line: 266
PolicyFile$3.run() line: 546
AccessController.doPrivileged(PrivilegedAction<T>) line: not available [native method]
PolicyFile.initPolicyFile(String, String, PolicyFile$PolicyInfo) line: 519
PolicyFile.initPolicyFile(PolicyFile$PolicyInfo, URL) line: 505
PolicyFile.init(URL) line: 464
PolicyFile.<init>() line: 309
NativeConstructorAccessorImpl.newInstance0(Constructor, Object[]) line: not available [native method]
NativeConstructorAccessorImpl.newInstance(Object[]) line: 39
DelegatingConstructorAccessorImpl.newInstance(Object[]) line: 27
Constructor<T>.newInstance(Object...) line: 513
Class<T>.newInstance0() line: 355
Class<T>.newInstance() line: 308
Policy.getPolicyNoCheck() line: 167
ProtectionDomain.implies(Permission) line: 224
AccessControlContext.checkPermission(Permission) line: 352
AccessController.checkPermission(Permission) line: 546
SecurityManager.checkPermission(Permission) line: 532
Policy.getPolicy() line: 133
SecurityManagerInstaller.install(URL...) line: 81
DevAppServerFactory.createDevAppServer(File, File, File, String, int, boolean, boolean, Map<String,Object>) line: 136
DevAppServerFactory.createDevAppServer(File, File, File, String, int, boolean) line: 78
DevAppServerFactory.createDevAppServer(File, String, int) line: 52
DevAppServerMain$StartAction.apply() line: 175
Parser$ParseResult.applyArgs() line: 48
DevAppServerMain.<init>(String[]) line: 128
DevAppServerMain.main(String[]) line: 104}
I went on and downloaded the latest for GAE and the eclipse plugin hoping that would fix it but no luck.
Regards,
John
Fixed - My workspace was corrupt. I created a new workspace folder and had to import my project and settings.