错误消息“cvc-complex-type.4:Attribute'bean-discovery-mode'必须出现在元素'beans'上。”(Error message “cvc-complex-type.4: Attribute 'bean-discovery-mode' must appear on element 'beans'.”)
我有一个简单的Java EE项目,在WEB-INF下有一个简单的beans.xml。 它基本上什么都没有。 但我总是得到这个错误消息“cvc-complex-type.4:属性'bean-discovery-mode'必须出现在元素'beans'上。” 在JBoss Developer Studio中为“ http://xmlns.jcp.org/xml/ns/javaee/beans_1_1.xsd ”行指明。
这条消息是什么意思? 我用谷歌搜索但没有发现任何东西。 可能是什么原因导致的
<?xml version="1.0" encoding="UTF-8"?> <!-- Marker file indicating CDI should be enabled --> <beans xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/beans_1_1.xsd"> <!-- Uncomment this alternative to see EJB declarative transactions in use --> <!-- <alternatives> --> <!-- <class>org.jboss.as.quickstarts.greeter.domain.EJBUserDao</class> --> <!-- </alternatives> --> </beans>
I have a simple Java EE project and under WEB-INF there is a simple beans.xml. It basically contains nothing. But I always got this error message "cvc-complex-type.4: Attribute 'bean-discovery-mode' must appear on element 'beans'." indicated for the line "http://xmlns.jcp.org/xml/ns/javaee/beans_1_1.xsd" in JBoss Developer Studio.
What does this message mean? I googled but found nothing. What might cause this?
<?xml version="1.0" encoding="UTF-8"?> <!-- Marker file indicating CDI should be enabled --> <beans xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/beans_1_1.xsd"> <!-- Uncomment this alternative to see EJB declarative transactions in use --> <!-- <alternatives> --> <!-- <class>org.jboss.as.quickstarts.greeter.domain.EJBUserDao</class> --> <!-- </alternatives> --> </beans>
原文:https://stackoverflow.com/questions/26686423
最满意答案
由于
AsyncTask
实例依赖于调用者Activity
,我认为这不是正确的方法。 在您的情况下,由于您需要在任何Activity
恢复结果,我将使用未绑定的Service
以便随时随地访问它。您还可以使用本地
BroadcastReceiver
,它将向您的所有Activity
发送信号,并且那些注册发送AsyncTask
/Service
的操作的人将执行您可能需要的必要操作。 请注意,好像您的Activity
尚未启动,显然Activity
不能处理您发送的内容,因为该接收者应该取消注册。Since
AsyncTask
instances are dependent of the callerActivity
, I think this is not the correct approach. In your case, as you need to recover the result within anyActivity
, I'd use an unboundService
so it might be accessed whenever you want, wherever you want.You might also use a local
BroadcastReceiver
which would send a signal to all of yourActivity
s and, those registering the action that sent yourAsyncTask
/Service
, would perform the necessary actions you may need. Be careful as if yourActivity
has not been started, obviously thatActivity
won't be able to process what you've sent since that receiver should be unregistered.
相关问答
更多-
Activity2有一个AsyncTask,在那个任务的onPostExecute()中,我想处理Activity1中的TextView。 不,你不能。 您可以在Activtiy1中使用startActivtiyForResult并更新textview 在Activity1中 Intent intent=new Intent(Activity.this,Activity2.class); startActivityForResult(intent, 2); 然后 @Override ...
-
如何在未启动主Activity时从AsyncTask发送通知?(How to send notification from AsyncTask while main Activity is not started?)[2022-08-03]
因为getSystemService是Context类的方法。 看看这里 。 在调用函数之前,在AsyncTask中创建一个Context变量。 然后在构造函数中初始化它,即 Context context; public MyAsyncTask(Context contextin) { context = contextin;} 然后使用此上下文变量来调用您的函数: NotificationManager notManager = (NotificationManager) context.getSy ... -
Android - 使用AsyncTask结果中的新数据刷新运行活动(Android - refresh running activity with new data from AsyncTask result)[2019-11-09]
没有回复,所以我回答了我自己的问题。 我的解决方案是: - 将我的活动launchMode更改为singleTop - 覆盖方法onNewIntent 在这种情况下,每次我开始此活动时:如果活动已存在,则不会再次创建。 相反,将调用onNewIntent方法。 http://developer.android.com/guide/topics/manifest/activity-element.html#lmode http://developer.android.com/reference/android ... -
你可以通过以下代码调用活动, if(result.contains("Remote login success")){ Intent i = new Intent(context, MainpanelActivity.class); //use context here i.putExtra("email", this.email); startActivity(i); } you can call the activity from following code, if(r ...
-
AsyncTask的片段(AsyncTask on fragment)[2024-01-11]
您可以在任何需要的地方使用AsyncTask ,它可以位于Activity , Fragment或其他任何类中。 对于你的问题,首先你应该检查位置可用性,而不是你的工作。 有关更多详细信息,请参阅AsyncTask You can use AsyncTask anywhere you need, it can be in your Activity, Fragment or any other class. For your question first you should check for locat ... -
AsyncTask被设计为嵌套在Activity类中时效果最好。 AsyncTask的特殊之处在于它不仅仅是一个工作者线程 - 而是它将处理doInBackground(...)的代码的工作线程与在Activity的UI线程上运行的方法 - onProgressUpdate(...)和onPostExecute(...)是最常用的。 通过定期从doInBackground(...)调用updateProgress(...) ,调用onProgressUpdate(...)方法,允许它操作Activity的U ...
-
在调用asynctask之前确保你的用户在两个平台上登录,然后调用asynctask,因为现在在这种情况下有很多用户可以做的组合,所以我的建议是首先确保用户登录这两个facbook,tiwtter然后调用这个asynctask所以你不必让asynctask等待 I solved my problem by using a static variable which is set to true just before recreating an Activity and when Activity exec ...
-
android - 只在asynctask完成后才完成当前活动(android - finish the current activity only after the asynctask finishes)[2023-05-05]
你的 AsyncResponse delegate = null; delegate为null。 你还没有初步化! 编辑: 制作构造函数 public AsyncResponse delegate; public BackgroundTask(AsyncResponse delegate){ this.delegate = delagate; } 现在用。执行你的异步任务 BackgroundTask backgroundTask = new BackgroundTask(new ... -
在另一个活动中启动asynctask后刷新当前视图(Refresh current view after asynctask started in another activity)[2023-10-30]
由于AsyncTask实例依赖于调用者Activity ,我认为这不是正确的方法。 在您的情况下,由于您需要在任何 Activity恢复结果,我将使用未绑定的Service以便随时随地访问它。 您还可以使用本地BroadcastReceiver ,它将向您的所有Activity发送信号,并且那些注册发送AsyncTask / Service的操作的人将执行您可能需要的必要操作。 请注意,好像您的Activity尚未启动,显然Activity不能处理您发送的内容,因为该接收者应该取消注册。 Since Asy ... -
这是问题的根源...... new DownloadImageUrlsTask().execute(); if(urls != null){ ... } 对execute()的调用将立即返回,因为它是异步的(因此名称为AsyncTask)。 结果是代码中的条件检查if(urls != null)立即被调用,但AsyncTask的doInBackground(...)方法将不会完成它正在做的事情,并且urls将始终为null 。 This is the root of the problem... ...