Showing Null pointer exception** in this code.
** yrWebService.getUserInfo()**
I have tried most of the things but I can't figure it out.
Anyone please help to fix this issue.
The getUserInfo() throwing null pointer exception.
someone help me to solve this. I pasted the interface down there.
public void fetchUserProfile() {
YRWebService.getUserInfo()
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Observer<YRUserResponse>() {
#Override
public void onError(Throwable e) {
Toast.makeText(YarraApplication.this, "Error on server :" +e, Toast.LENGTH_SHORT).show();
}
#Override
public void onComplete() {
}
#Override
public void onSubscribe(Disposable d) {
}
#Override
public void onNext(YRUserResponse yrUserResponse) {
//progressDialog.dismiss();
if (yrUserResponse != null) {
if (yrUserResponse.getUser() != null) {
YRPreferenceManager.setString(PreferenceKeys.USER_PROFILE_RESPONSE,
new Gson().toJson(yrUserResponse));
YRUser yrUser = yrUserResponse.getUser();
YarraApplication.userId = yrUserResponse.getUser().getUser_id();
YarraApplication.access = yrUserResponse.getUser().getGoogle_access_token();
YarraApplication.email = yrUser.getEmail();
YarraApplication.fName = yrUser.getFirst_name();
YarraApplication.lName = yrUser.getLast_name();
YarraApplication.mobile = yrUser.getTelephone();
}else {
// YRUtils.showUnknownErrorDialog(YarraApplication.this);
}
}// else {
// YRUtils.showUnknownErrorDialog(UserProfileActivity.this);
// }
}
});
}
**Interface :::: **
The interface we are using here is this
public interface YRWebService {
#GET("/users")
Observable<YRUserResponse> getUserInfo();
}
public class YRUserResponse {
List<YRError> errors;
YRUser user;
public YRUser getUser() {
return user;
}
public void setUser(YRUser user) {
this.user = user;
}
**retrofit.RetrofitError**:
```
2019-05-06 15:26:49.506 30475-30475/com.rever.app E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.rever.app, PID: 30475
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.rever.app/com.rever.app.UserProfileActivity}: retrofit.RetrofitError
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2814)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2892)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1613)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:176)
at android.app.ActivityThread.main(ActivityThread.java:6635)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:823)
Caused by: retrofit.RetrofitError
at retrofit.RestAdapter$RestHandler.invokeRequest(RestAdapter.java:400)
at retrofit.RestAdapter$RestHandler.invoke(RestAdapter.java:240)
at java.lang.reflect.Proxy.invoke(Proxy.java:913)
at $Proxy0.getUserInfo(Unknown Source)
at com.rever.app.UserProfileActivity.fetchUserProfile(UserProfileActivity.java:220)
at com.rever.app.UserProfileActivity.onCreate(UserProfileActivity.java:132)
at android.app.Activity.performCreate(Activity.java:7084)
at android.app.Activity.performCreate(Activity.java:7075)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1215)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2767)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2892)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1613)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:176)
at android.app.ActivityThread.main(ActivityThread.java:6635)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:823)
Caused by: android.os.NetworkOnMainThreadException
at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1450)
at java.net.Inet6AddressImpl.lookupHostByName(Inet6AddressImpl.java:102)
at java.net.Inet6AddressImpl.lookupAllHostAddr(Inet6AddressImpl.java:90)
at java.net.InetAddress.getAllByName(InetAddress.java:787)
at com.squareup.okhttp.internal.Dns$1.getAllByName(Dns.java:29)
at com.squareup.okhttp.internal.http.RouteSelector.resetNextInetSocketAddress(RouteSelector.java:231)
at com.squareup.okhttp.internal.http.RouteSelector.next(RouteSelector.java:124)
at com.squareup.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:317)
at com.squareup.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:241)
at com.squareup.okhttp.Call.getResponse(Call.java:198)
at com.squareup.okhttp.Call.execute(Call.java:80)
at retrofit.client.OkClient.execute(OkClient.java:53)
at retrofit.RestAdapter$RestHandler.invokeRequest(RestAdapter.java:326)
at retrofit.RestAdapter$RestHandler.invoke(RestAdapter.java:240)
at java.lang.reflect.Proxy.invoke(Proxy.java:913)
at $Proxy0.getUserInfo(Unknown Source)
at com.rever.app.UserProfileActivity.fetchUserProfile(UserProfileActivity.java:220)
at com.rever.app.UserProfileActivity.onCreate(UserProfileActivity.java:132)
at android.app.Activity.performCreate(Activity.java:7084)
at android.app.Activity.performCreate(Activity.java:7075)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1215)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2767)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2892)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1613)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:176)
at android.app.ActivityThread.main(ActivityThread.java:6635)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:823)
```
Related
Axon framework version : 4.4.7
Axon server : 4.5.7
#Component
#ProcessingGroup("product-group")
public class ProductEventHandler {
private final ProductRepository productsRepository;
private final QueryUpdateEmitter queryUpdateEmitter;
public ProductEventHandler(ProductRepository productsRepository, QueryUpdateEmitter queryUpdateEmitter) {
this.productsRepository = productsRepository;
this.queryUpdateEmitter = queryUpdateEmitter;
}
#EventHandler
public void handle(ProductCreatedEvent event) throws Exception {
ProductEntity entity = new ProductEntity();
BeanUtils.copyProperties(event, entity);
try {
productsRepository.save(entity);
} catch (IllegalArgumentException ex) {
ex.printStackTrace();
}
}
#EventHandler
public void handle(ProductUpdatedEvent event) {
ProductEntity entity = new ProductEntity();
BeanUtils.copyProperties(event, entity);
try {
productsRepository.save(entity);
} catch (IllegalArgumentException ex) {
ex.printStackTrace();
}
ProductResponse productResponse = new ProductResponse();
productResponse.setProductId(event.getProductId());
productResponse.setStatus("Updated");
//queryUpdateEmitter.emit(FetchProductQuery.class, query -> true, productResponse);
queryUpdateEmitter.emit(FetchProductQuery.class,
query -> query.getProductId().equals(event.getProductId()), productResponse);
}
}
#RestController
#RequestMapping("/product")
public class ProductController {
private final CommandGateway commandGateway;
private final QueryGateway queryGateway;
private SubscriptionQueryResult<ProductResponse, ProductResponse> queryResult;
#Autowired
public ProductController(CommandGateway commandGateway, QueryGateway queryGateway) {
this.queryGateway = queryGateway;
this.commandGateway = commandGateway;
}
#PutMapping("/{id}")
public ProductResponse updateProduct(#PathVariable("id") String id,
#Valid #RequestBody ProductRequest request) {
UpdateProductCommand updateProductCommand = UpdateProductCommand.builder().productId(id)
.price(request.getPrice()).quantity(request.getQuantity()).title(request.getTitle()).build();
commandGateway.sendAndWait(updateProductCommand);
queryResult = queryGateway.subscriptionQuery(
FetchProductQuery.builder().productId(id), ResponseTypes.instanceOf(ProductResponse.class),
ResponseTypes.instanceOf(ProductResponse.class));
try {
// return queryResult.updates().blockFirst();
return queryResult.initialResult().block();
} catch (Exception e) {
e.printStackTrace();
throw e;
} finally {
queryResult.close();
}
}
}
#Component
public class ProductsQueryHandler {
private final ProductRepository productsRepository;
public ProductsQueryHandler(ProductRepository productsRepository) {
this.productsRepository = productsRepository;
}
#QueryHandler
public ProductResponse handler(FetchProductQuery query) {
ProductEntity productEntity = productsRepository.findByProductId(query.getProductId());
ProductResponse productResponse = new ProductResponse();
BeanUtils.copyProperties(productEntity, productResponse);
return productResponse;
}
}
I could not see any subscription queries in AXON dashboard, getting below error. Can you please help me for the cause and solution???
2021-10-21 18:09:42.468[0;39m [32m INFO[0;39m [35m19608[0;39m [2m---[0;39m [2m[nio-8888-exec-2][0;39m [36mo.a.m.interceptors.LoggingInterceptor [0;39m [2m:[0;39m Dispatched messages: [FetchProductQueryBuilder]
org.axonframework.axonserver.connector.AxonServerException: CANCELLED: AXONIQ-5000
at org.axonframework.axonserver.connector.ErrorCode.lambda$static$24(ErrorCode.java:145)
at org.axonframework.axonserver.connector.ErrorCode.convert(ErrorCode.java:182)
at org.axonframework.axonserver.connector.ErrorCode.convert(ErrorCode.java:213)
at org.axonframework.axonserver.connector.ErrorCode.convert(ErrorCode.java:202)
at org.axonframework.axonserver.connector.event.util.GrpcExceptionParser.parse(GrpcExceptionParser.java:57)
at reactor.core.publisher.Mono.lambda$onErrorMap$31(Mono.java:3437)
at reactor.core.publisher.FluxOnErrorResume$ResumeSubscriber.onError(FluxOnErrorResume.java:94)
at reactor.core.publisher.MonoCompletionStage.lambda$subscribe$0(MonoCompletionStage.java:79)
at java.base/java.util.concurrent.CompletableFuture.uniWhenComplete(CompletableFuture.java:859)
at java.base/java.util.concurrent.CompletableFuture.uniWhenCompleteStage(CompletableFuture.java:883)
at java.base/java.util.concurrent.CompletableFuture.whenComplete(CompletableFuture.java:2321)
at java.base/java.util.concurrent.CompletableFuture.whenComplete(CompletableFuture.java:143)
at reactor.core.publisher.MonoCompletionStage.subscribe(MonoCompletionStage.java:57)
at reactor.core.publisher.MonoDefer.subscribe(MonoDefer.java:52)
at reactor.core.publisher.Mono.subscribe(Mono.java:4099)
at reactor.core.publisher.Mono.block(Mono.java:1702)
at com.demo.product.controller.ProductController.updateProduct(ProductController.java:75)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:78)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:567)
at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:197)
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:141)
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:106)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:894)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:808)
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1060)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:962)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006)
at org.springframework.web.servlet.FrameworkServlet.doPut(FrameworkServlet.java:920)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:655)
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:733)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:227)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:202)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:542)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:143)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:357)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:374)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:893)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1707)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:630)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.base/java.lang.Thread.run(Thread.java:831)
Suppressed: java.lang.Exception: #block terminated with an error
at reactor.core.publisher.BlockingSingleSubscriber.blockingGet(BlockingSingleSubscriber.java:99)
at reactor.core.publisher.Mono.block(Mono.java:1703)
... 51 more
[2m2021-10-21 18:09:42.493[0;39m [33m WARN[0;39m [35m19608[0;39m [2m---[0;39m [2m[nio-8888-exec-2][0;39m [36m.m.m.a.ExceptionHandlerExceptionResolver[0;39m [2m:[0;39m Resolved [org.axonframework.axonserver.connector.AxonServerException: CANCELLED: AXONIQ-5
000]
The error code AXONIQ-5000 indicates that no query handler for the given query request type could be found.
I don't have the complete code, of course, but checking the code it looks like the first parameter of the query request is a builder (the result of FetchProductQuery.builder().productId(id)) and not a FetchProductQuery instance.
Creating an widget to turn on and off Flash light
Getting Error on turning off flash light
My Widget Class Code
Code In onRecieve
#Override
public void onReceive(Context context, Intent intent)
{
super.onReceive(context, intent);
if(SYNC_CLICKED.equals(intent.getAction()))
{
AppWidgetManager appWidgetManager=AppWidgetManager.getInstance(context);
RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.widget__flash);
ComponentName componentName=new ComponentName(context,Widget_Flash.class);
if(Allowed_Flash) {
if (!Flash_Light_On) {
getCamera();
Turn_On_Flash_Light();
views.setImageViewResource(R.id.Widget_On_Off_Button, R.drawable.button2);
Flash_Light_On = true;
} else {
views.setImageViewResource(R.id.Widget_On_Off_Button, R.drawable.button1);
getCamera();
Turn_Off_Flash_Light();
}
Flash_Light_On = false;
}
}
appWidgetManager.updateAppWidget(componentName, views);
}
}
Get Camera
private void getCamera() {
if (camera == null) {
try {
camera = Camera.open();
params = camera.getParameters();
} catch (RuntimeException e) {
}
}
}
Turn On
private void Turn_On_Flash_Light()
{
params.setFlashMode(Camera.Parameters.FLASH_MODE_TORCH);
camera.setParameters(params);
camera.startPreview();
}
Turn Off
private void Turn_Off_Flash_Light()
{
params.setFlashMode(Camera.Parameters.FLASH_MODE_OFF);
camera.setParameters(params);
camera.startPreview();
camera.release();
}
Error
E/AndroidRuntime: FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to start receiver
io.farooq.flash_light.Widget_Flash: java.lang.NullPointerException
at android.app.ActivityThread.handleReceiver(ActivityThread.java:2287)
at android.app.ActivityThread.access$1600(ActivityThread.java:140)
at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1313)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4921)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1038)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:805)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NullPointerException
at
io.farooq.flash_light.Widget_Flash.Turn_Off_Flash_Light(Widget_Flash.java:143)
at io.farooq.flash_light.Widget_Flash.onReceive(Widget_Flash.java:74)
at android.app.ActivityThread.handleReceiver(ActivityThread.java:2280)
at android.app.ActivityThread.access$1600(ActivityThread.java:140)
at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1313)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4921)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1038)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:805)
at dalvik.system.NativeStart.main(Native Method)
In Samsung J5 Prime (API 23) Code is working fine But in Tried it in (API 16) & (API 19) Flash Is Turning On But getting error while turning off
MY application is crashing on line 43:
float value = dataSnapshot.child("temp").getValue(float.class);
When i remove the .child from the addChildEventListener and from the Datasnapshot , the app will display the float value from the database.
My aim is to display both a float value and then add in another line to display the Humidity value my database will hold.
so i will be attempting .child("temp").child("humi") to be displayed on a listview.
Can anybody steer me in the right direction or help me resolve why i cant specify child entries.
ListView listview = (ListView) findViewById(R.id.listview);
adapter = new ArrayAdapter<String>(this, android.R.layout.simple_expandable_list_item_1, list);
listview.setAdapter(adapter);
//INITIALIZE FIREBASE DB
db = FirebaseDatabase.getInstance().getReference();
db.child("temp").limitToLast(1).addChildEventListener(new ChildEventListener() {
#Override
public void onChildAdded(DataSnapshot dataSnapshot, String s) {
float value = dataSnapshot.child("temp").getValue(float.class);
list.add("System Temperture: " + value);
adapter.notifyDataSetChanged();
}
#Override
public void onChildChanged(DataSnapshot dataSnapshot, String s) {
adapter.clear();
float value = dataSnapshot.child("temp").getValue(float.class);
list.add("System Temperture: " + value);
adapter.notifyDataSetChanged();
}
#Override
public void onChildRemoved(DataSnapshot dataSnapshot) {
}
#Override
public void onChildMoved(DataSnapshot dataSnapshot, String s) {
}
#Override
public void onCancelled(DatabaseError databaseError) {
}
});
}
JSON value from firebase
{
"humi" : {
"-KaxKLD00Ib97d1dRbvR" : 17.0
},
"temp" : {
"-KaxKL8G17y4ezfdBMDP" : 21.0
}
}
Logcat
01-20 18:32:18.675 16935-16935/com.m.j.project.josephmay E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.m.j.project.josephmay, PID: 16935
java.lang.NullPointerException: Attempt to invoke virtual method 'float java.lang.Float.floatValue()' on a null object reference
at com.m.j.project.josephmay.MainActivity$1.onChildAdded(MainActivity.java:43)
at com.google.android.gms.internal.zzblz.zza(Unknown Source)
at com.google.android.gms.internal.zzbnz.zzYj(Unknown Source)
at com.google.android.gms.internal.zzboc$1.run(Unknown Source)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:158)
at android.app.ActivityThread.main(ActivityThread.java:7229)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
01-20 18:32:26.645 16935-17099/com.m.j.project.josephmay W/DynamiteModule: Local module descriptor class for com.google.firebase.auth not found.
01-20 18:32:26.645 16935-17099/com.m.j.project.josephmay W/ResourcesManager: getTopLevelResources: /data/app/com.google.android.gms-1/base.apk / 1.0 running in com.m.j.project.josephmay rsrc of package com.google.android.gms
I think I was running into a similar issue and this response from Frank helped me: https://groups.google.com/forum/#!topic/firebase-talk/-cdTDFBOmMw.
When you are creating the new record within Firebase, are you doing setValue() for "humi" and "temp" separately or doing setValue() for the entire object? Try switching it to setValue() for the whole object.
public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception {
super.userEventTriggered(ctx, evt);
if (evt instanceof IdleStateEvent) {
IdleStateEvent event = (IdleStateEvent) evt;
if (event.state().equals(IdleState.READER_IDLE)) {
System.out.println("READER_IDLE");
ctx.disconnect();
ctx.close();
}
}
}
Do I need invoke ctx.disconnect() before ctx.close()?
Is it possible to fire CDI events from within a interceptor ? (Using Jboss 7.1.1)
For example, if I have an interceptor PerformanceLogInterceptor
#Interceptors({PerformanceLogInterceptor.class})
public class ProcessHandler extends HandlerBase {
.
.
.
Could it fire an event as such:
public class PerformanceLogInterceptor {
private Logger LOG = LoggerFactory.getLogger("PerformanceLog");
#EJB
PerformanceMonitor performanceMonitor;
#Inject
Event<ExceptionEvent> exceptionEvent;
#AroundInvoke
#AroundTimeout
public Object performanceLog( InvocationContext invocationContext ) throws Exception {
String methodName = invocationContext.getMethod().toString();
long start = System.currentTimeMillis();
try {
return invocationContext.proceed();
} catch( Exception e ) {
LOG.warn( "During invocation of: {} exception occured: {}", methodName, Throwables.getRootCause(e).getMessage() );
performanceMonitor.addException( methodName, e );
Exception toSend;
if(e instanceof EfsobExceptionInformation ){
toSend = e;
} else {
LOG.debug("Wrapping exception");
EfsobExceptionWrapper wrapped = new EfsobExceptionWrapper(e);
toSend = wrapped;
}
if(exceptionEvent != null) {
LOG.debug("sending exceptionEvent");
exceptionEvent.fire(new ExceptionEventBuilder()
.setExceptionName(toSend)
.setEfsobExceptionType(toSend)
.setId(toSend)
.setStacktrace(toSend)
.build()
);
} else {
LOG.debug("exceptionEvent was null");
}
LOG.debug("rethrowing");
throw toSend;
} finally {
long total = System.currentTimeMillis() - start;
performanceMonitor.addPerformanceMetrics(methodName, total);
}
}
}
Note: exceptionEvent is null at runtime in the Above.
I moved it into an Async block of the PerformanceMonitor bean referenced above.... and then it works (WAT?)
#Singleton
#ConcurrencyManagement(ConcurrencyManagementType.BEAN)
public class PerformanceMonitor {
#Inject
Event<ExceptionEvent> exceptionEvent;
private Logger LOG = LoggerFactory.getLogger("PerformanceMonitor");
#Asynchronous
public void addException(String methodName, Exception e) {
if(exceptionEvent != null) {
LOG.debug("sending exceptionEvent");
exceptionEvent.fire(new ExceptionEventBuilder()
.setExceptionName(e)
.setEfsobExceptionType(e)
.setId(e)
.setStacktrace(e)
.build()
);
} else {
LOG.debug("exceptionEvent was null");
}
}
}