NoSuchMethod exception when using scala Regex class... confused
I have a simple Scala project that runs without any problems inside Eclipse, however, when packaged into a .jar I receive this exception when running it:
Exception in thread "AWT-EventQueue-0" java.lang.NoSuchMethodError: scala.util.matching.Regex.replaceAllIn(Ljava/lang/CharSequence;Lscala/Function1;)Ljava/lang/String;
What is going on here?...
The code line in question, and the full stack are below.
This is the offending line:
"alt=\"[^>]+\">".r.replaceAllIn(inputStr, {_.replace(">", "/>")})
Full stack:
Exception in thread "AWT-EventQueue-0" java.lang.NoSuchMethodError: scala.util.matching.Regex.replaceAllIn(Ljava/lang/CharSequence;Lscala/Function1;)Ljava/lang/String;
at com.inosat.fuel.FuelStationDgge.fixhtml(FuelStationDgge.scala:40)
at com.inosat.fuel.FuelStationDgge.setDetails(FuelStationDgge.scala:82)
at com.inosat.fuel.DggeParser$$anon$1.propertyChange(DggeParser.scala:49)
at java.beans.PropertyChangeSupport.firePropertyChange(Unknown Source)
at java.beans.PropertyChangeSupport.firePropertyChange(Unknown Source)
at java.beans.PropertyChangeSupport.firePropertyChange(Unknown Source)
at org.jdesktop.beans.AbstractBean.firePropertyChange(AbstractBean.java:302)
at org.jdesktop.http.async.AsyncHttpRequest.setReadyState(AsyncHttpRequest.java:705)
at org.jdesktop.http.async.AsyncHttpRequest.access$600(AsyncHttpRequest.java:79)
at org.jdesktop.http.async.AsyncHttpRequest$AsyncWorker.done(AsyncHttpRequest.java:831)
at javax.swing.SwingWorker$5.run(Unknown Source)
at javax.swing.SwingWorker$DoSubmitAccumulativeRunnable.run(Unknown Source)
at sun.swing.AccumulativeRunnable.run(Unknown Source)
at javax.swing.SwingWorker$DoSubmitAccumulativeRunnable.actionPerformed(Unknown Source)
at javax.swing.Timer.fireActionPerformed(Unknown Source)
at javax.swing.Timer$DoPostEvent.run(Unknown Source)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.开发者_StackOverflow中文版pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
Found out what's wrong, Eclipse is using a scala-library.jar from:
C:\eclipse\configuration\org.eclipse.osgi\bundles
and for some reason the jar I copied from Scala's installation folder is not the same. Fixed by using the same scala-library.jar that Eclipse is using.
精彩评论