I am trying to implement twilio chat using laravel. I have follow tutorial and try the source from github, https://github.com/TwilioDevEd/twiliochat-laravel. Works well in desktop, but when moving to linux enviroment, it shows error:
(1/1) BindingResolutionException
Unresolvable dependency resolving [Parameter #0 [ <required> $accountSid ]] in class Twilio\Jwt\AccessToken
The linux environment is using Laravel/Lumen 5.8.4
Here's the steps I have done :
composer require twilio/sdk
in routes/web.php :
//twilio
$router->group(['prefix' => 'twilio'], function() use ($router){
$router->post('/token',['uses' => 'TwilioController#generate','as' => 'token-generate']);
});
in app/Http/Controller :
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Http\Requests;
use App\Http\Controllers\Controller;
use Twilio\Jwt\AccessToken;
use Twilio\Jwt\Grants\ChatGrant;
class TwilioController extends Controller
{
public function generate(Request $request, AccessToken $accessToken, ChatGrant $chatGrant)
{
var_dump('test aja');
exit;
$appName = "allsmartchat";
$deviceId = $request->input("device");
$identity = $request->input("identity");
$TWILIO_CHAT_SERVICE_SID = 'IS****'; //my SID
$endpointId = $appName . ":" . $identity . ":" . $deviceId;
$accessToken->setIdentity($identity);
$chatGrant->setServiceSid($TWILIO_CHAT_SERVICE_SID);
$chatGrant->setEndpointId($endpointId);
$accessToken->addGrant($chatGrant);
$response = array(
'identity' => $identity,
'token' => $accessToken->toJWT()
);
return response()->json($response);
}
}
in app/Providers/TwilioAccessProvider.php :
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
use Twilio\Jwt\AccessToken;
class TwilioAccessTokenProvider extends ServiceProvider
{
/**
* Register the application services.
*
* #return void
*/
public function register()
{
$this->app->bind(
AccessToken::class, function ($app) {
$TWILIO_ACCOUNT_SID = 'AC***';
$TWILIO_API_KEY = 'SK***';
$TWILIO_API_SECRET = '***';
$token = new AccessToken(
$TWILIO_ACCOUNT_SID,
$TWILIO_API_KEY,
$TWILIO_API_SECRET,
3600
);
return $token;
}
);
}
}
I use postman to get the token value, in localhost, it produces token :
{
"identity": null,
"token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiIsImN0eSI6InR3aWxpby1mcGE7dj0xIn0.eyJqdGkiOiJTS2E4OGQ2ZjVjNTEyNTkzMWMxMmYxYmFiYmFiZWY4MTU0LTE1NjM0MzkzOTQiLCJpc3MiOiJTS2E4OGQ2ZjVjNTEyNTkzMWMxMmYxYmFiYmFiZWY4MTU0Iiwic3ViIjoiQUFBQUNjZjMyMTdkNWU3NTEwMzA4ZjM2ZDZlYzNhZmJkOGNiZCIsImV4cCI6MTU2MzQ0Mjk5NCwiZ3JhbnRzIjp7ImNoYXQiOnsic2VydmljZV9zaWQiOiJJU2JjM2Y3N2Y2MjEzYjQ3MzliZTBlYTJiOTRiZTc4OWRmIiwiZW5kcG9pbnRfaWQiOiJUd2lsaW9DaGF0OjoifX19.OuAjJs_KGz-J_WTPlrCfAV_bjKmKCvSOTzj_ZGU0mUA"
}
but in server, it shows error :
(1/1) BindingResolutionException
Unresolvable dependency resolving [Parameter #0 [ <required> $accountSid ]] in class Twilio\Jwt\AccessToken
in Container.php line 973
at Container->unresolvablePrimitive(object(ReflectionParameter))
in Container.php line 911
at Container->resolvePrimitive(object(ReflectionParameter))
in Container.php line 852
at Container->resolveDependencies(array(object(ReflectionParameter), object(ReflectionParameter), object(ReflectionParameter), object(ReflectionParameter), object(ReflectionParameter)))
in Container.php line 818
at Container->build('Twilio\\Jwt\\AccessToken')
in Container.php line 667
at Container->resolve('Twilio\\Jwt\\AccessToken', array())
in Container.php line 615
at Container->make('Twilio\\Jwt\\AccessToken', array())
in Application.php line 260
at Application->make('Twilio\\Jwt\\AccessToken')
in BoundMethod.php line 167
at BoundMethod::addDependencyForCallParameter(object(Application), object(ReflectionParameter), array(), array(object(Request)))
in BoundMethod.php line 121
at BoundMethod::getMethodDependencies(object(Application), array(object(TwilioController), 'generate'), array())
in BoundMethod.php line 32
at BoundMethod::Illuminate\Container\{closure}()
in BoundMethod.php line 90
at BoundMethod::callBoundMethod(object(Application), array(object(TwilioController), 'generate'), object(Closure))
in BoundMethod.php line 34
at BoundMethod::call(object(Application), array(object(TwilioController), 'generate'), array(), null)
in Container.php line 576
at Container->call(array(object(TwilioController), 'generate'), array())
in RoutesRequests.php line 376
at Application->callControllerCallable(array(object(TwilioController), 'generate'), array())
in RoutesRequests.php line 342
at Application->callLumenController(object(TwilioController), 'generate', array(true, array('uses' => 'App\\Http\\Controllers\\TwilioController#generate', 'as' => 'token-generate'), array()))
in RoutesRequests.php line 316
at Application->callControllerAction(array(true, array('uses' => 'App\\Http\\Controllers\\TwilioController#generate', 'as' => 'token-generate'), array()))
in RoutesRequests.php line 278
at Application->callActionOnArrayBasedRoute(array(true, array('uses' => 'App\\Http\\Controllers\\TwilioController#generate', 'as' => 'token-generate'), array()))
in RoutesRequests.php line 263
at Application->handleFoundRoute(array(true, array('uses' => 'App\\Http\\Controllers\\TwilioController#generate', 'as' => 'token-generate'), array()))
in RoutesRequests.php line 165
at Application->Laravel\Lumen\Concerns\{closure}(object(Request))
in RoutesRequests.php line 416
at Application->sendThroughPipeline(array(), object(Closure))
in RoutesRequests.php line 171
at Application->dispatch(null)
in RoutesRequests.php line 108
at Application->run()
in index.php line 28
Above solution is ok but also you can add this code in the App Provider it will definately work
First include the class
use Twilio\Jwt\AccessToken;
$this->app->bind(
AccessToken::class,
function ($app) {
$accountSid = config('services.twilio')['accountSid'];
$apiKey = config('services.twilio')['apiKey'];
$apiSecret = config('services.twilio')['apiSecret'];
return new AccessToken($accountSid, $apiKey, $apiSecret, 3600, 'identity');
}
);
solved,
you need to register service in bootstrap/app.php
$app->register(App\Providers\TwilioAccessTokenProvider::class);
$app->register(App\Providers\TwilioChatGrantProvider::class);
also in laravel, you need to register service in config/app.php
App\Providers\TwilioAccessTokenProvider::class,
App\Providers\TwilioChatGrantProvider::class,
Related
I am trying to follow the example in
https://nicolewhite.github.io/neo4j-jupyter/hello-world.html
from scripts.vis import draw
import neo4jupyter
options = {"Person": "name", "Drink": "name", "Manufacturer": "name"}
draw(graph, options)
For this part of the code, I encounter this error:
ypeError Traceback (most recent call last)
<ipython-input-7-6a87e5426fa3> in <module>
3
4 options = {"Person": "name", "Drink": "name", "Manufacturer": "name"}
----> 5 draw(graph, options)
~\PycharmProjects\Knowledge_Graph\scripts\vis.py in draw(graph, options, physics, limit)
104 target_id = row[4]
105
--> 106 source_info = get_vis_info(source_node, source_id)
107
108 if source_info not in nodes:
~\PycharmProjects\Knowledge_Graph\scripts\vis.py in get_vis_info(node, id)
91
92 def get_vis_info(node, id):
---> 93 node_label = list(node.labels())[0]
94 prop_key = options.get(node_label)
95 vis_label = node.properties.get(prop_key, "")
TypeError: 'LabelSetView' object is not callable
I read online that there might be some issues with scripts.vis but I am not too sure how to resolve it
Please checkout the latest version from the below link and it fixes the problem
https://github.com/merqurio/neo4jupyter/issues/5
I'm currently searching for a problem in one of our projects, which uses Xtext to generate java source code.
We use the model inferrer and Xannotation to use javax.* annotations to generate our entities.
import javax.persistence.FetchType
import javax.persistence.Id
import javax.persistence.Column
import javax.persistence.ManyToOne
package test.some.namespace {
domain DomainA {
entity for table "DOMAINA" {
#Id
#Column(name = "DAIA", unique = true)
Long id;
}
}
domain DomainB {
entity for table "DOMAINB" {
#Id
#Column(name = "DAIB", unique = true)
Long id;
#ManyToOne(fetch = FetchType::LAZY)
DomainA domainA;
}
}
domain DomainC {
entity for table "DOMAINC" {
#Id
#Column(name = "DAIC", unique = true)
Long id;
#ManyToOne(fetch = FetchType::LAZY)
DomainA domainA;
}
}
}
We search for the annotation by iterating through XAnnotationElementValuePair pair : annotation.getElementValuePairs() and return the value pair.getValue(), so far it works.
Now we try to access the FetchType with (exp as XMemberFeatureCall).feature where exp is the result of pair.getValue().
For DomainB.domainA it will return an instance of org.eclipse.xtext.common.types.impl.JvmEnumerationLiteralImplCustom.
For DomainC.domainA it will return an instance of org.eclipse.xtext.common.types.impl.JvmVoidImplCustom.
This problem only occurs when I save the document. This is the current thread stack from eclipse.
Thread [Worker-5] (Suspended (breakpoint at line 60 in CustomDSLJvmModelInferrer$2))
owns: ClusteringBuilderState (id=19135)
CustomDSLJvmModelInferrer.xtend line: 60
JvmDispatchableModelAssociator.installDerivedState(DerivedStateAwareResource, boolean) line: 66
BatchLinkableResource(DerivedStateAwareResource).installDerivedState(boolean) line: 159
DerivedStateAwareResourceDescriptionManager.internalGetResourceDescription(Resource, IDefaultResourceDescriptionStrategy) line: 53
DefaultResourceDescriptionManager$1.get() line: 60
DefaultResourceDescriptionManager$1.get() line: 1
OnChangeEvictingCache.get(Object, Resource, Provider<T>) line: 75
DerivedStateAwareResourceDescriptionManager(DefaultResourceDescriptionManager).getResourceDescription(Resource) line: 58
ClusteringBuilderState.writeNewResourceDescriptions(BuildData, IResourceDescriptions, CurrentDescriptions, IProgressMonitor) line: 366
ClusteringBuilderState.doUpdate(BuildData, ResourceDescriptionsData, IProgressMonitor) line: 121
ClusteringBuilderState(AbstractBuilderState).update(BuildData, IProgressMonitor) line: 112
XtextBuilder.doBuild(ToBeBuilt, IProgressMonitor, IXtextBuilderParticipant$BuildType) line: 194
XtextBuilder.incrementalBuild(IResourceDelta, IProgressMonitor) line: 171
XtextBuilder.build(int, Map, IProgressMonitor) line: 99
BuildManager$2.run() line: 734
SafeRunner.run(ISafeRunnable) line: 42
BuildManager.basicBuild(int, IncrementalProjectBuilder, Map<String,String>, MultiStatus, IProgressMonitor) line: 206
BuildManager.basicBuild(IBuildConfiguration, int, IBuildContext, ICommand[], MultiStatus, IProgressMonitor) line: 246
BuildManager$1.run() line: 299
SafeRunner.run(ISafeRunnable) line: 42
BuildManager.basicBuild(IBuildConfiguration, int, IBuildContext, MultiStatus, IProgressMonitor) line: 302
BuildManager.basicBuildLoop(IBuildConfiguration[], IBuildConfiguration[], int, MultiStatus, IProgressMonitor) line: 358
BuildManager.build(IBuildConfiguration[], IBuildConfiguration[], int, IProgressMonitor) line: 381
AutoBuildJob.doBuild(IProgressMonitor) line: 143
AutoBuildJob.run(IProgressMonitor) line: 241
Worker.run() line: 54
But it works fine if I just modify the document without saving. Stack from eclipse:
Thread [Worker-3] (Suspended (breakpoint at line 60 in CustomDSLJvmModelInferrer$2))
owns: DirtyStateManager (id=19093)
owns: Object (id=19094)
CustomDSLJvmModelInferrer.xtend line: 60
JvmDispatchableModelAssociator.installDerivedState(DerivedStateAwareResource, boolean) line: 66
BatchLinkableResource(DerivedStateAwareResource).installDerivedState(boolean) line: 159
DirtyStateResourceDescription$Manager.getResourceDescription(Resource) line: 65
DirtyStateEditorSupport.announceDirtyState(XtextResource) line: 467
XtextDocumentReconcileStrategy.postParse(XtextResource, IProgressMonitor) line: 160
XtextDocumentReconcileStrategy.doReconcile(IRegion) line: 146
XtextDocumentReconcileStrategy.reconcile(IRegion) line: 65
XtextReconciler.doRun(XtextResource, IProgressMonitor) line: 401
XtextReconciler.access$3(XtextReconciler, XtextResource, IProgressMonitor) line: 386
XtextReconciler$1.process(XtextResource) line: 327
XtextReconciler$1.process(Object) line: 1
XtextReconciler$1(IUnitOfWork$Void).exec(T) line: 36
XtextDocument$XtextDocumentLocker.modify(IUnitOfWork<T,XtextResource>) line: 418
XtextDocument.internalModify(IUnitOfWork<T,XtextResource>) line: 131
XtextReconciler.run(IProgressMonitor) line: 324
Worker.run() line: 54
So far I am all out of ideas. Is it a bug? Is there something i missed?
I hope you guys can help me.
Best regards
I have a problem using Dart postgresql database driver (xxgreg on Github) insofar as when the postgresql server is not running and it needs to be, I am unable to correctly handle the error. I’ve attempted to solve this for a while now, so any help would be appreciated. I can easily work around it by handling it silently and simply testing if the database connection object is null, however I think it should be possible to handle the raising of an error. It should be noted that when the Postgresql server is running, there is no problem.
The error that I am getting is as follows :
“Uncaught Error: Exception: fConnectToDb: Database is not connected
Stack Trace: ………….”
The problem area relates to these lines of code : (Line 663 is called from line 169 below)
663 async.Future<bool> fConnectToDb(String sUri) {
664 async.Completer<bool> oCompleter = new async.Completer<bool>();
665
666 pg.connect(sUri)
667 .catchError((oError) {
668 String sErrorMsg = (oError is SocketException) ?
669 "Database is not connected"
670 : "Fatal error encountered ${oError}";
671 throw("fConnectToDb: ${sErrorMsg}");
//(expanded below)
I have previously encountered problems in this area where at line 671, instead of throwing an exception, I called an internal method which displayed an error, and terminated the program. I found however what appeared to be a problem doing that, and I found in that situation, throwing an error enabled the program to exit the Future method, and not doing that appeared to be the problem. The problem may relate to the Future not being completed, but I don’t know how to do that and also throw an exception.
The overall code in-question is as follows. I put a try at line 167… 406, however that doesn’t catch the error either.
164 /*
165 * Connect to database
166 */
167 try {
168 sCheckpoint = "Connect to Database";
169 fConnectToDb(sUri)
170 .catchError((oError) =>
171 fFatal(sCheckpoint, "Error = \n${oError}"))
172 .then((_) {
173 if (ogDb == null) // ogDb is global object for db connection
174 fFatal(sCheckpoint, "Database did not connect");
175
176 /*
177 * Perform an SQL Select to test connection
178 */
179 ogPrintLine.fPrintForce("Testing Db connection .....");
180 sCheckpoint = "test connection";
181 return fProcessSqlSelect ("SELECT count(*) FROM ${S_TABLE_NAME}",
182 false);
183 }).then((llResult) {
184
…………
…………
// (catch related to line 167)
406 } catch(oError) {fFatal("Program Main()",
407 "Checkpoint ${sCheckpoint}, Error = \n${oError}");}
408 }
………..
………..
660 /*
661 * Connect To Database
662 */
663 async.Future<bool> fConnectToDb(String sUri) {
664 async.Completer<bool> oCompleter = new async.Completer<bool>();
665
666 pg.connect(sUri)
667 .catchError((oError) {
668 String sErrorMsg = (oError is SocketException) ?
669 "Database is not connected"
670 : "Fatal error encountered ${oError}";
671 throw("fConnectToDb: ${sErrorMsg}");
672
673 }).then((pg.Connection oDb) {
674 ogDb = oDb;
675 oCompleter.complete(true);
676 return;
677
678 });
679
680 return oCompleter.future;
681 }
As far as I can determine, it appears to me that it's Ok to throw an error in a Future providing it's followed by a catchError() that doesn't throw an error.
The following code appears to solve the problem that I was having :
/*
* Connect To Database
*/
async.Future<bool> fConnectToDb(String sUri) {
async.Completer<bool> oCompleter = new async.Completer<bool>();
pg.connect(sUri).then((pg.Connection oDb) {
ogDb = oDb; // assign to global database object
oCompleter.complete(true);
return;
}).catchError((oError) =>
fFatal("fConnectToDb", "Error=\n${oError}"));
return oCompleter.future;
}
I have been debugging for many, many hours but I can't understand why the code is not working.
Two service classes, annotated in the same way, show a different interceptor behaviour.
Stack trace #1:
Daemon Thread [http-thread-pool-8080(1)] (Suspended (breakpoint at line 120 in UserService))
UserService.saveUserOnLogin(UserBE) line: 120
NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not available [native method]
NativeMethodAccessorImpl.invoke(Object, Object[]) line: 57
DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 43
Method.invoke(Object, Object...) line: 601
EJBSecurityManager.runMethod(Method, Object, Object[]) line: 1052
EJBSecurityManager.invoke(Method, boolean, Object, Object[]) line: 1124
StatelessSessionContainer(BaseContainer).invokeBeanMethod(EjbInvocation) line: 5388
EjbInvocation.invokeBeanMethod() line: 619
AroundInvokeChainImpl.invokeNext(int, InterceptorManager$AroundInvokeContext) line: 800
EjbInvocation.proceed() line: 571
_GuiceInterceptor_Serializable(GuiceInterceptor).injectByGuice(InvocationContext) line: 24
NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not available [native method]
NativeMethodAccessorImpl.invoke(Object, Object[]) line: 57
DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 43
Method.invoke(Object, Object...) line: 601
AroundInvokeInterceptor.intercept(InterceptorManager$AroundInvokeContext) line: 861
AroundInvokeChainImpl.invokeNext(int, InterceptorManager$AroundInvokeContext) line: 800
EjbInvocation.proceed() line: 571
_SystemInterceptorProxy_Serializable(SystemInterceptorProxy).doAround(InvocationContext, Method) line: 162
_SystemInterceptorProxy_Serializable(SystemInterceptorProxy).aroundInvoke(InvocationContext) line: 144
NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not available [native method]
NativeMethodAccessorImpl.invoke(Object, Object[]) line: 57
DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 43
Method.invoke(Object, Object...) line: 601
AroundInvokeInterceptor.intercept(InterceptorManager$AroundInvokeContext) line: 861
AroundInvokeChainImpl.invokeNext(int, InterceptorManager$AroundInvokeContext) line: 800
InterceptorManager.intercept(InterceptorManager$InterceptorChain, InterceptorManager$AroundInvokeContext) line: 370
StatelessSessionContainer(BaseContainer).__intercept(EjbInvocation) line: 5360
StatelessSessionContainer(BaseContainer).intercept(EjbInvocation) line: 5348
EJBLocalObjectInvocationHandler.invoke(Class, Method, Object[]) line: 214
EJBLocalObjectInvocationHandlerDelegate.invoke(Object, Method, Object[]) line: 88
$Proxy209.saveUserOnLogin(UserBE) line: not available
__EJB31_Generated__UserService__Intf____Bean__.saveUserOnLogin(UserBE) line: not available
LoginUserHandler.saveUser(UserDTO) line: 165
LoginUserHandler.loginUser(UserDTO) line: 123
LoginUserHandler.loginWithOAuth(String, String, String, String) line: 158
LoginUserHandler.execute(LoginUser, ExecutionContext) line: 103
LoginUserHandler.execute(Action, ExecutionContext) line: 1
GuiceDispatch(AbstractDispatch).doExecute(A, ExecutionContext) line: 81
GuiceDispatch(AbstractDispatch).execute(A) line: 68
HupaDispatchServlet(AbstractSecureDispatchServlet).execute(String, Action<?>) line: 29
HupaDispatchServlet.execute(String, Action<?>) line: 56
NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not available [native method]
NativeMethodAccessorImpl.invoke(Object, Object[]) line: 57
DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 43
Method.invoke(Object, Object...) line: 601
RPC.invokeAndEncodeResponse(Object, Method, Object[], SerializationPolicy, int) line: 569
HupaDispatchServlet(RemoteServiceServlet).processCall(String) line: 208
HupaDispatchServlet(RemoteServiceServlet).processPost(HttpServletRequest, HttpServletResponse) line: 248
HupaDispatchServlet(AbstractRemoteServiceServlet).doPost(HttpServletRequest, HttpServletResponse) line: 62
HupaDispatchServlet(HttpServlet).service(HttpServletRequest, HttpServletResponse) line: 688
HupaDispatchServlet(HttpServlet).service(ServletRequest, ServletResponse) line: 770
ServletDefinition.doService(ServletRequest, ServletResponse) line: 263
ServletDefinition.service(ServletRequest, ServletResponse) line: 178
ManagedServletPipeline.service(ServletRequest, ServletResponse) line: 91
FilterChainInvocation.doFilter(ServletRequest, ServletResponse) line: 62
ManagedFilterPipeline.dispatch(ServletRequest, ServletResponse, FilterChain) line: 118
GuiceFilter.doFilter(ServletRequest, ServletResponse, FilterChain) line: 113
ApplicationFilterChain.internalDoFilter(ServletRequest, ServletResponse) line: 256
ApplicationFilterChain.doFilter(ServletRequest, ServletResponse) line: 217
StandardWrapperValve.invoke(Request, Response) line: 279
StandardContextValve.invoke(Request, Response) line: 175
StandardPipeline.doInvoke(Request, Response, boolean) line: 655
StandardPipeline.invoke(Request, Response) line: 595
StandardHostValve.invoke(Request, Response) line: 161
CoyoteAdapter.doService(Request, Request, Response, Response) line: 331
CoyoteAdapter.service(Request, Response) line: 231
ContainerMapper$AdapterCallable.call() line: 317
ContainerMapper.service(Request, Response) line: 195
ProcessorTask.invokeAdapter() line: 849
ProcessorTask.doProcess() line: 746
ProcessorTask.process(InputStream, OutputStream) line: 1045
DefaultProtocolFilter.execute(Context) line: 228
HttpProtocolChain(DefaultProtocolChain).executeProtocolFilter(Context, int) line: 137
HttpProtocolChain(DefaultProtocolChain).execute(Context, int) line: 104
HttpProtocolChain(DefaultProtocolChain).execute(Context) line: 90
HttpProtocolChain.execute(Context) line: 79
ProtocolChainContextTask.doCall() line: 54
ProtocolChainContextTask(SelectionKeyContextTask).call() line: 59
ProtocolChainContextTask(ContextTask).run() line: 71
FixedThreadPool$BasicWorker(AbstractThreadPool$Worker).doWork() line: 532
FixedThreadPool$BasicWorker(AbstractThreadPool$Worker).run() line: 513
HttpWorkerThread(Thread).run() line: 722
Stack trace #2
Daemon Thread [http-thread-pool-8080(2)] (Suspended (entry into method synchronizeHeaders in MessageService))
__EJB31_Generated__MessageService__Intf____Bean__(MessageService).synchronizeHeaders(String) line: 93
FetchMessagesHandler.executeInternal(FetchMessages, ExecutionContext) line: 80
FetchMessagesHandler.executeInternal(Action, ExecutionContext) line: 1
FetchMessagesHandler(AbstractSessionHandler<A,R>).executeWithRetries(A, ExecutionContext, int) line: 127
FetchMessagesHandler(AbstractSessionHandler<A,R>).execute(A, ExecutionContext) line: 97
GuiceDispatch(AbstractDispatch).doExecute(A, ExecutionContext) line: 81
GuiceDispatch(AbstractDispatch).execute(A) line: 68
HupaDispatchServlet(AbstractSecureDispatchServlet).execute(String, Action<?>) line: 29
HupaDispatchServlet.execute(String, Action<?>) line: 56
NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not available [native method]
NativeMethodAccessorImpl.invoke(Object, Object[]) line: 57
DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 43
Method.invoke(Object, Object...) line: 601
RPC.invokeAndEncodeResponse(Object, Method, Object[], SerializationPolicy, int) line: 569
HupaDispatchServlet(RemoteServiceServlet).processCall(String) line: 208
HupaDispatchServlet(RemoteServiceServlet).processPost(HttpServletRequest, HttpServletResponse) line: 248
HupaDispatchServlet(AbstractRemoteServiceServlet).doPost(HttpServletRequest, HttpServletResponse) line: 62
HupaDispatchServlet(HttpServlet).service(HttpServletRequest, HttpServletResponse) line: 688
HupaDispatchServlet(HttpServlet).service(ServletRequest, ServletResponse) line: 770
ServletDefinition.doService(ServletRequest, ServletResponse) line: 263
ServletDefinition.service(ServletRequest, ServletResponse) line: 178
ManagedServletPipeline.service(ServletRequest, ServletResponse) line: 91
FilterChainInvocation.doFilter(ServletRequest, ServletResponse) line: 62
ManagedFilterPipeline.dispatch(ServletRequest, ServletResponse, FilterChain) line: 118
GuiceFilter.doFilter(ServletRequest, ServletResponse, FilterChain) line: 113
ApplicationFilterChain.internalDoFilter(ServletRequest, ServletResponse) line: 256
ApplicationFilterChain.doFilter(ServletRequest, ServletResponse) line: 217
StandardWrapperValve.invoke(Request, Response) line: 279
StandardContextValve.invoke(Request, Response) line: 175
StandardPipeline.doInvoke(Request, Response, boolean) line: 655
StandardPipeline.invoke(Request, Response) line: 595
StandardHostValve.invoke(Request, Response) line: 161
CoyoteAdapter.doService(Request, Request, Response, Response) line: 331
CoyoteAdapter.service(Request, Response) line: 231
ContainerMapper$AdapterCallable.call() line: 317
ContainerMapper.service(Request, Response) line: 195
ProcessorTask.invokeAdapter() line: 849
ProcessorTask.doProcess() line: 746
ProcessorTask.process(InputStream, OutputStream) line: 1045
DefaultProtocolFilter.execute(Context) line: 228
HttpProtocolChain(DefaultProtocolChain).executeProtocolFilter(Context, int) line: 137
HttpProtocolChain(DefaultProtocolChain).execute(Context, int) line: 104
HttpProtocolChain(DefaultProtocolChain).execute(Context) line: 90
HttpProtocolChain.execute(Context) line: 79
ProtocolChainContextTask.doCall() line: 54
ProtocolChainContextTask(SelectionKeyContextTask).call() line: 59
ProtocolChainContextTask(ContextTask).run() line: 71
FixedThreadPool$BasicWorker(AbstractThreadPool$Worker).doWork() line: 532
FixedThreadPool$BasicWorker(AbstractThreadPool$Worker).run() line: 513
HttpWorkerThread(Thread).run() line: 722
It seems as if the interceptor is not invoked for the message service class. However, it does work for the user service class. Why could this be?
The message service class:
#Stateless
#Interceptors(GuiceInterceptor.class)
public class MessageService {
/**
* The gmail folder default.
*/
private static final String GMAIL_ALL_MAIL = "[Gmail]/All Mail";
/**
* The IMAP store cache.
*/
#Inject
private IMAPStoreCache imapStoreCache;
/**
* The EJB resolver.
*/
#Inject
private EJBResolver ejbResolver;
The user service class:
#Stateless
#Interceptors(GuiceInterceptor.class)
public class UserService {
/**
* The entity manager.
*/
#PersistenceContext(unitName = "hupa")
private EntityManager em;
/**
* The session provider.
*/
#Inject
private Provider<HttpSession> sessionProvider;
And finally the interceptor:
public class GuiceInterceptor {
#EJB
private GuiceInjectorHolder injectorHolder;
#AroundInvoke
#AroundTimeout
public Object injectByGuice(InvocationContext invocationContext) throws Exception {
Injector injector = injectorHolder.getInjector();
injector.injectMembers(invocationContext.getTarget());
return invocationContext.proceed();
}
}
Hope there are experts on this, I am frustrated ;)
The problem was that I could not use the final modifier anywhere in the class or it would not work with Guice. Not even on auxiliary helper methods.
Can you fill in details on who is invoking MessageService and how they obtained a reference to it?
My first guess is that whoever is invoking MessageService has a direct reference to the instance itself and is not invoking the bean via the container-created proxy that is obtained via either #EJB MessageService service; injection or JNDI lookup.
See this answer on the importance of using the proxy and how that differs from using the this or similar direct reference to the bean instance.
I use symfony 1.4.11. In my site I have 3 languages in my site "se","en","no". In my backend, I use only en, and I have in settings:
all:
.settings:
default_culture: en
But in some module, when in frontend I have "se" language, have error :
Data file for "se" was not found.
In frontend I try, make i18n with database;
Stack trace:
stack trace
at ()
in SF_SYMFONY_LIB_DIR/i18n/sfCultureInfo.class.php line 301 ...
if (is_file($filename) == false)
{
throw new sfException(sprintf('Data file for "%s" was not found.', $file));
}
if (in_array($filename, $this->dataFiles) == false)
at sfCultureInfo->loadCultureData('se')
in SF_SYMFONY_LIB_DIR/i18n/sfCultureInfo.class.php line 217 ...
at sfCultureInfo->__construct('se')
in SF_SYMFONY_LIB_DIR/i18n/sfCultureInfo.class.php line 136 ...
at sfCultureInfo::getInstance('se')
in SF_SYMFONY_LIB_DIR/i18n/sfDateTimeFormatInfo.class.php line 186 ...
at sfDateTimeFormatInfo::getInstance('se')
in SF_SYMFONY_LIB_DIR/i18n/sfDateFormat.class.php line 100 ...
at sfDateFormat->__construct('se')
in SF_SYMFONY_LIB_DIR/helper/DateHelper.php line 57 ...
at format_date('2011-07-22 01:36:02', 'f')
in SF_ROOT_DIR/cache/backend/dev/modules/autoSfGuardUser/templates/_list_td_tabular.php line 5 ...
at require('/home/dan/WEB/www/europellets-dev.my/cache/backend/dev/modules/autoSfGuardUser/templates/_list_td_tabular.php')
in SF_SYMFONY_LIB_DIR/view/sfPHPView.class.php line 75 ...
at sfPHPView->renderFile('/home/dan/WEB/www/europellets-dev.my/cache/backend/dev/modules/autoSfGuardUser/templates/_list_td_tabular.php')
in SF_SYMFONY_LIB_DIR/view/sfPartialView.class.php line 124 ...
at sfPartialView->render()
in SF_SYMFONY_LIB_DIR/helper/PartialHelper.php line 218 ...
at get_partial('sfGuardUser/list_td_tabular', array('sf_guard_user' => object('sfOutputEscaperIteratorDecorator')))
in SF_SYMFONY_LIB_DIR/helper/PartialHelper.php line 180 ...
at include_partial('sfGuardUser/list_td_tabular', array('sf_guard_user' => object('sfOutputEscaperIteratorDecorator')))
in SF_ROOT_DIR/cache/backend/dev/modules/autoSfGuardUser/templates/_list.php line 31 ...
at require('/home/dan/WEB/www/europellets-dev.my/cache/backend/dev/modules/autoSfGuardUser/templates/_list.php')
in SF_SYMFONY_LIB_DIR/view/sfPHPView.class.php line 75 ...
at sfPHPView->renderFile('/home/dan/WEB/www/europellets-dev.my/cache/backend/dev/modules/autoSfGuardUser/templates/_list.php')
in SF_SYMFONY_LIB_DIR/view/sfPartialView.class.php line 124 ...
at sfPartialView->render()
in SF_SYMFONY_LIB_DIR/helper/PartialHelper.php line 218 ...
at get_partial('sfGuardUser/list', array('pager' => object('sfOutputEscaperIteratorDecorator'), 'sort' => object('sfOutputEscaperArrayDecorator'), 'helper' => object('sfGuardUserGeneratorHelper')))
in SF_SYMFONY_LIB_DIR/helper/PartialHelper.php line 180 ...
at include_partial('sfGuardUser/list', array('pager' => object('sfOutputEscaperIteratorDecorator'), 'sort' => object('sfOutputEscaperArrayDecorator'), 'helper' => object('sfGuardUserGeneratorHelper')))
in SF_ROOT_DIR/cache/backend/dev/modules/autoSfGuardUser/templates/indexSuccess.php line 19 ...
at require('/home/dan/WEB/www/europellets-dev.my/cache/backend/dev/modules/autoSfGuardUser/templates/indexSuccess.php')
in SF_SYMFONY_LIB_DIR/view/sfPHPView.class.php line 75 ...
at sfPHPView->renderFile('/home/dan/WEB/www/europellets-dev.my/cache/backend/dev/modules/autoSfGuardUser/templates/indexSuccess.php')
in SF_SYMFONY_LIB_DIR/view/sfPHPView.class.php line 185 ...
at sfPHPView->render()
in SF_SYMFONY_LIB_DIR/filter/sfExecutionFilter.class.php line 155 ...
at sfExecutionFilter->executeView('sfGuardUser', 'index', 'Success', array('configuration' => object('sfGuardUserGeneratorConfiguration'), 'helper' => object('sfGuardUserGeneratorHelper'), 'filters' => object('sfGuardUserFormFilter'), 'pager' => object('sfDoctrinePager'), 'sort' => array(null, null)))
in SF_SYMFONY_LIB_DIR/filter/sfExecutionFilter.class.php line 116 ...
at sfExecutionFilter->handleView(object('sfFilterChain'), object('sfGuardUserActions'), 'Success')
in SF_SYMFONY_LIB_DIR/filter/sfExecutionFilter.class.php line 47 ...
at sfExecutionFilter->execute(object('sfFilterChain'))
in SF_SYMFONY_LIB_DIR/filter/sfFilterChain.class.php line 53 ...
at sfFilterChain->execute()
in SF_SYMFONY_LIB_DIR/filter/sfRenderingFilter.class.php line 33 ...
at sfRenderingFilter->execute(object('sfFilterChain'))
in SF_SYMFONY_LIB_DIR/filter/sfFilterChain.class.php line 53 ...
at sfFilterChain->execute()
in SF_SYMFONY_LIB_DIR/controller/sfController.class.php line 238 ...
at sfController->forward('sfGuardUser', 'index')
in SF_SYMFONY_LIB_DIR/controller/sfFrontWebController.class.php line 48 ...
at sfFrontWebController->dispatch()
in SF_SYMFONY_LIB_DIR/util/sfContext.class.php line 170 ...
at sfContext->dispatch()
in SF_ROOT_DIR/web/backend_dev.php line 13 ...
This error means that there is no ICU data file inside SF_SYMFONY_LIB_DIR/i18n/data/ dir for the 'se' culture. Symfony supports many cultures, but not all. In your case, if 'se' is Swedish - use 'sv' code.
sv sv-SE Swedish
sv-FI sv-FI Swedish (Finland)
sv-SE sv-SE Swedish (Sweden)
If 'se' is not Swedish and it is not in out of the box list (see SF_SYMFONY_LIB_DIR/i18n/data/ dir) - use internal tokens instead of pattern (e.g. format_date($date, 'f') -> format_date($date, 'd MMMM YYYY, hh:mm')) formatDateHowTo