Creating New Modules

CPAS Forum (Inactive)
Creating New Modules kimsm  2006-06-21 00:01
Status: Closed
 
Hi guys,

Wondering if I can get any guidance on coding my own module. I've compiled 1.4 from source code, tinkered with the demo module, and taken a look at the build scripts. As a first step, I copied the demo module into another directory in the modules folder and modified the build script:

  1. added <antcall target="myModule"/> to "build_module_classes" target

2. added
  <target name="myModule" depends="init" unless="production_build">
       <antcall target="sub_build_module">
           <param name="moduleName" value="demo"/>
       </antcall>
   </target>

3. edited a simple function call in DemoController.jpf to test if new module is being modified:
  ActionButton insert = new ActionButton("showInsert.view", "Add Person Can You See Me");

4. built & compiled the code.

The additional demo module now shows up in the "Add Web Part" drop down box as another "Demo Summary" module. Once I add this module, and navigate to the "Demo" tab, the button label is not changed to the above label. Can you provide more instructions on setting up our own modules?

Thanks a bunch,

Sul-Min

 
 
maïtt responded:  2006-06-21 08:45
Simply copying the folder will not be sufficient. For one thing all the class names will still be the same. You need to refactor (rename) all the packages, so you have your own distinct set of classes.

Also, you will need to edit DemoModule.java to update the strings and classes you register at startup.

 
kimsm responded:  2006-06-27 01:40
Thanks Matt.

I renamed the all the classes and packages except for the schema name in the postgres script (demo-0.00-1.00.sql). The only hitch that I ran into was that CPAS complained about the duplicate schema during installation.

So I renamed the schema (msPounds) and tried to install again. This time the browser returned this error:
"The following error occurred while running a SQL script in module MSPounds: error executing /admin/sql/errors.gm"

The following error message was found in cpas.log:

DEBUG Table 2006-06-27 00:31:52,648 8080-Processor24 : parameter[1]=Demo
DEBUG Table 2006-06-27 00:31:52,648 8080-Processor24 : parameter[2]=cpas.demo.DemoModule
DEBUG Table 2006-06-27 00:31:52,648 8080-Processor24 : parameter[3]=1.0


DEBUG Table 2006-06-27 00:31:54,020 QL Script Runner : parameter[1]=mspounds
DEBUG ViewServlet 2006-06-27 00:31:54,050 8080-Processor24 : >> GET /cpas/admin-sql/waitForScripts.view?finish=1&moduleName=MSPounds&path=%2FmsPounds%2Fscri
pts%2Fpostgresql&from=0.0&to=1.0&uri=%2Fcpas%2Fadmin%2FmoduleUpgrade.view%3FmoduleName%3DMSPounds%26oldVersion%3D0.0%26newVersion%3D1.0%26state%3DInstalling&reco
mmend=0 (kimsm@cshs.org;D16E785B743B4D56FDFE55F43B5B65CD)
DEBUG ViewServlet 2006-06-27 00:31:54,060 8080-Processor24 : << GET
DEBUG ViewServlet 2006-06-27 00:31:54,170 8080-Processor24 : >> GET /cpas/admin-sql/showRunningScripts.view?finish=1&moduleName=MSPounds&path=%2FmsPounds%2F
scripts%2Fpostgresql&from=0.0&to=1.0&uri=%2Fcpas%2Fadmin%2FmoduleUpgrade.view%3FmoduleName%3DMSPounds%26oldVersion%3D0.0%26newVersion%3D1.0%26state%3DInstalling&
recommend=0 (kimsm@cshs.org;D16E785B743B4D56FDFE55F43B5B65CD)
ERROR GroovyView 2006-06-27 00:31:54,320 8080-Processor24 : error executing /admin/sql/errors.gm
java.lang.StackOverflowError
        at java.lang.AbstractStringBuilder.append(Unknown Source)
        at java.lang.StringBuilder.append(Unknown Source)
        at org.fhcrc.cpas.data.SqlScriptManager$SqlScriptException.getMessage(SqlScriptManager.java:520)

There seems to be some parameters not passed in the debugging table phase. Which functions are responsible for the debugging process, and which parameters are necessary?

Are there any other processes which I should take note of in order to create my own module from scratch?

Thanks!

S.
 
jeckels responded:  2006-06-27 09:55
It looks like you ran into a CPAS bug that's masking whatever the real problem is. I'll make a fix for 1.5, but since you're building the source yourself, I think you can replace line 520 of SqlScriptManager.java with

return _filename + " : " + super.getMessage();

to prevent the StackOverflowError and let you see the root problem.

The Table layer will log all of the JDBC parameters associated with the PreparedStatement it's about to execute, as well as the SQL itself. The code's that responsible is in org.fhcrc.cpas.data.Table._logQuery().

As you probably noticed, our documentation for creating new modules is quite sparse at this point. There's a little bit at https://cpas.fhcrc.org/Wiki/home/help/1.4/page.view?name=buildingModule but it's certainly something we'd like to improve. In 1.5, we will have a new way of building modules so that they can be distributed in a single self-contained file.

Josh

 
kimsm responded:  2006-06-28 09:47
Thanks Josh. Your code fix now gets me past the browser error during install. I checked cpas.log and the install completes with no problem. However, when I add my module in the cpas homepage, the module does not add and the resulting page does not have any content. I have added a screenshot. From the cpas.log I get this error:

DEBUG Table 2006-06-28 09:04:31,450 8080-Processor25 : parameter1=msPounds
ERROR Global 2006-06-28 09:04:31,510 8080-Processor25 : Unhandled exception caught in Global.app: 500: Unexpected server error
java.lang.NullPointerException
        
at org.fhcrc.cpas.data.Table.columnInfos(Table.java:1138)        
at org.fhcrc.cpas.data.Table.select(Table.java:1083)        
at cshs.msPounds.MSPoundsManager.getPeople(MSPoundsManager.java:63)        
at cshs.msPounds.MSPoundsManager.getPeople(MSPoundsManager.java:38)        
at cshs.msPounds.view.MSPoundsWebPart.prepare(MSPoundsWebPart.java:31)        
at cshs.msPounds.view.MSPoundsWebPart.prepare(MSPoundsWebPart.java:16)        
at org.fhcrc.cpas.view.HttpView._prepare(HttpView.java:235)        
at org.fhcrc.cpas.view.HttpView._render(HttpView.java:262)        
at org.fhcrc.cpas.view.HttpView.include(HttpView.java:442)        
at org.fhcrc.cpas.view.VBox.renderView(VBox.java:67)        
at org.fhcrc.cpas.view.VBox.renderView(VBox.java:24)        
at org.fhcrc.cpas.view.HttpView.renderView(HttpView.java:127)        
at org.fhcrc.cpas.view.HttpView.render(HttpView.java:106)        
at org.fhcrc.cpas.view.HttpView._render(HttpView.java:267)        
at org.fhcrc.cpas.view.HttpView.include(HttpView.java:465)        
at org.fhcrc.cpas.jsp.compiled.org.fhcrc.cpas.view.HomeTemplate_jsp._jspService(HomeTemplate_jsp.java:110)        
at org.fhcrc.cpas.view.JspView.renderView(JspView.java:61)        
at org.fhcrc.cpas.view.HttpView.render(HttpView.java:106)        
at org.fhcrc.cpas.view.WebPartView.render(WebPartView.java:128)        
at org.fhcrc.cpas.view.HttpView._render(HttpView.java:267)        
at org.fhcrc.cpas.view.HttpView.include(HttpView.java:442)        
at org.fhcrc.cpas.view.ViewController.includeView(ViewController.java:48)        
at Project.ProjectController.begin(ProjectController.java:83)        
at Project.ProjectController.begin(ProjectController.java:62)        
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)        
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)        
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)        
at java.lang.reflect.Method.invoke(Unknown Source)        
at org.apache.beehive.netui.pageflow.FlowController.invokeActionMethod(FlowController.java:824)        
at org.apache.beehive.netui.pageflow.FlowController.getActionMethodForward(FlowController.java:754)        
at org.apache.beehive.netui.pageflow.FlowController.internalExecute(FlowController.java:428)        
at org.apache.beehive.netui.pageflow.PageFlowController.internalExecute(PageFlowController.java:285)        
at org.apache.beehive.netui.pageflow.FlowController.execute(FlowController.java:308)        
at org.apache.beehive.netui.pageflow.internal.FlowControllerAction.execute(FlowControllerAction.java:48)        
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:419)        
at org.apache.beehive.netui.pageflow.PageFlowRequestProcessor.access$201(PageFlowRequestProcessor.java:106)        
at org.apache.beehive.netui.pageflow.PageFlowRequestProcessor$ActionRunner.execute(PageFlowRequestProcessor.java:2049)        
at org.apache.beehive.netui.pageflow.interceptor.action.internal.ActionInterceptors.wrapAction(ActionInterceptors.java:90)        
at org.apache.beehive.netui.pageflow.PageFlowRequestProcessor.processActionPerform(PageFlowRequestProcessor.java:2120)        
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:224)        
at org.apache.beehive.netui.pageflow.PageFlowRequestProcessor.processInternal(PageFlowRequestProcessor.java:601)        
at org.apache.beehive.netui.pageflow.PageFlowRequestProcessor.process(PageFlowRequestProcessor.java:887)        
at org.apache.beehive.netui.pageflow.AutoRegisterActionServlet.process(AutoRegisterActionServlet.java:611)        
at org.apache.beehive.netui.pageflow.PageFlowActionServlet.process(PageFlowActionServlet.java:157)        
at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)        
at javax.servlet.http.HttpServlet.service(HttpServlet.java:689)        
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)        
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)        
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)        
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:672)        
at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:463)        
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:398)        
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:301)        
at org.fhcrc.cpas.view.ViewServlet.service(ViewServlet.java:129)        
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)        
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)        
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)        
at org.fhcrc.cpas.data.TransactionFilter.doFilter(TransactionFilter.java:36)        
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)        
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)        
at filters.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:124)        
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)        
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)        
at org.fhcrc.cpas.module.ModuleLoader.doFilter(ModuleLoader.java:499)        
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)        
at org.apache.catalina.core.ApplicationFilterChai n.doFilter(ApplicationFilterChain.java:173)        
at org.fhcrc.cpas.security.AuthFilter.doFilter(AuthFilter.java:78)        
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)        
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)        
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)        
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)        
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)        
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)        
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)        
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)        
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)        
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:667)        
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)        
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)        
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)        
at java.lang.Thread.run(Unknown Source) DEBUG ViewServlet 2006-06-28 09:04:31,510 8080-Processor25 : << GET

 
jeckels responded:  2006-06-28 10:14
It looks like the TableInfo you are passing in to Table.select() is null.

The TableInfo class holds metadata about a table or view in the database. CPAS populates TableInfos using JDBC metadata as well as an XML file (cpasroot/modules/demo/src/cpasProperties/demo.xml for the demo module, for example). The name of the XML file needs to match the schema name in the database.

You can debug the loading of the metadata in org.fhcrc.cpas.data.DbSchema.get() to see why it's not finding the tables for your schema.

Josh

 
jeckels responded:  2006-06-28 10:21
I should add that the fix I included in my post should only change the error message you get to have it be the real failure, not fix the underlying problem. Depending on exactly what you did, CPAS might have marked the SQL script as having run even though it failed when executing. The problem might be that your database tables don't exist - you should check the database to see if it looks like what you'd expect.
 
kimsm responded:  2006-06-28 10:52
Josh, I checked my xml file, and I did rename it. Checking the my database reveals that my database table is created with the correct columns. Any other hints?

Thanks for your help,

S.

 
kimsm responded:  2006-07-06 17:25
Any more thoughts on this issue?

Thanks~

 
brendanx responded:  2006-07-06 21:36
Have you set breakpoints and debugged into the functions suggested? Did the schema XML file load or not? If not, did you go directly to the built module jar, and look at its contents for cpasProperties/<name>.xml? If the schema loaded, did DbSchema.getTable() fail? If so, what happened inside DbSchema.loadXml()? Did you see your table loaded? What did get loaded?
 
adam responded:  2007-01-04 09:02