如果您想了解javax.activation.UnsupportedDataTypeException:MIME类型为multipart/mixed的无对象DCH;边界的知识,那么本篇文章将是您的不二
如果您想了解javax.activation.UnsupportedDataTypeException:MIME类型为multipart / mixed的无对象DCH;边界的知识,那么本篇文章将是您的不二之选。同时我们将深入剖析Android – java.lang.UnsupportedOperationException:无法转换为dimension:type = 0x12、Android’InvocationTargetException’和’UnsupportedOperationException’、Caused by: java.lang.UnsupportedOperationException、hibernate---java.lang.UnsupportedOperationException: The user must supply a JDBC connection的各个方面,并给出实际的案例分析,希望能帮助到您!
本文目录一览:- javax.activation.UnsupportedDataTypeException:MIME类型为multipart / mixed的无对象DCH;边界
- Android – java.lang.UnsupportedOperationException:无法转换为dimension:type = 0x12
- Android’InvocationTargetException’和’UnsupportedOperationException’
- Caused by: java.lang.UnsupportedOperationException
- hibernate---java.lang.UnsupportedOperationException: The user must supply a JDBC connection
javax.activation.UnsupportedDataTypeException:MIME类型为multipart / mixed的无对象DCH;边界
目前,我正在编写要侦听目录的代码。当目录使用.apk文件更新时,我会将带有此.apk文件的邮件发送到gmail帐户。我在程序中使用Jnotify和JAVA
Mail。
我得到的错误是
javax.mail.MessagingException: IOException while sending message; nested exception is:javax.activation.UnsupportedDataTypeException: no object DCH for MIME type multipart/mixed; boundary="----=_Part_0_145238.1392728439484"
我寻找了stackoverflow中给出的解决方案以寻求帮助,但没有一个有帮助。
提前致谢
public void fileCreated(int wd, String rootPath, String name) { print("created " + rootPath + " : " + name); if (name.contains(".apk")) SendEmail(name); else System.out.println("Not the APK file");}void SendEmail(String strname){ String Path = "D:/POC/Email/apk folder/"+strname; System.out.println("Path->" + Path); Properties props = new Properties(); props.put("mail.smtp.host","173.194.78.108"); props.put("mail.smtp.socketFactory.port", "465"); props.put("mail.smtp.socketFactory.class","javax.net.ssl.SSLSocketFactory"); props.put("mail.smtp.auth","true"); props.put("mail.smtp.port","465"); System.out.println("Properties has been set properly"); Session session = Session.getDefaultInstance(props, new javax.mail.Authenticator(){ protected PasswordAuthentication getPasswordAuthentication(){ return new PasswordAuthentication("SenderEmailID@gmail.com", "senderPassword"); } } ); System.out.println("Session Created successfully"); try{ Message message = new MimeMessage(session); message.setFrom(new InternetAddress("SenderEmailID@gmail.com")); message.setRecipients(Message.RecipientType.TO, InternetAddress.parse("ToReceiverEmailID@gmail.com")); message.setSubject("Android : " + strname); MimeBodyPart msgbody = new MimeBodyPart(); msgbody.setText("This is the message content which is sent using JAVA MAIL 1.4.5"); Multipart mulpart = new MimeMultipart(); mulpart.addBodyPart(msgbody); //Attachement Starts here. msgbody = new MimeBodyPart(); javax.activation.DataSource source = new FileDataSource(Path); msgbody.setDataHandler(new DataHandler(source)); msgbody.setFileName(strname); message.setContent(mulpart); System.out.println("Attached the message going to start transporting the mail"); //If I''ve the code before sending the email is getting sent but without attachment. //Thread.currentThread().setContextClassLoader( getClass().getClassLoader() ); Transport.send(message); System.out.println("Mail Sent successfully"); } catch(MessagingException msg){ msg.printStackTrace(); } catch(Exception e){ e.printStackTrace(); }}
答案1
小编典典通过采取以下两个步骤,可以解决此问题。
- 确保Java邮件为1.4.7。(以前我使用1.4.5导致了所有混乱)。从http://www.oracle.com/technetwork/java/index-138643.html下载
- 在发送消息之前添加以下代码:
Thread.currentThread().setContextClassLoader( getClass().getClassLoader() );
Android – java.lang.UnsupportedOperationException:无法转换为dimension:type = 0x12
我正在尝试为我的Android应用程序创建一个UI,但它崩溃了,错误就是
“java.lang.RuntimeException: Unable to start activity
ComponentInfo{com.example.test/com.example.test.MainActivity}:
java.lang.UnsupportedOperationException: Can’t convert to dimension:
type=0x12”
这是我的XML代码
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ff000000"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin">
<EditText
android:id="@+id/symbolName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textCapCharacters"
android:textColor="#ffffffff" >
</EditText>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:orientation="vertical" >
<RadioButton
android:id="@+id/radioButton1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="RadioButton" />
<RadioButton
android:id="@+id/RadioButton01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="RadioButton" />
<RadioButton
android:id="@+id/RadioButton02"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="RadioButton" />
<RadioButton
android:id="@+id/RadioButton03"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="RadioButton" />
</LinearLayout>
<LinearLayout
android:id="@+id/condition"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="@+id/RadioButton03">
<EditText
android:inputType="number"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Add Alert"/>
</LinearLayout>
我做错了什么?有任何想法吗?
解决方法:
您在此行提供了无效资源:
android:layout_marginTop="@+id/RadioButton03"
尺寸应该用于保证金,例如
android:layout_marginTop="@dimen/margin_top"
Android’InvocationTargetException’和’UnsupportedOperationException’
xml文件:(分隔符的边距最初是7.5dp,这可能是问题吗?)
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/item_full" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="#eff0f7" android:baselineAligned="false" android:orientation="vertical" > <RelativeLayout android:id="@+id/item_first_half" android:layout_width="match_parent" android:layout_height="36dp" android:orientation="vertical" > <View android:id="@+id/first_path" android:layout_width="4dp" android:layout_height="4dp" android:layout_marginLeft="40dp" android:layout_marginStart="40dp" android:background="@drawable/selector_car_action_path" /> <ImageView android:id="@+id/im_car_direction_icon" android:layout_width="28dp" android:layout_height="28dp" android:layout_gravity="top" android:layout_marginLeft="28dp" android:layout_marginStart="28dp" android:layout_marginTop="4dp" android:background="@drawable/selector_car_action_background" android:padding="2dp" android:src="@drawable/selector_navi_icon_63" /> <View android:id="@+id/second_path" android:layout_width="4dp" android:layout_height="4dp" android:layout_below="@id/im_car_direction_icon" android:layout_marginLeft="40dp" android:layout_marginStart="40dp" android:background="@drawable/selector_car_action_path" /> <TextView android:id="@+id/tv_direction" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_centerVertical="true" android:layout_marginEnd="15dp" android:layout_marginLeft="68dp" android:layout_marginRight="15dp" android:layout_marginStart="68dp" android:singleLine="true" android:text="" android:textColor="@drawable/selector_car_route_turn_text" android:textSize="16sp" /> </RelativeLayout> <RelativeLayout android:id="@+id/item_second_half" android:layout_width="match_parent" android:layout_height="32dp" > <View android:id="@+id/third_path" android:layout_width="4dp" android:layout_height="match_parent" android:layout_marginLeft="40dp" android:layout_marginStart="40dp" android:background="@drawable/selector_car_action_path" /> <TextView android:id="@+id/tv_road_name" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="68dp" android:layout_marginStart="68dp" android:layout_marginTop="4dp" android:singleLine="true" android:text="" android:textColor="@drawable/selector_car_route_desc" android:textSize="16sp" /> <TextView android:id="@+id/divider_for_road_and_distance" android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_marginEnd="7dp" android:layout_marginLeft="7dp" android:layout_marginRight="7dp" android:layout_marginStart="7dp" android:layout_marginTop="4dp" android:layout_toEndOf="@id/tv_road_name" android:layout_toRightOf="@id/tv_road_name" android:singleLine="true" android:text="|" android:textColor="@drawable/selector_car_route_desc" android:textSize="16sp" /> <TextView android:id="@+id/tv_ride_distance" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginEnd="15dp" android:layout_marginRight="15dp" android:layout_marginTop="4dp" android:layout_toEndOf="@id/divider_for_road_and_distance" android:layout_toRightOf="@id/divider_for_road_and_distance" android:singleLine="true" android:text="" android:textColor="@drawable/selector_car_route_desc" android:textSize="16sp" /> <View android:layout_width="match_parent" android:layout_height="1px" android:layout_alignParentBottom="true" android:layout_marginEnd="15dp" android:layout_marginLeft="68dp" android:layout_marginRight="15dp" android:layout_marginStart="68dp" android:background="#dee1f0" /> </RelativeLayout> </LinearLayout>
drawable / selector_car_route_desc文件是
<?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_selected="true" android:color="@color/color_999999"/> <item android:state_selected="false" android:color="@color/color_333333"/> </selector>
崩溃日志:
android.view.InflateException: Binary XML file line #106: Error inflating class <unkNown> android.view.LayoutInflater.createView(LayoutInflater.java:606) com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56) android.view.LayoutInflater.onCreateView(LayoutInflater.java:653) android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:678) android.view.LayoutInflater.rInflate(LayoutInflater.java:739) android.view.LayoutInflater.rInflate(LayoutInflater.java:742) android.view.LayoutInflater.inflate(LayoutInflater.java:489) android.view.LayoutInflater.inflate(LayoutInflater.java:396) android.view.LayoutInflater.inflate(LayoutInflater.java:352) com.tencent.map.ama.route.ui.view.e.<init>(CarRouteShowItem.java:78) com.tencent.map.ama.route.ui.view.f.a(CarRouteShowView.java:100) com.tencent.map.ama.route.ui.view.d.a(CarRouteDetailView.java:37) com.tencent.map.ama.route.ui.MapStateCarRoute.e(MapStateCarRoute.java:418) com.tencent.map.ama.route.ui.MapStateCarRoute$1.run(MapStateCarRoute.java:255) android.os.Handler.handleCallback(Handler.java:605) android.os.Handler.dispatchMessage(Handler.java:92) android.os.Looper.loop(Looper.java:137) android.app.ActivityThread.main(ActivityThread.java:4476) java.lang.reflect.Method.invokeNative(Native Method) java.lang.reflect.Method.invoke(Method.java:511) com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:808) com.android.internal.os.ZygoteInit.main(ZygoteInit.java:575) dalvik.system.NativeStart.main(Native Method) cause by: java.lang.reflect.InvocationTargetException: null java.lang.reflect.Constructor.constructNative(Native Method) java.lang.reflect.Constructor.newInstance(Constructor.java:417) android.view.LayoutInflater.createView(LayoutInflater.java:586) com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56) android.view.LayoutInflater.onCreateView(LayoutInflater.java:653) android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:678) android.view.LayoutInflater.rInflate(LayoutInflater.java:739) android.view.LayoutInflater.rInflate(LayoutInflater.java:742) android.view.LayoutInflater.inflate(LayoutInflater.java:489) android.view.LayoutInflater.inflate(LayoutInflater.java:396) android.view.LayoutInflater.inflate(LayoutInflater.java:352) com.tencent.map.ama.route.ui.view.e.<init>(CarRouteShowItem.java:78) com.tencent.map.ama.route.ui.view.f.a(CarRouteShowView.java:100) com.tencent.map.ama.route.ui.view.d.a(CarRouteDetailView.java:37) com.tencent.map.ama.route.ui.MapStateCarRoute.e(MapStateCarRoute.java:418) com.tencent.map.ama.route.ui.MapStateCarRoute$1.run(MapStateCarRoute.java:255) android.os.Handler.handleCallback(Handler.java:605) android.os.Handler.dispatchMessage(Handler.java:92) android.os.Looper.loop(Looper.java:137) android.app.ActivityThread.main(ActivityThread.java:4476) java.lang.reflect.Method.invokeNative(Native Method) java.lang.reflect.Method.invoke(Method.java:511) com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:808) com.android.internal.os.ZygoteInit.main(ZygoteInit.java:575) dalvik.system.NativeStart.main(Native Method) cause by: java.lang.UnsupportedOperationException: Can''t convert to dimension: type=0x12 android.content.res.TypedArray.getDimensionPixelSize(TypedArray.java:463) android.view.View.<init>(View.java:2849) android.widget.TextView.<init>(TextView.java:499) android.widget.TextView.<init>(TextView.java:492) java.lang.reflect.Constructor.constructNative(Native Method) java.lang.reflect.Constructor.newInstance(Constructor.java:417) android.view.LayoutInflater.createView(LayoutInflater.java:586) com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56) android.view.LayoutInflater.onCreateView(LayoutInflater.java:653) android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:678) android.view.LayoutInflater.rInflate(LayoutInflater.java:739) android.view.LayoutInflater.rInflate(LayoutInflater.java:742) android.view.LayoutInflater.inflate(LayoutInflater.java:489) android.view.LayoutInflater.inflate(LayoutInflater.java:396) android.view.LayoutInflater.inflate(LayoutInflater.java:352) com.tencent.map.ama.route.ui.view.e.<init>(CarRouteShowItem.java:78) com.tencent.map.ama.route.ui.view.f.a(CarRouteShowView.java:100) com.tencent.map.ama.route.ui.view.d.a(CarRouteDetailView.java:37) com.tencent.map.ama.route.ui.MapStateCarRoute.e(MapStateCarRoute.java:418) com.tencent.map.ama.route.ui.MapStateCarRoute$1.run(MapStateCarRoute.java:255) android.os.Handler.handleCallback(Handler.java:605) android.os.Handler.dispatchMessage(Handler.java:92) android.os.Looper.loop(Looper.java:137) android.app.ActivityThread.main(ActivityThread.java:4476) java.lang.reflect.Method.invokeNative(Native Method) java.lang.reflect.Method.invoke(Method.java:511) com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:808) com.android.internal.os.ZygoteInit.main(ZygoteInit.java:575) dalvik.system.NativeStart.main(Native Method)
CarRouteShowItem.java:78的代码是这样的:
View mView = LayoutInflater.from(mContext).inflate(R.layout.car_route_detail_item,null);
CarRouteShowItem不是View的子代,其代码如下:
public class CarRouteShowItem { private Context mContext; private View mView; public CarRouteShowItem(Context context) { mContext = context; // mView is used by caller mView = LayoutInflater.from(mContext).inflate(R.layout.car_route_detail_item,null); // some view finds } // some other methods related with specific logic }
图形布局可以在Eclipse中从API级别8预览到API级别23,但是当我在API级别15的Android Studio中预览时,它会显示错误消息:无法解析资源@style / Widget.TextView,其他API级别没问题,但我没有使用TextView的样式.
解决方法
android:layout_height="1px"
希望你现在能看到.第二个RelativeLayout中的最后一个子项,其id为item_second_half,类型为< View,将其更改为
android:layout_height="1dp"
让我尽快回顾一下
Caused by: java.lang.UnsupportedOperationException
对Arrays.asList()返回的List进行操作之后报错Caused by: java.lang.UnsupportedOperationException
让我们来看一下Arrays.asList的源码:
/** * Returns a {@code List} of the objects in the specified array. The size of the * {@code List} cannot be modified, i.e. adding and removing are unsupported, but * the elements can be set. Setting an element modifies the underlying * array. * * @param array * the array. * @return a {@code List} of the elements of the specified array. */
@SafeVarargs
public static <T> List<T> asList(T... array) {
return new ArrayList<T>(array);
}
private static class ArrayList<E> extends AbstractList<E> implements
List<E>, Serializable, RandomAccess {
private static final long serialVersionUID = -2764017481108945198L;
private final E[] a;
ArrayList(E[] storage) {
if (storage == null) {
throw new NullPointerException("storage == null");
}
a = storage;
}
@Override
public boolean contains(Object object) {
if (object != null) {
for (E element : a) {
if (object.equals(element)) {
return true;
}
}
} else {
for (E element : a) {
if (element == null) {
return true;
}
}
}
return false;
}
@Override
public E get(int location) {
try {
return a[location];
} catch (ArrayIndexOutOfBoundsException e) {
throw java.util.ArrayList.throwIndexOutOfBoundsException(location, a.length);
}
}
@Override
public int indexOf(Object object) {
if (object != null) {
for (int i = 0; i < a.length; i++) {
if (object.equals(a[i])) {
return i;
}
}
} else {
for (int i = 0; i < a.length; i++) {
if (a[i] == null) {
return i;
}
}
}
return -1;
}
@Override
public int lastIndexOf(Object object) {
if (object != null) {
for (int i = a.length - 1; i >= 0; i--) {
if (object.equals(a[i])) {
return i;
}
}
} else {
for (int i = a.length - 1; i >= 0; i--) {
if (a[i] == null) {
return i;
}
}
}
return -1;
}
@Override
public E set(int location, E object) {
E result = a[location];
a[location] = object;
return result;
}
@Override
public int size() {
return a.length;
}
@Override
public Object[] toArray() {
return a.clone();
}
@Override
@SuppressWarnings({"unchecked", "SuspiciousSystemArraycopy"})
public <T> T[] toArray(T[] contents) {
int size = size();
if (size > contents.length) {
Class<?> ct = contents.getClass().getComponentType();
contents = (T[]) Array.newInstance(ct, size);
}
System.arraycopy(a, 0, contents, 0, size);
if (size < contents.length) {
contents[size] = null;
}
return contents;
}
}
索噶,原来返回的是Arrays类的静态内部类!这样能会报错也就正常咯。
hibernate---java.lang.UnsupportedOperationException: The user must supply a JDBC connection
在配置 hibernate 时。运行代码时一直抛错:
Exception in thread "main" java.lang.UnsupportedOperationException: The user must supply a JDBC connection
at org.hibernate.connection.UserSuppliedConnectionProvider.getConnection(UserSuppliedConnectionProvider.java:54)
at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:446)
at org.hibernate.jdbc.ConnectionManager.getConnection(ConnectionManager.java:167)
at org.hibernate.jdbc.AbstractBatcher.prepareQueryStatement(AbstractBatcher.java:161)
at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1616)
at org.hibernate.loader.Loader.doQuery(Loader.java:717)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:270)
at org.hibernate.loader.Loader.loadEntity(Loader.java:1953)
at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:86)
at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:76)
at org.hibernate.persister.entity.AbstractEntityPersister.load(AbstractEntityPersister.java:3270)
at org.hibernate.event.def.DefaultLoadEventListener.loadFromDatasource(DefaultLoadEventListener.java:496)
at org.hibernate.event.def.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:477)
at org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:227)
at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:285)
at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:152)
at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:1080)
at org.hibernate.impl.SessionImpl.get(SessionImpl.java:997)
at org.hibernate.impl.SessionImpl.get(SessionImpl.java:990)
at com.ado.test.hibernate.HibernateTest.main(HibernateTest.java:25)
后来看了后台的源代码,发现创建的 ConnectionProvider 实例为 UserSuppliedConnectionProvider(用户自己定义的 Provider),配置有点异常。断点跟踪了创建该实例的代码,原来是由于在依据各个配置属性创建该实例时。由于配置属性 keyword 与 hibernatekeyword 不一样。所以导致创建了用户自己定义的 Provider,从而出现了上面的异常。
測试代码使用的是 hibernate 3.5.6。标准的 keyword 能够查看 org.hibernate.cfg.Environment 类中的定义。
hibernate 版本号不一样,使用的 keyword 也不一样。
这点须要注意。
hibernate 3.5.6 使用的是:
hibernate.connection.driver_class
hibernate.connection.url
hibernate.connection.username
hibernate.connection.password
关于javax.activation.UnsupportedDataTypeException:MIME类型为multipart / mixed的无对象DCH;边界的问题就给大家分享到这里,感谢你花时间阅读本站内容,更多关于Android – java.lang.UnsupportedOperationException:无法转换为dimension:type = 0x12、Android’InvocationTargetException’和’UnsupportedOperationException’、Caused by: java.lang.UnsupportedOperationException、hibernate---java.lang.UnsupportedOperationException: The user must supply a JDBC connection等相关知识的信息别忘了在本站进行查找喔。
本文标签: