I use background_locator to track geo_location when the user activates tracking by clicking a button. The location is then posted to an API, which logs it in a database.
The feature works in debug mode, but crashes with the following exception, in release mode:
E/AndroidRuntime(31736): FATAL EXCEPTION: main
E/AndroidRuntime(31736): Process: za.co.liquidedge.celltrack, PID: 31736
E/AndroidRuntime(31736): java.lang.RuntimeException: Unable to start service rekab.app.background_locator.IsolateHolderServiceolateHolderService (has extras) }: java.lang.RuntimeException: Missing type parameter.
E/AndroidRuntime(31736): at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:4759)
E/AndroidRuntime(31736): at android.app.ActivityThread.access$1900(ActivityThread.java:301)
E/AndroidRuntime(31736): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2186)
E/AndroidRuntime(31736): at android.os.Handler.dispatchMessage(Handler.java:106)6)
E/AndroidRuntime(31736): at android.os.Looper.loop(Looper.java:246) a:8506)
E/AndroidRuntime(31736): at android.app.ActivityThread.main(ActivityThread.java:8506) aller.run(RuntimeInit.java:602)
E/AndroidRuntime(31736): at com.android.internal.os.RuntimeInit$MethodAndArgsC.java:1130)aller.run(RuntimeInit.java:602) r.
E/AndroidRuntime(31736): at com.android.internal.os.ZygoteInit.main(ZygoteInite:26).java:1130)
E/AndroidRuntime(31736): Caused by: java.lang.RuntimeException: Missing type parametece:0)r. )
E/AndroidRuntime(31736): at d.c.c.O.a.getSuperclassTypeParameter(Unknown Sourc23)e:26) onStartCommand(:11)
E/AndroidRuntime(31736): at d.c.c.O.a.<init>(Unknown Source:7) ityThread.java:4741)
E/AndroidRuntime(31736): at rekab.app.background_locator.e.<init>(Unknown Source:0)
E/AndroidRuntime(31736): at rekab.app.background_locator.f.b(Unknown Source:24)
E/AndroidRuntime(31736): at rekab.app.background_locator.g.d.a(Unknown Source:23)
E/AndroidRuntime(31736): at rekab.app.background_locator.IsolateHolderService.onStartCommand(:11)
E/AndroidRuntime(31736): at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:4741)
I fixed this issue by adding these rules to android/app/proguard-rules.pro
# Gson uses generic type information stored in a class file when working with fields. Proguard
# removes such information by default, so configure it to keep all of it.
-keepattributes Signature
# Gson specific classes
-keep class sun.misc.Unsafe { *; }
#-keep class com.google.gson.stream.** { *; }
# Application classes that will be serialized/deserialized over Gson
-keep class com.google.gson.examples.android.model.** { *; }
Related
FATAL EXCEPTION: main
Process: PID: 9915
java.lang.NullPointerException: Attempt to invoke virtual method 'float
com.github.mikephil.charting.data.Entry.getX()' on a null object reference
at com.github.mikephil.charting.renderer.LineChartRenderer.drawCubicBezier(LineChartRenderer.java:236)
at enter code herecom.github.mikephil.charting.renderer.LineChartRenderer.drawDataSet(LineChartRenderer.java:123)
at com.github.mikephil.charting.renderer.LineChartRenderer.drawData(LineChartRenderer.java:101)
at com.github.mikephil.charting.charts.BarLineChartBase.onDraw(BarLineChartBase.java:237)
I have implemented the following test class:
import com.mongodb.BasicDBObjectBuilder;
import com.mongodb.DBObject;
import org.assertj.core.api.Assertions;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.data.mongo.DataMongoTest;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit.jupiter.SpringExtension;
#DataMongoTest(properties = {"spring.mongodb.embedded.version=4.0.2"})
#ExtendWith(SpringExtension.class)
public class MyIntegrationTest {
#DisplayName("Test display name")
#Test
public void test(#Autowired MongoTemplate mongoTemplate) {
// given
DBObject objectToSave = BasicDBObjectBuilder.start()
.add("key", "value")
.get();
// when
mongoTemplate.save(objectToSave, "collection");
// then
Assertions.assertThat(mongoTemplate.findAll(DBObject.class, "collection")).extracting("key")
.containsOnly("value");
}
}
This is exactly the same as in Springs documentation, however when I run the test I keep getting the following errors:
java.lang.IllegalStateException: Failed to load ApplicationContext
and
2022-01-04 10:35:02 UTC | WARN | AnnotationConfigApplicationContext | Exception encountered during context
initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'mongoDatabaseFactory' defined in class path
resource [org/springframework/boot/autoconfigure/data/mongo/MongoDatabaseFactoryConfiguration.class]:
Bean instantiation via factory method failed; nested exception is
org.springframework.beans.BeanInstantiationException: Failed to instantiate
[org.springframework.data.mongodb.core.MongoDatabaseFactorySupport]: Factory method 'mongoDatabaseFactory'
threw exception; nested exception is java.lang.IllegalArgumentException: The connection string is invalid.
Connection strings must start with either 'mongodb://' or 'mongodb+srv://
What am I doing wrong? What I'm trying to do is to test with an embedded, in-memory MongoDB.
Update:
This is my project structure:
▼ src
▼ main
▼ java
▼ youben
YouBenApplication (Spring Boot Runnable Class)
▼ test
▼ java
▼ youben
MyIntegrationTest (this is the test class)
Here is my the runnable class:
#SpringBootApplication
public class YouBenApplication {
public static void main(String[] args) {
SpringApplication.run(YouBenApplication.class, args);
}
}
This is the error message:
java.lang.IllegalStateException: Failed to load ApplicationContext
at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:132)
at org.springframework.test.context.support.DefaultTestContext.getApplicationContext(DefaultTestContext.java:124)
at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.injectDependencies(DependencyInjectionTestExecutionListener.java:118)
at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.prepareTestInstance(DependencyInjectionTestExecutionListener.java:83)
at org.springframework.boot.test.autoconfigure.SpringBootDependencyInjectionTestExecutionListener.prepareTestInstance(SpringBootDependencyInjectionTestExecutionListener.java:43)
at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:248)
at org.springframework.test.context.junit.jupiter.SpringExtension.postProcessTestInstance(SpringExtension.java:138)
at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.lambda$invokeTestInstancePostProcessors$6(ClassBasedTestDescriptor.java:350)
at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.executeAndMaskThrowable(ClassBasedTestDescriptor.java:355)
at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.lambda$invokeTestInstancePostProcessors$7(ClassBasedTestDescriptor.java:350)
at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:179)
at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1625)
at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484)
at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
at java.base/java.util.stream.StreamSpliterators$WrappingSpliterator.forEachRemaining(StreamSpliterators.java:312)
at java.base/java.util.stream.Streams$ConcatSpliterator.forEachRemaining(Streams.java:735)
at java.base/java.util.stream.Streams$ConcatSpliterator.forEachRemaining(Streams.java:734)
at java.base/java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:762)
at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.invokeTestInstancePostProcessors(ClassBasedTestDescriptor.java:349)
at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.lambda$instantiateAndPostProcessTestInstance$4(ClassBasedTestDescriptor.java:270)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.instantiateAndPostProcessTestInstance(ClassBasedTestDescriptor.java:269)
at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.lambda$testInstancesProvider$2(ClassBasedTestDescriptor.java:259)
at java.base/java.util.Optional.orElseGet(Optional.java:364)
at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.lambda$testInstancesProvider$3(ClassBasedTestDescriptor.java:258)
at org.junit.jupiter.engine.execution.TestInstancesProvider.getTestInstances(TestInstancesProvider.java:31)
at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$prepare$0(TestMethodTestDescriptor.java:101)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.prepare(TestMethodTestDescriptor.java:100)
at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.prepare(TestMethodTestDescriptor.java:65)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$prepare$1(NodeTestTask.java:111)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.prepare(NodeTestTask.java:111)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:79)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:38)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:143)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:129)
at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:127)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:126)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:84)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:38)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:143)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:129)
at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:127)
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:126)
at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:84)
at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:32)
at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:57)
at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:51)
at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:108)
at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:88)
at org.junit.platform.launcher.core.EngineExecutionOrchestrator.lambda$execute$0(EngineExecutionOrchestrator.java:54)
at org.junit.platform.launcher.core.EngineExecutionOrchestrator.withInterceptedStreams(EngineExecutionOrchestrator.java:67)
at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:52)
at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:96)
at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:75)
at com.intellij.junit5.JUnit5IdeaTestRunner.startRunnerWithArgs(JUnit5IdeaTestRunner.java:71)
at com.intellij.rt.junit.IdeaTestRunner$Repeater$1.execute(IdeaTestRunner.java:38)
at com.intellij.rt.execution.junit.TestsRepeater.repeat(TestsRepeater.java:11)
at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:35)
at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:235)
at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:54)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mongoDatabaseFactory' defined in class path resource [org/springframework/boot/autoconfigure/data/mongo/MongoDatabaseFactoryConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.data.mongodb.core.MongoDatabaseFactorySupport]: Factory method 'mongoDatabaseFactory' threw exception; nested exception is java.lang.IllegalArgumentException: The connection string is invalid. Connection strings must start with either 'mongodb://' or 'mongodb+srv://
I think you have used this tutorial.
The following annotations seem to be correct
#DataMongoTest
#ExtendWith(SpringExtension.class)
However as spring doc for embedded mongo db advices you should define the embedded mongo db version that should be used.
So you should configure those previous annotations as
#DataMongoTest(properties = {"spring.mongodb.embedded.version=4.0.2"})
#ExtendWith(SpringExtension.class)
if for example you need the version 4.0.2
\
Edit:
For #ExtendWith to work you have to also have a spring boot application configured in your main directory. Using only test directory alone is not sufficient.
So make sure that you have in src/main/java/yourpackage something like
#SpringBootApplication
public class ServiceLauncher {
public static void main(String[] args) {
SpringApplication.run(ServiceLauncher.class, args);
}
}
Important! Tests should also be in the same mypackage directory example src/test/java/yourpackage
After upgrading Android 10 Q my dialogFragment not working, I have also converted android project into "AdroidX" but still the problem is same.
I am xamarin developer so please help me to understand this problem.
please check error:
2019-09-27 19:01:30.551 2177-2218/? E/memtrack: Couldn't load memtrack module
2019-09-27 19:01:33.135 6797-6797/com.anotherroundapps.apps.kegid E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.anotherroundapps.apps.kegid, PID: 6797
java.lang.IllegalStateException: Could not execute method for android:onClick
at android.view.View$DeclaredOnClickListener.onClick(View.java:5994)
at android.view.View.performClick(View.java:7140)
at android.view.View.performClickInternal(View.java:7117)
at android.view.View.access$3500(View.java:801)
at android.view.View$PerformClick.run(View.java:27351)
at android.os.Handler.handleCallback(Handler.java:883)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7356)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invoke(Native Method)
at android.view.View$DeclaredOnClickListener.onClick(View.java:5989)
at android.view.View.performClick(View.java:7140)
at android.view.View.performClickInternal(View.java:7117)
at android.view.View.access$3500(View.java:801)
at android.view.View$PerformClick.run(View.java:27351)
at android.os.Handler.handleCallback(Handler.java:883)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7356)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
Caused by: java.lang.IllegalStateException: Fragment com.anotherroundapps.apps.kegid.ManifestBuilder.EffectiveDateManagerFragment must be a public static class to be properly recreated from instance state.
at androidx.fragment.app.BackStackRecord.doAddOp(BackStackRecord.java:400)
at androidx.fragment.app.BackStackRecord.add(BackStackRecord.java:379)
at androidx.fragment.app.DialogFragment.show(DialogFragment.java:143)
at com.anotherroundapps.apps.kegid.ManifestBuilder.showEffectiveDateDialog(ManifestBuilder.java:540)
at com.anotherroundapps.apps.kegid.ManifestBuilder.itemClick(ManifestBuilder.java:275)
at java.lang.reflect.Method.invoke(Native Method)
at android.view.View$DeclaredOnClickListener.onClick(View.java:5989)
at android.view.View.performClick(View.java:7140)
at android.view.View.performClickInternal(View.java:7117)
at android.view.View.access$3500(View.java:801)
at android.view.View$PerformClick.run(View.java:27351)
at android.os.Handler.handleCallback(Handler.java:883)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7356)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
2019-09-27 19:01:33.147 2177-2201/? E/system_server: Invalid ID 0x00000000.
2019-09-27 19:01:33.193 1812-2126/? E/SurfaceFlinger: ro.sf.lcd_density must be defined as a build property
2019-09-27 19:01:33.196 1812-2284/? E/SurfaceFlinger: ro.sf.lcd_density must be defined as a build property
2019-09-27 19:01:35.611 2177-5427/? E/InputDispatcher: Window handle Window{bf1e32f u0 Application Error: com.anotherroundapps.apps.kegid} has no registered input channel
2019-09-27 19:01:35.669 2177-4730/? E/InputDispatcher: Window handle Window{bf1e32f u0 Application Error: com.anotherroundapps.apps.kegid} has no registered input channel
2019-09-27 19:01:35.738 2177-2285/? E/InputDispatcher: channel '94f2618 com.anotherroundapps.apps.kegid/com.anotherroundapps.apps.kegid.MainActivity (server)' ~ Channel is unrecoverably broken and will be disposed!
2019-09-27 19:01:35.739 2177-2285/? E/InputDispatcher: channel 'f095afe com.anotherroundapps.apps.kegid/com.anotherroundapps.apps.kegid.ManifestBuilder (server)' ~ Channel is unrecoverably broken and will be disposed!
2019-09-27 19:01:37.342 2735-2735/? E/BeaconBle: Missing BluetoothAdapter
2019-09-27 19:01:37.393 2735-2735/? E/BeaconBle: Scan couldn't start for Places
2019-09-27 19:01:50.830 1935-1935/? E/netmgr: Failed to open QEMU pipe 'qemud:network': Invalid argument
2019-09-27 19:01:50.831 1935-1935/? E/netmgr: WifiForwarder unable to open QEMU pipe: Invalid argument
2019-09-27 19:02:50.865 1935-1935/? E/netmgr: Failed to open QEMU pipe 'qemud:network': Invalid argument
2019-09-27 19:02:50.865 1935-1935/? E/netmgr: WifiForwarder unable to open QEMU pipe: Invalid argument
2019-09-27 19:03:09.797 2177-2218/? E/memtrack: Couldn't load memtrack module
2019-09-27 19:03:09.810 2177-2218/? E/memtrack: Couldn't load memtrack module
2019-09-27 19:03:09.812 2177-2218/? E/memtrack: Couldn't load memtrack module
2019-09-27 19:03:50.928 1935-1935/? E/netmgr: Failed to open QEMU pipe 'qemud:network': Invalid argument
2019-09-27 19:03:50.929 1935-1935/? E/netmgr: WifiForwarder unable to open QEMU pipe: Invalid argument
2019-09-27 19:03:56.639 2735-6578/? E/WakeLock: GCM_HB_ALARM release without a matched acquire!
2019-09-27 19:03:56.645 2735-6578/? E/WakeLock: GCM_CONN_ALARM release without a matched acquire!
2019-09-27 19:03:56.893 2177-2218/? E/memtrack: Couldn't load memtrack module
2019-09-27 19:03:56.897 2177-2218/? E/memtrack: Couldn't load memtrack module
2019-09-27 19:04:02.386 2735-6917/? E/WakeLock: GCM_CONN_ALARM release without a matched acquire!
2019-09-27 19:04:45.446 2177-2218/? E/memtrack: Couldn't load memtrack module
I have tried with AndroidX and some of the googles artical but couldn't get much of help
public void showEffectiveDateDialog() {
DialogFragment newFragment = new EffectiveDateManagerFragment();
newFragment.show(getFragmentManager(), "datePicker");
}
public class EffectiveDateManagerFragment extends DialogFragment {
#Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
DateTime currentEffectiveDate = mNewManifest.getEffectiveDate();
// prompt use scan date or select another date
ArrayList<CharSequence> selections = new ArrayList<CharSequence>();
if (currentEffectiveDate != null)
selections.add(Html.fromHtml(String.format("Current selection: <b>%s</b>", currentEffectiveDate.toString(KegIdApplication.DATETIME_DISPLAY_FORMAT))));
else
selections.add(Html.fromHtml(String.format("Current selection: <b>%s</b>", getString(R.string.label_use_scan_date))));
selections.add(getString(R.string.label_use_scan_date));
selections.add(getString(R.string.label_choose_a_date));
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
builder.setTitle(R.string.label_effectivedate).setItems(selections.toArray(new CharSequence[selections.size()]), new DialogInterface.OnClickListener() {
#Override
public void onClick(DialogInterface dialog, int which) {
switch (which) {
case 0:
//leave as is
dialog.dismiss();
break;
case 1:
// use scan date, clear effective date
mNewManifest.setEffectiveDate(null);
mEffectiveDateText.setText(R.string.label_use_scan_date);
break;
case 2:
// choose an effectivedate
dialog.dismiss();
DialogFragment newFragment = new DateTimePickerFragment(mNewManifest.getEffectiveDate());
newFragment.show(getFragmentManager(), "datePicker");
break;
default:
//cancel;
dialog.dismiss();
break;
}
}
});
//builder.setMessage("Choose the effective date for these kegs");
return builder.create();
}
}
I have custom dialog will have to open
Answer is I have created new java class for EffectiveDateManagerFragment and other related class changes into static class it solved my problem
I am trying to use DI to inject a webservice client in my application. I get runtime exception as i refer current application in the object being injected. Below is the skeletal of my code.
**import play.api.Play.Current**
#Singleton
class MicorServiceClient#Inject()(ws: WSclient) {
// References curret.configuraiton.getString(
....
}
class Application #Inject()(microServiceClient: MicorServiceClient) extends Controller {
def someMethod= Action {
//Calls the micorservicelient.getResponse()
}
}
I see following error when my api is called.
#709lj5bmd: Unexpected exception
at play.core.server.DevServerStart$$anonfun$mainDev$1$$anon$1$$anonfun$get$1$$anonfun$apply$1$$anonfun$1.apply(DevServerStart.scala:170)
at play.core.server.DevServerStart$$anonfun$mainDev$1$$anon$1$$anonfun$get$1$$anonfun$apply$1$$anonfun$1.apply(DevServerStart.scala:126)
at scala.Option.map(Option.scala:146)
at play.core.server.DevServerStart$$anonfun$mainDev$1$$anon$1$$anonfun$get$1$$anonfun$apply$1.apply(DevServerStart.scala:126)
at play.core.server.DevServerStart$$anonfun$mainDev$1$$anon$1$$anonfun$get$1$$anonfun$apply$1.apply(DevServerStart.scala:124)
at scala.util.Success.flatMap(Try.scala:231)
at play.core.server.DevServerStart$$anonfun$mainDev$1$$anon$1$$anonfun$get$1.apply(DevServerStart.scala:124)
at play.core.server.DevServerStart$$anonfun$mainDev$1$$anon$1$$anonfun$get$1.apply(DevServerStart.scala:116)
at scala.concurrent.impl.Future$PromiseCompletingRunnable.liftedTree1$1(Future.scala:24)
at scala.concurrent.impl.Future$PromiseCompletingRunnable.run(Future.scala:24)
at java.util.concurrent.ForkJoinTask$RunnableExecuteAction.exec(ForkJoinTask.java:1402)
at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)
at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056)
at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1689)
at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157)
Caused by: com.google.inject.ProvisionException: Unable to provision, see the following errors:
1) Error injecting constructor, java.lang.RuntimeException: There is no started application
Ah, solved the issue, i need to pass play.api.Configuration to the Client and remove the references to current
so my MicroServiceClient definition looks like below
class MicroServiceClient(ws: WSclient, configuration: play.api.Configuration) {
}
I am building a Play Scala project and need an authentication for the apps.
I am using this one : https://github.com/nulab/scala-oauth2-provider as the Oauth Provider libs.
I have implement everything based on the docs. But when implement the Auth on the controller below :
object Token extends MainController with OAuth2Provider {
def accessToken = Action.async { implicit request =>
issueAccessToken(new MyDataHandler()
}
And here my router :
GET /test controllers.Token.test
POST /token controllers.Token.accessToken
When I access localhost/token, i got this error :
And here the error from console :
play.api.Application$$anon$1: Execution exception[[RuntimeException: java.lang.IncompatibleClassChangeError: Found interface play.api.mvc.Headers, but class was expected]]
at play.api.Application$class.handleError(Application.scala:296) ~[play_2.10-2.3.7.jar:2.3.7]
at play.api.DefaultApplication.handleError(Application.scala:402) [play_2.10-2.3.7.jar:2.3.7]
at play.core.server.netty.PlayDefaultUpstreamHandler$$anonfun$3$$anonfun$applyOrElse$4.apply(PlayDefaultUpstreamHandler.scala:320) [play_2.10-2.3.7.jar:2.3.7]
at play.core.server.netty.PlayDefaultUpstreamHandler$$anonfun$3$$anonfun$applyOrElse$4.apply(PlayDefaultUpstreamHandler.scala:320) [play_2.10-2.3.7.jar:2.3.7]
at scala.Option.map(Option.scala:145) [scala-library-2.10.5.jar:na]
Caused by: java.lang.RuntimeException: java.lang.IncompatibleClassChangeError: Found interface play.api.mvc.Headers, but class was expected
at play.api.mvc.ActionBuilder$$anon$1.apply(Action.scala:523) ~[play_2.10-2.3.7.jar:2.3.7]
at play.api.mvc.Action$$anonfun$apply$1$$anonfun$apply$4$$anonfun$apply$5.apply(Action.scala:130) ~[play_2.10-2.3.7.jar:2.3.7]
at play.api.mvc.Action$$anonfun$apply$1$$anonfun$apply$4$$anonfun$apply$5.apply(Action.scala:130) ~[play_2.10-2.3.7.jar:2.3.7]
at play.utils.Threads$.withContextClassLoader(Threads.scala:21) ~[play_2.10-2.3.7.jar:2.3.7]
at play.api.mvc.Action$$anonfun$apply$1$$anonfun$apply$4.apply(Action.scala:129) ~[play_2.10-2.3.7.jar:2.3.7]
Caused by: java.lang.IncompatibleClassChangeError: Found interface play.api.mvc.Headers, but class was expected
at scalaoauth2.provider.OAuth2BaseProvider$class.play2oauthRequest(OAuth2Provider.scala:24) ~[play2-oauth2-provider_2.10-0.15.1.jar:0.15.1]
at controllers.Token$.play2oauthRequest(Token.scala:14) ~[na:na]
at scalaoauth2.provider.OAuth2Provider$class.issueAccessToken(OAuth2Provider.scala:138) ~[play2-oauth2-provider_2.10-0.15.1.jar:0.15.1]
at controllers.Token$.issueAccessToken(Token.scala:14) ~[na:na]
at controllers.Token$$anonfun$accessToken$1.apply(Token.scala:25) ~[na:na]
I have implement everything what does docs said. Sorry I am actually new on Scala and on the Play it self.
What do you use Play and scala-oauth2-provider version?
The error looks Play version is different.
If you use Play 2.3, you should use 0.14.0 in scala-oauth2-provider.
See readme.