Alternate API hits are getting failed in WSO2 API Manager. Any suggestion? - wso2-api-manager

I've tried hitting an API, alternate hits are getting failed and showing as connection timeout.
In logs I've found this.
WSO2 API Manager 2.6.0
Database: Mysql
Environment: Distributed Environment
ERROR {org.apache.tomcat.jdbc.pool.interceptor.ConnectionState} - Unable to reset autocommit state to connection. {org.apache.tomcat.jdbc.pool.interceptor.ConnectionState}
com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure
The last packet successfully received from the server was 936,547 milliseconds ago. The last packet sent successfully to the server was 936,550 milliseconds ago.
at com.mysql.cj.jdbc.exceptions.SQLError.createCommunicationsException(SQLError.java:174)
at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:64)
at com.mysql.cj.jdbc.ConnectionImpl.setAutoCommit(ConnectionImpl.java:2054)
at org.apache.tomcat.jdbc.pool.interceptor.ConnectionState.reset(ConnectionState.java:91)
at org.apache.tomcat.jdbc.pool.ConnectionPool.setupConnection(ConnectionPool.java:327)
at org.apache.tomcat.jdbc.pool.ConnectionPool.getConnection(ConnectionPool.java:201)
at org.apache.tomcat.jdbc.pool.DataSourceProxy.getConnection(DataSourceProxy.java:128)
at org.wso2.carbon.registry.core.jdbc.dataaccess.JDBCTransactionManager.beginTransaction(JDBCTransactionManager.java:80)
at org.wso2.carbon.registry.core.jdbc.dao.JDBCLogsDAO.beginTransaction(JDBCLogsDAO.java:325)
at org.wso2.carbon.registry.core.jdbc.dao.JDBCLogsDAO.getLogList(JDBCLogsDAO.java:296)
at org.wso2.carbon.registry.core.jdbc.EmbeddedRegistry.getLogs(EmbeddedRegistry.java:2389)
at org.wso2.carbon.registry.core.caching.CacheBackedRegistry.getLogs(CacheBackedRegistry.java:485)
at org.wso2.carbon.registry.core.session.UserRegistry.getLogsInternal(UserRegistry.java:1810)
at org.wso2.carbon.registry.core.session.UserRegistry.access$3600(UserRegistry.java:61)
at org.wso2.carbon.registry.core.session.UserRegistry$37.run(UserRegistry.java:1781)
at org.wso2.carbon.registry.core.session.UserRegistry$37.run(UserRegistry.java:1778)
at java.security.AccessController.doPrivileged(Native Method)
at org.wso2.carbon.registry.core.session.UserRegistry.getLogs(UserRegistry.java:1778)
at org.wso2.carbon.registry.indexing.ResourceSubmitter.submitResource(ResourceSubmitter.java:119)
at org.wso2.carbon.registry.indexing.ResourceSubmitter.run(ResourceSubmitter.java:77)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: com.mysql.cj.exceptions.CJCommunicationsException: Communications link failure
registry.xml
<?xml version="1.0" encoding="ISO-8859-1"?>
<!--
~ Copyright 2005-2011 WSO2, Inc. (http://wso2.com)
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<wso2registry>
<!--
For details on configuring different config & governance registries see;
http://wso2.org/library/tutorials/2010/04/sharing-registry-space-across-multiple-product-instances
-->
<currentDBConfig>wso2registry</currentDBConfig>
<readOnly>false</readOnly>
<enableCache>true</enableCache>
<registryRoot>/</registryRoot>
<dbConfig name="wso2registry">
<dataSource>jdbc/WSO2CarbonDB</dataSource>
</dbConfig>
<!-- This handler provides the feature to add a simlink to a given resource -->
<handler class="org.wso2.carbon.registry.extensions.handlers.ExtensionsSymLinkHandler">
<filter class="org.wso2.carbon.registry.core.jdbc.handlers.filters.URLMatcher">
<property name="pattern">.*</property>
</filter>
</handler>
<!-- This handler provides resource retention locking for the resources -->
<handler class="org.wso2.carbon.registry.extensions.handlers.RetentionHandler"
methods="PUT,DELETE,MOVE,RENAME,IMPORT,COPY,ADD_ASSOCIATION,REMOVE_ASSOCIATION,RESTORE,RESTORE_VERSION">
<filter class="org.wso2.carbon.registry.core.jdbc.handlers.filters.URLMatcher">
<property name="pattern">.*</property>
</filter>
</handler>
<!-- This handler processes the services being added to the registry -->
<handler class="org.wso2.carbon.registry.extensions.handlers.ServiceMediaTypeHandler">
<!--property name="disableWSDLValidation">true</property-->
<property name="defaultServiceVersion">1.0.0-SNAPSHOT</property>
<property name="disableSymlinkCreation">true</property>
<property name="smartLifecycleLinks" type="xml">
<key>dev</key>
<key>qa</key>
<key>live</key>
</property>
<filter class="org.wso2.carbon.registry.core.jdbc.handlers.filters.MediaTypeMatcher">
<property name="mediaType">application/vnd.wso2-service+xml</property>
</filter>
</handler>
<!-- This handler provides the ability to remove the entire heirarchy for a given service while deleting the service -->
<handler class="org.wso2.carbon.registry.extensions.handlers.DeleteHierarchyHandler">
<filter class="org.wso2.carbon.registry.core.jdbc.handlers.filters.MediaTypeMatcher">
<property name="mediaType">application/vnd.wso2-service+xml</property>
</filter>
</handler>
<!-- This handler use to index APIs when there change in Api artifact-->
<handler class="org.wso2.carbon.registry.indexing.IndexingHandler">
<filter class = "org.wso2.carbon.registry.core.jdbc.handlers.filters.MediaTypeMatcher">
<property name="mediaType">application/vnd.wso2-api+xml</property>
</filter>
</handler>
<!--This handler delete the subscription hierarcy generated in the notifications path when a subscription is deleted directly -->
<handler class="org.wso2.carbon.registry.extensions.handlers.DeleteHierarchyHandler">
<filter class="org.wso2.carbon.registry.core.jdbc.handlers.filters.URLMatcher">
<property name="deletePattern">/_system/governance/event/topics/registry/notifications/.*</property>
</filter>
</handler>
<!-- This handler processes the links for the lifecycle -->
<handler class="org.wso2.carbon.registry.extensions.handlers.SmartLifecycleLinkHandler">
<property name="states" type="xml">
<state key="dev">Created</state>
<state key="qa">Tested</state>
<state key="live">Deployed</state>
</property>
<filter class="org.wso2.carbon.registry.core.jdbc.handlers.filters.MediaTypeMatcher">
<property name="mediaType">application/vnd.wso2-smart-link</property>
</filter>
</handler>
<!-- This handler processes the policy files of the given media type defined by the filter -->
<handler class="org.wso2.carbon.registry.extensions.handlers.PolicyMediaTypeHandler">
<property name="policyLocationConfiguration" type="xml">
<location>/trunk/policies/</location>
</property>
<filter class="org.wso2.carbon.registry.core.jdbc.handlers.filters.MediaTypeMatcher">
<property name="mediaType">application/policy+xml</property>
</filter>
</handler>
<!-- This handler processes the schema types which are defined by the filter -->
<handler class="org.wso2.carbon.registry.extensions.handlers.XSDMediaTypeHandler">
<!--property name="disableSchemaValidation">true</property-->
<property name="disableSymlinkCreation">true</property>
<property name="locationConfiguration" type="xml">
<location>/trunk/schemas/</location>
</property>
<filter class="org.wso2.carbon.registry.core.jdbc.handlers.filters.MediaTypeMatcher">
<property name="mediaType">application/x-xsd+xml</property>
</filter>
</handler>
<!-- This handler processes making an external link to a given resource -->
<handler class="org.wso2.carbon.registry.extensions.handlers.ExternalLinkHandler">
<filter class="org.wso2.carbon.registry.core.jdbc.handlers.filters.MediaTypeMatcher">
<property name="mediaType">application/vnd.wso2-hyperlink</property>
</filter>
</handler>
<!-- This handler processes service end-points defined in the WSDL files being uploaded to the registry -->
<handler class="org.wso2.carbon.registry.extensions.handlers.EndpointMediaTypeHandler">
<property name="endpointMediaType">application/vnd.wso2.endpoint</property>
<property name="endpointLocationConfiguration" type="xml">
<location>/trunk/endpoints/</location>
</property>
<filter class="org.wso2.carbon.registry.extensions.filters.EndpointMediaTypeMatcher">
</filter>
</handler>
<handler class="org.wso2.carbon.governance.registry.extensions.handlers.UriMediaTypeHandler">
<filter class="org.wso2.carbon.registry.core.jdbc.handlers.filters.MediaTypeMatcher">
<property name="mediaType">application/vnd.wso2-uri+xml</property>
</filter>
</handler>
<!-- When a resource/governance artifact is deleted, this handler will cleanup all its bounded subscriptions from registry-->
<handler class="org.wso2.carbon.registry.extensions.handlers.DeleteSubscriptionHandler">
<filter class="org.wso2.carbon.registry.core.jdbc.handlers.filters.URLMatcher">
<property name="pattern">.*</property>
</filter>
</handler>
<!--This handler manage the meta data resource caching-->
<handler class="org.wso2.carbon.governance.registry.extensions.handlers.MetaDataCacheHandler">
<filter class="org.wso2.carbon.registry.core.jdbc.handlers.filters.URLMatcher">
<property name="pattern">.*</property>
</filter>
</handler>
<!--This handler clears the caches when workflow-extension config is updated.-->
<handler class="org.wso2.carbon.apimgt.impl.handlers.APIConfigMediaTypeHandler" methods="PUT,DELETE">
<filter class="org.wso2.carbon.registry.core.jdbc.handlers.filters.MediaTypeMatcher">
<property name="mediaType">workflow-config</property>
</filter>
</handler>
<indexingConfiguration>
<startIndexing>false</startIndexing>
<skipCache>true</skipCache>
<startingDelayInSeconds>35</startingDelayInSeconds>
<indexingFrequencyInSeconds>3</indexingFrequencyInSeconds>
<!--number of resources submit for given indexing thread -->
<batchSize>40</batchSize>
<!--number of worker threads for indexing -->
<indexerPoolSize>40</indexerPoolSize>
<!-- location storing the time the indexing took place-->
<lastAccessTimeLocation>/_system/local/repository/components/org.wso2.carbon.registry/indexing/lastaccesstime</lastAccessTimeLocation>
<!-- the indexers that implement the indexer interface for a relevant media type/(s) -->
<indexers>
<indexer class="org.wso2.carbon.governance.registry.extensions.indexers.RXTIndexer" mediaTypeRegEx="application/vnd.(.)+\+xml" profiles ="default,api-store,api-publisher"/>
<indexer class="org.wso2.carbon.apimgt.impl.indexing.indexer.PlainTextIndexer" mediaTypeRegEx="text/plain+" profiles ="default,api-store,api-publisher"/>
<indexer class="org.wso2.carbon.apimgt.impl.indexing.indexer.PDFIndexer" mediaTypeRegEx="application/pdf" profiles ="default,api-store,api-publisher"/>
<indexer class="org.wso2.carbon.apimgt.impl.indexing.indexer.MSWordIndexer" mediaTypeRegEx="application/msword" profiles ="default,api-store,api-publisher"/>
<indexer class="org.wso2.carbon.apimgt.impl.indexing.indexer.MSPowerpointIndexer" mediaTypeRegEx="application/vnd.ms-powerpoint" profiles ="default,api-store,api-publisher"/>
<indexer class="org.wso2.carbon.apimgt.impl.indexing.indexer.MSExcelIndexer" mediaTypeRegEx="application/vnd.ms-excel" profiles ="default,api-store,api-publisher"/>
<indexer class="org.wso2.carbon.apimgt.impl.indexing.indexer.XMLIndexer" mediaTypeRegEx="application/xml" profiles ="default,api-store,api-publisher"/>
<indexer class="org.wso2.carbon.apimgt.impl.indexing.indexer.WSDLIndexer" mediaTypeRegEx="application/api-wsdl" profiles ="default,api-store,api-publisher"/>
</indexers>
<exclusions>
<exclusion pathRegEx="/_system/config/repository/dashboards/gadgets/swfobject1-5/.*[.]html"/>
<exclusion pathRegEx="/_system/local/repository/components/org[.]wso2[.]carbon[.]registry/mount/.*"/>
</exclusions>
</indexingConfiguration>
<versionResourcesOnChange>false</versionResourcesOnChange>
<!-- NOTE: You can edit the options under "StaticConfiguration" only before the
startup. -->
<staticConfiguration>
<versioningProperties>true</versioningProperties>
<versioningComments>true</versioningComments>
<versioningTags>true</versioningTags>
<versioningRatings>true</versioningRatings>
<!-- Location you want to add service and default location will be /services/ -->
<servicePath>/trunk/services/</servicePath>
</staticConfiguration>
<!-- This enables auto-versioning of resources (non-collection). Whenever a resource is updated a new version will be created -->
<versionResourcesOnChange>false</versionResourcesOnChange>
<!-- This enables JMX management for G-Reg -->
<jmx enabled="false">
<service name="InvocationStatistics" enabled="true"/>
<service name="Activities" enabled="true"/>
<service name="Properties" enabled="true"/>
<service name="Subscriptions" enabled="true"/>
<service name="Events" enabled="true"/>
</jmx>
</wso2registry>
In gateway node, value is set to false. But still we are facing the issue
Any suggestions please?

The error is related to indexing, and can't be related to API calls. And the gateway node does not need indexing. Let's try disabling indexing.
Open repository/conf/registry.xml and set the value of <startIndexing> to false. Then restart.

Related

Not able to call Dynamic Endpoints/URLs on the basis of Message Mediation polices in WSO2 API Manager

I'm using APIM-3.1.0 and I need to Redirect APIs’ based upon header or request parameter. I have tried for request parameter but unable to call different API's. I have used below custom mediation policy and added it to a test API, but unable to call the different URLs. Every time I was calling API, I was getting output for the else part (URL mention in the else part) in below code even if I am passing the value of operation as menu.
<sequence xmlns="http://ws.apache.org/ns/synapse" name="dynamic-endpoint-seq">
<property expression="json-eval($.operation)" name="operation" />
<filter regex="menu" source="$ctx:operation">
<then>
<property name="C" expression="fn:concat('http://localhost:8080/Test/','getC')"/>
<header name="To" expression="get-property('C')"/>
</then>
<else>
<property name="B" expression="fn:concat('http://localhost:8080/Test/','getB')"/>
<header name="To" expression="get-property('B')"/>
</else>
</filter>
</sequence>
I was getting warning in Console even passing value of parameter as shown below:
[2020-07-24 17:20:38,643] WARN - SynapseJsonPath Json Payload is empty.
Is there a way to do the same or there is any error in mediation policy?
Here, you can pass value in header with some variable name and define the same in mediation policies.
The below Code calls different endpoints on the basis of variable "check" is present or not,
if it is present in header with any value,the endpoint_B will get called, if value of check is not present or check is not present in header, then it will call endpoint_C.
<sequence xmlns="http://ws.apache.org/ns/synapse" name="dynamic-endpoint-seq-boolean">
<!--it checks the value for variabe check in header if there exist value for check
then it will call B, if value not exist or check is not present then C called-->
<property name="uri.var.check" expression="get-property('transport','check')"/>
<filter source="boolean(get-property('uri.var.check'))" regex="false">
<then>
<property name="C" expression="fn:concat('http://localhost:8080/Test/','getC')"/>
<header name="To" expression="get-property('C')"/>
</then>
<else>
<property name="B" expression="fn:concat('http://localhost:8080/Test/','getB')"/>
<header name="To" expression="get-property('B')"/>
</else>
</filter>
</sequence>
There is one more way to do the same thing, you can use Switch case in XML,as shown below and configure multiple endpoints. Here, if you pass the value of check as 'B' in header, endpoint_B will called, else if you pass value of 'check' as 'C' in header, then endpoint_C will get called, and if you pass any other value than 'B' or 'C' or not pass any value or even not pass check in header than default endpoint here endpoint_A will get called.
<sequence name="dynamic_ep_switch" trace="disable" xmlns="http://ws.apache.org/ns/synapse">
<property name="uri.var.check" expression="get-property('transport','check')"/>
<switch source="get-property('uri.var.check')">
<case regex="B">
<!-- We are then assigning the endpoint which we need to route to in a property named service_ep in this step -->
<property name="B" expression="fn:concat('http://localhost:8080/Test/','getB')"/>
<header name="To" expression="get-property('B')"/>
</case>
<case regex="C">
<property name="C" expression="fn:concat('http://localhost:8080/Test/','getC')"/>
<header name="To" expression="get-property('C')"/>
</case>
<default>
<property name="A" expression="fn:concat('http://localhost:8080/Test/','getA')"/>
<header name="To" expression="get-property('A')"/>
</default>
</switch>
There is one more way to use switch if your endpoint are running on same host and port by using property="rest_url_postfix" as shown in below code. Here,output will be same as above but some changes that you need to make are for the above code you need to select dynamic endpoint in Endpoints tab in WSO2-APIM publisher while for the below code, you select REST Endpoints and select value of endpoint as http://<host_name>:<port_number>// . For example,
http://localhost:8080/Test/
<sequence name="dynamic_same_ep_switch" trace="disable" xmlns="http://ws.apache.org/ns/synapse">
<!-- The property which is retrieved as get-property('To')" stores the request URI for the API. Based on this value we will determine the endpoint which the request needs to be routed to.-->
<property name="uri.var.check" expression="get-property('transport','check')"/>
<switch source="get-property('uri.var.check')">
<case regex="B">
<!-- We are then assigning the endpoint which we need to route to in a property named service_ep in this step -->
<property name="REST_URL_POSTFIX" value="getB" scope="axis2"/>
</case>
<case regex="C">
<property name="REST_URL_POSTFIX" value="getC" scope="axis2"/>
</case>
<default>
<property name="REST_URL_POSTFIX" value="getA" scope="axis2"/>
</default>
</switch>
</sequence>
For anymore information regarding sample mediation sequences refer following links:
https://docs.wso2.com/display/APICloud/Sample+Mediation+Sequences
https://docs.wso2.com/display/ESB480/HTTP+Transport+Properties
Hope. This resolves your Query.

integration between bmc remedy and serviceNow using wso2

we would like to integrate incident module between BMC Remedy and ServiceNow ITSM applications using ESB-WSO2, need assistance on this to achieve this integration.
Use case: Service now has to create incident then WSO2 will consume the request and process then processed request will be send to Remedy. This is nothing but a e-bonding or you can call it as ticket replication.
Any help would be much appreciated
Here is a sample API for you. Supposing that you have already installed ServiceNow connector.
You can call it from Postman using GET or browser, http://{yourWso2EiServer}:8280/serviceNow/test
After testing you can change method to POST and try to send different messages using POSTMAN. Then you will have to evaluate properties from a message, using like"expression"="json-eval($.tablename)" instead of "value"= in you Property mediators and your message must be an application/json and contain this field, like
{"tablename":"incident"....
<api xmlns="http://ws.apache.org/ns/synapse" name="ServiceNowApi" context="/serviceNow" version-type="context">
<resource methods="GET" uri-template="/test" outSequence="" faultSequence="">
<inSequence>
<property name="tablename" value="incident" description="here you can set your request variables with constants for test or read it from request using json-evalng "/>
<property name="sysparmDisplayValue" value="true"/>
<property name="sysparmFields" value="short_description,number,sys_id"/>
<property name="sysparmView" value="short_description,number,sys_id"/>
<property name="number" value="12345678"/>
<property name="shortDescription" value="Testing integration using ServiceNow connector"/>
<property name="active" value="true"/>
<property name="approval" value="owner"/>
<property name="category" value="inquery"/>
<property name="contactType" value="phone"/>
<servicenow.init>
<serviceNowInstanceURL>dev85868.service-now.com</serviceNowInstanceURL>
<username>rest_test</username>
<password>12345678</password>
</servicenow.init>
<servicenow.postRecord>
<tableName>{$ctx:tableName}</tableName>
<sysparmDisplayValue>{$ctx:sysparmDisplayValue}</sysparmDisplayValue>
<sysparmFields>{$ctx:sysparmFields}</sysparmFields>
<sysparmView>{$ctx:sysparmView}</sysparmView>
<sysparmExcludeReferenceLink>{$ctx:sysparmExcludeReferenceLink}</sysparmExcludeReferenceLink>
<sysparmInputDisplayValue>{$ctx:sysparmInputDisplayValue}</sysparmInputDisplayValue>
<number>{$ctx:number}</number>
<shortDescription>{$ctx:shortDescription}</shortDescription>
<active>{$ctx:active}</active>
<approval>{$ctx:approval}</approval>
<category>{$ctx:category}</category>
<contactType>{$ctx:contactType}</contactType>
<apiColumns>{$ctx:apiColumns}</apiColumns>
</servicenow.postRecord>
</respond>
</inSequence>
</inSequence>
</resource>
</api>

Modify Alfresco Thumbnail Resolution

I'm using Alfresco Community v5.2.0 to store some files (pdf, jpg/png essentially).
I'm creating a web app to retrieve this files.
I'm trying to create a grid of files from a specific folder in my application.
But when i'm retrieving the list of a specific folders with their thumbnails, the resolution of the thumbnail is very low (100x75).
How to configure Alfresco to generate a larger thumbnail ?
I tried to override the settings in :
C:\alfresco-community\tomcat\webapps\alfresco\cmisfs\stylesheets\
thumbnails.xsl
But this didn't work..
I'm using Alfresco on my computer (windows), with REST API call.
Where can i configure this resolution ?
Thanks in advance,
Julien
Lyon, FR.
Ok I found a way to ovveride the thumbnail definition :
I created a file
thumbnail-service-context.xml
in
[AlfrescoRootFolder]\tomcat\shared\classes\alfresco\extension\
In this file I wrote :
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
<!-- Slingshot Document Library image thumbnail options -->
<!-- Note that this will auto-register with parent="baseThumbnailDefinition" in the future -->
<bean id="thumbnailDefinitionDoclib" class="org.alfresco.repo.thumbnail.ThumbnailDefinition">
<property name="name" value="doclib" />
<property name="mimetype" value="image/png"/>
<property name="transformationOptions">
<bean parent="defaultImageTransformationOptions">
<property name="resizeOptions">
<bean parent="defaultImageResizeOptions">
<property name="width" value="900"/>
<property name="height" value="900"/>
<property name="allowEnlargement" value="false" />
</bean>
</property>
</bean>
</property>
<property name="placeHolderResourcePath" value="alfresco/thumbnail/thumbnail_placeholder_doclib.png" />
<property name="mimeAwarePlaceHolderResourcePath" value="alfresco/thumbnail/thumbnail_placeholder_doclib{0}.png" />
<property name="runAs" value="System"/>
<property name="failureHandlingOptions" ref="standardFailureOptions"/>
</bean>
</beans>
And now I can retrieve a thumbnail by calling :
/alfresco/api/-default-/public/alfresco/versions/1/nodes/{idDocAlfresco}/renditions/doclib/content

nested exception is java.sql.SQLException: Cannot create JDBC driver of class '' for connect URL 'null' - Spring MVC JNDI issue

I am developing SpringMvcJndiDataSourceXML example. In this example I'm facing below error. I found many links but none of them worked fine for me. Although this is duplicate question, but still I'd like to get the answer to the following question. Please guide.
org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is java.sql.SQLException: Cannot create JDBC driver of class '' for connect URL 'null'
at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:80)
at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:394)
at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:474)
at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:484)
at net.codejava.spring.dao.UserDAOImpl.list(UserDAOImpl.java:24)
at net.codejava.spring.controller.HomeController.home(HomeController.java:21)
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 org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:221)
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:136)
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:114)
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:963)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:897)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970)
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:861)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:622)
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 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.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:1099)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:670)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1520)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1476)
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.sql.SQLException: Cannot create JDBC driver of class '' for connect URL 'null'
at org.apache.tomcat.dbcp.dbcp2.BasicDataSource.createConnectionFactory(BasicDataSource.java:2160)
at org.apache.tomcat.dbcp.dbcp2.BasicDataSource.createDataSource(BasicDataSource.java:2032)
at org.apache.tomcat.dbcp.dbcp2.BasicDataSource.getConnection(BasicDataSource.java:1532)
at org.springframework.jdbc.datasource.DataSourceUtils.doGetConnection(DataSourceUtils.java:111)
at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:77)
... 43 common frames omitted
Caused by: java.sql.SQLException: No suitable driver
at java.sql.DriverManager.getDriver(DriverManager.java:315)
at org.apache.tomcat.dbcp.dbcp2.BasicDataSource.createConnectionFactory(BasicDataSource.java:2144)
... 47 common frames omitted
I'm using tomcat for deployment.
spring-context.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd">
<mvc:annotation-driven />
<context:component-scan base-package="net.codejava.spring" />
<mvc:resources mapping="/resources/**" location="/resources/" />
<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/views/" />
<property name="suffix" value=".jsp" />
</bean>
<bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName" value="java:comp/env/jdbc/UsersDB"/>
</bean>
<bean id="userDao" class="net.codejava.spring.dao.UserDAOImpl">
<constructor-arg>
<ref bean="dataSource" />
</constructor-arg>
</bean>
</beans>
web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
<display-name>SpringMvcJndiDataSourceXML</display-name>
<servlet>
<servlet-name>SpringDispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring-context.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>SpringDispatcher</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<!-- database JNDI reference -->
<description></description>
<resource-ref>
<description>DBConnection</description>
<res-ref-name>jdbc/test</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
<session-config>
<session-timeout>30</session-timeout>
</session-config>
</web-app>
tomcat server.xml
<?xml version="1.0" encoding="UTF-8"?>
<!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor
license agreements. See the NOTICE file distributed with this work for additional
information regarding copyright ownership. The ASF licenses this file to
You under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of
the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required
by applicable law or agreed to in writing, software distributed under the
License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
OF ANY KIND, either express or implied. See the License for the specific
language governing permissions and limitations under the License. --><!-- Note: A "Server" is not itself a "Container", so you may not define
subcomponents such as "Valves" at this level. Documentation at /docs/config/server.html -->
<Server port="8005" shutdown="SHUTDOWN">
<Listener className="org.apache.catalina.startup.VersionLoggerListener" />
<!-- Security listener. Documentation at /docs/config/listeners.html <Listener
className="org.apache.catalina.security.SecurityListener" /> -->
<!--APR library loader. Documentation at /docs/apr.html -->
<Listener SSLEngine="on"
className="org.apache.catalina.core.AprLifecycleListener" />
<!-- Prevent memory leaks due to use of particular java/javax APIs -->
<Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" />
<Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />
<Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener" />
<Resource auth="Container"
driverClassName="com.mysql.jdbc.Driver"
maxActive="20" maxIdle="10"
maxWait="-1"
name="jdbc/UsersDB"
type="javax.sql.DataSource"
username="root" password="root"
url="jdbc:mysql://localhost:3306/test" />
<!-- Global JNDI resources Documentation at /docs/jndi-resources-howto.html -->
<GlobalNamingResources>
<!-- Editable user database that can also be used by UserDatabaseRealm
to authenticate users -->
<Resource auth="Container" description="User database that can be updated and saved"
factory="org.apache.catalina.users.MemoryUserDatabaseFactory" name="UserDatabase"
pathname="conf/tomcat-users.xml" type="org.apache.catalina.UserDatabase" />
</GlobalNamingResources>
<!-- A "Service" is a collection of one or more "Connectors" that share
a single "Container" Note: A "Service" is not itself a "Container", so you
may not define subcomponents such as "Valves" at this level. Documentation
at /docs/config/service.html -->
<Service name="Catalina">
<!--The connectors can use a shared executor, you can define one or more
named thread pools -->
<!-- <Executor name="tomcatThreadPool" namePrefix="catalina-exec-" maxThreads="150"
minSpareThreads="4"/> -->
<!-- A "Connector" represents an endpoint by which requests are received
and responses are returned. Documentation at : Java HTTP Connector: /docs/config/http.html
(blocking & non-blocking) Java AJP Connector: /docs/config/ajp.html APR (HTTP/AJP)
Connector: /docs/apr.html Define a non-SSL/TLS HTTP/1.1 Connector on port
8080 -->
<Connector connectionTimeout="20000" port="8080" protocol="HTTP/1.1"
redirectPort="8443" />
<!-- A "Connector" using the shared thread pool -->
<!-- <Connector executor="tomcatThreadPool" port="8080" protocol="HTTP/1.1"
connectionTimeout="20000" redirectPort="8443" /> -->
<!-- Define a SSL/TLS HTTP/1.1 Connector on port 8443 This connector uses
the NIO implementation that requires the JSSE style configuration. When using
the APR/native implementation, the OpenSSL style configuration is required
as described in the APR/native documentation -->
<!-- <Connector port="8443" protocol="org.apache.coyote.http11.Http11NioProtocol"
maxThreads="150" SSLEnabled="true" scheme="https" secure="true" clientAuth="false"
sslProtocol="TLS" /> -->
<!-- Define an AJP 1.3 Connector on port 8009 -->
<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
<!-- An Engine represents the entry point (within Catalina) that processes
every request. The Engine implementation for Tomcat stand alone analyzes
the HTTP headers included with the request, and passes them on to the appropriate
Host (virtual host). Documentation at /docs/config/engine.html -->
<!-- You should set jvmRoute to support load-balancing via AJP ie : <Engine
name="Catalina" defaultHost="localhost" jvmRoute="jvm1"> -->
<Engine defaultHost="localhost" name="Catalina">
<!--For clustering, please take a look at documentation at: /docs/cluster-howto.html
(simple how to) /docs/config/cluster.html (reference documentation) -->
<!-- <Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"/> -->
<!-- Use the LockOutRealm to prevent attempts to guess user passwords
via a brute-force attack -->
<Realm className="org.apache.catalina.realm.LockOutRealm">
<!-- This Realm uses the UserDatabase configured in the global JNDI resources
under the key "UserDatabase". Any edits that are performed against this UserDatabase
are immediately available for use by the Realm. -->
<Realm className="org.apache.catalina.realm.UserDatabaseRealm"
resourceName="UserDatabase" />
</Realm>
<Host appBase="webapps" autoDeploy="true" name="localhost"
unpackWARs="true">
<!-- SingleSignOn valve, share authentication between web applications
Documentation at: /docs/config/valve.html -->
<!-- <Valve className="org.apache.catalina.authenticator.SingleSignOn"
/> -->
<!-- Access log processes all example. Documentation at: /docs/config/valve.html
Note: The pattern used is equivalent to using pattern="common" -->
<Valve className="org.apache.catalina.valves.AccessLogValve"
directory="logs" pattern="%h %l %u %t "%r" %s %b" prefix="localhost_access_log"
suffix=".txt" />
<Context docBase="SpringMvcJndiDataSourceXML" path="/SpringMvcJndiDataSourceXML"
reloadable="true" source="org.eclipse.jst.jee.server:SpringMvcJndiDataSourceXML" />
</Host>
</Engine>
</Service>
</Server>
In Server.xml place resource under <GlobalNamingResources>
<GlobalNamingResources>
<Resource auth="Container"
driverClassName="com.mysql.jdbc.Driver"
maxActive="20" maxIdle="10"
maxWait="-1"
name="jdbc/UsersDB"
type="javax.sql.DataSource"
username="root" password="root"
url="jdbc:mysql://localhost:3306/test" />
</GlobalNamingResources>
In Context.xml
<ResourceLink global="jdbc/UsersDB" name="jdbc/UsersDB" auth="Container" type="javax.sql.DataSource"/>

Unable to get FlowHandlerMapping working in Spring Webflow

I'm using SWF 2.1 with Spring 2.5.6. and am trying to get the default mapping strategy for 2.1 to work. I had previously been using the mapping strategy that was the 1.0 default (whereby the flow id was retrieved from the request parameters)
In spring MVC configuration, I'm using the simpleUrlMapping strategy (order = 1) and have declared the SimpleControllerHandlerAdapter bean.
<bean class="org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter"/>
SWF configuration:
<bean id="flowController" class="org.springframework.webflow.mvc.servlet.FlowController">
<property name="flowExecutor" ref="flowExecutor"/>
</bean><!--
Launches new flow executions and resumes existing executions. -->
<webflow:flow-executor id="flowExecutor" flow-registry="flowRegistry">
<webflow:flow-execution-repository max-executions="5" max-execution-snapshots="80"/>
</webflow:flow-executor>
<bean class="org.springframework.webflow.mvc.servlet.FlowHandlerAdapter">
<property name="flowExecutor" ref="flowExecutor" />
</bean>
<!--
Creates the registry of flow definitions for this application -->
<webflow:flow-registry id="flowRegistry" flow-builder-services="flowBuilderServices" base-path="/WEB-INF/flows">
<webflow:flow-location-pattern value="/**/*-flow.xml"/>
</webflow:flow-registry>
<webflow:flow-builder-services id="flowBuilderServices" view-factory-creator="viewFactoryCreator" development="true"/>
<bean id="viewFactoryCreator" class="org.springframework.webflow.mvc.builder.MvcViewFactoryCreator">
<property name="viewResolvers">
<list>
<ref local="beanNameViewResolver"/>
<ref local="internalResourceViewResolver"/>
</list>
</property>
</bean>
<!-- Maps request paths to flows in the flowRegistry;
e.g. a path of /hotels/booking looks for a flow with id "hotels/booking" -->
<bean class="org.springframework.webflow.mvc.servlet.FlowHandlerMapping" p:order="0">
<property name="flowRegistry" ref="flowRegistry"/>
</bean>
Here is the directory structure in the web folder:
/WEB-INF/flows/flow1-name/flow1-flow.xml
/WEB-INF/flows/flow2-name/flow2-flow.xml
/WEB-INF/flows/flow3-name/flow3-flow.xml
I have been trying to access the flows by going to
http://www.appdomain.com/flow1-name
the mapping does not work and I get a 404.
Also, how should I name subflows and where should I put them? I would like to be able to access the subflows from more than one top-level flow.
I don't know what your servlet mapping in web.xml looks like but http://www.appdomain.com/flow1-name doesn't seem to include the name of your webapp and possibly the name of your servlet mapping. Check if the DispatcherServlet is getting reached at all. You can do that by enabling the org.springframework.web and org.springframework.webflow logging categories and looking for the output.

Resources