关于Java音频流和mp3spilib,UnsupportedAudioFileException的问题就给大家分享到这里,感谢你花时间阅读本站内容,更多关于Cause:java.lang.Unsup
关于Java音频流和mp3spi lib,UnsupportedAudioFileException的问题就给大家分享到这里,感谢你花时间阅读本站内容,更多关于Cause: java.lang.UnsupportedOperationException、Caused by: java.lang.UnsupportedOperationException、Caused by: redis.clients.jedis.exceptions.JedisDataException: ERR This instance has cluster support disabled、hibernate---java.lang.UnsupportedOperationException: The user must supply a JDBC connection等相关知识的信息别忘了在本站进行查找喔。
本文目录一览:- Java音频流(mp3spi lib),UnsupportedAudioFileException(Java音频流前后端传输)
- Cause: java.lang.UnsupportedOperationException
- Caused by: java.lang.UnsupportedOperationException
- Caused by: redis.clients.jedis.exceptions.JedisDataException: ERR This instance has cluster support disabled
- hibernate---java.lang.UnsupportedOperationException: The user must supply a JDBC connection
Java音频流(mp3spi lib),UnsupportedAudioFileException(Java音频流前后端传输)
我已经看到多个有关MP3流(例如Icecast)的堆栈溢出问题。他们都说我使用的是MP3SPI库。MP3SPI用于允许支持audio/mpeg
mime类型。那就是我的Icecast流。我在类路径中正确地拥有了所有三个jar文件,但是在使用它们在示例中提供的相同代码时,我仍然得到了UnsupportedAudioFileException
:
javax.sound.sampled.UnsupportedAudioFileException: could not get audio input stream from input URL at javax.sound.sampled.AudioSystem.getAudioInputStream(AudioSystem.java:1153) at DJUtils.testPlay(DJUtils.java:16) at DJ.play(DJ.java:13) at DJ.init(DJ.java:4) at Loader.main(Loader.java:69)
这是我的代码:
public static void testPlay(){ try { AudioInputStream in= AudioSystem.getAudioInputStream(new URL("http://localhost:8000/listen.m3u")); AudioInputStream din = null; AudioFormat baseFormat = in.getFormat(); AudioFormat decodedFormat = new AudioFormat(AudioFormat.Encoding.PCM_SIGNED, baseFormat.getSampleRate(), 16, baseFormat.getChannels(), baseFormat.getChannels() * 2, baseFormat.getSampleRate(), false); din = AudioSystem.getAudioInputStream(decodedFormat, in); // Play now. rawplay(decodedFormat, din); in.close(); } catch (Exception e){ e.printStackTrace(); }}private static void rawplay(AudioFormat targetFormat, AudioInputStream din) throws LineUnavailableException, IOException{ try{ byte[] data = new byte[4096]; SourceDataLine line = getLine(targetFormat); if (line != null) { // Start line.start(); int nBytesRead = 0, nBytesWritten = 0; while (nBytesRead != -1) { nBytesRead = din.read(data, 0, data.length); if (nBytesRead != -1) nBytesWritten = line.write(data, 0, nBytesRead); } // Stop line.drain(); line.stop(); line.close(); din.close(); } }catch(IOException e){ e.printStackTrace(); }}private static SourceDataLine getLine(AudioFormat audioFormat) throws LineUnavailableException{ try{ SourceDataLine res = null; DataLine.Info info = new DataLine.Info(SourceDataLine.class, audioFormat); res = (SourceDataLine) AudioSystem.getLine(info); res.open(audioFormat); return res; }catch(LineUnavailableException e){ e.printStackTrace(); return null; }}
我的这个项目的开始脚本:
java -Dfile.encoding=Cp1252 -classpath bin;lib/libs.jar;lib/graphics.jar;lib/mp3spi/mp3spi.jar;lib/mp3spi/jl.jar;lib/mp3spi/tritonus.jar; Loader
我的Icecast控制面板说它正在流式传输audio/mpeg
。通过在任何媒体播放器中打开代码中的URL,我可以很好地访问流。有人可以指出我做错了什么吗?谢谢!
答案1
小编典典这样的mp3spi库不会将m3u播放列表文件视为受支持的文件。
尝试使用m3u文件中使用的实时流url。即直接将网址指向mp3文件或流。
检查以下功能。mp3spi库直接来自MpegAudioFileReader.java,用于标识使用URL呈现的数据流的格式。它无法识别m3u文件。您可以从http://www.javazoom.net/mp3spi/sources.html检查源。
public AudioFileFormat getAudioFileFormat(InputStream inputStream, long mediaLength) throws UnsupportedAudioFileException, IOException{ if (TDebug.TraceAudioFileReader) TDebug.out(">MpegAudioFileReader.getAudioFileFormat(InputStream inputStream, long mediaLength): begin"); HashMap aff_properties = new HashMap(); HashMap af_properties = new HashMap(); int mLength = (int) mediaLength; int size = inputStream.available(); PushbackInputStream pis = new PushbackInputStream(inputStream, MARK_LIMIT); byte head[] = new byte[22]; pis.read(head); if (TDebug.TraceAudioFileReader) { TDebug.out("InputStream : " + inputStream + " =>" + new String(head)); } // Check for WAV, AU, and AIFF, Ogg Vorbis, Flac, MAC file formats. // Next check for Shoutcast (supported) and OGG (unsupported) streams. if ((head[0] == ''R'') && (head[1] == ''I'') && (head[2] == ''F'') && (head[3] == ''F'') && (head[8] == ''W'') && (head[9] == ''A'') && (head[10] == ''V'') && (head[11] == ''E'')) { if (TDebug.TraceAudioFileReader) TDebug.out("RIFF/WAV stream found"); int isPCM = ((head[21]<<8)&0x0000FF00) | ((head[20])&0x00000FF); if (weak == null) { if (isPCM == 1) throw new UnsupportedAudioFileException("WAV PCM stream found"); } } else if ((head[0] == ''.'') && (head[1] == ''s'') && (head[2] == ''n'') && (head[3] == ''d'')) { if (TDebug.TraceAudioFileReader) TDebug.out("AU stream found"); if (weak == null) throw new UnsupportedAudioFileException("AU stream found"); } else if ((head[0] == ''F'') && (head[1] == ''O'') && (head[2] == ''R'') && (head[3] == ''M'') && (head[8] == ''A'') && (head[9] == ''I'') && (head[10] == ''F'') && (head[11] == ''F'')) { if (TDebug.TraceAudioFileReader) TDebug.out("AIFF stream found"); if (weak == null) throw new UnsupportedAudioFileException("AIFF stream found"); } else if (((head[0] == ''M'') | (head[0] == ''m'')) && ((head[1] == ''A'') | (head[1] == ''a'')) && ((head[2] == ''C'') | (head[2] == ''c''))) { if (TDebug.TraceAudioFileReader) TDebug.out("APE stream found"); if (weak == null) throw new UnsupportedAudioFileException("APE stream found"); } else if (((head[0] == ''F'') | (head[0] == ''f'')) && ((head[1] == ''L'') | (head[1] == ''l'')) && ((head[2] == ''A'') | (head[2] == ''a'')) && ((head[3] == ''C'') | (head[3] == ''c''))) { if (TDebug.TraceAudioFileReader) TDebug.out("FLAC stream found"); if (weak == null) throw new UnsupportedAudioFileException("FLAC stream found"); } // Shoutcast stream ? else if (((head[0] == ''I'') | (head[0] == ''i'')) && ((head[1] == ''C'') | (head[1] == ''c'')) && ((head[2] == ''Y'') | (head[2] == ''y''))) { pis.unread(head); // Load shoutcast meta data. loadShoutcastInfo(pis, aff_properties); } // Ogg stream ? else if (((head[0] == ''O'') | (head[0] == ''o'')) && ((head[1] == ''G'') | (head[1] == ''g'')) && ((head[2] == ''G'') | (head[2] == ''g''))) { if (TDebug.TraceAudioFileReader) TDebug.out("Ogg stream found"); if (weak == null) throw new UnsupportedAudioFileException("Ogg stream found"); } // No, so pushback. else { pis.unread(head); } // MPEG header info. int nVersion = AudioSystem.NOT_SPECIFIED; int nLayer = AudioSystem.NOT_SPECIFIED; int nSFIndex = AudioSystem.NOT_SPECIFIED; int nMode = AudioSystem.NOT_SPECIFIED; int FrameSize = AudioSystem.NOT_SPECIFIED; int nFrameSize = AudioSystem.NOT_SPECIFIED; int nFrequency = AudioSystem.NOT_SPECIFIED; int nTotalFrames = AudioSystem.NOT_SPECIFIED; float FrameRate = AudioSystem.NOT_SPECIFIED; int BitRate = AudioSystem.NOT_SPECIFIED; int nChannels = AudioSystem.NOT_SPECIFIED; int nHeader = AudioSystem.NOT_SPECIFIED; int nTotalMS = AudioSystem.NOT_SPECIFIED; boolean nVBR = false; AudioFormat.Encoding encoding = null; try { Bitstream m_bitstream = new Bitstream(pis); aff_properties.put("mp3.header.pos", new Integer(m_bitstream.header_pos())); Header m_header = m_bitstream.readFrame(); // nVersion = 0 => MPEG2-LSF (Including MPEG2.5), nVersion = 1 => MPEG1 nVersion = m_header.version(); if (nVersion == 2) aff_properties.put("mp3.version.mpeg", Float.toString(2.5f)); else aff_properties.put("mp3.version.mpeg", Integer.toString(2 - nVersion)); // nLayer = 1,2,3 nLayer = m_header.layer(); aff_properties.put("mp3.version.layer", Integer.toString(nLayer)); nSFIndex = m_header.sample_frequency(); nMode = m_header.mode(); aff_properties.put("mp3.mode", new Integer(nMode)); nChannels = nMode == 3 ? 1 : 2; aff_properties.put("mp3.channels", new Integer(nChannels)); nVBR = m_header.vbr(); af_properties.put("vbr", new Boolean(nVBR)); aff_properties.put("mp3.vbr", new Boolean(nVBR)); aff_properties.put("mp3.vbr.scale", new Integer(m_header.vbr_scale())); FrameSize = m_header.calculate_framesize(); aff_properties.put("mp3.framesize.bytes", new Integer(FrameSize)); if (FrameSize < 0) throw new UnsupportedAudioFileException("Invalid FrameSize : " + FrameSize); nFrequency = m_header.frequency(); aff_properties.put("mp3.frequency.hz", new Integer(nFrequency)); FrameRate = (float) ((1.0 / (m_header.ms_per_frame())) * 1000.0); aff_properties.put("mp3.framerate.fps", new Float(FrameRate)); if (FrameRate < 0) throw new UnsupportedAudioFileException("Invalid FrameRate : " + FrameRate); if (mLength != AudioSystem.NOT_SPECIFIED) { aff_properties.put("mp3.length.bytes", new Integer(mLength)); nTotalFrames = m_header.max_number_of_frames(mLength); aff_properties.put("mp3.length.frames", new Integer(nTotalFrames)); } BitRate = m_header.bitrate(); af_properties.put("bitrate", new Integer(BitRate)); aff_properties.put("mp3.bitrate.nominal.bps", new Integer(BitRate)); nHeader = m_header.getSyncHeader(); encoding = sm_aEncodings[nVersion][nLayer - 1]; aff_properties.put("mp3.version.encoding", encoding.toString()); if (mLength != AudioSystem.NOT_SPECIFIED) { nTotalMS = Math.round(m_header.total_ms(mLength)); aff_properties.put("duration", new Long((long) nTotalMS * 1000L)); } aff_properties.put("mp3.copyright", new Boolean(m_header.copyright())); aff_properties.put("mp3.original", new Boolean(m_header.original())); aff_properties.put("mp3.crc", new Boolean(m_header.checksums())); aff_properties.put("mp3.padding", new Boolean(m_header.padding())); InputStream id3v2 = m_bitstream.getRawID3v2(); if (id3v2 != null) { aff_properties.put("mp3.id3tag.v2", id3v2); parseID3v2Frames(id3v2, aff_properties); } if (TDebug.TraceAudioFileReader) TDebug.out(m_header.toString()); } catch (Exception e) { if (TDebug.TraceAudioFileReader) TDebug.out("not a MPEG stream:" + e.getMessage()); throw new UnsupportedAudioFileException("not a MPEG stream:" + e.getMessage()); } // Deeper checks ? int cVersion = (nHeader >> 19) & 0x3; if (cVersion == 1) { if (TDebug.TraceAudioFileReader) TDebug.out("not a MPEG stream: wrong version"); throw new UnsupportedAudioFileException("not a MPEG stream: wrong version"); } int cSFIndex = (nHeader >> 10) & 0x3; if (cSFIndex == 3) { if (TDebug.TraceAudioFileReader) TDebug.out("not a MPEG stream: wrong sampling rate"); throw new UnsupportedAudioFileException("not a MPEG stream: wrong sampling rate"); } // Look up for ID3v1 tag if ((size == mediaLength) && (mediaLength != AudioSystem.NOT_SPECIFIED)) { FileInputStream fis = (FileInputStream) inputStream; byte[] id3v1 = new byte[128]; long bytesSkipped = fis.skip(inputStream.available() - id3v1.length); int read = fis.read(id3v1, 0, id3v1.length); if ((id3v1[0] == ''T'') && (id3v1[1] == ''A'') && (id3v1[2] == ''G'')) { parseID3v1Frames(id3v1, aff_properties); } } AudioFormat format = new MpegAudioFormat(encoding, (float) nFrequency, AudioSystem.NOT_SPECIFIED // SampleSizeInBits - The size of a sample , nChannels // Channels - The number of channels , -1 // The number of bytes in each frame , FrameRate // FrameRate - The number of frames played or recorded per second , true, af_properties); return new MpegAudioFileFormat(MpegFileFormatType.MP3, format, nTotalFrames, mLength, aff_properties);}
Cause: java.lang.UnsupportedOperationException
运行web项目的时候出现以下错误:
### Cause: java.lang.UnsupportedOperationException
at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:77)
at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:446)
at com.sun.proxy.$Proxy74.selectList(Unknown Source)
at org.mybatis.spring.SqlSessionTemplate.selectList(SqlSessionTemplate.java:230)
at org.apache.ibatis.binding.MapperMethod.executeForMany(MapperMethod.java:137)
at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:75)
at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:59)
at com.sun.proxy.$Proxy81.getEnjoyCourseByUser(Unknown Source)
at com.ros.serviceimpl.CourseServiceImpl.getCourseByEngoy(CourseServiceImpl.java:1168)
at com.ros.controller.CourseController.getCourseByEngoy(CourseController.java:427)
at com.ros.controller.CourseController$$FastClassBySpringCGLIB$$8a9731c4.invoke(<generated>)
at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:669)
at com.ros.controller.CourseController$$EnhancerBySpringCGLIB$$3f51ab5d.getCourseByEngoy(<generated>)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:205)
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:133)
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:97)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:827)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:738)
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:967)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:901)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970)
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:872)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:661)
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:61)
at org.apache.shiro.web.servlet.AdviceFilter.executeChain(AdviceFilter.java:108)
at org.apache.shiro.web.servlet.AdviceFilter.doFilterInternal(AdviceFilter.java:137)
at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125)
at org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:66)
at org.apache.shiro.web.servlet.AbstractShiroFilter.executeChain(AbstractShiroFilter.java:449)
at org.apache.shiro.web.servlet.AbstractShiroFilter$1.call(AbstractShiroFilter.java:365)
at org.apache.shiro.subject.support.SubjectCallable.doCall(SubjectCallable.java:90)
at org.apache.shiro.subject.support.SubjectCallable.call(SubjectCallable.java:83)
at org.apache.shiro.subject.support.DelegatingSubject.execute(DelegatingSubject.java:387)
at org.apache.shiro.web.servlet.AbstractShiroFilter.doFilterInternal(AbstractShiroFilter.java:362)
at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.springframework.web.filter.HttpPutFormContentFilter.doFilterInternal(HttpPutFormContentFilter.java:108)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:81)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:197)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:199)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:478)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:803)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:868)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1459)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:748)
Caused by: org.apache.ibatis.exceptions.PersistenceException:
### Error querying database. Cause: java.lang.UnsupportedOperationException
### The error may exist in file [F:\idea\ros1.0\target\classes\mybatis\mapper\CourseMapper.xml]
### The error may involve com.ros.dao.CourseDao.getEnjoyCourseByUser
### The error occurred while handling results
### SQL: SELECT ros_course.id, ros_course.c_image AS image, ros_course.cname, ros_course.remark, ros_course.is_favorite AS isFavorite, ros_course.is_remark AS isRemark, ros_course.classify, ros_course.price, ros_course.visit, ros_course.update_time AS updateTime FROM ros_course WHERE id IN ( SELECT DISTINCT course_id FROM user_course_chartor WHERE user_id = ? ) and c_type=? LIMIT ?
### Cause: java.lang.UnsupportedOperationException
at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:30)
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:150)
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:141)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:433)
... 80 more
Caused by: java.lang.UnsupportedOperationException
at org.apache.ibatis.reflection.wrapper.CollectionWrapper.findProperty(CollectionWrapper.java:48)
at org.apache.ibatis.reflection.MetaObject.findProperty(MetaObject.java:85)
at org.apache.ibatis.executor.resultset.DefaultResultSetHandler.createAutomaticMappings(DefaultResultSetHandler.java:488)
at org.apache.ibatis.executor.resultset.DefaultResultSetHandler.applyAutomaticMappings(DefaultResultSetHandler.java:512)
at org.apache.ibatis.executor.resultset.DefaultResultSetHandler.getRowValue(DefaultResultSetHandler.java:397)
at org.apache.ibatis.executor.resultset.DefaultResultSetHandler.handleRowValuesForSimpleResultMap(DefaultResultSetHandler.java:351)
at org.apache.ibatis.executor.resultset.DefaultResultSetHandler.handleRowValues(DefaultResultSetHandler.java:326)
at org.apache.ibatis.executor.resultset.DefaultResultSetHandler.handleResultSet(DefaultResultSetHandler.java:299)
at org.apache.ibatis.executor.resultset.DefaultResultSetHandler.handleResultSets(DefaultResultSetHandler.java:192)
at org.apache.ibatis.executor.statement.PreparedStatementHandler.query(PreparedStatementHandler.java:64)
at org.apache.ibatis.executor.statement.RoutingStatementHandler.query(RoutingStatementHandler.java:79)
at org.apache.ibatis.executor.SimpleExecutor.doQuery(SimpleExecutor.java:63)
at org.apache.ibatis.executor.BaseExecutor.queryFromDatabase(BaseExecutor.java:324)
at org.apache.ibatis.executor.BaseExecutor.query(BaseExecutor.java:156)
at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:109)
at com.github.pagehelper.PageInterceptor.intercept(PageInterceptor.java:136)
at org.apache.ibatis.plugin.Plugin.invoke(Plugin.java:61)
at com.sun.proxy.$Proxy111.query(Unknown Source)
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:148)
... 86 more
经过排查可以发现是mybatis中的返回数据错误
在dao的函数定义如下:
在mapper中映射为
调整为:
ok,这个错误解决完成
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类的静态内部类!这样能会报错也就正常咯。
Caused by: redis.clients.jedis.exceptions.JedisDataException: ERR This instance has cluster support disabled
项目配置redis,编译不报错,但是启动报错了,Caused by: redis.clients.jedis.exceptions.JedisDataException: ERR This instance has cluster support disabled,请问怎么解决?
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
今天关于Java音频流和mp3spi lib,UnsupportedAudioFileException的介绍到此结束,谢谢您的阅读,有关Cause: java.lang.UnsupportedOperationException、Caused by: java.lang.UnsupportedOperationException、Caused by: redis.clients.jedis.exceptions.JedisDataException: ERR This instance has cluster support disabled、hibernate---java.lang.UnsupportedOperationException: The user must supply a JDBC connection等更多相关知识的信息可以在本站进行查询。
本文标签: