jboss-fuse / wsdl2rest

A tool allowing quick migration from existing JAX-WS services to REST
Apache License 2.0
25 stars 22 forks source link

adding support method to avoid Velocity log issue in Eclipse #61

Closed bfitzpat closed 5 years ago

bfitzpat commented 5 years ago

So it seems that we've hit a snag with running the wsdl2rest utility within an Eclipse instance. The OSGI classloader setup in the latest updates to Eclipse Photon (and beyond) seem to cause issues when wsdl2rest attempts to update the velocity.log during its template process.

Adding the Velocity property "runtime.log.logsystem.class" and setting it to "org.apache.velocity.runtime.log.NullLogChute" is the known workaround for this issue if we don't mind Velocity actually not logging events during WSDL processing.

Adding this line to the org.jboss.fuse.wsdl2rest.impl.codegen.CamelContextGenerator class (about line 58) resolves it:

        ve.setProperty("runtime.log.logsystem.class", org.apache.velocity.runtime.log.NullLogChute.class.getName());        

I'm thinking that maybe we can add a flag to the command line to set this property if we need the workaround, which will keep other uses of this utility not seeing an impact to the change. Edit: Unnecessary to have command-line flag at this point - just went with another utility method we could call to set the flag.

Otherwise we end up with a utility we can't run inside Eclipse and we get this error:

!ENTRY org.fusesource.ide.wsdl2rest.ui 4 0 2018-09-19 15:55:27.019
!MESSAGE Error initializing log: Failed to initialize an instance of org.apache.velocity.runtime.log.Log4JLogChute with the current runtime configuration.
!STACK 0
org.apache.velocity.exception.VelocityException: Error initializing log: Failed to initialize an instance of org.apache.velocity.runtime.log.Log4JLogChute with the current runtime configuration.
    at org.apache.velocity.runtime.RuntimeInstance.initializeLog(RuntimeInstance.java:875)
    at org.apache.velocity.runtime.RuntimeInstance.init(RuntimeInstance.java:262)
    at org.apache.velocity.app.VelocityEngine.init(VelocityEngine.java:93)
    at org.jboss.fuse.wsdl2rest.impl.codegen.CamelContextGenerator.process(CamelContextGenerator.java:59)
    at org.jboss.fuse.wsdl2rest.impl.Wsdl2Rest.process(Wsdl2Rest.java:92)
    at org.fusesource.ide.wsdl2rest.ui.wizard.Wsdl2RestWizard.generate(Wsdl2RestWizard.java:341)
    at org.fusesource.ide.wsdl2rest.ui.wizard.Wsdl2RestWizard.access$0(Wsdl2RestWizard.java:304)
    at org.fusesource.ide.wsdl2rest.ui.wizard.Wsdl2RestWizard$1.run(Wsdl2RestWizard.java:112)
    at org.eclipse.jface.operation.ModalContext.runInCurrentThread(ModalContext.java:437)
    at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:353)
    at org.eclipse.jface.wizard.WizardDialog.run(WizardDialog.java:974)
    at org.fusesource.ide.wsdl2rest.ui.wizard.Wsdl2RestWizard.performFinish(Wsdl2RestWizard.java:107)
    at org.eclipse.jface.wizard.WizardDialog.finishPressed(WizardDialog.java:772)
    at org.eclipse.jface.wizard.WizardDialog.buttonPressed(WizardDialog.java:411)
    at org.eclipse.jface.dialogs.Dialog.lambda$0(Dialog.java:619)
    at org.eclipse.swt.events.SelectionListener$1.widgetSelected(SelectionListener.java:84)
    at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:252)
    at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:89)
    at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4145)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1055)
    at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3958)
    at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3561)
    at org.eclipse.jface.window.Window.runEventLoop(Window.java:818)
    at org.eclipse.jface.window.Window.open(Window.java:794)
    at org.eclipse.ui.internal.handlers.WizardHandler$New.executeHandler(WizardHandler.java:269)
    at org.eclipse.ui.internal.handlers.WizardHandler.execute(WizardHandler.java:290)
    at org.eclipse.ui.internal.handlers.HandlerProxy.execute(HandlerProxy.java:291)
    at org.eclipse.ui.internal.handlers.E4HandlerProxy.execute(E4HandlerProxy.java:93)
    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.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:58)
    at org.eclipse.e4.core.internal.di.InjectorImpl.invokeUsingClass(InjectorImpl.java:320)
    at org.eclipse.e4.core.internal.di.InjectorImpl.invoke(InjectorImpl.java:254)
    at org.eclipse.e4.core.contexts.ContextInjectionFactory.invoke(ContextInjectionFactory.java:164)
    at org.eclipse.e4.core.commands.internal.HandlerServiceHandler.execute(HandlerServiceHandler.java:153)
    at org.eclipse.core.commands.Command.executeWithChecks(Command.java:494)
    at org.eclipse.core.commands.ParameterizedCommand.executeWithChecks(ParameterizedCommand.java:487)
    at org.eclipse.e4.core.commands.internal.HandlerServiceImpl.executeHandler(HandlerServiceImpl.java:204)
    at org.eclipse.e4.ui.bindings.keys.KeyBindingDispatcher.executeCommand(KeyBindingDispatcher.java:305)
    at org.eclipse.e4.ui.bindings.keys.KeyBindingDispatcher.press(KeyBindingDispatcher.java:579)
    at org.eclipse.e4.ui.bindings.keys.KeyBindingDispatcher.processKeyEvent(KeyBindingDispatcher.java:648)
    at org.eclipse.e4.ui.bindings.keys.KeyBindingDispatcher.filterKeySequenceBindings(KeyBindingDispatcher.java:438)
    at org.eclipse.e4.ui.bindings.keys.KeyBindingDispatcher.access$2(KeyBindingDispatcher.java:381)
    at org.eclipse.e4.ui.bindings.keys.KeyBindingDispatcher$KeyDownFilter.handleEvent(KeyBindingDispatcher.java:93)
    at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:89)
    at org.eclipse.swt.widgets.Display.filterEvent(Display.java:1193)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1054)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1079)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1064)
    at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:1106)
    at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:1102)
    at org.eclipse.swt.widgets.Widget.wmChar(Widget.java:1489)
    at org.eclipse.swt.widgets.Control.WM_CHAR(Control.java:4888)
    at org.eclipse.swt.widgets.Tree.WM_CHAR(Tree.java:5968)
    at org.eclipse.swt.widgets.Control.windowProc(Control.java:4768)
    at org.eclipse.swt.widgets.Tree.windowProc(Tree.java:5963)
    at org.eclipse.swt.widgets.Display.windowProc(Display.java:4784)
    at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method)
    at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:2309)
    at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3559)
    at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$5.run(PartRenderingEngine.java:1170)
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:336)
    at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1059)
    at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:153)
    at org.eclipse.ui.internal.Workbench.lambda$3(Workbench.java:625)
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:336)
    at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:560)
    at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:148)
    at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:152)
    at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:388)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:243)
    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.eclipse.equinox.launcher.Main.invokeFramework(Main.java:656)
    at org.eclipse.equinox.launcher.Main.basicRun(Main.java:592)
    at org.eclipse.equinox.launcher.Main.run(Main.java:1498)
    at org.eclipse.equinox.launcher.Main.main(Main.java:1471)
Caused by: org.apache.velocity.exception.VelocityException: Failed to initialize an instance of org.apache.velocity.runtime.log.Log4JLogChute with the current runtime configuration.
    at org.apache.velocity.runtime.log.LogManager.createLogChute(LogManager.java:220)
    at org.apache.velocity.runtime.log.LogManager.updateLog(LogManager.java:269)
    at org.apache.velocity.runtime.RuntimeInstance.initializeLog(RuntimeInstance.java:871)
    ... 83 more
Caused by: java.lang.RuntimeException: Error configuring Log4JLogChute :
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
    at org.apache.velocity.util.ExceptionUtils.createWithCause(ExceptionUtils.java:68)
    at org.apache.velocity.util.ExceptionUtils.createRuntimeException(ExceptionUtils.java:45)
    at org.apache.velocity.runtime.log.Log4JLogChute.initAppender(Log4JLogChute.java:133)
    at org.apache.velocity.runtime.log.Log4JLogChute.init(Log4JLogChute.java:85)
    at org.apache.velocity.runtime.log.LogManager.createLogChute(LogManager.java:157)
    ... 85 more
Caused by: java.io.FileNotFoundException: velocity.log (Access is denied)
    at java.io.FileOutputStream.open0(Native Method)
    at java.io.FileOutputStream.open(FileOutputStream.java:270)
    at java.io.FileOutputStream.<init>(FileOutputStream.java:213)
    at java.io.FileOutputStream.<init>(FileOutputStream.java:133)
    at org.apache.log4j.FileAppender.setFile(FileAppender.java:294)
    at org.apache.log4j.RollingFileAppender.setFile(RollingFileAppender.java:207)
    at org.apache.log4j.FileAppender.<init>(FileAppender.java:110)
    at org.apache.log4j.RollingFileAppender.<init>(RollingFileAppender.java:79)
    at org.apache.velocity.runtime.log.Log4JLogChute.initAppender(Log4JLogChute.java:118)
    ... 87 more
bfitzpat commented 5 years ago

Created a PR - stayed away from adding a command line option since we don't go that route in Eclipse

https://github.com/jboss-fuse/wsdl2rest/pull/62

tdiesler commented 5 years ago

Done

bfitzpat commented 5 years ago

Thanks!