Freemarker DOM attribute check not working - freemarker

I have the following XML
<OS_LINESTATUS LINENUMBER="1" QUANTITY="6" REQUESTNUMBER="598089607" STATUSCODE="LC"/>
<OS_LINESTATUS LINENUMBER="1" QUANTITY="1" REQUESTNUMBER="725772899" STATUSCODE="LC"/>
<OS_LINESTATUS LINENUMBER="1" REQUESTNUMBER="599927622" STATUSCODE="LI"/>
I have the following freemarker template where the xml elements are injected as "elements".
[<#list elements as element>{"primeLineNo":"${element.OS_LINESTATUS.#LINENUMBER}","poLineStatusInfos":[{"poLineStatus":"${element.OS_LINESTATUS.#STATUSCODE}"<#if element.OS_LINESTATUS.#QUANTITY??>,"poLineStatusQuantity":{"measurementValue":"${element.OS_LINESTATUS.#QUANTITY}","unitOfMeasure":"EA"}</#if>}]}<#sep>,</#sep></#list>]}]}}
But this fails at the third line as there is not quantity attribute even though I have put an if condition. Why is the if condition not working?
Following is the stack trace
==> element.OS_LINESTATUS.#QUANTITY [in template "suman-xml-to-xml- orderrequestxform/xml-aggregation/linestatus.ftl" at line 4, column 331]
----
Tip: This XML query result can't be used as string because for that it had to contain exactly 1 XML node, but it contains 0 nodes. That is, the constructing XML query has found no matches.
FTL stack trace ("~" means nesting-related): - Failed at: ${element.OS_LINESTATUS.#QUANTITY} [in template "suman-xml-to- xml-orderrequestxform/xml-aggregation/linestatus.ftl" at line 4, column 329]
Java stack trace (for programmers):
freemarker.core.NonStringException: [... Exception message was already printed; see it above ...]
at freemarker.core.EvalUtil.coerceModelToString(EvalUtil.java:390)
at freemarker.core.Expression.evalAndCoerceToString(Expression.java:82)
at freemarker.core.DollarVariable.accept(DollarVariable.java:41)
at freemarker.core.Environment.visit(Environment.java:324)
at freemarker.core.MixedContent.accept(MixedContent.java:54)
at freemarker.core.Environment.visitByHiddingParent(Environment.java:345)
at freemarker.core.ConditionalBlock.accept(ConditionalBlock.java:48)
at freemarker.core.Environment.visit(Environment.java:324)
at freemarker.core.MixedContent.accept(MixedContent.java:54)
at freemarker.core.Environment.visitByHiddingParent(Environment.java:345)
at freemarker.core.IteratorBlock$IterationContext.executeNestedBlockInner(IteratorBlock.java:268)
at freemarker.core.IteratorBlock$IterationContext.executeNestedBlock(IteratorBlock.java:220)
at freemarker.core.IteratorBlock$IterationContext.accept(IteratorBlock.java:194)
at freemarker.core.Environment.visitIteratorBlock(Environment.java:572)
at freemarker.core.IteratorBlock.acceptWithResult(IteratorBlock.java:78)
at freemarker.core.IteratorBlock.accept(IteratorBlock.java:64)
at freemarker.core.Environment.visit(Environment.java:324)
at freemarker.core.MixedContent.accept(MixedContent.java:54)
at freemarker.core.Environment.visit(Environment.java:324)
at freemarker.core.Environment.process(Environment.java:302)
at freemarker.template.Template.process(Template.java:325)
at example.aggregation.XmlElementAggregator.output(XmlElementAggregator.java:93)
at example.aggregation.XmlElementAggregator.aggregate(XmlElementAggregator.java:58)
at example.aggregation.XmlElementAggregator.visitAfter(XmlElementAggregator.java:45)
at org.milyn.delivery.sax.SAXHandler.visitAfter(SAXHandler.java:389)
at org.milyn.delivery.sax.SAXHandler.endElement(SAXHandler.java:204)
at org.milyn.delivery.SmooksContentHandler.endElement(SmooksContentHandler.java:96)
at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown Source)
at org.apache.xerces.parsers.AbstractXMLDocumentParser.emptyElement(Unknown Source)
at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
at org.milyn.delivery.sax.SAXParser.parse(SAXParser.java:76)
at org.milyn.delivery.sax.SmooksSAXFilter.doFilter(SmooksSAXFilter.java:86)
at org.milyn.delivery.sax.SmooksSAXFilter.doFilter(SmooksSAXFilter.java:64)
at org.milyn.Smooks._filter(Smooks.java:526)
at org.milyn.Smooks.filterSource(Smooks.java:482)
at example.TransformerBuilder.transform(TransformerBuilder.java:66)
at example.TransformAggregation.main(TransformAggregation.java:31)
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 com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)

The #if condition works because you are asking if element.OS_LINESTATUS.#QUANTITY exists, which does, as it's a result set of size 0. Use element.OS_LINESTATUS.#QUANTITY[0]?? instead. So that's the tricky about FreeMarker's DOM wrapper, that even queries which find nothing returns something. That's why such a result is #list-able, and more importantly, can be the context of further XPath queries (like element.maybeMissingElement.child never fails, just sometimes gives an empty result set).

Related

ST4 saving javascript changes from compare editor fails

Saving changes in javascript file after comparing projects and editing fails with IllegalStateException
Steps to reproduce
STS4 4.17.2 macos arm_64 (fresh install)
Create project comp1 and comp2
Create file comp1/hello.js with
console.log("Hello Foo");
Create file comp2/hello.js with
console.log("Hello Bar");
Select comp1 and comp2 projects and select Compare With->Each Other
In compare editor, double click on hello.js and make change(s) to either side
Try to save
Result:
Changes are not saved and exception found in the error log
!MESSAGE Unhandled event loop exception
!STACK 0
java.lang.IllegalStateException
at org.eclipse.jface.text.TextViewer.setHyperlinkPresenter(TextViewer.java:5639)
at org.eclipse.jface.text.source.SourceViewer.configure(SourceViewer.java:529)
at org.eclipse.ui.internal.genericeditor.compare.GenericEditorMergeViewer.configureTextViewer(GenericEditorMergeViewer.java:68)
at org.eclipse.ui.internal.genericeditor.compare.GenericEditorMergeViewer$1.inputDocumentChanged(GenericEditorMergeViewer.java:50)
at org.eclipse.jface.text.TextViewer.fireInputDocumentChanged(TextViewer.java:2849)
at org.eclipse.jface.text.TextViewer.setDocument(TextViewer.java:2890)
at org.eclipse.jface.text.source.SourceViewer.setDocument(SourceViewer.java:663)
at org.eclipse.jface.text.source.SourceViewer.setDocument(SourceViewer.java:603)
at org.eclipse.compare.contentmergeviewer.TextMergeViewer$ContributorInfo.updateViewerDocument(TextMergeViewer.java:807)
at org.eclipse.compare.contentmergeviewer.TextMergeViewer$ContributorInfo.internalSetDocument(TextMergeViewer.java:762)
at org.eclipse.compare.contentmergeviewer.TextMergeViewer$ContributorInfo.setDocument(TextMergeViewer.java:679)
at org.eclipse.compare.contentmergeviewer.TextMergeViewer.updateContent(TextMergeViewer.java:3029)
at org.eclipse.compare.contentmergeviewer.ContentMergeViewer.internalRefresh(ContentMergeViewer.java:793)
at org.eclipse.compare.contentmergeviewer.ContentMergeViewer.refresh(ContentMergeViewer.java:769)
at org.eclipse.compare.contentmergeviewer.ContentMergeViewer.handleCompareInputChange(ContentMergeViewer.java:1389)
at org.eclipse.compare.contentmergeviewer.TextMergeViewer.handleCompareInputChange(TextMergeViewer.java:5345)
at org.eclipse.compare.contentmergeviewer.ContentMergeViewer.lambda$1(ContentMergeViewer.java:390)
at org.eclipse.compare.structuremergeviewer.DiffNode.fireChange(DiffNode.java:140)
at org.eclipse.compare.internal.ResourceCompareInput$MyDiffNode.fireChange(ResourceCompareInput.java:90)
at org.eclipse.compare.internal.MergeViewerContentProvider.saveLeftContent(MergeViewerContentProvider.java:152)
at org.eclipse.compare.contentmergeviewer.ContentMergeViewer.flushLeftSide(ContentMergeViewer.java:1272)
at org.eclipse.compare.contentmergeviewer.TextMergeViewer.flushLeftSide(TextMergeViewer.java:5235)
at org.eclipse.compare.contentmergeviewer.TextMergeViewer.flushContent(TextMergeViewer.java:5258)
at org.eclipse.compare.contentmergeviewer.ContentMergeViewer.flush(ContentMergeViewer.java:1243)
at org.eclipse.compare.CompareEditorInput.flushViewer(CompareEditorInput.java:1220)
at org.eclipse.compare.CompareEditorInput.flushViewers(CompareEditorInput.java:1189)
at org.eclipse.compare.internal.ResourceCompareInput.getAdapter(ResourceCompareInput.java:508)
at org.eclipse.core.runtime.Adapters.adapt(Adapters.java:67)
at org.eclipse.core.runtime.Adapters.adapt(Adapters.java:116)
at org.eclipse.ui.ide.ResourceUtil.getFile(ResourceUtil.java:61)
at org.eclipse.ui.internal.ide.actions.BuildUtilities.findSelectedProjects(BuildUtilities.java:108)
at org.eclipse.ui.actions.BuildAction.isEnabled(BuildAction.java:231)
at org.eclipse.ui.actions.RetargetAction.setActionHandler(RetargetAction.java:268)
at org.eclipse.ui.internal.ide.actions.RetargetActionWithDefault.setActionHandler(RetargetActionWithDefault.java:51)
at org.eclipse.ui.actions.RetargetAction.propagateChange(RetargetAction.java:204)
at org.eclipse.ui.SubActionBars.firePropertyChange(SubActionBars.java:289)
at org.eclipse.ui.SubActionBars.fireActionHandlersChanged(SubActionBars.java:273)
at org.eclipse.ui.SubActionBars.updateActionBars(SubActionBars.java:603)
at org.eclipse.compare.internal.CompareHandlerService.updateActionBars(CompareHandlerService.java:131)
at org.eclipse.compare.internal.CompareHandlerService.updatePaneActionHandlers(CompareHandlerService.java:161)
at org.eclipse.compare.contentmergeviewer.TextMergeViewer.connectGlobalActions(TextMergeViewer.java:2784)
at org.eclipse.compare.contentmergeviewer.TextMergeViewer.setActiveViewer(TextMergeViewer.java:2719)
at org.eclipse.compare.contentmergeviewer.TextMergeViewer$22.focusLost(TextMergeViewer.java:2682)
at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:147)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:89)
at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4646)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1524)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1547)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1528)
at org.eclipse.swt.widgets.Control.sendFocusEvent(Control.java:3433)
at org.eclipse.swt.widgets.Canvas.sendFocusEvent(Canvas.java:80)
at org.eclipse.swt.widgets.Display.checkFocus(Display.java:744)
at org.eclipse.swt.widgets.Shell.makeFirstResponder(Shell.java:1317)
at org.eclipse.swt.widgets.Display.windowProc(Display.java:6522)
at org.eclipse.swt.internal.cocoa.OS.objc_msgSend_bool(Native Method)
at org.eclipse.swt.internal.cocoa.NSWindow.makeFirstResponder(NSWindow.java:197)
at org.eclipse.swt.widgets.Control.forceFocus(Control.java:1472)
at org.eclipse.swt.widgets.Control.forceFocus(Control.java:1452)
at org.eclipse.swt.widgets.Control.setFocus(Control.java:3880)
at org.eclipse.swt.widgets.Composite.setFocus(Composite.java:1129)
at org.eclipse.swt.widgets.Composite.setFocus(Composite.java:1127)
at org.eclipse.swt.widgets.Composite.setFocus(Composite.java:1127)
at org.eclipse.swt.widgets.Composite.setFocus(Composite.java:1127)
at org.eclipse.swt.widgets.Composite.setFocus(Composite.java:1127)
at org.eclipse.swt.widgets.Control.fixFocus(Control.java:1377)
at org.eclipse.swt.widgets.Control.setEnabled(Control.java:3860)
at org.eclipse.ui.internal.WorkbenchWindow.disableControl(WorkbenchWindow.java:2278)
at org.eclipse.ui.internal.WorkbenchWindow.run(WorkbenchWindow.java:2324)
at org.eclipse.ui.internal.SaveableHelper.runProgressMonitorOperation(SaveableHelper.java:278)
at org.eclipse.ui.internal.SaveableHelper.runProgressMonitorOperation(SaveableHelper.java:260)
at org.eclipse.ui.internal.SaveableHelper.saveModels(SaveableHelper.java:207)
at org.eclipse.ui.internal.SaveableHelper.savePart(SaveableHelper.java:150)
at org.eclipse.ui.internal.WorkbenchPage.saveSaveable(WorkbenchPage.java:3802)
at org.eclipse.ui.internal.WorkbenchPage.saveEditor(WorkbenchPage.java:3815)
at org.eclipse.ui.internal.handlers.SaveHandler.execute(SaveHandler.java:82)
at org.eclipse.ui.internal.handlers.HandlerProxy.execute(HandlerProxy.java:283)
at org.eclipse.ui.internal.handlers.E4HandlerProxy.execute(E4HandlerProxy.java:97)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:58)
at org.eclipse.e4.core.internal.di.InjectorImpl.invokeUsingClass(InjectorImpl.java:317)
at org.eclipse.e4.core.internal.di.InjectorImpl.invoke(InjectorImpl.java:251)
at org.eclipse.e4.core.contexts.ContextInjectionFactory.invoke(ContextInjectionFactory.java:173)
at org.eclipse.e4.core.commands.internal.HandlerServiceHandler.execute(HandlerServiceHandler.java:156)
at org.eclipse.core.commands.Command.executeWithChecks(Command.java:488)
at org.eclipse.core.commands.ParameterizedCommand.executeWithChecks(ParameterizedCommand.java:485)
at org.eclipse.e4.core.commands.internal.HandlerServiceImpl.executeHandler(HandlerServiceImpl.java:213)
at org.eclipse.e4.ui.bindings.keys.KeyBindingDispatcher.executeCommand(KeyBindingDispatcher.java:308)
at org.eclipse.e4.ui.bindings.keys.KeyBindingDispatcher.press(KeyBindingDispatcher.java:580)
at org.eclipse.e4.ui.bindings.keys.KeyBindingDispatcher.processKeyEvent(KeyBindingDispatcher.java:647)
at org.eclipse.e4.ui.bindings.keys.KeyBindingDispatcher.filterKeySequenceBindings(KeyBindingDispatcher.java:439)
at org.eclipse.e4.ui.bindings.keys.KeyBindingDispatcher$KeyDownFilter.handleEvent(KeyBindingDispatcher.java:96)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:89)
at org.eclipse.swt.widgets.Display.filterEvent(Display.java:1217)
at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4641)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1524)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1547)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1532)
at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:1561)
at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:1557)
at org.eclipse.swt.widgets.Canvas.sendKeyEvent(Canvas.java:522)
at org.eclipse.swt.widgets.Control.doCommandBySelector(Control.java:1085)
at org.eclipse.swt.widgets.Display.windowProc(Display.java:6492)
at org.eclipse.swt.internal.cocoa.OS.objc_msgSend(Native Method)
at org.eclipse.swt.internal.cocoa.NSResponder.interpretKeyEvents(NSResponder.java:59)
at org.eclipse.swt.widgets.Composite.keyDown(Composite.java:607)
at org.eclipse.swt.widgets.Display.windowProc(Display.java:6324)
at org.eclipse.swt.internal.cocoa.OS.objc_msgSendSuper(Native Method)
at org.eclipse.swt.widgets.Widget.callSuper(Widget.java:236)
at org.eclipse.swt.widgets.Widget.windowSendEvent(Widget.java:2264)
at org.eclipse.swt.widgets.Shell.windowSendEvent(Shell.java:2511)
at org.eclipse.swt.widgets.Display.windowProc(Display.java:6444)
at org.eclipse.swt.internal.cocoa.OS.objc_msgSendSuper(Native Method)
at org.eclipse.swt.widgets.Display.applicationSendEvent(Display.java:5692)
at org.eclipse.swt.widgets.Display.applicationProc(Display.java:5831)
at org.eclipse.swt.internal.cocoa.OS.objc_msgSend(Native Method)
at org.eclipse.swt.internal.cocoa.NSApplication.sendEvent(NSApplication.java:117)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3986)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$5.run(PartRenderingEngine.java:1155)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:338)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1046)
at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:155)
at org.eclipse.ui.internal.Workbench.lambda$3(Workbench.java:643)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:338)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:550)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:171)
at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:152)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:203)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:136)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:402)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:255)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:659)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:596)
at org.eclipse.equinox.launcher.Main.run(Main.java:1467)
Work around:
Uninstalled Wild Web Developer plugin allows it to work
Changing the file extension to .txt also avoids the problem

spring.data.ldap with multiple spring.ldap.urls in application.properties

We use an LdapRepository<MyUser> within a Spring Boot project. The repo is auto-generated with a few additional query methods. We now have a second Active Directory domain server, and would like to add that to our Spring configuration. Before the .properties file looked like this:
spring.ldap.base=cn=Users,dc=company,dc=local
spring.ldap.password=really_save_password
spring.ldap.username=ldapuser#company.local
spring.ldap.urls=ldap://172.16.36.82:389
So I changed the last line to:
spring.ldap.urls=ldap://172.16.36.80:389 ldap://172.16.36.82:389
Because from other Stackoverflow questions I understood that multiple urls should be supplied with separating spaces.
But using userRepo.findAll() (or any query method) then leads to an exception:
Exception in thread "main" java.lang.IllegalStateException: Failed to execute CommandLineRunner
at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:803)
at org.springframework.boot.SpringApplication.callRunners(SpringApplication.java:784)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:338)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1258)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1246)
at com.company.product.web.WebApp.main(WebApp.java:22)
Caused by: org.springframework.ldap.NameNotFoundException: [LDAP: error code 32 - 0000208D: NameErr: DSID-0310021B, problem 2001 (NO_OBJECT), data 0, best match of:
''
]; nested exception is javax.naming.NameNotFoundException: [LDAP: error code 32 - 0000208D: NameErr: DSID-0310021B, problem 2001 (NO_OBJECT), data 0, best match of:
''
]; remaining name '/'
at org.springframework.ldap.support.LdapUtils.convertLdapException(LdapUtils.java:183)
at org.springframework.ldap.core.LdapTemplate.search(LdapTemplate.java:376)
at org.springframework.ldap.core.LdapTemplate.search(LdapTemplate.java:309)
at org.springframework.ldap.core.LdapTemplate.search(LdapTemplate.java:642)
at org.springframework.ldap.core.LdapTemplate.search(LdapTemplate.java:578)
at org.springframework.ldap.core.LdapTemplate.find(LdapTemplate.java:1840)
at org.springframework.ldap.core.LdapTemplate.findAll(LdapTemplate.java:1806)
at org.springframework.ldap.core.LdapTemplate.findAll(LdapTemplate.java:1814)
at org.springframework.data.ldap.repository.support.SimpleLdapRepository.findAll(SimpleLdapRepository.java:183)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:64)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:564)
at org.springframework.data.repository.core.support.RepositoryComposition$RepositoryFragments.invoke(RepositoryComposition.java:377)
at org.springframework.data.repository.core.support.RepositoryComposition.invoke(RepositoryComposition.java:200)
at org.springframework.data.repository.core.support.RepositoryFactorySupport$ImplementationMethodExecutionInterceptor.invoke(RepositoryFactorySupport.java:629)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:185)
at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.doInvoke(RepositoryFactorySupport.java:593)
at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke(RepositoryFactorySupport.java:578)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:185)
at org.springframework.data.projection.DefaultMethodInvokingMethodInterceptor.invoke(DefaultMethodInvokingMethodInterceptor.java:59)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:185)
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:185)
at org.springframework.data.repository.core.support.SurroundingTransactionDetectorMethodInterceptor.invoke(SurroundingTransactionDetectorMethodInterceptor.java:61)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:185)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:212)
at com.sun.proxy.$Proxy173.findAll(Unknown Source)
at com.company.product.web.Foo.run(Foo.java:22)
at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:800)
... 5 more
Caused by: javax.naming.NameNotFoundException: [LDAP: error code 32 - 0000208D: NameErr: DSID-0310021B, problem 2001 (NO_OBJECT), data 0, best match of:
''
]; remaining name '/'
at java.naming/com.sun.jndi.ldap.LdapCtx.mapErrorCode(LdapCtx.java:3284)
at java.naming/com.sun.jndi.ldap.LdapCtx.processReturnCode(LdapCtx.java:3205)
at java.naming/com.sun.jndi.ldap.LdapCtx.processReturnCode(LdapCtx.java:2996)
at java.naming/com.sun.jndi.ldap.LdapCtx.searchAux(LdapCtx.java:1875)
at java.naming/com.sun.jndi.ldap.LdapCtx.c_search(LdapCtx.java:1798)
at java.naming/com.sun.jndi.toolkit.ctx.ComponentDirContext.p_search(ComponentDirContext.java:392)
at java.naming/com.sun.jndi.toolkit.ctx.PartialCompositeDirContext.search(PartialCompositeDirContext.java:358)
at java.naming/javax.naming.directory.InitialDirContext.search(InitialDirContext.java:305)
at org.springframework.ldap.core.LdapTemplate$3.executeSearch(LdapTemplate.java:303)
at org.springframework.ldap.core.LdapTemplate.search(LdapTemplate.java:363)
... 33 more
It does work when I use just the second domain server, so either server works when used by its own in the .properties file.
What am I doing wrong?
If you want to use multiple ldap urls, you must declare them as a string array according to official spring-ldap document:
It is possible to configure multiple alternate LDAP servers using the urls property. In this case, supply all server urls in a String array to the urls property.
In your case try:
spring.ldap.urls=ldap://172.16.36.80:389,ldap://172.16.36.82:389

JPA EclipseLink - The expression is not a valid conditional expression

Although there is nothing wrong with this query, eclipselink throws this exception.
[34, 130] The expression is not a valid conditional expression.
I am trying to run Spring boot with Jpa/eclipselink in windows 7.
The problem occurs when I change system language to Turkish.
Why eclipselink doesnt work on OS that uses Turkish lang? When I change system language to English, it works fine.
Please somebody help me out.
Query:
return em.createQuery("select c from Orderdetail c where c.status=1 and c.triggertime > 0 and c.printstatus = 0 and c.idorder.idorderstatus.id in (1, 4)").setHint(QueryHints.REFRESH, HintValues.TRUE).getResultList();
This is another query parsing error. Full log
Exception Description: Syntax error parsing [select c from Orderdetail c where c.status=1 and c.triggertime > 0 and c.printstatus = 0 and c.idorder.idorderstatus.id in (1, 4)].
[34, 131] The expression is not a valid conditional expression.
at org.springframework.orm.jpa.EntityManagerFactoryUtils.convertJpaAccessExceptionIfPossible(EntityManagerFactoryUtils.java:367) ~[spring-orm-5.0.9.RELEASE.jar!/:5.0.9.RELEASE]
at org.springframework.orm.jpa.DefaultJpaDialect.translateExceptionIfPossible(DefaultJpaDialect.java:127) ~[spring-orm-5.0.9.RELEASE.jar!/:5.0.9.RELEASE]
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.translateExceptionIfPossible(AbstractEntityManagerFactoryBean.java:527) ~[spring-orm-5.0.9.RELEASE.jar!/:5.0.9.RELEASE]
at org.springframework.dao.support.ChainedPersistenceExceptionTranslator.translateExceptionIfPossible(ChainedPersistenceExceptionTranslator.java:61) ~[spring-tx-5.0.9.RELEASE.jar!/:5.0.9.RELEASE]
at org.springframework.dao.support.DataAccessUtils.translateIfNecessary(DataAccessUtils.java:242) ~[spring-tx-5.0.9.RELEASE.jar!/:5.0.9.RELEASE]
at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:153) ~[spring-tx-5.0.9.RELEASE.jar!/:5.0.9.RELEASE]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:185) ~[spring-aop-5.0.9.RELEASE.jar!/:5.0.9.RELEASE]
at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:688) ~[spring-aop-5.0.9.RELEASE.jar!/:5.0.9.RELEASE]
at tr.com.abeja.acservice.repository.DictionariesRepository$$EnhancerBySpringCGLIB$$9c377301.findTriggeredOrderDetails(<generated>) ~[classes!/:3.2.1]
at tr.com.abeja.acservice.service.DictsController.findAndPrintTriggeredOrderDetails(DictsController.java:887) ~[classes!/:3.2.1]
at tr.com.abeja.acservice.controller.DictsResource.updateTimerProductsPrice(DictsResource.java:48) ~[classes!/:3.2.1]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_202]
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[na:1.8.0_202]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[na:1.8.0_202]
at java.lang.reflect.Method.invoke(Unknown Source) ~[na:1.8.0_202]
at org.springframework.scheduling.support.ScheduledMethodRunnable.run(ScheduledMethodRunnable.java:84) ~[spring-context-5.0.9.RELEASE.jar!/:5.0.9.RELEASE]
at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:54) ~[spring-context-5.0.9.RELEASE.jar!/:5.0.9.RELEASE]
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) [na:1.8.0_202]
at java.util.concurrent.FutureTask.runAndReset(Unknown Source) [na:1.8.0_202]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(Unknown Source) [na:1.8.0_202]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(Unknown Source) [na:1.8.0_202]
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) [na:1.8.0_202]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [na:1.8.0_202]
at java.lang.Thread.run(Unknown Source) [na:1.8.0_202]
Caused by: java.lang.IllegalArgumentException: An exception occurred while creating a query in EntityManager:
Exception Description: Syntax error parsing [select c from Orderdetail c where c.status=1 and c.triggertime > 0 and c.printstatus = 0 and c.idorder.idorderstatus.id in (1, 4)].
[34, 131] The expression is not a valid conditional expression.
at org.eclipse.persistence.internal.jpa.EntityManagerImpl.createQuery(EntityManagerImpl.java:1746) ~[eclipselink-2.7.4.jar!/:2.7.4.v20190115-ad5b7c6b2a]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_202]
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[na:1.8.0_202]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[na:1.8.0_202]
at java.lang.reflect.Method.invoke(Unknown Source) ~[na:1.8.0_202]
at org.springframework.orm.jpa.ExtendedEntityManagerCreator$ExtendedEntityManagerInvocationHandler.invoke(ExtendedEntityManagerCreator.java:350) ~[spring-orm-5.0.9.RELEASE.jar!/:5.0.9.RELEASE]
at com.sun.proxy.$Proxy68.createQuery(Unknown Source) ~[na:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_202]
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[na:1.8.0_202]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[na:1.8.0_202]
at java.lang.reflect.Method.invoke(Unknown Source) ~[na:1.8.0_202]
at org.springframework.orm.jpa.SharedEntityManagerCreator$SharedEntityManagerInvocationHandler.invoke(SharedEntityManagerCreator.java:305) ~[spring-orm-5.0.9.RELEASE.jar!/:5.0.9.RELEASE]
at com.sun.proxy.$Proxy68.createQuery(Unknown Source) ~[na:na]
at tr.com.abeja.acservice.repository.DictionariesRepository.findTriggeredOrderDetails(DictionariesRepository.java:857) ~[classes!/:3.2.1]
at tr.com.abeja.acservice.repository.DictionariesRepository$$FastClassBySpringCGLIB$$5a490717.invoke(<generated>) ~[classes!/:3.2.1]
at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204) ~[spring-core-5.0.9.RELEASE.jar!/:5.0.9.RELEASE]
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:746) ~[spring-aop-5.0.9.RELEASE.jar!/:5.0.9.RELEASE]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) ~[spring-aop-5.0.9.RELEASE.jar!/:5.0.9.RELEASE]
at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:139) ~[spring-tx-5.0.9.RELEASE.jar!/:5.0.9.RELEASE]
... 18 common frames omitted
Caused by: org.eclipse.persistence.exceptions.JPQLException:
Exception Description: Syntax error parsing [select c from Orderdetail c where c.status=1 and c.triggertime > 0 and c.printstatus = 0 and c.idorder.idorderstatus.id in (1, 4)].
[34, 131] The expression is not a valid conditional expression.
at org.eclipse.persistence.internal.jpa.jpql.HermesParser.buildException(HermesParser.java:157) ~[eclipselink-2.7.4.jar!/:2.7.4.v20190115-ad5b7c6b2a]
at org.eclipse.persistence.internal.jpa.jpql.HermesParser.validate(HermesParser.java:336) ~[eclipselink-2.7.4.jar!/:2.7.4.v20190115-ad5b7c6b2a]
at org.eclipse.persistence.internal.jpa.jpql.HermesParser.populateQueryImp(HermesParser.java:280) ~[eclipselink-2.7.4.jar!/:2.7.4.v20190115-ad5b7c6b2a]
at org.eclipse.persistence.internal.jpa.jpql.HermesParser.buildQuery(HermesParser.java:165) ~[eclipselink-2.7.4.jar!/:2.7.4.v20190115-ad5b7c6b2a]
at org.eclipse.persistence.internal.jpa.EJBQueryImpl.buildEJBQLDatabaseQuery(EJBQueryImpl.java:142) ~[eclipselink-2.7.4.jar!/:2.7.4.v20190115-ad5b7c6b2a]
at org.eclipse.persistence.internal.jpa.EJBQueryImpl.buildEJBQLDatabaseQuery(EJBQueryImpl.java:118) ~[eclipselink-2.7.4.jar!/:2.7.4.v20190115-ad5b7c6b2a]
at org.eclipse.persistence.internal.jpa.EJBQueryImpl.<init>(EJBQueryImpl.java:104) ~[eclipselink-2.7.4.jar!/:2.7.4.v20190115-ad5b7c6b2a]
at org.eclipse.persistence.internal.jpa.EJBQueryImpl.<init>(EJBQueryImpl.java:88) ~[eclipselink-2.7.4.jar!/:2.7.4.v20190115-ad5b7c6b2a]
at org.eclipse.persistence.internal.jpa.EntityManagerImpl.createQuery(EntityManagerImpl.java:1744) ~[eclipselink-2.7.4.jar!/:2.7.4.v20190115-ad5b7c6b2a]
... 36 common frames omitted
[SOLVED]
After spending hours of debugging, I found the reason of this exception.
LSS: Exception was occurring in HermesParser which is query parser in eclipselink. Starting from there, i found a code that converts in, and, or, like etc parts of jpql to uppercase.
Part of my query(failing to parse).
and c.idorder.idorderstatus.id in (1, 4)
Here and and in gets converted to uppercase AND and IN. The problem is, in turkish, uppercase of i letter is İ(dotted I), so upprecase of in is İN which is incorrect expression. When Operation system language is in Turkish, uppercase method converts i to İ. That was the problem.
I changed all lowercase letters in jpql to uppercase beforehand, and solved the problem.
Hope it helps someone else ever encountered with this problem

How to generate Dashboard report for existing JMeter csv/jtl files with tab delimiter

I am trying to generate JMeter Dashboard graph for existing results i.e., csv/jtl files.
Following is the csv file content (temp1.csv):
timeStamp elapsed label responseCode responseMessage threadName dataType success failureMessage bytes grpThreads allThreads Latency
1475842232895 1158 HTTP Request 200 OK Thread Group 1-1 text true 22175 1 1 911
1475842234094 529 HTTP Request 200 OK Thread Group 2-1 text true 682 1 1 529
Following is the command I ran:
jmeter -g J:\temp_ws\temp1.csv -o J:\temp_ws\temp1
and delimiter set to , in user.properties
jmeter.save.saveservice.default_delimiter=,
It is giving the following error I got (from JMeter.log file)
FATAL - jmeter.JMeter: An error occurred: org.apache.jmeter.report.dashboard.GenerationException: Error while processing samples:Consumer failed with message :No column <timeStamp> found in sample metadata <timeStamp elapsed label responseCode responseMessage threadName dataType success failureMessage bytes grpThreads allThreads Latency>, check #jmeter.save.saveservice.* properties to add the missing column
at org.apache.jmeter.report.dashboard.ReportGenerator.generate(ReportGenerator.java:245)
at org.apache.jmeter.JMeter.start(JMeter.java:478)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.jmeter.NewDriver.main(NewDriver.java:259)
Then tried to change the delimiter to \t in user.properties and run the command again to generate the report, I got the following error:
2016/10/07 17:59:32 FATAL - jmeter.JMeter: An error occurred:
java.lang.ExceptionInInitializerError
at org.apache.jmeter.JMeter.start(JMeter.java:477)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.jmeter.NewDriver.main(NewDriver.java:259)
Caused by: java.lang.StringIndexOutOfBoundsException: String index out of range: 0
at java.lang.String.charAt(Unknown Source)
at org.apache.jmeter.report.dashboard.ReportGenerator.<clinit>(ReportGenerator.java:79)
... 6 more
Please help me how to generate the Dashboard report for tab delimited Jmeter results (either csv/jtl)
Note: For comma delimiter, Dashboard reports are getting generated.
You're facing a bug of 3.0:
https://bz.apache.org/bugzilla/show_bug.cgi?id=60125
It is fixed in nightly build and will be available in 3.1 coming soon.
Meanwhile you can use Nightly Builds:
http://jmeter.apache.org/nightly.html

Derby "&" is not working

Select distinct APP.bca_cart.InventoryCode,APP.bca_cart.InventoryID,APP.bca_cart.CartID,APP.bca_cart.InvoiceID,APP.bca_cart.UnitPrice,APP.bca_cart.DateAdded,APP.bca_cart.CustomSku,APP.bca_cart.InventoryCode & '-' & APP.bca_cart.CustomSku AS fullsku,APP.bca_cart.Qty AS O_QTY,APP.storage_clientvendor.FirstName,APP.storage_clientvendor.LastName,APP.storage_clientvendor.Name FROM ((APP.bca_iteminventory INNER JOIN (APP.bca_cart INNER JOIN APP.bca_invoice ON APP.bca_cart.InvoiceID = APP.bca_invoice.InvoiceID) ON APP.bca_iteminventory.InventoryID = APP.bca_cart.InventoryID)INNER JOIN APP.storage_clientvendor ON APP.bca_invoice.ClientVendorID =APP.storage_clientvendor.ClientVendorID) Where APP.bca_iteminventory.StoreTypeID <= 0 AND APP.bca_iteminventory.ItemTypeID NOT IN (5,4,6) AND APP.bca_iteminventory.companyId =18 ORDER BY APP. storage_clientvendor.LastName ASC
I am getting following Stacktrace. please help me to solve this error.
SEVERE: null
java.sql.SQLSyntaxErrorException: Syntax error: Encountered "&" at line 1, column 145.
at org.apache.derby.impl.jdbc.SQLExceptionFactory40.getSQLException(Unknown Source)
at org.apache.derby.impl.jdbc.Util.generateCsSQLException(Unknown Source)
at org.apache.derby.impl.jdbc.TransactionResourceImpl.wrapInSQLException(Unknown Source)
at org.apache.derby.impl.jdbc.TransactionResourceImpl.handleException(Unknown Source)
at org.apache.derby.impl.jdbc.EmbedConnection.handleException(Unknown Source)
at org.apache.derby.impl.jdbc.ConnectionChild.handleException(Unknown Source)
at org.apache.derby.impl.jdbc.EmbedStatement.execute(Unknown Source)
at org.apache.derby.impl.jdbc.EmbedStatement.executeQuery(Unknown Source)
at com.bzcomposer.global.tables.tblItemLoader.getBackOrderItemListByCustomer(tblItemLoader.java:8488)
at com.bzcomposer.items.ItemListPanel$BackOrderItemModel.setTableData(ItemListPanel.java:4424)
at com.bzcomposer.items.ItemListPanel$BackOrderItemModel.<init>(ItemListPanel.java:4407)
at com.bzcomposer.items.ItemListPanel.<init>(ItemListPanel.java:140)
at com.bzcomposer.modules.internalPanel.SalesPanels.<init>(SalesPanels.java:90)
at com.bzcomposer.modules.internalPanel.InternalPanelsControl.init_internalPanel1(InternalPanelsControl.java:162)
at com.bzcomposer.modules.MainFrame2.init_internalframe1(MainFrame2.java:1104)
at com.bzcomposer.modules.MainFrame2.invokeInit(MainFrame2.java:816)
at com.bzcomposer.modules.MainPanel$1.run(MainPanel.java:393)
Caused by: java.sql.SQLException: Syntax error: Encountered "&" at line 1, column 145.
at org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(Unknown Source)
at org.apache.derby.impl.jdbc.SQLExceptionFactory40.wrapArgsForTransportAcrossDRDA(Unknown Source)
... 17 more
Caused by: ERROR 42X01: Syntax error: Encountered "&" at line 1, column 145.
at org.apache.derby.iapi.error.StandardException.newException(Unknown Source)
at org.apache.derby.impl.sql.compile.ParserImpl.parseStatement(Unknown Source)
i search a lot on internet but still i am not getting solution of it.
I guess you would like to concatinate the strings by using &.
For concatination you have to use ||
APP.bca_cart.InventoryCode || '-' || APP.bca_cart.CustomSku

Resources