Java DMI - Datasource configuration

Hi,

We are using a custom framework built around Struts and Spring and working on a POC to use SmartClient for frontend. We have found the sample given in forums to integrate with DMI and Java beans. We have developed all the components, but, we are not able to place our .ds xml file properly. Kindly let us know ho to configure/place the same and get the reference of datasource in DynamicForm?

Regards,
Kumbesh

The default location is [webroot]/shared/ds. Then, load the DataSource via the <isc:loadDS> tag.

We are trying the asme way, but getting null pointer exception while calling LoasDSTag.doStartTag(). Kindly assist and we are struck with this.

We are now facing “The filename, directory name, or volume label syntax is incorrect” and have kept the file in “$webroot/shared/ds” and the file name is supplyItemDMI.ds.xml. Kindly let us know how to resolve this.

You didn’t actually create a directory called “$webroot” did you? “$webroot” is intended to indicate the root level of user-accessible files - generally the same directory that contains WEB-INF.

If that doesn’t solve the problem for you, please post the complete logs where you are seeing that error message (this is something you should always do).

Sorry for mentioning it as $webroot. I meant only the rrot directory. For example, if our project is “isomorphic”, I have kept the shared directory under that and WEB_INF is also in the same directory.

Kindly see the error trace I am getting.

21 Sep 2008 17:02:13,257:[http-8080-Processor23] [ERROR] org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/dbfcweb].[jsp] - Servlet.service() for servlet jsp threw exception
javax.servlet.jsp.JspException: java.io.IOException: The filename, directory name, or volume label syntax is incorrect
at java.io.WinNTFileSystem.canonicalize0(Native Method)
at java.io.Win32FileSystem.canonicalize(Unknown Source)
at java.io.File.getCanonicalPath(Unknown Source)
at com.isomorphic.io.ISCFile.getCanonicalPath(ISCFile.java:195)
at com.isomorphic.store.ProcessedFileCache.getObjectFromFile(ProcessedFileCache.java:77)
at com.isomorphic.xml.XML.loadCacheableDSRecords(XML.java:334)
at com.isomorphic.store.DataStructCache.loadInstance(DataStructCache.java:143)
at com.isomorphic.datasource.DataSource.forName(DataSource.java:144)
at com.isomorphic.datasource.PoolableDataSourceFactory.makeUnpooledObject(PoolableDataSourceFactory.java:84)
at com.isomorphic.datasource.PoolableDataSourceFactory.makeObject(PoolableDataSourceFactory.java:91)
at org.apache.commons.pool.impl.GenericKeyedObjectPool.borrowObject(GenericKeyedObjectPool.java:964)
at com.isomorphic.pool.PoolManager.borrowObject(PoolManager.java:70)
at com.isomorphic.datasource.DataSourceManager.getDataSource(DataSourceManager.java:56)
at com.isomorphic.taglib.LoadDSTag.doStartTag(LoadDSTag.java:58)
at org.apache.jsp.WEB_002dINF.jsp.batchentry.batch.Batch_002dlist_jspx._jspx_meth_isomorphic_005floadDS_005f0(Batch_002dlist_jspx.java:138)
at org.apache.jsp.WEB_002dINF.jsp.batchentry.batch.Batch_002dlist_jspx._jspService(Batch_002dlist_jspx.java:69)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:331)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:679)
at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:461)
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:399)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:301)
at org.apache.struts2.dispatcher.ServletDispatcherResult.doExecute(ServletDispatcherResult.java:139)
at org.apache.struts2.dispatcher.StrutsResultSupport.execute(StrutsResultSupport.java:178)
at com.opensymphony.xwork2.DefaultActionInvocation.executeResult(DefaultActionInvocation.java:348)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:253)
at com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:221)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:86)
at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224)
at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223)
at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile

That configurations sounds correct, however, somehow a corrupt path has been passed to Java. It looks like an invalid path has somehow been specified, possibly in the server.properties file that configures the path where DataSources are expected to be placed.

Can you show a complete log, from startup of the application server? The SmartClient Server automatically logs various settings, such as filesystem paths, in order to help with exactly this kind of issue.

Have you done anything that differs from the standard installation instructions in the SmartClient Reference? Any configuration after deployment? Because you appear to be using Tomcat/Catalina on Windows and those instructions are known to work in that environment.

I tried giving another taglib entry for iscTagLib.xml and I gave it with extra slash. I have commented it now as it takes from iscTagLib.xml. But, I am facing a syntax error in the following line

<script type=“text/javascript”><isomorphic:loadISC/><isomorphic:loadDS ID=“supplyItemDMIDS”/>

See my jspx file below..

<?xml version=“1.0” encoding=“UTF-8” ?>
<jsp:root xmlns:jsp=“http://java.sun.com/JSP/Page” xmlns:isomorphic=“isomorphic” version=“2.0”>
<jsp:directive.page language=“java”
contentType=“text/html; charset=UTF-8” pageEncoding=“UTF-8” />
<html xmlns=“http://www.w3.org/1999/xhtml”>
<head>
<title>
Title
</title>

	&lt;/head&gt;

	&lt;body&gt;
	&lt;table border="1"&gt;
	&lt;tr&gt;
	&lt;td&gt;
	
	Test Item
	
	&lt;script type="text/javascript"&gt;
	&lt;isomorphic:loadISC/&gt;
	&lt;isomorphic:loadDS ID="supplyItemDMIDS"/&gt;
				
	
	isc.DynamicForm.create({
	    ID:"boundForm",
	    dataSource: supplyItemDMIDS,
	    numCols:"2",
	    autoFocus:false,
	    useAllDataSourceFields: true,
	    fields: [{name: "SKU", useTextField: true}]
	});
	isc.Button.create({
			    ID: "boundGrid",
			    title: "Click",
			    width: "10%",
			    top: 200
	});
	boundForm.filterData();
	&lt;/script&gt;
	
	&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
	&lt;/body&gt;
&lt;/html&gt;

</jsp:root>

I have kept the datasource in ds and given the mapping in server.properties. I have kept the iscTagLib.xml under WEB-INF and I am trying to make DMI calls to java. I am able to see buttons, but, that too not properly getting aligned within HTML tables I am trying with. Kindly suggest.

Regards,
Kumbesh

I don’t know why it is not loading tht taglibs. Our application is Struts2/Spring based and we have copied everything from web.xml as suggested. Also, kept iscTaglib.xml under WEB-INF and it doesn’t allow to add one more entry in web.xml for these tags. Just added xmlns:isomorphic and maped it to the uri given in iscTaglib.xml. Please see the entries below
<taglib>
<tlibversion>1.0</tlibversion>
<jspversion>1.1</jspversion>
<shortname>iso</shortname>
<uri>/isomorphic</uri>

But, it is giving javascript syntax error exactly at

<isomorphic:loadDS ID=“supplyItemDMIDS”/>

Kindly let us know what/where we need to make a change? We have kept supplyItemDMIDS.ds.xml under webroot/shared/ds/.

This is a question about JSP document syntax, rather than anything to do with SmartClient as such. That said, have you tried:

xmlns:isomorphic="urn:jsptld:/WEB-INF/iscTaglib.xml"

in your jsp:root tag?

Yes.. I will try the same. Do I have to chnage anything for jsp:root? We are using that.

Hi,
It is giving me the follwoing exception now..

22 Sep 2008 21:39:04,120:[http-8080-Processor24] [WARN] net.sf.ehcache.constructs.web.filter.Filter - Throwable thrown during doFilter on request with URI: /dbfcweb/secure/crud/batchentry/batch/Batch/list.xhtml and Query: null/WEB-INF/jsp/batchentry/batch/Batch-list.jspx(2,142) Could not add one or more tag libraries.
javax.servlet.ServletException: /WEB-INF/jsp/batchentry/batch/Batch-list.jspx(2,142) Could not add one or more tag libraries.
at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:515)
at org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:419)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
at com.opensymphony.module.sitemesh.filter.PageFilter.parsePage(PageFilter.java:119)
at com.opensymphony.module.sitemesh.filter.PageFilter.doFilter(PageFilter.java:55)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
at org.apache.struts2.dispatcher.ActionContextCleanUp.doFilter(ActionContextCleanUp.java:99)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:359)
at org.springframework.security.intercept.web.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:109)
at org.springframework.security.intercept.web.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:83)

Regards,
Kumbesh

Any luck with this? This isn’t looking like a SmartClient problem, just servlet engine bizarreness. We’d suggest simplifying your web.xml, perhaps trying to run a SmartClient sample in a directory that doesn’t have filters or other special logic configured.

We haven’t moved forward from this. When we tried standalone examples, we can find it working. But, we want to integrate SmartClient in our framework, which we use across organization. Still searching for solutions.

Still getting the same error - Could not add one or more tag libraries when I added xmlns:isomorphic="urn:jsptld:WEB-INF/iscTaglib.xml.

I created a jspx file in my application’s webroot (for Tomcat, this would be webapps/appdir). The <jsp:root> tag for this file was:

<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" xmlns:isomorphic="urn:jsptld:/WEB-INF/iscTaglib.xml" version="2.0">

Within my webroot, at the same level as the jspx file, is my WEB-INF folder; iscTaglib.xml is in that WEB-INF folder.

With this arrangement, my jspx file picks up iscTaglib fine, and eg, the <isomorphic:loadModules /> tag works fine.

If you have the same file arrangement and the same <jsp:root> declaration, and it isn’t working, I’m not sure what else we can do to help, given that we don’t have the context of your bespoke framework.

Hi,

Currently I am testing all these in jsp files instead of jspx. I have included
<%@ taglib uri=“/WEB-INF/iscTaglib.xml” prefix=“isomorphic” %>
and <isomorphic:loadISC skin=“SmartClient”/> is working fine. We are fcacing the following issues now.

a) Still loadDS is giving errors. We have kept .ds.xml file only under shared/ds under webroot and still not able to load it properly. we also have kept server.properties under classes.
b) To overcome that, we have defined the datsource in jsp itself, but, trying to load its values from java file through DMI call. Kindly see our code snippets below and let us know if we are going wrong anywhere.

var supplyDMIDS = DataSource.create({
ID:“supplyDMIDS”,
serverType:“generic”,
serverObject:“com.db.dbfc.core.smartclient.FetchData”,
fields:[
{name:“SKU”, type:“text”, title:“SKU”},
{name:“BankName”, type:“text”, title:“BankName”}
]
});
.
:
DynamicForm.create({
ID:“newForm”,
autoDraw:false,
dataSource: supplyDMIDS,
numCols:“2”,
autoFocus:false
})
:
:
supplyDMIDS.fetchData();

we are getting Transpot Error making a call to URL isomorphic/IDACall. Kindly let us know if we missing any steps.

Regards,
Kumbesh

Hi Kumbesh,

Once again, every time you report an error, post the logs.

The fact you are getting a transport error for IDACall sounds like an incomplete installation, eg, IDACall not added to web.xml. Likewise your continued problems with loadDS, which could be explained by failing to copy server.properties and other contents of WEB-INF.

Please make sure you have gone through the Deployment Instructions on a line by line basis and not omitted any steps.

If you’re still having trouble, again please post logs with every error.

Note also: your attempt at DMI from the client side won’t work, the presence of the .ds.xml file on disk is what tells SmartClient it is allowed to invoke particular Java methods. If you could invoke any Java method you liked from JavaScript, that would be a security issue.

Thanks for your replies. I tried replcaing all the jars and able to integrate. Once I made DMI calls, I have mapped the Data source with two fields, retieved the values from Java, but in the screen, it is showing only one value in the Grid. Can you please help how to map all the values from fetch to the ListGrid? Please see out code sippets below.

public DSResponse fetch(DSRequest dsRequest)
throws Exception

    {
        DSResponse dsResponse = new DSResponse();
        List matchingItemts = ListCriteria.findMatchingItems();	        dsResponse.setStartRow(0);
		dsResponse.setEndRow(matchingItemts.size());

        dsResponse.setData(matchingItemts);
        return dsResponse;
    }

:
:
SupplyItem item = new SupplyItem();
Long itemID = new Long(1);
item.setSKU(“sku1”);
item.setBankName(“Deutsche Bank”);
item.setItemID(itemID);
elementList.add(item);
item = new SupplyItem();
itemID = new Long(2);
item.setSKU(“sku2”);
item.setBankName(“Citi Bank”);
item.setItemID(itemID);
elementList.add(item);

public class SupplyItem implements Serializable {
protected String SKU;
protected String BankName;
protected Long itemID;

public SupplyItem() {    }
public void setBankName(String BankName) {this.BankName=BankName;  }
public void setSKU(String sku) {this.SKU = sku;}
public String getBankName() {return  BankName;}
public String getSKU() {return SKU;}

public Long getItemID() {return itemID;}
public void setItemID(Long itemID) {this.itemID = itemID;}

JS:
<isomorphic:loadDS ID=“supplyItemDMI” />
isc.ListGrid.create({
ID: “boundGrid”,
dataSource: “supplyItemDMI”,
width: “30%”,
height: 150,
autoFetchData: true

	});
	
	boundGrid.fetchData();

ds.xml file
<DataSource
ID=“supplyItemDMI”
serverType=“generic”>
<fields>
<field name=“SKU” type=“text” title=“SKU”/>
<field name=“BankName” type=“text” title=“BankName”/>
</fields>
<serverObject lookupStyle=“new” className=“com.db.dbfc.core.smartclient.FetchData”/>
</DataSource>

Please suggest what am i missing. I am getting values only for SKU. BankName is not getting printed.
Regards,
Kumbesh

Great, now that you’ve installed correctly, it’s just down to Java basics - given a getter method “getBankName”, the Java Beans standard says that the property name is bankName, with a lowercase b. Correct your DataSource field name and the value will display.

Thanks a lot. We figured it out and it worked. The framework we are using is using Struts2 and all the objects are directly accessible in Jsp from actions. We want to use SmartClient dynamic forms instead of struts forms. Is that possible? If so, how can we retrieve values? Our framework is Struts 2 talking to Spring and we want to integrate SmartClient with this for RIA. It is the existing framework through out here and we want to have our JSPs with SmartClient. Kindly let us know how we can do it?

See some of the samples I am trying

<td colspan=“35”><s:text name=“batchentry.batch.label.batchnumber” /></td>
<td><s:textfield name=“batch.batchNumber” theme=“simple” /></td>

Is it possible to get these values mapped to dynamic form as below? We anyway have all the values from action to Jsp. Kindly let us know.

DynamicForm.create({
ID: “BATCH”,
autoDraw: false,
submitParamsOnly: true,
fields : [
{ name:“firstName”, title: “<s:text name=“batchentry.batch.screen.title” />”,
type: “text”, length: 30},
{ name:“batch.refNumber”, title: “Ref number”,
type: “text”, length: 60},
{ name:“batch.pickupLoc”, title: “Pickup Loc”,
type: “text”, length: 2000},
{ name:“batch.batchNumber”, title:“Batch Number”, type:“staticText”, length: 200}
]
});