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
Related
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
Which format should a postgresql field be retrieved in, for Hibernate to automatically deserialize it into an org.postgis.Point, or more generally an org.postgis.Geometry object?
Example:
#Formula("ST_PointOnSurface(surface)::geometry")
private Point pointOnSurface;
I have tried to wrap the above expression in ST_AsGeoJson, ST_AsBinary and other functions, but all result in the following exception when attempting to deserialize:
Caused by: org.hibernate.type.SerializationException: could not deserialize
at org.hibernate.internal.util.SerializationHelper.doDeserialize(SerializationHelper.java:243)
at org.hibernate.internal.util.SerializationHelper.deserialize(SerializationHelper.java:287)
at org.hibernate.type.descriptor.java.SerializableTypeDescriptor.fromBytes(SerializableTypeDescriptor.java:139)
at org.hibernate.type.descriptor.java.SerializableTypeDescriptor.wrap(SerializableTypeDescriptor.java:114)
at org.hibernate.type.descriptor.java.SerializableTypeDescriptor.wrap(SerializableTypeDescriptor.java:28)
at org.hibernate.type.descriptor.sql.VarbinaryTypeDescriptor$2.doExtract(VarbinaryTypeDescriptor.java:60)
at org.hibernate.type.descriptor.sql.BasicExtractor.extract(BasicExtractor.java:47)
at org.hibernate.type.AbstractStandardBasicType.nullSafeGet(AbstractStandardBasicType.java:258)
at org.hibernate.type.AbstractStandardBasicType.nullSafeGet(AbstractStandardBasicType.java:254)
at org.hibernate.type.AbstractStandardBasicType.nullSafeGet(AbstractStandardBasicType.java:244)
at org.hibernate.type.AbstractStandardBasicType.hydrate(AbstractStandardBasicType.java:327)
at org.hibernate.persister.entity.AbstractEntityPersister.hydrate(AbstractEntityPersister.java:2775)
at org.hibernate.loader.Loader.loadFromResultSet(Loader.java:1741)
at org.hibernate.loader.Loader.instanceNotYetLoaded(Loader.java:1667)
at org.hibernate.loader.Loader.getRow(Loader.java:1556)
at org.hibernate.loader.Loader.getRowFromResultSet(Loader.java:740)
at org.hibernate.loader.Loader.processResultSet(Loader.java:985)
at org.hibernate.loader.Loader.doQuery(Loader.java:943)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:349)
at org.hibernate.loader.Loader.doList(Loader.java:2615)
at org.hibernate.loader.Loader.doList(Loader.java:2598)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2430)
at org.hibernate.loader.Loader.list(Loader.java:2425)
at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:502)
at org.hibernate.hql.internal.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:371)
at org.hibernate.engine.query.spi.HQLQueryPlan.performList(HQLQueryPlan.java:216)
at org.hibernate.internal.SessionImpl.list(SessionImpl.java:1459)
at org.hibernate.query.internal.AbstractProducedQuery.doList(AbstractProducedQuery.java:1426)
at org.hibernate.query.internal.AbstractProducedQuery.list(AbstractProducedQuery.java:1398)
at org.hibernate.Query.getResultList(Query.java:417)
at org.hibernate.query.criteria.internal.compile.CriteriaQueryTypeQueryAdapter.getResultList(CriteriaQueryTypeQueryAdapter.java:72)
at my.confidential.package.name.MyEntityDaoImpl.getAll(MyEntityDaoImpl.java:42)
at sun.reflect.GeneratedMethodAccessor1168.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.__invoke(DelegatingMethodAccessorImpl.java:43)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:45009)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:45012)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:333)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:136)
... 34 common frames omitted
Caused by: java.io.StreamCorruptedException: invalid stream header: 30313031
at java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:866)
at java.io.ObjectInputStream.<init>(ObjectInputStream.java:358)
at org.hibernate.internal.util.SerializationHelper$CustomObjectInputStream.<init>(SerializationHelper.java:309)
at org.hibernate.internal.util.SerializationHelper$CustomObjectInputStream.<init>(SerializationHelper.java:299)
at org.hibernate.internal.util.SerializationHelper.doDeserialize(SerializationHelper.java:218)
... 74 common frames omitted
PostgreSQL 12.3 with postgis extension
The column surface is of type geometry
Java 8
net.postgis:postgis-geometry:2.5.0
org.hibernate.javax.persistence:hibernate-jpa-2.1-api:1.0.0.Final
Hibernate 5.2.4
Spring 4.3.25
Use hibernate spatial. Check out https://www.baeldung.com/hibernate-spatial
Mapping custom types is much more complex than simple types but you can still do it using Hibernate. Check out baeldung.com/hibernate-custom-types
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).
Im trying to read data from cassandra using Hive with CqlStorageHandler.
The versions:
Hive 0.11.0
Hadoop 1.2.1
Cassandra 1.2.6
Im able to create EXTERNAL table with the following HIVE Query
CREATE EXTERNAL TABLE input(number string,name string,address string) STORED BY 'org.apache.hadoop.hive.cassandra.cql.CqlStorageHandler' WITH SERDEPROPERTIES ("cassandra.columns.mapping" = ":key, name, address", "cassandra.ks.name" ="cassandradb", "cassandra.host" = "localhost" ,"cassandra.port" = "9160") TBLPROPERTIES ("cassandra.input.split.size" = "64000","cassandra.range.size" = "1000","cassandra.slice.predicate.size" = "1000");
(The table "input" is already existing and containing some data in cassandra created with CQL3)
However, When I try to read data with the following query
select * from input where number="1";
Im facing the folowing issue:
Total MapReduce jobs = 1
Launching Job 1 out of 1
Number of reduce tasks is set to 0 since there's no reduce operator
java.io.IOException: Could not get input splits
at org.apache.cassandra.hadoop.AbstractColumnFamilyInputFormat.getSplits(AbstractColumnFamilyInputFormat.java:189)
at org.apache.hadoop.hive.cassandra.input.cql.HiveCqlInputFormat.getSplits(HiveCqlInputFormat.java:213)
at org.apache.hadoop.hive.cassandra.input.cql.HiveCqlInputFormat.getSplits(HiveCqlInputFormat.java:169)
at org.apache.hadoop.hive.ql.io.HiveInputFormat.getSplits(HiveInputFormat.java:292)
at org.apache.hadoop.hive.ql.io.CombineHiveInputFormat.getSplits(CombineHiveInputFormat.java:297)
at org.apache.hadoop.mapred.JobClient.writeOldSplits(JobClient.java:1081)
at org.apache.hadoop.mapred.JobClient.writeSplits(JobClient.java:1073)
at org.apache.hadoop.mapred.JobClient.access$700(JobClient.java:179)
at org.apache.hadoop.mapred.JobClient$2.run(JobClient.java:983)
at org.apache.hadoop.mapred.JobClient$2.run(JobClient.java:936)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.Subject.doAs(Subject.java:415)
at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1190)
at org.apache.hadoop.mapred.JobClient.submitJobInternal(JobClient.java:936)
at org.apache.hadoop.mapred.JobClient.submitJob(JobClient.java:910)
at org.apache.hadoop.hive.ql.exec.ExecDriver.execute(ExecDriver.java:447)
at org.apache.hadoop.hive.ql.exec.MapRedTask.execute(MapRedTask.java:138)
at org.apache.hadoop.hive.ql.exec.Task.executeTask(Task.java:144)
at org.apache.hadoop.hive.ql.exec.TaskRunner.runSequential(TaskRunner.java:57)
at org.apache.hadoop.hive.ql.Driver.launchTask(Driver.java:1355)
at org.apache.hadoop.hive.ql.Driver.execute(Driver.java:1139)
at org.apache.hadoop.hive.ql.Driver.run(Driver.java:945)
at org.apache.hadoop.hive.cli.CliDriver.processLocalCmd(CliDriver.java:259)
at org.apache.hadoop.hive.cli.CliDriver.processCmd(CliDriver.java:216)
at org.apache.hadoop.hive.cli.CliDriver.processLine(CliDriver.java:413)
at org.apache.hadoop.hive.cli.CliDriver.run(CliDriver.java:756)
at org.apache.hadoop.hive.cli.CliDriver.main(CliDriver.java:614)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.apache.hadoop.util.RunJar.main(RunJar.java:160)
Caused by: java.util.concurrent.ExecutionException: java.lang.NumberFormatException: For input string: "143514173170822869679056708180186660043"
at java.util.concurrent.FutureTask.report(FutureTask.java:122)
at java.util.concurrent.FutureTask.get(FutureTask.java:188)
at org.apache.cassandra.hadoop.AbstractColumnFamilyInputFormat.getSplits(AbstractColumnFamilyInputFormat.java:185)
... 31 more
Caused by: java.lang.NumberFormatException: For input string: "143514173170822869679056708180186660043"
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
at java.lang.Long.parseLong(Long.java:444)
at java.lang.Long.valueOf(Long.java:540)
at org.apache.cassandra.dht.Murmur3Partitioner$1.fromString(Murmur3Partitioner.java:188)
at org.apache.cassandra.hadoop.AbstractColumnFamilyInputFormat$SplitCallable.call(AbstractColumnFamilyInputFormat.java:239)
at org.apache.cassandra.hadoop.AbstractColumnFamilyInputFormat$SplitCallable.call(AbstractColumnFamilyInputFormat.java:207)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:744)
Job Submission failed with exception 'java.io.IOException(Could not get input splits)'
FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.MapRedTask
Am I missing anything? Kindly advise.
I have a huge log file with a lot of exceptions and I need to extract full stack traces and few lines before and after it. It will be perfect if tool for this is bash script.
example:
$16.02.2012 16:04:34 *INFO * [main] InitialContextInitializer: Reference bound: rmirepository (InitialContextInitializer.java, line 203)
16.02.2012 16:04:34 *ERROR* [main] StandaloneContainerInitializedListener: Error of StandaloneContainer initialization (StandaloneContainerInitializedListener.java, line 109)
java.lang.RuntimeException: Cannot instantiate component key=org.exoplatform.services.jcr.ext.script.groovy.GroovyScript2RestLoader type=org.exoplatform.services.jcr.ext.script.groovy.GroovyScript2RestLoader found at file:/home/roman/reports/backup/1.14.7-5636/rdbms/single/exo-tomcat_1.14.7-5636/exo-configuration.xml
at org.exoplatform.container.jmx.MX4JComponentAdapter.getComponentInstance(MX4JComponentAdapter.java:134)
at org.exoplatform.container.management.ManageableComponentAdapter.getComponentInstance(ManageableComponentAdapter.java:68)
at org.exoplatform.container.ConcurrentPicoContainer.getInstance(ConcurrentPicoContainer.java:468)
at org.exoplatform.container.ConcurrentPicoContainer.getComponentInstancesOfType(ConcurrentPicoContainer.java:366)
at org.exoplatform.container.CachingContainer.getComponentInstancesOfType(CachingContainer.java:111)
at org.exoplatform.container.LifecycleVisitor.visitContainer(LifecycleVisitor.java:151)
at org.exoplatform.container.ConcurrentPicoContainer.accept(ConcurrentPicoContainer.java:615)
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 org.picocontainer.defaults.AbstractPicoVisitor.traverse(AbstractPicoVisitor.java:32)
at org.exoplatform.container.LifecycleVisitor.traverse(LifecycleVisitor.java:90)
at org.exoplatform.container.LifecycleVisitor.start(LifecycleVisitor.java:170)
at org.exoplatform.container.ConcurrentPicoContainer.start(ConcurrentPicoContainer.java:554)
at org.exoplatform.container.ExoContainer.start(ExoContainer.java:266)
at org.exoplatform.container.StandaloneContainer$3.run(StandaloneContainer.java:178)
at org.exoplatform.container.StandaloneContainer$3.run(StandaloneContainer.java:175)
at org.exoplatform.commons.utils.SecurityHelper.doPrivilegedAction(SecurityHelper.java:291)
at org.exoplatform.container.StandaloneContainer.getInstance(StandaloneContainer.java:174)
at org.exoplatform.container.StandaloneContainer.getInstance(StandaloneContainer.java:129)
at org.exoplatform.ws.frameworks.servlet.StandaloneContainerInitializedListener.contextInitialized(StandaloneContainerInitializedListener.java:104)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4205)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4704)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:799)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:779)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:601)
at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:675)
at org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java:601)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:502)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1315)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:324)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:142)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1061)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:840)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463)
at org.apache.catalina.core.StandardService.start(StandardService.java:525)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:754)
at org.apache.catalina.startup.Catalina.start(Catalina.java:595)
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 org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
Caused by: java.lang.RuntimeException: Cannot instantiate component key=org.exoplatform.services.jcr.RepositoryService type=org.exoplatform.services.jcr.impl.RepositoryServiceImpl found at file:/home/roman/reports/backup/1.14.7-5636/rdbms/single/exo-tomcat_1.14.7-5636/exo-configuration.xml
at org.exoplatform.container.jmx.MX4JComponentAdapter.getComponentInstance(MX4JComponentAdapter.java:134)
at org.exoplatform.container.management.ManageableComponentAdapter.getComponentInstance(ManageableComponentAdapter.java:68)
at org.exoplatform.container.ConcurrentPicoContainer.getInstance(ConcurrentPicoContainer.java:468)
at org.exoplatform.container.ConcurrentPicoContainer.getComponentInstanceOfType(ConcurrentPicoContainer.java:422)
at org.exoplatform.container.CachingContainer.getComponentInstanceOfType(CachingContainer.java:139)
at org.exoplatform.container.ExoContainer.createComponent(ExoContainer.java:407)
at org.exoplatform.container.jmx.MX4JComponentAdapter.getComponentInstance(MX4JComponentAdapter.java:96)
... 45 more
Use awk:
BEGIN {
previous = "";
}
/^\tat / {
if( previous != "" ) {
print previous;
previous = "";
}
print;
next;
}
{ previous = $0; }
should do the trick. In a nutshell, look for the pattern \tat (tab, at, blank) which almost always is used in a stack trace.
If you have many exceptions, then you can use maps (associative arrays in AWK's lingo) to save part of the exception message and then do statistics (like which exception happens the most).
Most of line in Java exception block are start with TAB delimiter.
So to get all exceptions from a huge log file you can use grep TAB delimiter.
Use following command to grep all exceptions from a file:
**$ grep -P -A 15 -B 15 "^\t" inputLogFile**
You can use below command
grep -B 10 -A 100 "Caused By" app.log -->this will give all the java exception logged in application log file. You can change string if you want to find specific exceptions.
https://www.techiedelight.com/java-program-search-exceptions-huge-log-file-on-server/
You can try something like this,
=======
grep -B20 -A20 ^'$16.02.2012 16:04:34' <path/to/log/file>
=======
Where
-B20 -- will display 20 lines before the line where the match was found.
-A20 -- will display 20 lines after the line where the match was found.