I'm beginner in java so need help.
I have a javafx app that works with Apache POI (for Excel files).
When I click menubutton I have an Error in Controller class which should load Excel data in Map collection and then show new Stage window.
But I have a strange error "Not on FX application thread; currentThread = JavaFX Application Thread" when press the button.
THere is a list of red masseges in output window with such main titles:
Exception in thread "JavaFX Application Thread"
java.lang.RuntimeException:
java.lang.reflect.InvocationTargetException
Caused by: java.lang.reflect.InvocationTargetException
Caused by: java.lang.IllegalStateException: Not on FX application thread;
currentThread = JavaFX Application Thread
Here is the code for Method in Controller
public void SKULoading(ActionEvent ae) {
Stage stage = (Stage) menuBar.getScene().getWindow();
stage.hide();
XSSFWorkbook wb = ExcelModel.OpenFile(stage); //using Filechooser
ExcelModel book = new ExcelModel(wb);
Map<Integer, List<String>> data = book.SheetToArray(0);
book.WBclose();
Stage primarystage;
// Since that moment error occurs!
primarystage = new Stage();
FXMLLoader loader = new FXMLLoader();
Pane root = null;
try {
root = loader.load(getClass().getResource("/FProject/SKUmanager.fxml").openStream());
} catch (IOException ex) {
Logger.getLogger(MainWindowController.class.getName()).log(Level.SEVERE, null, ex);
}
Scene scene = new Scene(root);
primarystage.setScene(scene);
primarystage.show();
}
I saw this topic How to avoid Not on FX application thread; currentThread = JavaFX Application Thread error? but solution like "Platform.runLater(new Runnable(){});" seems to solve the problem if I wrap in it almost all code in the Method. but I'm not sure it is right desicion because I didn't create any new Thread before.
When I removed row stage.hide(); new Stage was shown
Or When I left row stage.hide(); and removed rows
XSSFWorkbook wb = ExcelModel.OpenFile(stage);
ExcelModel book = new ExcelModel(wb);
Map<Integer, List<String>> data = book.SheetToArray(0);
book.WBclose();
Stage was shown again.
When I replace code
FileChooser fileChooser = new FileChooser();
fileChooser.setTitle("Open Resource File");
File file = fileChooser.showOpenDialog(stage);
in method ExcelModel.OpenFile(stage); by this
File file = new File("C:\\Users\\Maks\\Desktop\\Test.xlsx");
Stage was also shown.
So, I think, answer is lying near creating/hiding Stages or using FileChooser (Looks like using Filechooser somehow influences on the appearence of a new Stage after privious Stage was hidden)
UPD
Exception in thread "JavaFX Application Thread" java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
at javafx.fxml.FXMLLoader$MethodHandler.invoke(FXMLLoader.java:1774)
at javafx.fxml.FXMLLoader$ControllerMethodEventHandler.handle(FXMLLoader.java:1657)
at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:86)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:49)
at javafx.event.Event.fireEvent(Event.java:198)
at javafx.scene.control.MenuItem.fire(MenuItem.java:462)
at com.sun.javafx.scene.control.skin.ContextMenuContent$MenuItemContainer.doSelect(ContextMenuContent.java:1405)
at com.sun.javafx.scene.control.skin.ContextMenuContent$MenuItemContainer.lambda$createChildren$343(ContextMenuContent.java:1358)
at com.sun.javafx.event.CompositeEventHandler$NormalEventHandlerRecord.handleBubblingEvent(CompositeEventHandler.java:218)
at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:80)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:54)
at javafx.event.Event.fireEvent(Event.java:198)
at javafx.scene.Scene$MouseHandler.process(Scene.java:3757)
at javafx.scene.Scene$MouseHandler.access$1500(Scene.java:3485)
at javafx.scene.Scene.impl_processMouseEvent(Scene.java:1762)
at javafx.scene.Scene$ScenePeerListener.mouseEvent(Scene.java:2494)
at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:352)
at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:275)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.tk.quantum.GlassViewEventHandler.lambda$handleMouseEvent$354(GlassViewEventHandler.java:388)
at com.sun.javafx.tk.quantum.QuantumToolkit.runWithoutRenderLock(QuantumToolkit.java:389)
at com.sun.javafx.tk.quantum.GlassViewEventHandler.handleMouseEvent(GlassViewEventHandler.java:387)
at com.sun.glass.ui.View.handleMouseEvent(View.java:555)
at com.sun.glass.ui.View.notifyMouse(View.java:937)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.lambda$null$148(WinApplication.java:191)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.reflect.InvocationTargetException
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:497)
at sun.reflect.misc.Trampoline.invoke(MethodUtil.java:71)
at sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at sun.reflect.misc.MethodUtil.invoke(MethodUtil.java:275)
at javafx.fxml.FXMLLoader$MethodHandler.invoke(FXMLLoader.java:1769)
... 43 more
Caused by: java.lang.IllegalStateException: Not on FX application thread; currentThread = JavaFX Application Thread
at com.sun.javafx.tk.Toolkit.checkFxUserThread(Toolkit.java:236)
at com.sun.javafx.tk.quantum.QuantumToolkit.checkFxUserThread(QuantumToolkit.java:423)
at javafx.stage.Stage.<init>(Stage.java:241)
at javafx.stage.Stage.<init>(Stage.java:227)
at FProject.MainWindowController.SKULoading(MainWindowController.java:124)
... 53 more
Help me to find out what is the root of problem to avoid such errors in future. Thanks!
Related
I have a Springboot Kotlin app running in AWS ECS/EC2 with some code written by my predecessor. It runs into OutOfMemoryError after running a while in the server. I am not familiar with ReactiveX and threading, so would like to ask for some help on this.
I see from the error logs that it should be related to the Observable.blockingForEach method?
The listOfKeys is a limited source of 5 to 50 items, so it should not be due to backpressure?
I also pasted the thread dump when OutOfMemoryError occurred.
Code inside myMethod
Observable.fromIterable(listOfKeys)
.flatMap { key ->
Maybe.fromCallable {
Pair(key, methodWhichCallsExternalAPI))
}
.toObservable()
.subscribeOn(Schedulers.from(Executors.newFixedThreadPool(4)))
}
.blockingForEach {
// some simple assignment of result to variables
}
Exception logs
Caused by: java.lang.OutOfMemoryError: unable to create new native thread
at java.lang.Thread.start0(Native Method)
at java.lang.Thread.start(Thread.java:717)
at java.util.concurrent.ThreadPoolExecutor.addWorker(ThreadPoolExecutor.java:957)
at java.util.concurrent.ThreadPoolExecutor.execute(ThreadPoolExecutor.java:1367)
at java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:134)
at io.reactivex.internal.schedulers.ExecutorScheduler.scheduleDirect(ExecutorScheduler.java:59)
at io.reactivex.internal.operators.observable.ObservableSubscribeOn.subscribeActual(ObservableSubscribeOn.java:36)
at io.reactivex.Observable.subscribe(Observable.java:12284)
at io.reactivex.internal.operators.observable.ObservableMap.subscribeActual(ObservableMap.java:32)
at io.reactivex.Observable.subscribe(Observable.java:12284)
at io.reactivex.internal.operators.observable.ObservableFlatMap$MergeObserver.subscribeInner(ObservableFlatMap.java:165)
at io.reactivex.internal.operators.observable.ObservableFlatMap$MergeObserver.onNext(ObservableFlatMap.java:139)
at io.reactivex.internal.operators.observable.ObservableFromIterable$FromIterableDisposable.run(ObservableFromIterable.java:98)
at io.reactivex.internal.operators.observable.ObservableFromIterable.subscribeActual(ObservableFromIterable.java:58)
at io.reactivex.Observable.subscribe(Observable.java:12284)
at io.reactivex.internal.operators.observable.ObservableFlatMap.subscribeActual(ObservableFlatMap.java:55)
at io.reactivex.Observable.subscribe(Observable.java:12284)
at io.reactivex.internal.operators.observable.BlockingObservableIterable.iterator(BlockingObservableIterable.java:39)
at io.reactivex.Observable.blockingForEach(Observable.java:5183)
at com.myOrg.MyController.myMethod(MyController.kt:240)
at com.myOrg.MyController$$FastClassBySpringCGLIB$$38688575.invoke(<generated>)
at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218)
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:779)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:750)
at org.springframework.security.access.intercept.aopalliance.MethodSecurityInterceptor.invoke(MethodSecurityInterceptor.java:61)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:750)
at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:692)
at com.dbs.localisemanagement.localise.LocaliseController$$EnhancerBySpringCGLIB$$3e102d4f.lokaliseProjectsS3(<generated>)
at sun.reflect.GeneratedMethodAccessor134.invoke(Unknown Source)
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:197)
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:141)
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:106)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:895)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:808)
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1064)
Thread dump - each of the 3 parts are repeated many times
at sun.misc.Unsafe.park(Native Method)
"pool-30968-thread-1" Id=36794 WAITING on java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject#394a0729
at java.lang.Thread.run(Thread.java:748)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1134)
at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1074)
at java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:442)
at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2039)
at java.util.concurrent.locks.LockSupport.park(LockSupport.java:175)
- waiting on java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject#f0c2d74
at sun.security.ssl.SSLSocketImpl.readDataRecord(SSLSocketImpl.java:940)
- locked java.lang.Object#5e78eb81
at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:983)
at sun.security.ssl.InputRecord.read(InputRecord.java:503)
at sun.security.ssl.InputRecord.readFully(InputRecord.java:465)
at java.net.SocketInputStream.read(SocketInputStream.java:141)
at java.net.SocketInputStream.read(SocketInputStream.java:171)
at java.net.SocketInputStream.socketRead(SocketInputStream.java:116)
at java.net.SocketInputStream.socketRead0(Native Method)
"pool-30982-thread-1" Id=36808 RUNNABLE
- java.util.concurrent.ThreadPoolExecutor$Worker#7d90150f
Number of locked synchronizers = 1
at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.leaseConnection(PoolingHttpClientConnectionManager.java:306)
at org.apache.http.pool.AbstractConnPool$2.get(AbstractConnPool.java:198)
- locked org.apache.http.pool.AbstractConnPool$2#a0abf72
at org.apache.http.pool.AbstractConnPool$2.get(AbstractConnPool.java:253)
at org.apache.http.pool.AbstractConnPool.access$300(AbstractConnPool.java:70)
at org.apache.http.pool.AbstractConnPool.getPoolEntryBlocking(AbstractConnPool.java:393)
at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2039)
at java.util.concurrent.locks.LockSupport.park(LockSupport.java:175)
- waiting on java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject#7399fe63
at sun.misc.Unsafe.park(Native Method)
"pool-30987-thread-1" Id=36813 WAITING on java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject#7399fe63
- java.util.concurrent.ThreadPoolExecutor$Worker#5b4dcfd1
Number of locked synchronizers = 1
The most likely problem is the repeated creation of a thread pool that is not released after use.
.subscribeOn(Schedulers.from(Executors.newFixedThreadPool(4)))
The more the method runs the more abandoned threads it creates.
You should probably create a static Scheduler and use that:
static final ExecutorService pool =
Executors.newFixedThreadPool(4);
static final Scheduler scheduler = Schedulers.from(pool);
Later on, after the app's lifecycle ended, call pool.shutdown() to free the threads.
I made a java agent with bytebuddy. It works well untill target application load classes form uRLConnection.getInputStream. The target app works well without attachment the agent, but shows exception [java.lang.ClassNotFoundException] when the agent attached.
this is app's classloading line.
return this.getClass().getClassLoader().loadClass(string) //string points the name of a byte array.
In the application, the classes is provided in the form of byte array from the uRLConnection.getInputStream at runtime and the application loads those at runtime.
The eclipst stacktrace:
[Byte Buddy] COMPLETE client [app.m#7dc3712, null, loaded=false]
Exception in thread "main" java.lang.NoClassDefFoundError: kh
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at app.m.loadClass(m.java:22)
at java.lang.ClassLoader.loadClass(Unknown Source)
at app.appletviewer.b(appletviewer.java:1176)
at app.appletviewer.a(appletviewer.java:454)
at Launcher.main(Launcher.java:43)
Caused by: java.lang.ClassNotFoundException: kh
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at app.u.loadClass(u.java:79)
at java.lang.ClassLoader.findSystemClass(Unknown Source)
at app.m.loadClass(m.java:30)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 7 more
My agent is:
try {
new AgentBuilder.Default()
.with(new AgentBuilder.InitializationStrategy.SelfInjection.Eager())
.with(AgentBuilder.Listener.StreamWriting.toSystemError())
.type((ElementMatchers.any()))
.transform((builder, typeDescription, classLoader, module) -> builder
.method(ElementMatchers.any())
.intercept(Advice.to(MyAdviser.class))
).installOn(instrumentation);
} catch (Exception e) {
return;
}
I also tried
.transform(new AgentBuilder.Transformer.ForAdvice()
.include(MyAdviser.class.getClassLoader())
.advice(ElementMatchers.any(), MyAdviser.class.getName()))
But it doesn't seem to be attached.
I think your problem might be something else here. Try the second form of advice which avoids class loading where a class loading of a system class in an too ealry stage is probably is your problem in the application of loaded advice. Set an .ignore(none()) matcher for the instrumentation to make the second approach work as boot strap classes like URLConnection are not by instrumented by Byte Buddy in the default configuration.
What I want to achieve is that a user in the flash client calls a handler method defined in the red5 app which creates a server side stream and then plays it so that other users with flash client can view the broadcasted stream.
Here is my actionscript client side code triggered by a button click:
private function playLiveStream():void {
nc.call("remoteControl.playLiveStream", null, "demo_video.flv");
}
Here is my server side java code defined in a registered handler:
public void playLiveStream(String fileName) {
IScope scope=Red5.getConnectionLocal().getScope();
IServerStream stream=
StreamUtils.getServerStream(scope,"livestream1");
if (stream==null) {
stream=StreamUtils.createServerStream(scope, "livestream1");
StreamUtils.putServerStream(scope, "livestream1");
}
stream.addItem(SimplePlayItem.build(fileName));
stream.start();
}
Here is the actionscript to play the broadcasted stream:
ns = new NetStream(nc);
ns.play("livestream1");
However, in flash client, the stream plays for only one second and then stopped.
If I click the button to call the handler method again, there is error in the java log. Here is my java log for the error:
java.lang.reflect.InvocationTargetException: null
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_25]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_25]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_25]
at java.lang.reflect.Method.invoke(Method.java:483) ~[na:1.8.0_25]
at org.red5.server.service.ServiceInvoker.invoke(ServiceInvoker.java:193) [red5-server-common-1.0.6-RELEASE.jar:na]
at org.red5.server.service.ServiceInvoker.invoke(ServiceInvoker.java:115) [red5-server-common-1.0.6-RELEASE.jar:na]
at org.red5.server.net.rtmp.RTMPHandler.invokeCall(RTMPHandler.java:186) [red5-server-common-1.0.6-RELEASE.jar:1.0.6-RELEASE]
at org.red5.server.net.rtmp.RTMPHandler.onCommand(RTMPHandler.java:293) [red5-server-common-1.0.6-RELEASE.jar:1.0.6-RELEASE]
at org.red5.server.net.rtmp.BaseRTMPHandler.messageReceived(BaseRTMPHandler.java:105) [red5-server-common-1.0.6-RELEASE.jar:1.0.6-RELEASE]
at org.red5.server.net.rtmp.ReceivedMessageTask.call(ReceivedMessageTask.java:63) [red5-server-common-1.0.6-RELEASE.jar:1.0.6-RELEASE]
at org.red5.server.net.rtmp.ReceivedMessageTask.call(ReceivedMessageTask.java:14) [red5-server-common-1.0.6-RELEASE.jar:1.0.6-RELEASE]
at java.util.concurrent.FutureTask.run(FutureTask.java:266) [na:1.8.0_25]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [na:1.8.0_25]
at java.util.concurrent.FutureTask.run(FutureTask.java:266) [na:1.8.0_25]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_25]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_25]
at java.lang.Thread.run(Thread.java:745) [na:1.8.0_25]
Caused by: java.lang.IllegalStateException: State STOPPED not valid to start
at org.red5.server.stream.ServerStream.start(ServerStream.java:428) ~[red5-server.jar:1.0.6-RELEASE]
at com.eeplace.red5.core.RemoteControlHandler.playLiveStream(RemoteControlHandler.java:144) ~[classes/:na]
... 17 common frames omitted
Did anyone encounter the same error before?
Thank you for any suggestion.
I created a simple project from scratch to test the form snapshot functionality.
The project has one source file and uses the defaults of File->New Project. The source is:
package com.company;
import javax.swing.*;
import java.awt.*;
public class Main {
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
#Override
public void run() {
JLabel label = new JLabel("Hello");
JFrame frame = new JFrame("Title");
frame.setLayout(new BorderLayout());
frame.add(label,BorderLayout.CENTER);
frame.setSize(400,300);
frame.setVisible(true);
}
});
}
}
I get the following exception when I try to take a snap shot:
Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: com/intellij/designer/DesignerEditorPanelFacade
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
at com.intellij.uiDesigner.radComponents.RadComponent.createSnapshotComponent(RadComponent.java:742)
at com.intellij.uiDesigner.radComponents.RadContainer.importSnapshotComponent(RadContainer.java:639)
at com.intellij.uiDesigner.radComponents.RadComponent.createSnapshotComponent(RadComponent.java:752)
at com.intellij.uiDesigner.snapShooter.SnapShooterDaemon$SuspendSwingRunnable.createFormSnapshot(SnapShooterDaemon.java:271)
at com.intellij.uiDesigner.snapShooter.SnapShooterDaemon$SuspendSwingRunnable.doSnapshotCommand(SnapShooterDaemon.java:259)
at com.intellij.uiDesigner.snapShooter.SnapShooterDaemon$SuspendSwingRunnable.run(SnapShooterDaemon.java:238)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:251)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:733)
at java.awt.EventQueue.access$200(EventQueue.java:103)
at java.awt.EventQueue$3.run(EventQueue.java:694)
at java.awt.EventQueue$3.run(EventQueue.java:692)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:703)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:91)
Caused by: java.lang.ClassNotFoundException: com.intellij.designer.DesignerEditorPanelFacade
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
... 32 more
I checked the box for "Enable capturing form snapshots" in the run configuration.
When I go to New->Form Snapshot I get this window:
When I click "Create Snapshot" I get the exception I mentioned above.
Any ideas why this is happening? I have IDEA 14.1.4. I ran "Check for Updates" to be sure there wasn't anything new for IDEA or the plugins.
This is a bug in IntelliJ IDEA: https://youtrack.jetbrains.com/issue/IDEA-132891
I am using JCR 1.0 and I am having problems re-opening JCR connections after I close them.
Here are my two helper methods:
private void openConnection() throws Exception {
loadDbProperties();
repository = new TransientRepository(repositoryConfig,repositoryHome);
session = repository.login(new SimpleCredentials("testUserName","testPassword".toCharArray()));
ws = session.getWorkspace();
rootNode = session.getRootNode();
}
private void closeConnection() throws Exception {
session.save();
session.logout();
session = null;
repository = null;
}
I have two methods called, addProperty() and getProperty(), both need a connection to the JCR repository. I placed the openConnection() and closeConnection() methods at the beginning of both add and get methods but it seems that whichever method runs second is not able to re-open an already closed connection.
This is the exception I get:
javax.faces.el.EvaluationException: javax.jcr.RepositoryException: this session has been closed
at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:102)
at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102)
at javax.faces.component.UICommand.broadcast(UICommand.java:315)
at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:775)
at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1267)
at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:82)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:312)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:306)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:240)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:550)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:380)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:243)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:188)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:288)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:619)
Caused by: javax.jcr.RepositoryException: this session has been closed
at org.apache.jackrabbit.core.SessionImpl.sanityCheck(SessionImpl.java:340)
at org.apache.jackrabbit.core.ItemImpl.sanityCheck(ItemImpl.java:154)
at org.apache.jackrabbit.core.NodeImpl.addNode(NodeImpl.java:1751)
at pgts.trueMiner.core.dao.TenureDAOImpl.addTenure(TenureDAOImpl.java:63)
at pgts.trueMiner.core.biz.TenureServiceImpl.addTenure(TenureServiceImpl.java:63)
at pgts.trueMiner.core.ui.TenureForm.addTenure(TenureForm.java:50)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.sun.el.parser.AstValue.invoke(AstValue.java:234)
at com.sun.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:297)
at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:98)
at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:88)
... 23 more
How do you re-open the same connection? I don't want to always keep the connection open because a lock will prevent other applications from using the repository.
It looks like you try to add a node after the session was closed. I can reproduce the exception using the following test case:
Repository repository = new TransientRepository();
Session session = repository.login(
new SimpleCredentials("admin", "admin".toCharArray()));
session.getWorkspace();
Node rootNode = session.getRootNode();
session.save();
session.logout();
rootNode.addNode("test");
With a recent version of Jackrabbit (I used Jackrabbit trunk) you will get the stack trace of where the session was closed:
Exception in thread "main" javax.jcr.RepositoryException: This session has been closed. See the chained exception for a trace of where the session was closed.
at org.apache.jackrabbit.core.session.SessionState.checkAlive(SessionState.java:121)
at org.apache.jackrabbit.core.session.SessionState.perform(SessionState.java:171)
at org.apache.jackrabbit.core.ItemImpl.perform(ItemImpl.java:91)
at org.apache.jackrabbit.core.NodeImpl.addNodeWithUuid(NodeImpl.java:1790)
at org.apache.jackrabbit.core.NodeImpl.addNode(NodeImpl.java:1742)
at org.apache.jackrabbit.api.Test.main(Test.java:21)
Caused by: java.lang.Exception: Stack trace of where session-admin-4 was originally closed
at org.apache.jackrabbit.core.session.SessionState.close(SessionState.java:246)
at org.apache.jackrabbit.core.SessionImpl.logout(SessionImpl.java:888)
at org.apache.jackrabbit.core.XASessionImpl.logout(XASessionImpl.java:389)
at org.apache.jackrabbit.api.Test.main(Test.java:20)