FAILED: CampaignTest
java.lang.NullPointerException at
com.test.synapse.Synapse4.UIActions.CampaignPage.Campaigns(CampaignPage.java:282)
at
com.test.Synapse4.Campaings.TC001_BulkSMS.CampaignTest(TC001_BulkSMS.java:30)
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.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:104)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:645) at
org.testng.internal.Invoker.invokeTestMethod(Invoker.java:851) at
org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1177) at
org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:129)
at
org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:112)
at org.testng.TestRunner.privateRun(TestRunner.java:756) at
org.testng.TestRunner.run(TestRunner.java:610) at
org.testng.SuiteRunner.runTest(SuiteRunner.java:387) at
org.testng.SuiteRunner.runSequentially(SuiteRunner.java:382) at
org.testng.SuiteRunner.privateRun(SuiteRunner.java:340) at
org.testng.SuiteRunner.run(SuiteRunner.java:289) at
org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52) at
org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86) at
org.testng.TestNG.runSuitesSequentially(TestNG.java:1293) at
org.testng.TestNG.runSuitesLocally(TestNG.java:1218) at
org.testng.TestNG.runSuites(TestNG.java:1133) at
org.testng.TestNG.run(TestNG.java:1104) at
org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:114)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:251)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:77)**
===============================================
Default test
Tests run: 1, Failures: 1, Skips: 0
=============================================== Code as===========
public void Campaigns() throws IOException, InterruptedException
{
Campaigns.click();
Thread.sleep(4000);
Bulksms.click();`enter code here`
log.info("enter the Campaign Name" +Campaign_Name +"Object of Campaign_Name"
+Campaign_Name.toString());
Campaign_Name.sendKeys("CampaignTest3");
Thread.sleep(2000);
log.info("Select SenderId" +SenderId +"Object of SenderId"
+SenderId.toString());
SenderId.click();
Select drop = new Select(SenderId);
drop.selectByVisibleText("Babyshop");
Thread.sleep(2000);
log.info("Click to RecipientType" +RecipientType +"Object of RecipientType"
+RecipientType.toString());
RecipientType.click();
Thread.sleep(4000);
log.info("Upload the File" +SelectFile +"Object of SelectFile"
+SelectFile.toString());
uploadfile();
Thread.sleep(3000);
log.info("Select the Excel sheet" +SelectSheet +"Object of SelectSheet"
+SelectSheet.toString());
SelectSheet.click();
Select sel = new Select(SelectSheet);
sel.selectByVisibleText("Sheet1");Thread.sleep(2000);
log.info("Select the Mobile number" +MobileNo +"Object of MobileNo"
+MobileNo.toString());
MobileNo.click();
Select drop1 = new Select(MobileNo);
drop1.selectByVisibleText("MOBILENO");
Thread.sleep(2000);
log.info("Enter the Message" +Message +"Object of MobileNo"
+Message.toString());
Message.sendKeys("Recharge or Pay Bills & 7 Lucky Winners will get 100%
cashback every hour.");
Thread.sleep(2000);
log.info("Click on Schedule radio button" +Schedule +"Object of Schedule"
+Schedule.toString());
Schedule.click();
Thread.sleep(3000);
log.info("Click on Date selection" +ScheduleDate +"Object of ScheduleDate"
+ScheduleDate.toString());
ScheduleDate.click();
Thread.sleep(3000);
log.info("Select the Date form Calendar" +Date +"Object of Date"
+Date.toString());
Date.click();
Thread.sleep(2000);
log.info("Select the Hours form Calendar" +Hours +"Object of Date"
+Hours.toString());
Hours.click();
Select dropdown1 = new Select(Hours);
dropdown1.getOptions().get(17).click();
Thread.sleep(2000);
log.info("Select the Minutes form Calendar" +Minutes +"Object of Minutes"
+Minutes.toString());
Minutes.click();
Select dropdown2 = new Select(Minutes);
dropdown2.getOptions().get(5).click();//Minutes();
Thread.sleep(2000);
log.info("Checking the AllowDups button" +AllowDups +"Object of AllowDups"
+AllowDups.toString());
AllowDups.click();
Thread.sleep(2000);
log.info("Click to Submit button and Obejct is:" +Save.toString());
Save.click();
Thread.sleep(6000);
boolean alert;
if(alert=true)
{Assert.assertEquals("Campaign name already existed in db.", "Campaign name
already existed in db.", getalertmessage());
System.out.println(alertmessage.getText());
}log.info("Swicth to SendCampaign page:" +iframe.toString());
driver.switchTo().frame(iframe);
Thread.sleep(6000);
log.info("Click to SendCampaign and Obejct is:" +SendCampaign.toString());
SendCampaign.click();
Thread.sleep(10000);
}
Related
1. When I tried to create a new Geoserver layer from a new SQL view, after type the sql statement and all the parameters, when I click save, got the following saving error:
Failed to create SQL view: class org.geoserver.feature.retype.RetypingDataStore cannot be cast to class org.geotools.jdbc.JDBCDataStore (org.geoserver.feature.retype.RetypingDataStore and org.geotools.jdbc.JDBCDataStore are in unnamed module of loader org.apache.catalina.loader.ParallelWebappClassLoader #63fdab07)
Here's a screenshot of how that same error message looks like
Here is the sql statement we use to create view on Geoserver and it has 2 parameters:
SELECT link_id, st_name,
CASE
WHEN %npi_id% = 1 THEN npi_1_cat
WHEN %npi_id% = 2 THEN npi_2_cat
WHEN %npi_id% = 3 THEN npi_3_cat
WHEN %npi_id% = 4 THEN npi_4_cat
WHEN %npi_id% = 5 THEN npi_5_cat
ELSE npi_1_cat
END as cond_cat,
geom
FROM tl_link_qid_npi5
WHERE q_id = %query_id%
If we run the normal sql query on the view in database directly, it's fine and result been returned.
And also this is the log we got from Geoserver regarding to this exception:
[geoserver.web] - Failed to create feature type
java.lang.ClassCastException: class org.geoserver.feature.retype.RetypingDataStore cannot be cast to class org.geotools.jdbc.JDBCDataStore (org.geoserver.feature.retype.RetypingDataStore and org.geotools.jdbc.JDBCDataStore are in unnamed module of loader org.apache.catalina.loader.ParallelWebappClassLoader #63fdab07)
at org.geoserver.web.data.layer.SQLViewNewPage.onSave(SQLViewNewPage.java:34)
at org.geoserver.web.data.layer.SQLViewAbstractPage$6.onSubmit(SQLViewAbstractPage.java:306)
at ...
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.base/java.lang.Thread.run(Thread.java:829)
Caused by: java.lang.reflect.InvocationTargetException
at jdk.internal.reflect.GeneratedMethodAccessor710.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.apache.wicket.RequestListenerInterface.internalInvoke(RequestListenerInterface.java:258)
... 118 more
Caused by: java.lang.ClassCastException: class org.geoserver.feature.retype.RetypingDataStore cannot be cast to class org.geotools.jdbc.JDBCDataStore (org.geoserver.feature.retype.RetypingDataStore and org.geotools.jdbc.JDBCDataStore are in unnamed module of loader org.apache.catalina.loader.ParallelWebappClassLoader #63fdab07)
at org.geoserver.web.data.layer.SQLViewAbstractPage.testViewDefinition(SQLViewAbstractPage.java:351)
...
at org.apache.wicket.ajax.AjaxEventBehavior.respond(AjaxEventBehavior.java:155)
at org.apache.wicket.ajax.AbstractDefaultAjaxBehavior.onRequest(AbstractDefaultAjaxBehavior.java:601)
... 122 more
An error occurred while loading the page
2. Also, when I tried to open some existing layers, if I click the 'Edit sql view' button, I got the following exception message and it also stopped me to see the sql view setup.
Not sure will this help to identify the issue?
2023-01-23 01:46:10,461 WARN [org.geoserver.catalog] - Error while getting feature type, flushing cache and retrying: Unknown type tl_link_npi5_qid
2023-01-23 01:46:10,461 DEBUG [org.geoserver.catalog] - java.io.IOException: Unknown type tl_link_npi5_qid
at org.geoserver.feature.retype.RetypingDataStore.getSchema(RetypingDataStore.java:114)
at org.geoserver.feature.retype.RetypingDataStore.getSchema(RetypingDataStore.java:320)
at org.geoserver.feature.retype.RetypingDataStore.getSchema(RetypingDataStore.java:47)
...
at java.base/java.lang.Thread.run(Thread.java:829)
2023-01-23 01:46:10,463 DEBUG [org.geoserver.catalog] - Unable to clean up cached feature type tl_link_npi5_qid in data store ToolboxAWS - not a ContentDataStore
2023-01-23 01:46:10,463 ERROR [org.geoserver.web.data.resource] - Grabbing the attribute list failed
java.io.IOException: Unknown type tl_link_npi5_qid
at org.geoserver.feature.retype.RetypingDataStore.getSchema(RetypingDataStore.java:114)
at org.geoserver.feature.retype.RetypingDataStore.getSchema(RetypingDataStore.java:320)
...
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.base/java.lang.Thread.run(Thread.java:829)
Unable to find component with id 'guessParams' in [Form [Component id = form]]
Expected: 'form:guessParams'.
Found with similar names: ''
MarkupStream: [markup = jar:file:/opt/tomcat/apache-tomcat-9.0.38/webapps/geoserver/WEB-INF/lib/gs-web-core-2.19.0.jar!/org/geoserver/web/data/layer/SQLViewAbstractPage.html
<form wicket:id="form">
<ul>
<li><label for="name"><wicket:message key="name">name</wicket:message></label>
<input type="text" wicket:id="name"/>
</li>
<li><label for="sqlDefinition"><wicket:message key="sqlDefinition">sql definition</wicket:message></label>
<textarea rows="60" cols="20" wicket:id="sql"></textarea>
</li>
<li><label for="parameters"><wicket:message key="parameters">parameters</wicket:message></label>
<wicket:message key="guessParams">guess from sql</wicket:message>
<wicket:message key="addNewParam">add new</wicket:message>
<wicket:message key="removeSelected">remove selected</wicket:message>
<div wicket:id="parameters"></div>
<input type="checkbox" wicket:id="escapeSql"/><wicket:message key="escapeSql">Escape special characters</wicket:message>
</li>
<li><label for="attributes"><wicket:message key="attributes">attributes</wicket:message></label>
<wicket:message key="refresh">refresh</wicket:message>
<span wicket:message="title:guessGeometrySridWarning"><input type="checkbox" wicket:id="guessGeometrySrid"/><wicket:message key="guessGeometrySrid">Guess geometry type and srid</wicket:message></span>
<div wicket:id="attributes"></div>
</li>
</ul>
<div class="button-group toolbar-sticky selfclear"><wicket:message key="save">Save</wicket:message> <wicket:message key="cancel">Cancel</wicket:message></div>
</form>, index = 19, current = '<a href="#" wicket:id="guessParams">' (line 0, column 0)]
at org.apache.wicket.markup.MarkupStream.throwMarkupException(MarkupStream.java:526)
at org.apache.wicket.MarkupContainer.throwException(MarkupContainer.java:1620)
at org.apache.wicket.MarkupContainer.renderNext(MarkupContainer.java:1539)
...
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:143)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:690)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:374)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:868)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1590)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.base/java.lang.Thread.run(Thread.java:829)
What's the cause of this error, and how can the problem be resolved?
I am guessing that you are not defining parameters and providing default values for them, which is something you must do before saving the layer.
As per the documentation (https://docs.geoserver.org/2.22.x/en/user/data/database/sqlview.html), "default values should be specified, since the query cannot be executed without values for the parameters as it would be invalid sql".
In case that doesn't resolve the problem, post a screenshot of your full layer definition in geoserver.
I have one value of timestamp that I retrieve from the database and then compare it with the current timestamp. I actually want to retrieve data of people who have been logged in for the last two hours. Unfortunately, I am facing this error. please help me, guys. I shall be thankful to you. I have stuck in this code.
My query is given below.
super.findByHibernateQuery(LogSession.class, "SELECT ls from LogSession ls, SysUser su where ls.startTime > " + timestamp + " and ls.eventId = " + eventId + " and ls.status= '" + status + "' and su.userType like '%" + userType + "%' and su.userId = ls.userId ");[enter image description here][1]
This is the error I get.
org.hibernate.hql.ast.QuerySyntaxException: unexpected token: 04 near line 1, column 128 [SELECT ls from com.ideacrossing.skild.hbm.LogSession ls, com.ideacrossing.skild.hbm.SysUser su where ls.startTime > 2020-05-04 04:08:25.0 and ls.eventId = 1 and ls.status= 'Login' and su.userType like '%Contestant%' and su.userId = ls.userId ]
at org.hibernate.hql.ast.QuerySyntaxException.convert(QuerySyntaxException.java:31)
at org.hibernate.hql.ast.QuerySyntaxException.convert(QuerySyntaxException.java:24)
at org.hibernate.hql.ast.ErrorCounter.throwQueryException(ErrorCounter.java:59)
at org.hibernate.hql.ast.QueryTranslatorImpl.parse(QueryTranslatorImpl.java:258)
at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:157)
at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:111)
at org.hibernate.engine.query.HQLQueryPlan.(HQLQueryPlan.java:77)
at org.hibernate.engine.query.HQLQueryPlan.(HQLQueryPlan.java:56)
at org.hibernate.engine.query.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:72)
at org.hibernate.impl.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:133)
at org.hibernate.impl.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:112)
at org.hibernate.impl.SessionImpl.createQuery(SessionImpl.java:1623)
at com.ideacrossing.skild.impl.SessionImpl.findByHibernateQuery(SessionImpl.java:126)
at com.ideacrossing.skild.dao.BaseObjectDAO.findByHibernateQuery(BaseObjectDAO.java:210)
at com.ideacrossing.skild.dao.LogSessionDAO.getContestantLogSessionByStatus(LogSessionDAO.java:55)
at com.ideacrossing.reports.bo.ContestantReportBO.getActiveSessions(ContestantReportBO.java:228)
at com.ideacrossing.admin.action.Reports.activeSessionsJson(Reports.java:1769)
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 ognl.OgnlRuntime.invokeMethod(OgnlRuntime.java:899)
at ognl.OgnlRuntime.callAppropriateMethod(OgnlRuntime.java:1544)
at ognl.ObjectMethodAccessor.callMethod(ObjectMethodAccessor.java:68)
at com.opensymphony.xwork2.ognl.accessor.XWorkMethodAccessor.callMethodWithDebugInfo(XWorkMethodAccessor.java:96)
at com.opensymphony.xwork2.ognl.accessor.XWorkMethodAccessor.callMethod(XWorkMethodAccessor.java:88)
at ognl.OgnlRuntime.callMethod(OgnlRuntime.java:1620)
at ognl.ASTMethod.getValueBody(ASTMethod.java:91)
at ognl.SimpleNode.evaluateGetValueBody(SimpleNode.java:212)
at ognl.SimpleNode.getValue(SimpleNode.java:258)
at ognl.Ognl.getValue(Ognl.java:470)
at ognl.Ognl.getValue(Ognl.java:434)
at com.opensymphony.xwork2.ognl.OgnlUtil$3.execute(OgnlUtil.java:371)
at com.opensymphony.xwork2.ognl.OgnlUtil.compileAndExecuteMethod(OgnlUtil.java:423)
at com.opensymphony.xwork2.ognl.OgnlUtil.callMethod(OgnlUtil.java:369)
at com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:436)
at com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:291)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:252)
at org.apache.struts2.interceptor.debugging.DebuggingInterceptor.intercept(DebuggingInterceptor.java:253)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:247)
at com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:176)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:247)
at com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:260)
at org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:52)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:247)
at com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.doIntercept(ConversionErrorInterceptor.java:139)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:247)
at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:134)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:247)
at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:134)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:247)
at com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:199)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:247)
at org.apache.struts2.interceptor.MultiselectInterceptor.intercept(MultiselectInterceptor.java:69)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:247)
at org.apache.struts2.interceptor.DateTextFieldInterceptor.intercept(DateTextFieldInterceptor.java:115)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:247)
at org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:88)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:247)
at org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:246)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:247)
at com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:99)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:247)
at com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept(ScopedModelDrivenInterceptor.java:139)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:247)
at com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(ChainingInterceptor.java:157)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:247)
at com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:174)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:247)
at org.apache.struts2.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:123)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:247)
at org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:171)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:247)
at com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:201)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:247)
at com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:193)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:247)
at org.apache.struts2.factory.StrutsActionProxy.execute(StrutsActionProxy.java:53)
at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:577)
at org.apache.struts2.dispatcher.ExecuteOperations.executeAction(ExecuteOperations.java:81)
at org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:143)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:219)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:142)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:616)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:518)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1091)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:673)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1526)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1482)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:745)
You are getting the error because you have not wrapped the timestamp in quotes, so when sql hits the space in the timestamp it doesn't know what to do and throws an error. Add single quotes around the timestamp part like so:
super.findByHibernateQuery(LogSession.class, "SELECT ls from LogSession ls, SysUser su where ls.startTime > '" + timestamp + "' and ls.eventId = " + eventId + " and ls.status= '" + status + "' and su.userType like '%" + userType + "%' and su.userId = ls.userId ");[enter image description here][1]
I am unable to access the select option in this.
<tooltip-component params="id:'title1',title:'Alert name should be unique',isImportant:true"></tooltip-c
<br>
<select class="chosen-select" data-placeholder="Alert Type" id="alert_type" data-bind="options:alertType,optionsText: 'name', optionsValue: 'id',chosenSelectedOptions: selected Alert,valueAllowUnset: true" ></select>
How can I make this drop list visible and accessible??
You can use ID to locate it , try this code
Select dropdown= new Select(driver.findElement(By.id("alert_type")));
dropdown.selectByVisibleText("Value under Dropdown");.
You can also use xpath
Select dropdown= new Select(driver.findElement(By.xpath("//*[#id='alert_type']")));
dropdown.selectByVisibleText("Value under Dropdown");
Try any of the below mentioned answers.
new WebDriverWait(driver, 10).until(ExpectedConditions.visibilityOfElementLocated(By.id("alert_type")));
new Select(driver.findElement(By.id("alert_type"))).selectByVisibleText("Text Name Under Your Dropdown");
OR
new WebDriverWait(driver, 10).until(ExpectedConditions.visibilityOfElementLocated(By.id("alert_type")));
new Select(driver.findElement(By.id("alert_type"))).selectByIndex(0); //Indexing start from zero
OR
new WebDriverWait(driver, 10).until(ExpectedConditions.visibilityOfElementLocated(By.id("alert_type")));
new Select(driver.findElement(By.id("alert_type"))).selectByValue("Value Name Under your Dropdown");
Development environment.
OS: windows 8
IDE : Eclipse Luna with JAVA 8
Postgresql : 9.3.4 in OPENBSD 5.5
Other All JPA query like findFirst3ByTextOrderByTextAsc are working fine.
But not in NativeQuery, especially with INTERVAL
Repository
#RepositoryRestResource(collectionResourceRel = "Nodes", path = "Nodes")
public interface NodeRepository extends
JpaRepository<Node, Integer>,
CrudRepository<Node, Integer>,
PagingAndSortingRepository<Node, Integer>,
Repository<Node, Integer>
{
//1st INTERVAL is native keyword in POSTGRESQL
#Query(value = "SELECT n.* from nodes n WHERE n.node_id = 10510 AND n.last_good_ping > CURRENT_DATE - INTERVAL '1 day' ", nativeQuery = true)
List<Node> getLast24HoursByNodeId();
//2nd
#Query(value = "SELECT n.* from nodes n WHERE n.node_id = 10510 AND n.last_good_ping > CURRENT_DATE - INTERVAL :interval ", nativeQuery = true)
List<Node> getByNodeIdAndInterval(#Param("interval") String interval);
//3rd
#Query(value = "SELECT n.* from nodes n WHERE n.node_id = 10510 AND n.last_good_ping > CURRENT_DATE - INTERVAL ?1", nativeQuery = true)
List<Node> getByNodeIdAndInterval(String interval);
}
1st query is working find in Test, But not in 2nd,3rd Query
TEST
...
//1st
#Test
public void getLast24HoursByNodeId(){
List<Node> nodes = repo.getLast24HoursByNodeId();
log.debug(nodes.size());
Assert.assertTrue(nodes.size() > 0);
}
//2st
#Test
public void getByInterval(){
List<Node> nodes = repo.getByNodeIdAndInterval("1 day".toString());
log.debug(nodes.size());
Assert.assertTrue(nodes.size() > 0);
}
...
Failure Trace
org.springframework.dao.InvalidDataAccessResourceUsageException: could not extract ResultSet; SQL [n/a]; nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet
at org.springframework.orm.jpa.vendor.HibernateJpaDialect.convertHibernateAccessException(HibernateJpaDialect.java:231)
at org.springframework.orm.jpa.vendor.HibernateJpaDialect.translateExceptionIfPossible(HibernateJpaDialect.java:214)
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.translateExceptionIfPossible(AbstractEntityManagerFactoryBean.java:417)
at org.springframework.dao.support.ChainedPersistenceExceptionTranslator.translateExceptionIfPossible(ChainedPersistenceExceptionTranslator.java:59)
at org.springframework.dao.support.DataAccessUtils.translateIfNecessary(DataAccessUtils.java:213)
at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:147)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.data.jpa.repository.support.CrudMethodMetadataPostProcessor$CrudMethodMetadataPopulatingMethodIntercceptor.invoke(CrudMethodMetadataPostProcessor.java:122)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:207)
at com.sun.proxy.$Proxy83.getByNodeIdAndInterval(Unknown Source)
at ocdc.johnc.repository.NodeRepositoryTest.getByInterval(NodeRepositoryTest.java:83)
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:483)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:73)
at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:82)
at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:73)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:217)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:83)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:68)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:163)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
Caused by: org.hibernate.exception.SQLGrammarException: could not extract ResultSet
at org.hibernate.exception.internal.SQLStateConversionDelegate.convert(SQLStateConversionDelegate.java:123)
at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:49)
at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:126)
at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:112)
at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.extract(ResultSetReturnImpl.java:91)
at org.hibernate.loader.Loader.getResultSet(Loader.java:2066)
at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:1863)
at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:1839)
at org.hibernate.loader.Loader.doQuery(Loader.java:910)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:355)
at org.hibernate.loader.Loader.doList(Loader.java:2554)
at org.hibernate.loader.Loader.doList(Loader.java:2540)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2370)
at org.hibernate.loader.Loader.list(Loader.java:2365)
at org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:353)
at org.hibernate.internal.SessionImpl.listCustomQuery(SessionImpl.java:1873)
at org.hibernate.internal.AbstractSessionImpl.list(AbstractSessionImpl.java:311)
at org.hibernate.internal.SQLQueryImpl.list(SQLQueryImpl.java:141)
at org.hibernate.jpa.internal.QueryImpl.list(QueryImpl.java:573)
at org.hibernate.jpa.internal.QueryImpl.getResultList(QueryImpl.java:449)
at org.springframework.data.jpa.repository.query.JpaQueryExecution$CollectionExecution.doExecute(JpaQueryExecution.java:110)
at org.springframework.data.jpa.repository.query.JpaQueryExecution.execute(JpaQueryExecution.java:74)
at org.springframework.data.jpa.repository.query.AbstractJpaQuery.doExecute(AbstractJpaQuery.java:98)
at org.springframework.data.jpa.repository.query.AbstractJpaQuery.execute(AbstractJpaQuery.java:89)
at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.doInvoke(RepositoryFactorySupport.java:421)
at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke(RepositoryFactorySupport.java:381)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.data.repository.core.support.RepositoryFactorySupport$DefaultMethodInvokingMethodInterceptor.invoke(RepositoryFactorySupport.java:512)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99)
at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:281)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:136)
... 37 more
Caused by: org.postgresql.util.PSQLException: ERROR: syntax error at or near "$1"
Position: 103
at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2198)
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1927)
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:255)
at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:561)
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:419)
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeQuery(AbstractJdbc2Statement.java:304)
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:483)
at org.postgresql.ds.jdbc23.AbstractJdbc23PooledConnection$StatementHandler.invoke(AbstractJdbc23PooledConnection.java:453)
at com.sun.proxy.$Proxy99.executeQuery(Unknown Source)
at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.extract(ResultSetReturnImpl.java:82)
... 66 more
I presume something goes wrong in [generating Query] or [fetching and assigning to Domain Object] process.
Please help~
Ok, I spend really long time trying to make this work for me, BUT I FINALLY GOT IT. Let the future adventurers and community know it as well.
What worked for me was casting to interval presented by A.H. here:
select current_timestamp + ( 2 || ' days')::interval;
Your solution would be then something like that (when 2nd query is analyzed):
#Query(value = "SELECT n.* from nodes n WHERE n.node_id = 10510 AND n.last_good_ping > CURRENT_DATE - ( :interval )\\:\\:interval ", nativeQuery = true)
Or for 3rd query (which is exactly how I made it work in my case)
#Query(value = "SELECT n.* from nodes n WHERE n.node_id = 10510 AND n.last_good_ping > CURRENT_DATE - ( ?1 )\\:\\:interval", nativeQuery = true)
Please notice escaping :: becomes \\:\\:. In your pure SQL which you would test in your SQL editor use ::, but in your repository code within #Query these casting signs needs to be escaped (otherwise your Hibernate/JPA will be displeased).
Using Spring Boot, JPA/Hibernate, PostgreSQL. Worked for when I removed the
quotes around the INTERVAL value mark.
Instead of start_date - INTERVAL '3 months' <= current_date I used
start_date - INTERVAL 3 MONTH <= current_date
The full query amount up to something like this.
#Query(value =
"SELECT distinct AVTALE.* FROM AVTALE " +
"LEFT JOIN AVTALE_INNHOLD " +
"ON AVTALE.ID = AVTALE_INNHOLD.AVTALE " +
"WHERE AVTALE_INNHOLD.GODKJENT_AV_VEILEDER is not null " +
"AND AVTALE.tiltakstype not in ('ARBEIDSTRENING') " +
"AND (:tiltakstype is null or AVTALE.TILTAKSTYPE LIKE :tiltakstype) " +
"AND EXISTS (SELECT avtale_id, status, løpenummer, start_dato FROM TILSKUDD_PERIODE where avtale_id = AVTALE.ID AND " +
"(:tilskuddsperiodestatus LIKE 'UBEHANDLET' AND :tilskuddsperiodestatus = status AND " +
"((start_dato - INTERVAL 3 MONTH <= current_date) OR (løpenummer = 1 AND status LIKE 'UBEHANDLET')))) " +
"AND (AVTALE.ENHET_OPPFOLGING IN (:navEnheter) OR AVTALE.ENHET_GEOGRAFISK IN (:navEnheter))", nativeQuery = true)
List<Avtale> finnGodkjenteAvtalerMedTilskuddsperiodestatusOgNavEnheterUbehandlet(
#Param("tilskuddsperiodestatus") String tilskuddsperiodestatus,
#Param("navEnheter") Set<String> navEnheter,
#Param("tiltakstype") String tiltakstype);
I have a many To many relation in my resource classes using hibernate. In the Category class:
#Entity
public class Category {
Id
#GeneratedValue
private long id;
#ManyToMany
#JoinTable(name = "category_activity",
joinColumns = { #JoinColumn(name = "Category_id") },
inverseJoinColumns = { #JoinColumn(name = "activities_id") })
private Collection<Activity> activities;
}
And in the Activity class:
#Entity
public class Activity {
#Id
#GeneratedValue
private long id;
#ManyToMany
#JoinTable(name="category_activity",
joinColumns={#JoinColumn(name="activities_id")},
inverseJoinColumns={#JoinColumn(name="Category_id")})
private Collection<Category> category;
}
When I had oneToMany relation between them I was using a Query that worked fine for me:
Session session = HibernateUtil.getSessionFactory().getCurrentSession();
session.beginTransaction();
Collection<Activity> activities = (Collection<Activity>) session.createQuery("from Activity as a where a.category.id=" + categoryId + " order by a.key").list();
session.getTransaction().commit();
I appreciate any help that I can fix this query for the ManyToMany relation?
I also used this query :
activities = (List<Activity>) session.createQuery("from Activity a join a.category cs where cs.id= :categoryId order by a.key").setLong("categoryId", categoryId).list();
and I got this error in stack trace:
<html><head><title>Apache Tomcat/7.0.23 - Error report</title><style><!--H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A {color : black;}A.name {color : black;}HR {color : #525D76;}--></style> </head><body><h1>HTTP Status 500 - </h1><HR size="1" noshade="noshade"><p><b>type</b> Exception report</p><p><b>message</b> <u></u></p><p><b>description</b> <u>The server encountered an internal error () that prevented it from fulfilling this request.</u></p><p><b>exception</b> <pre>java.lang.ClassCastException: [Ljava.lang.Object; cannot be cast to java.lang.Comparable
java.util.ComparableTimSort.countRunAndMakeAscending(Unknown Source)
java.util.ComparableTimSort.sort(Unknown Source)
java.util.ComparableTimSort.sort(Unknown Source)
java.util.Arrays.sort(Unknown Source)
java.util.Collections.sort(Unknown Source)
se.softwerk.timelog.controller.ActivityManager.activityList2(ActivityManager.java:64)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
java.lang.reflect.Method.invoke(Unknown Source)
com.sun.jersey.spi.container.JavaMethodInvokerFactory$1.invoke(JavaMethodInvokerFactory.java:60)
com.sun.jersey.server.impl.model.method.dispatch.AbstractResourceMethodDispatchProvider$ResponseOutInvoker._dispatch(AbstractResourceMethodDispatchProvider.java:205)
com.sun.jersey.server.impl.model.method.dispatch.ResourceJavaMethodDispatcher.dispatch(ResourceJavaMethodDispatcher.java:75)
com.sun.jersey.server.impl.uri.rules.HttpMethodRule.accept(HttpMethodRule.java:288)
com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147)
com.sun.jersey.server.impl.uri.rules.ResourceClassRule.accept(ResourceClassRule.java:108)
com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147)
com.sun.jersey.server.impl.uri.rules.RootResourceClassesRule.accept(RootResourceClassesRule.java:84)
com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1469)
com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1400)
com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1349)
com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1339)
com.sun.jersey.spi.container.servlet.WebComponent.service(WebComponent.java:416)
com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:537)
com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:708)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
</pre></p><p><b>note</b> <u>The full stack trace of the root cause is available in the Apache Tomcat/7.0.23 logs.</u></p><HR size="1" noshade="noshade"><h3>Apache Tomcat/7.0.23</h3></body></html>
First of all you shouldn't be concatenating strings, that opens the door for SQLInjection attacks, you should be using named parameters. More on named parameters here
Second, if you have ManyToMany relationshio, both sides should be pluralized:
This
private Collection<Category> category;
Should be this:
private Collection<Category> categories;
Now on your particular question, you have this
from Activity as a where a.category.id= :categoryId order by a.key
You need this:
from Activity a join a.category cs where cs.id= :categoryId order by a.key