Can I limit token to make 20K per token validity requests. My use case is:
give to user token with year validity and 20K per token limitations.
Thank you in advance for any help!
EDIT:
When I'm adding application limit 20PerYear and generate token with validity -1, it's not working, because I can execute as many requests as I want, not only 20.
Use case: I want to sell to client 20K requests to my API not depending on time. Maybe WSO2 have another solutions for my use case?
UPDATE:
1) I added 5PerAllTime Application Tier:
2) Select new created application AllTime per token quota as 5PerAllTime
3) Generate production token for new created application AllTime with validity period -1
2) Add PizzaShackAPI to Application
4) Get a lot menu requests, but any restrictions is not visible :\
What am I doing wrong?
SOLUTION:
All working. I am on Windows and I saw in logs that something bad happening with filepaths on Windows, when I'm adding new application tier:
TID: [-1234] [] [2016-11-03 10:02:36,113] ERROR {org.apache.axis2.rpc.receivers.RPCMessageReceiver} - Illegal char <:> at index 2: /D:/taras2/wso2/WSO2AM~1.0/bin/../repository/deployment/server/\executionplans {org.apache.axis2.rpc.receivers.RPCMessageReceiver}
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at org.apache.axis2.rpc.receivers.RPCUtil.invokeServiceClass(RPCUtil.java:212)
at org.apache.axis2.rpc.receivers.RPCMessageReceiver.invokeBusinessLogic(RPCMessageReceiver.java:117)
at org.apache.axis2.receivers.AbstractInOutMessageReceiver.invokeBusinessLogic(AbstractInOutMessageReceiver.java:40)
at org.apache.axis2.receivers.AbstractMessageReceiver.receive(AbstractMessageReceiver.java:110)
at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:180)
at org.apache.axis2.transport.http.HTTPTransportUtils.processHTTPPostRequest(HTTPTransportUtils.java:173)
at org.apache.axis2.transport.http.AxisServlet.doPost(AxisServlet.java:146)
at org.wso2.carbon.core.transports.CarbonServlet.doPost(CarbonServlet.java:231)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:650)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
at org.eclipse.equinox.http.servlet.internal.ServletRegistration.service(ServletRegistration.java:61)
at org.eclipse.equinox.http.servlet.internal.ProxyServlet.processAlias(ProxyServlet.java:128)
at org.eclipse.equinox.http.servlet.internal.ProxyServlet.service(ProxyServlet.java:68)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
at org.wso2.carbon.tomcat.ext.servlet.DelegationServlet.service(DelegationServlet.java:68)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.owasp.csrfguard.CsrfGuardFilter.doFilter(CsrfGuardFilter.java:88)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.wso2.carbon.ui.filters.CSRFPreventionFilter.doFilter(CSRFPreventionFilter.java:88)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.wso2.carbon.ui.filters.CRLFPreventionFilter.doFilter(CRLFPreventionFilter.java:59)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.wso2.carbon.tomcat.ext.filter.CharacterSetFilter.doFilter(CharacterSetFilter.java:61)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.catalina.filters.HttpHeaderSecurityFilter.doFilter(HttpHeaderSecurityFilter.java:120)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:505)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:169)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
at org.wso2.carbon.tomcat.ext.valves.CompositeValve.continueInvocation(CompositeValve.java:99)
at org.wso2.carbon.tomcat.ext.valves.CarbonTomcatValve$1.invoke(CarbonTomcatValve.java:47)
at org.wso2.carbon.webapp.mgt.TenantLazyLoaderValve.invoke(TenantLazyLoaderValve.java:57)
at org.wso2.carbon.event.receiver.core.internal.tenantmgt.TenantLazyLoaderValve.invoke(TenantLazyLoaderValve.java:48)
at org.wso2.carbon.tomcat.ext.valves.TomcatValveContainer.invokeValves(TomcatValveContainer.java:47)
at org.wso2.carbon.tomcat.ext.valves.CompositeValve.invoke(CompositeValve.java:62)
at org.wso2.carbon.tomcat.ext.valves.CarbonStuckThreadDetectionValve.invoke(CarbonStuckThreadDetectionValve.java:159)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:956)
at org.wso2.carbon.tomcat.ext.valves.CarbonContextCreatorValve.invoke(CarbonContextCreatorValve.java:57)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:436)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1078)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:625)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1749)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1708)
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)
Caused by: java.nio.file.InvalidPathException: Illegal char <:> at index 2: /D:/taras2/wso2/WSO2AM~1.0/bin/../repository/deployment/server/\executionplans
at sun.nio.fs.WindowsPathParser.normalize(WindowsPathParser.java:182)
at sun.nio.fs.WindowsPathParser.parse(WindowsPathParser.java:153)
at sun.nio.fs.WindowsPathParser.parse(WindowsPathParser.java:77)
at sun.nio.fs.WindowsPath.parse(WindowsPath.java:94)
at sun.nio.fs.WindowsFileSystem.getPath(WindowsFileSystem.java:255)
at java.nio.file.Paths.get(Paths.java:84)
at org.wso2.carbon.event.processor.core.internal.util.EventProcessorUtil.validateFilePath(EventProcessorUtil.java:387)
at org.wso2.carbon.event.processor.core.internal.util.EventProcessorConfigurationFilesystemInvoker.save(EventProcessorConfigurationFilesystemInvoker.java:77)
at org.wso2.carbon.event.processor.core.internal.CarbonEventProcessorService.deployExecutionPlan(CarbonEventProcessorService.java:127)
at org.wso2.carbon.event.processor.admin.EventProcessorAdminService.deployExecutionPlan(EventProcessorAdminService.java:53)
... 63 more
After that error I can see my application tier into select box, but there is no file in system for my tier and limitations not working. So I added this file manually into filepath ${carbon.home}/repository/deployment/server/executionplans.
Example of 20KPerYear new execution plan (named carbon.super_app_20KPerYear.siddhiql):
/* Enter a unique ExecutionPlan */
#Plan:name('carbon.super_app_20KPerYear')
/* Enter a unique description for ExecutionPlan */
#Plan:description('Allows 20K request per year')
/* define streams/tables and write queries here ... */
#Import('org.wso2.throttle.processed.request.stream:1.0.0')
define stream RequestStream (messageID string, appKey string, appTier string, subscriptionKey string, apiKey string, apiTier string, subscriptionTier string, resourceKey string, resourceTier string, userId string, apiContext string, apiVersion string, appTenant string, apiTenant string, appId string, apiName string, propertiesMap string);
#Export('org.wso2.throttle.globalThrottle.stream:1.0.0')
define stream GlobalThrottleStream (throttleKey string, isThrottled bool, expiryTimeStamp long);
FROM RequestStream
SELECT messageID, ( appTenant == 'carbon.super' and appTier == '20KPerYear') AS isEligible, appKey AS throttleKey
INSERT INTO EligibilityStream;
FROM EligibilityStream[isEligible==true]#throttler:timeBatch(1 year, 0)
select throttleKey, (count(messageID) >= 20000) as isThrottled, expiryTimeStamp
group by throttleKey
INSERT ALL EVENTS into ResultStream;
from ResultStream#throttler:emitOnStateChange(throttleKey, isThrottled)
select *
insert into GlobalThrottleStream;
You can set an Application Level throttling policy for this. Read more information here.
Update: To limit the number of requests per year, you can set the throttling level to 20kPerYear. To expire tokens after 1 year, you can set AccessTokenDefaultValidityPeriod in identity.xml.
I just tried this myself with a 20perYear limit to make sure this works fine. After about 21-22 request requests failed with this response.
{"fault":{"code":900803,"message":"Message throttled out","description":"You have
exceeded your quota","nextAccessTime":"2016-Dec-20 00:00:00+0000 UTC"}}
Please note that since throttling works in an asynchronous manner, it may not throttle out exactly after 20 requests. There will be a small buffer.
Related
how to avoid Invalid character found in the request target error in spring boot, prior to being processed by the underlying servlet container
java.lang.IllegalArgumentException: Invalid character found in the request target [/index.php?s=/Index/\think\app/invokefunction&function=call_user_func_array&vars[0]=md5&vars[1][]=HelloThinkPHP21 ]. The valid characters are defined in RFC 7230 and RFC 3986
at org.apache.coyote.http11.Http11InputBuffer.parseRequestLine(Http11InputBuffer.java:494) ~[tomcat-embed-core-9.0.54.jar:9.0.54]
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:269) [tomcat-embed-core-9.0.54.jar:9.0.54]
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65) [tomcat-embed-core-9.0.54.jar:9.0.54]
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:895) [tomcat-embed-core-9.0.54.jar:9.0.54]
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1722) [tomcat-embed-core-9.0.54.jar:9.0.54]
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) [tomcat-embed-core-9.0.54.jar:9.0.54]
at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191) [tomcat-embed-core-9.0.54.jar:9.0.54]
at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659) [tomcat-embed-core-9.0.54.jar:9.0.54]
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) [tomcat-embed-core-9.0.54.jar:9.0.54]
at java.lang.Thread.run(Thread.java:831) [?:?]
I'm getting an exception on an Oracle WITH/SELECT construct, that if I pasted into SQL Developer, works fine and comes back in 9.655s.
[DEBUG] 2020-05-30 23:17:29.848 [http-nio-8090-exec-6] JdbcTransaction - [] Opening JDBC Connection
[DEBUG] 2020-05-30 23:17:30.336 [http-nio-8090-exec-6] JdbcTransaction - [] Setting autocommit to false on JDBC Connection [oracle.jdbc.driver.T4CConnection#c1d7134]
[DEBUG] 2020-05-30 23:17:30.336 [http-nio-8090-exec-6] getTotalUniqueUsersDetailsByKeyByTime - [] ==> Preparing: with main_data as ( select /*+ parallel(SCHUC) parallel(SCHU) parallel(SCHUT) parallel(SCHCM) parallel(SCHET) parallel(SCHES) */ distinct schutm.user_type_meta_name as KEY ,schuc.time_unit as TIME_UNIT ,schuc.user_key as VALUE from ( /* BP1 */ /* BP4 */ select /*+ parallel(SCHUCD) parallel(SCHFQL) */ YEAR_MONTH as TIME_UNIT ,schucd.TRACE_ID_KEY ,schucd.platform_id ,schucd.user_key ,schucd.event_type_id ,schucd.event_source_id ,REFERRER_ID ,PARENT_ID ,sum(USAGE_COUNT) as usage_count from sc_report_new.sc_hub_usage_counts_day schucd WHERE FISCAL_QUARTER_ID IN ( ? ) group by YEAR_MONTH ,schucd.TRACE_ID_KEY ,schucd.platform_id ,schucd.user_key ,schucd.event_type_id ,schucd.event_source_id ,REFERRER_ID ,PARENT_ID ) schuc inner join sc_hub_users schu on schuc.user_key=schu.user_key inner join sc_hub_user_types schut on schut.user_type_id=schu.user_type_id inner join sc_hub_user_types_meta_map schutmm on schutmm.user_type_id=schut.user_type_id inner join sc_hub_user_types_meta schutm ON schutm.user_type_meta_id = schutmm.user_type_meta_id inner join sc_hub_content_master schcm on schcm.trace_id_key=schuc.trace_id_key inner join sc_hub_event_types schet on schet.event_type_id = schuc.event_type_id inner join sc_hub_event_sources sches on sches.event_source_id = schuc.event_source_id WHERE ( (schcm.PAGETYPE='Page' AND sches.event_source_name='wem' AND schet.event_code='V') OR (schcm.PAGETYPE='Page' AND sches.event_source_name='purchaseshubs' AND schet.event_code='S') OR (schcm.PAGETYPE='Hub' AND sches.event_source_name='saleshubs' AND schet.event_code='S') ) ) select /*+parallel(AUTO) */ KEY,time_unit,count(VALUE) as VALUE from main_data group by KEY,TIME_UNIT order by case when KEY = 'Other' then 1 else 0 end, KEY, TIME_UNIT
[DEBUG] 2020-05-30 23:17:30.336 [http-nio-8090-exec-6] getTotalUniqueUsersDetailsByKeyByTime - [] ==> Parameters: 2020Q4(String)
org.apache.ibatis.exceptions.PersistenceException:
### Error querying database. Cause: java.sql.SQLRecoverableException: IO Error: Socket read timed out
### The error may exist in com/mycompany/myapp/screport/mapper/hubportfolio/TotalUniqueUsers.xml
### The error may involve com.mycompany.myapp.screport.mapper.hubportfolio.TotalUniqueUsers.getTotalUniqueUsersDetailsByKeyByTime-Inline
### The error occurred while setting parameters
### SQL: with main_data as ( select /*+ parallel(SCHUC) parallel(SCHU) parallel(SCHUT) parallel(SCHCM) parallel(SCHET) parallel(SCHES) */ distinct schutm.user_type_meta_name as KEY ,schuc.time_unit as TIME_UNIT ,schuc.user_key as VALUE from ( /* BP1 */ /* BP4 */ select /*+ parallel(SCHUCD) parallel(SCHFQL) */ YEAR_MONTH as TIME_UNIT ,schucd.TRACE_ID_KEY ,schucd.platform_id ,schucd.user_key ,schucd.event_type_id ,schucd.event_source_id ,REFERRER_ID ,PARENT_ID ,sum(USAGE_COUNT) as usage_count from sc_report_new.sc_hub_usage_counts_day schucd WHERE FISCAL_QUARTER_ID IN ( ? ) group by YEAR_MONTH ,schucd.TRACE_ID_KEY ,schucd.platform_id ,schucd.user_key ,schucd.event_type_id ,schucd.event_source_id ,REFERRER_ID ,PARENT_ID ) schuc inner join sc_hub_users schu on schuc.user_key=schu.user_key inner join sc_hub_user_types schut on schut.user_type_id=schu.user_type_id inner join sc_hub_user_types_meta_map schutmm on schutmm.user_type_id=schut.user_type_id inner join sc_hub_user_types_meta schutm ON schutm.user_type_meta_id = schutmm.user_type_meta_id inner join sc_hub_content_master schcm on schcm.trace_id_key=schuc.trace_id_key inner join sc_hub_event_types schet on schet.event_type_id = schuc.event_type_id inner join sc_hub_event_sources sches on sches.event_source_id = schuc.event_source_id WHERE ( (schcm.PAGETYPE='Page' AND sches.event_source_name='wem' AND schet.event_code='V') OR (schcm.PAGETYPE='Page' AND sches.event_source_name='purchaseshubs' AND schet.event_code='S') OR (schcm.PAGETYPE='Hub' AND sches.event_source_name='saleshubs' AND schet.event_code='S') ) ) select /*+parallel(AUTO) */ KEY,time_unit,count(VALUE) as VALUE from main_data group by KEY,TIME_UNIT order by case when KEY = 'Other' then 1 else 0 end, KEY, TIME_UNIT
### Cause: java.sql.SQLRecoverableException: IO Error: Socket read timed out
at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:30)
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:149)
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:140)
at com.mycompany.myapp.screport.dao.SCHubPortfolioServiceHandler.getTotalUniqueUserDetailsByTime(SCHubPortfolioServiceHandler.java:296)
at com.mycompany.myapp.screport.services.SCHubPortfolioService.getTotalUniqueUserDetailsByTime(SCHubPortfolioService.java:269)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.glassfish.jersey.server.model.internal.ResourceMethodInvocationHandlerFactory$1.invoke(ResourceMethodInvocationHandlerFactory.java:81)
at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher$1.run(AbstractJavaResourceMethodDispatcher.java:144)
at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.invoke(AbstractJavaResourceMethodDispatcher.java:161)
at org.glassfish.jersey.server.model.internal.JavaResourceMethodDispatcherProvider$ResponseOutInvoker.doDispatch(JavaResourceMethodDispatcherProvider.java:160)
at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.dispatch(AbstractJavaResourceMethodDispatcher.java:99)
at org.glassfish.jersey.server.model.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:389)
at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:347)
at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:102)
at org.glassfish.jersey.server.ServerRuntime$2.run(ServerRuntime.java:326)
at org.glassfish.jersey.internal.Errors$1.call(Errors.java:271)
at org.glassfish.jersey.internal.Errors$1.call(Errors.java:267)
at org.glassfish.jersey.internal.Errors.process(Errors.java:315)
at org.glassfish.jersey.internal.Errors.process(Errors.java:297)
at org.glassfish.jersey.internal.Errors.process(Errors.java:267)
at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:317)
at org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:305)
at org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:1154)
at org.glassfish.jersey.servlet.WebComponent.serviceImpl(WebComponent.java:473)
at org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:427)
at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:388)
at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:341)
at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:228)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at com.thetransactioncompany.cors.CORSFilter.doFilter(CORSFilter.java:174)
at com.thetransactioncompany.cors.CORSFilter.doFilter(CORSFilter.java:237)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:200)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:490)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:668)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:408)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:834)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1415)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.sql.SQLRecoverableException: IO Error: Socket read timed out
at oracle.jdbc.driver.T4CPreparedStatement.executeForDescribe(T4CPreparedStatement.java:897)
I'm using Tomcat 9 on a Java 1.8 JRE, MyBatis and Oracle 11g(I think). The Oracle database is not hosted by my machine, but is in the same timezone and latency is not an issue. If I take the query above, substitute the ? for '2020Q4' I can get an answer back in less than 10s according to SQL Developer.
Some key Maven dependencies include:
<dependency>
<groupId>com.cisco.oracle</groupId>
<artifactId>ojdbc6</artifactId>
<version>11.3</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis</artifactId>
<version>3.5.2</version>
</dependency>
When I get the DataSource to build the connection, I do it this way:
OracleDataSource result = new OracleDataSource();
Class.forName("oracle.jdbc.driver.OracleDriver");
String connectionString = lCiscoLifeJdbcUrl;
String username = lCiscoLifeJdbcUserName;
String password = lCiscoLifeJdbcPassword;
OracleDataSource oracleDataSource = (OracleDataSource)result;
oracleDataSource.setURL(connectionString);
oracleDataSource.setPassword(password);
oracleDataSource.setUser(username);
String timeoutKey = "oracle.jdbc.ReadTimeout";
Properties connectionProperties;
try {
connectionProperties = oracleDataSource.getConnectionProperties();
if(connectionProperties==null) {
connectionProperties = new Properties();
}
connectionProperties.put(timeoutKey, 60 /* minutes */ * 60 /* seconds per minutes */ * 1000 /* ms per seconds */);
} catch (SQLException e) {
e.printStackTrace();
}
From previous debugging, the connectionProperties defaulted to null, but I wanted to allow for those to be set by smarter people than myself.
Also, please note that this error occurs in about 8 out of 64 tests, so not every select triggers this issue. I do no database updates or DML type statements. Everything is assumed to be fully committed at this point.
I'm using MyBatis XML mapper files, but this is NOT a Spring driven project. I manually build the DataSource, Configuration, Environment via Java objects.
What am I missing?
Can you set the connection properties as shown in DataSourceSample Also, check out OracleConnection for the list of properties.
Recently I came up across strange scenario where I could see the application slows down after some point of time due to which I am unable to load application.
So I started monitoring the server and found that for some of the scenario's the GC activity is going more than 60% and it is impacting directly on application perfomance so in order to fix it I tried to increase the heap memory to 2.5G from 2GB but still I could find same issue can anyone help me is increasing Heap size further is an ideal approach or something else I can do.
System Ram Capability : 6 GB
Following is VisualVm monitor screenshot:
Kindly let me know if further info is required for analysis.
Thread Dump:
http-apr-8080-exec-15" - Thread t#110
java.lang.Thread.State: RUNNABLE
at java.util.regex.Pattern$BnM.match(Pattern.java:5464)
at java.util.regex.Matcher.search(Matcher.java:1248)
at java.util.regex.Matcher.find(Matcher.java:637)
at java.util.regex.Matcher.replaceAll(Matcher.java:951)
at java.lang.String.replace(String.java:2240)
at com.srik.security.SecureTrace.maskOther(SecureTrace.java:135)
at com.srik.security.SecureTrace.maskJsonData(SecureTrace.java:102)
at com.srik.mbweb.manager.MUSR.printResponse(MUSR.java:261)
at com.srik.mbweb.manager.MUSR.invokeService(MUSR.java:212)
at com.srik.mbweb.manager.MU.invokeCacheableService(MU.java:30)
at com.srik.mbweb.manager.MU$$FastClassBySpringCGLIB$$45933c60.invoke(<generated>)
at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:738)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
at org.springframework.cache.interceptor.CacheInterceptor$1.invoke(CacheInterceptor.java:52)
at org.springframework.cache.interceptor.CacheAspectSupport.invokeOperation(CacheAspectSupport.java:345)
at org.springframework.cache.interceptor.CacheAspectSupport.execute(CacheAspectSupport.java:408)
at org.springframework.cache.interceptor.CacheAspectSupport.execute(CacheAspectSupport.java:327)
at org.springframework.cache.interceptor.CacheInterceptor.invoke(CacheInterceptor.java:61)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:673)
at com.srik.mbweb.manager.MU$$EnhancerBySpringCGLIB$$36289a8f.invokeCacheableService(<generated>)
at com.srik.mbweb.manager.ChannelUnitedServiceManagerProxy.invokeService(ChannelUnitedServiceManagerProxy.java:35)
at com.srik.mbweb.controller.MobileUnitedController.processRequest(MobileUnitedController.java:32)
at com.srik.mbweb.controller.MobileUnitedControllerBase.invokeService(MobileUnitedControllerBase.java:58)
at sun.reflect.GeneratedMethodAccessor216.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:205)
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:133)
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:97)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:827)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:738)
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:967)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:901)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970)
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:872)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:648)
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:292)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
at com.srik.statemachine.web.AbstractStateMachineAwareFilter.doFilterInternal(AbstractStateMachineAwareFilter.java:63)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:197)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
at com.srik.mbweb.common.PreAuthenticationFilter.doFilterInternal(PreAuthenticationFilter.java:137)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346)
at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:262)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
at com.srik.mbweb.common.StatelessCSRFFilter.doFilterInternal(StatelessCSRFFilter.java:51)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346)
at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:262)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
at com.srik.mbweb.common.LoggerFilter.doFilterInternal(LoggerFilter.java:30)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346)
at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:262)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
at com.srik.mbweb.multitenant.filter.FITenantFilter.doFilterInternal(FITenantFilter.java:110)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346)
at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:262)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
at com.srik.mbweb.multitenant.filter.FITenantFilter.doFilterInternal(FITenantFilter.java:110)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:212)
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:141)
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:528)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1100)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:687)
at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.doRun(AprEndpoint.java:2521)
at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:2510)
- locked <1e41e77c> (a org.apache.tomcat.util.net.AprEndpoint$AprSocketWrapper)
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:748)
Locked ownable synchronizers:
- locked <5896885f> (a java.util.concurrent.ThreadPoolExecutor$Worker)
SecureTrace method:
private static Pattern PWD_XML_PATTERN = Pattern.compile("^(<.*?(?:(?i)Aomn|Amn|amn|aamn)>)(.*?)(<\\/.*?(?:(?i)Aomn|Amn|amn|aamn)>)");
public static String maskData(String data) {
try {
for(Matcher m = PWD_XML_PATTERN.matcher(data); m.find(); data = m.replaceAll("AA****BB")) {
;
}
} catch (Exception var2) {
var2.printStackTrace();
}
return maskOther(data);
}
private static String maskOther(String data) {
String mask = null;
int groupLen = false;
Matcher matcher = null;
try {
matcher = MASK_PATTERN.matcher(data);
while(matcher.find()) {
mask = "****";
String group = matcher.group();
int groupLen = group.length();
if (groupLen > 5) {
mask = mask + group.substring(groupLen - 4);
data = data.replace(group, mask);
}
}
} catch (Exception var5) {
; }
return data;
}
It’s not clear, how much the posted code relates to the spikes in CPU usage at all, as it looks like you’ve made a snapshot when the CPU load is close to zero. You should use the sampler/profiler to gather data about the actual bottlenecks.
But it’s worth considering that spikes of 100% CPU usage are not unnatural. A single CPU core doesn’t know other modes than being either, idle (0%) or processing code (100%). Any in-between number shown by a tool is the result of smoothing multiple values of 0% and 100%. When seeing spikes of 100%, it just means that an “executing code” phase lasted longer than the time window used for smoothing.
But the garbage collector activity looks high indeed and the memory usage pattern seems to fit. So you may test how the behavior changes when giving it more heap memory. But don’t use increments as small as 25%, just to get ambivalent results. When you have 6 G available, double the heap to 4 G or even raise to 5 G. If you still see the same pattern, you have a problem. Check that there are no explicit System.gc() calls or similar in your code. If that large heap memory solved the problem, search for the best trade off between that number and the old heap size (mind how Binary Search works).
Still, the code you’ve posted bears problems. First of all, the questionable try … catch blocks. Since in this code not involving external conditions any exception is an indicator of a programming error, you should solve any existing bug and not catch exceptions.
Regarding performance, you’re doing a lot of repeated work.
In maskData, you’re executing the following loop:
for(Matcher m = PWD_XML_PATTERN.matcher(data); m.find(); data = m.replaceAll("AA****BB"))
First, you’re calling m.find(), which is fine if there’s no match, but if there is a match, you’re calling data = m.replaceAll("AA****BB") which is a self-contained operation, i.e. not using the result of the previous find(). After that, you’re calling find() again, which is pointless as the Matcher still references the original string. Since replaceAll didn’t reset the matcher, you’re not running into an infinite loop but always getting false.
So instead, use
public static String maskData(String data) {
return maskOther(PWD_XML_PATTERN.matcher(data).replaceAll("AA****BB"));
}
Even worse, the maskOther method is performing a replacement loop, but instead of using the Matcher to perform the replace operation, it is calling replace on the string for each match. This can easily run towards quadratic time complexity in respect to the number of matches, multiplied with the source string length as the replace operation creates a new string each time.
But since replace also replaces all occurrences of the search string (the difference to replaceAll is that it doesn’t do regex patterns), it depends on the actual pattern, whether subsequent iterations of the while(matcher.find()) loop will process matches that have been replaced already.
A straight-forward linear replacement operation with the same result as your method¹ may look like:
private static String maskOther(String data) {
Matcher matcher = MASK_PATTERN.matcher(data);
if(!matcher.find()) return data;
StringBuilder sb = new StringBuilder(data.length()*2);
int pos = 0;
do {
if(matcher.end() - matcher.start() <= 5) continue;
sb.append(data, pos, matcher.start()).append("****");
pos = matcher.end() - 4;
} while(matcher.find());
return pos == 0? data: sb.append(data, pos, data.length()).toString();
}
¹ as long as the results of your replace operation do not create new matches. Otherwise, the results of your method become almost unpredictable.
I'm trying to use JMeter 2.13 to test my web service. One of the methods that I need to call has a parameter that is defined as char. The parameter is sex.
Here is my HTTP request body data.
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Body>
<ns2:SaveDocument xmlns:ns2="http://oword.muhc.ca/">
<DocumentID>0</DocumentID>
<StatusCode>DRA</StatusCode>
<TemplateID>17839</TemplateID>
<Document>Testing save document.</Document>
<PatientIDs>1172</PatientIDs>
<Sex>F</Sex>
<PatientFirstName>SUNNY</PatientFirstName>
<PatientLastName>OCTOBER</PatientLastName>
<ClassificationCode>0000</ClassificationCode>
<OrderNumber></OrderNumber>
</ns2:SaveDocument>
</S:Body>
</S:Envelope>
This is the error that I get in my JBoss log.
15:39:29,300 ERROR [SOAPFaultHelperJAXWS] SOAP request exception
javax.xml.ws.WebServiceException: javax.xml.bind.UnmarshalException: For input string: "M"
- with linked exception:
[java.lang.NumberFormatException: For input string: "M"]
at org.jboss.ws.core.jaxws.JAXBDeserializer.handleUnmarshallException(JAXBDeserializer.java:112)
at org.jboss.ws.core.jaxws.JAXBDeserializer.deserialize(JAXBDeserializer.java:80)
at org.jboss.ws.core.binding.DeserializerSupport.deserialize(DeserializerSupport.java:60)
at org.jboss.ws.core.soap.XMLContent.unmarshallObjectContents(XMLContent.java:181)
at org.jboss.ws.core.soap.XMLContent.transitionTo(XMLContent.java:98)
at org.jboss.ws.core.soap.SOAPContentElement.transitionTo(SOAPContentElement.java:140)
at org.jboss.ws.core.soap.SOAPContentElement.getObjectValue(SOAPContentElement.java:171)
at org.jboss.ws.core.EndpointInvocation.transformPayloadValue(EndpointInvocation.java:276)
at org.jboss.ws.core.EndpointInvocation.getRequestParamValue(EndpointInvocation.java:118)
at org.jboss.ws.core.EndpointInvocation.getRequestPayload(EndpointInvocation.java:138)
at org.jboss.ws.core.server.DelegatingInvocation.getArgs(DelegatingInvocation.java:82)
at org.jboss.wsf.container.jboss42.InvocationHandlerEJB3.invoke(InvocationHandlerEJB3.java:95)
at org.jboss.ws.core.server.ServiceEndpointInvoker.invoke(ServiceEndpointInvoker.java:223)
at org.jboss.wsf.stack.jbws.RequestHandlerImpl.processRequest(RequestHandlerImpl.java:421)
at org.jboss.wsf.stack.jbws.RequestHandlerImpl.handleRequest(RequestHandlerImpl.java:286)
at org.jboss.wsf.stack.jbws.RequestHandlerImpl.doPost(RequestHandlerImpl.java:196)
at org.jboss.wsf.stack.jbws.RequestHandlerImpl.handleHttpRequest(RequestHandlerImpl.java:122)
at org.jboss.wsf.stack.jbws.EndpointServlet.service(EndpointServlet.java:84)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
at org.apache.catalina.core.StandardContextValve.__invoke(StandardContextValve.java:173)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:182)
at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:241)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Thread.java:619)
Caused by: javax.xml.bind.UnmarshalException: For input string: "M"
- with linked exception:
[java.lang.NumberFormatException: For input string: "M"]
at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext.handleEvent(UnmarshallingContext.java:603)
at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext.handleError(UnmarshallingContext.java:632)
at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext.handleError(UnmarshallingContext.java:628)
at com.sun.xml.bind.v2.runtime.unmarshaller.Loader.handleParseConversionException(Loader.java:257)
at com.sun.xml.bind.v2.runtime.unmarshaller.TextLoader.text(TextLoader.java:69)
at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext.text(UnmarshallingContext.java:462)
at com.sun.xml.bind.v2.runtime.unmarshaller.InterningXmlVisitor.text(InterningXmlVisitor.java:89)
at com.sun.xml.bind.v2.runtime.unmarshaller.SAXConnector.processText(SAXConnector.java:168)
at com.sun.xml.bind.v2.runtime.unmarshaller.SAXConnector.endElement(SAXConnector.java:141)
at com.sun.xml.bind.unmarshaller.DOMScanner.visit(DOMScanner.java:251)
at com.sun.xml.bind.unmarshaller.DOMScanner.visit(DOMScanner.java:277)
at com.sun.xml.bind.unmarshaller.DOMScanner.visit(DOMScanner.java:246)
at com.sun.xml.bind.unmarshaller.DOMScanner.scan(DOMScanner.java:123)
at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:314)
at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:293)
at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:244)
at org.jboss.ws.core.jaxws.JAXBDeserializer.deserialize(JAXBDeserializer.java:73)
... 36 more
Caused by: java.lang.NumberFormatException: For input string: "M"
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:48)
at java.lang.Integer.parseInt(Integer.java:449)
at java.lang.Integer.valueOf(Integer.java:554)
at com.sun.xml.bind.DatatypeConverterImpl._parseInt(DatatypeConverterImpl.java:104)
at com.sun.xml.bind.v2.model.impl.RuntimeBuiltinLeafInfoImpl$2.parse(RuntimeBuiltinLeafInfoImpl.java:244)
at com.sun.xml.bind.v2.model.impl.RuntimeBuiltinLeafInfoImpl$2.parse(RuntimeBuiltinLeafInfoImpl.java:246)
at com.sun.xml.bind.v2.runtime.unmarshaller.TextLoader.text(TextLoader.java:65)
... 48 more
15:39:37,641 ERROR [SOAPFaultHelperJAXWS] SOAP request exception
javax.xml.ws.WebServiceException: javax.xml.bind.UnmarshalException: For input string: "F"
- with linked exception:
[java.lang.NumberFormatException: For input string: "F"]
at org.jboss.ws.core.jaxws.JAXBDeserializer.handleUnmarshallException(JAXBDeserializer.java:112)
at org.jboss.ws.core.jaxws.JAXBDeserializer.deserialize(JAXBDeserializer.java:80)
at org.jboss.ws.core.binding.DeserializerSupport.deserialize(DeserializerSupport.java:60)
at org.jboss.ws.core.soap.XMLContent.unmarshallObjectContents(XMLContent.java:181)
at org.jboss.ws.core.soap.XMLContent.transitionTo(XMLContent.java:98)
at org.jboss.ws.core.soap.SOAPContentElement.transitionTo(SOAPContentElement.java:140)
at org.jboss.ws.core.soap.SOAPContentElement.getObjectValue(SOAPContentElement.java:171)
at org.jboss.ws.core.EndpointInvocation.transformPayloadValue(EndpointInvocation.java:276)
at org.jboss.ws.core.EndpointInvocation.getRequestParamValue(EndpointInvocation.java:118)
at org.jboss.ws.core.EndpointInvocation.getRequestPayload(EndpointInvocation.java:138)
at org.jboss.ws.core.server.DelegatingInvocation.getArgs(DelegatingInvocation.java:82)
at org.jboss.wsf.container.jboss42.InvocationHandlerEJB3.invoke(InvocationHandlerEJB3.java:95)
at org.jboss.ws.core.server.ServiceEndpointInvoker.invoke(ServiceEndpointInvoker.java:223)
at org.jboss.wsf.stack.jbws.RequestHandlerImpl.processRequest(RequestHandlerImpl.java:421)
at org.jboss.wsf.stack.jbws.RequestHandlerImpl.handleRequest(RequestHandlerImpl.java:286)
at org.jboss.wsf.stack.jbws.RequestHandlerImpl.doPost(RequestHandlerImpl.java:196)
at org.jboss.wsf.stack.jbws.RequestHandlerImpl.handleHttpRequest(RequestHandlerImpl.java:122)
at org.jboss.wsf.stack.jbws.EndpointServlet.service(EndpointServlet.java:84)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
at org.apache.catalina.core.StandardContextValve.__invoke(StandardContextValve.java:173)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:182)
at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:241)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Thread.java:619)
Caused by: javax.xml.bind.UnmarshalException: For input string: "F"
- with linked exception:
[java.lang.NumberFormatException: For input string: "F"]
at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext.handleEvent(UnmarshallingContext.java:603)
at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext.handleError(UnmarshallingContext.java:632)
at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext.handleError(UnmarshallingContext.java:628)
at com.sun.xml.bind.v2.runtime.unmarshaller.Loader.handleParseConversionException(Loader.java:257)
at com.sun.xml.bind.v2.runtime.unmarshaller.TextLoader.text(TextLoader.java:69)
at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext.text(UnmarshallingContext.java:462)
at com.sun.xml.bind.v2.runtime.unmarshaller.InterningXmlVisitor.text(InterningXmlVisitor.java:89)
at com.sun.xml.bind.v2.runtime.unmarshaller.SAXConnector.processText(SAXConnector.java:168)
at com.sun.xml.bind.v2.runtime.unmarshaller.SAXConnector.endElement(SAXConnector.java:141)
at com.sun.xml.bind.unmarshaller.DOMScanner.visit(DOMScanner.java:251)
at com.sun.xml.bind.unmarshaller.DOMScanner.visit(DOMScanner.java:277)
at com.sun.xml.bind.unmarshaller.DOMScanner.visit(DOMScanner.java:246)
at com.sun.xml.bind.unmarshaller.DOMScanner.scan(DOMScanner.java:123)
at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:314)
at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:293)
at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:244)
at org.jboss.ws.core.jaxws.JAXBDeserializer.deserialize(JAXBDeserializer.java:73)
... 36 more
Caused by: java.lang.NumberFormatException: For input string: "F"
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:48)
at java.lang.Integer.parseInt(Integer.java:449)
at java.lang.Integer.valueOf(Integer.java:554)
at com.sun.xml.bind.DatatypeConverterImpl._parseInt(DatatypeConverterImpl.java:104)
at com.sun.xml.bind.v2.model.impl.RuntimeBuiltinLeafInfoImpl$2.parse(RuntimeBuiltinLeafInfoImpl.java:244)
at com.sun.xml.bind.v2.model.impl.RuntimeBuiltinLeafInfoImpl$2.parse(RuntimeBuiltinLeafInfoImpl.java:246)
at com.sun.xml.bind.v2.runtime.unmarshaller.TextLoader.text(TextLoader.java:65)
... 48 more
What must I do to be able to call this method?
Thanks!
Use Unicode value as integer instead of characters M or F.
Use 77 for character M (male) and 70 for character F (female)
So it should look like this
77 or
70
Hope this help.
I'm new to Jena and triplestore, when I deployed my application in tomcat 7, I'm getting the following exception.
Appreciate your help thank you.
Exception is
Jun 20, 2014 1:23:23 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet [ServletAdaptor] in context with path [/triplestore] threw exception [A MultiException has 2 exceptions. They are:
1. com.hp.hpl.jena.tdb.TDBException: Root blocks must be at position zero
2. java.lang.IllegalStateException: Unable to perform operation: create on au.com.rdf.triplestore.web.TripleStoreServlet ] with root cause
com.hp.hpl.jena.tdb.TDBException: Root blocks must be at position zero
at com.hp.hpl.jena.tdb.index.bplustree.BPTreeNodeMgr.createEmptyBPT(BPTreeNodeMgr.java:55)
at com.hp.hpl.jena.tdb.index.bplustree.BPlusTree.createIfAbsent(BPlusTree.java:215)
at com.hp.hpl.jena.tdb.index.bplustree.BPlusTree.create(BPlusTree.java:141)
at com.hp.hpl.jena.tdb.setup.Builder$RangeIndexBuilderStd.createBPTree(Builder.java:167)
at com.hp.hpl.jena.tdb.setup.Builder$RangeIndexBuilderStd.buildRangeIndex(Builder.java:134)
at com.hp.hpl.jena.tdb.setup.Builder$TupleIndexBuilderStd.buildTupleIndex(Builder.java:64)
at com.hp.hpl.jena.tdb.setup.DatasetBuilderStd.makeTupleIndex(DatasetBuilderStd.java:283)
at com.hp.hpl.jena.tdb.setup.DatasetBuilderStd.makeTupleIndexes(DatasetBuilderStd.java:272)
at com.hp.hpl.jena.tdb.setup.DatasetBuilderStd.makeTupleIndexes(DatasetBuilderStd.java:261)
at com.hp.hpl.jena.tdb.setup.DatasetBuilderStd.makeTripleTable(DatasetBuilderStd.java:193)
at com.hp.hpl.jena.tdb.setup.DatasetBuilderStd._build(DatasetBuilderStd.java:163)
at com.hp.hpl.jena.tdb.setup.DatasetBuilderStd.build(DatasetBuilderStd.java:149)
at com.hp.hpl.jena.tdb.setup.DatasetBuilderStd.build(DatasetBuilderStd.java:64)
at com.hp.hpl.jena.tdb.StoreConnection.make(StoreConnection.java:217)
at com.hp.hpl.jena.tdb.transaction.DatasetGraphTransaction.<init> (DatasetGraphTransaction.java:75)
at com.hp.hpl.jena.tdb.sys.TDBMaker._create(TDBMaker.java:57)
at com.hp.hpl.jena.tdb.sys.TDBMaker.createDatasetGraphTransaction(TDBMaker.java:45)
at com.hp.hpl.jena.tdb.TDBFactory._createDatasetGraph(TDBFactory.java:104)
at com.hp.hpl.jena.tdb.TDBFactory.createDatasetGraph(TDBFactory.java:73)
at com.hp.hpl.jena.tdb.TDBFactory.createDataset(TDBFactory.java:52)
at com.hp.hpl.jena.tdb.TDBFactory.createDataset(TDBFactory.java:48)
at au.com.traleerdf.xmldi.triplestore.core.impl.TripleStoreImpl.<init>(TripleStoreImpl.java:159)
at au.com.traleerdf.xmldi.triplestore.web.TripleStoreRs.<init>(TripleStoreRs.java:44)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
at org.glassfish.hk2.utilities.reflection.ReflectionHelper.makeMe(ReflectionHelper.java:1117)
at org.jvnet.hk2.internal.ClazzCreator.createMe(ClazzCreator.java:261)
at org.jvnet.hk2.internal.ClazzCreator.create(ClazzCreator.java:337)
at org.jvnet.hk2.internal.SystemDescriptor.create(SystemDescriptor.java:456)
at org.glassfish.jersey.process.internal.RequestScope.findOrCreate(RequestScope.java:158)
at org.jvnet.hk2.internal.Utilities.createService(Utilities.java:2350)
at org.jvnet.hk2.internal.ServiceLocatorImpl.getService(ServiceLocatorImpl.java:612)
at org.jvnet.hk2.internal.ServiceLocatorImpl.getService(ServiceLocatorImpl.java:597)
at org.glassfish.jersey.internal.inject.Injections.getOrCreate(Injections.java:173)
at org.glassfish.jersey.server.model.MethodHandler$ClassBasedMethodHandler.getInstance(MethodHandler.java:185)
at org.glassfish.jersey.server.internal.routing.PushMethodHandlerRouter.apply(PushMethodHandlerRouter.java:103)
at org.glassfish.jersey.server.internal.routing.RoutingStage._apply(RoutingStage.java:128)
at org.glassfish.jersey.server.internal.routing.RoutingStage._apply(RoutingStage.java:131)
at org.glassfish.jersey.server.internal.routing.RoutingStage._apply(RoutingStage.java:131)
at org.glassfish.jersey.server.internal.routing.RoutingStage._apply(RoutingStage.java:131)
at org.glassfish.jersey.server.internal.routing.RoutingStage._apply(RoutingStage.java:131)
at org.glassfish.jersey.server.internal.routing.RoutingStage.apply(RoutingStage.java:110)
at org.glassfish.jersey.server.internal.routing.RoutingStage.apply(RoutingStage.java:65)
at org.glassfish.jersey.process.internal.Stages.process(Stages.java:197)
at org.glassfish.jersey.server.ServerRuntime$1.run(ServerRuntime.java:250)
at org.glassfish.jersey.internal.Errors$1.call(Errors.java:271)
at org.glassfish.jersey.internal.Errors$1.call(Errors.java:267)
at org.glassfish.jersey.internal.Errors.process(Errors.java:315)
at org.glassfish.jersey.internal.Errors.process(Errors.java:297)
at org.glassfish.jersey.internal.Errors.process(Errors.java:267)
at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:318)
at org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:236)
at org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:1010)
at org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:373)
at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:382)
at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:345)
at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:220)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:501)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1040)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:607)
at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.doRun(AprEndpoint.java:2441)
at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:2430)
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)
And the code where it is failing is
TDBFactory.createDataset(datasetPath);
You have probably been updating the dataset non-transactionally and not sync'ed it. The database has become corrupted and you'll need to rebuild it.
Using transactions will mean the database on disk is robust against server exit.