JSP - Microsoft ODBC - Microsoft Access Driver Could not find file '(unknown)' - java

I am new to JSP. So i want to make a login web, but I stuck with the sql exception. Annyone know how to solve this? All program i use is 32bit, and I already add Ms Access Database to my user data sources.
here is the error information :
5: <%
6: Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
7: Connection con = DriverManager.getConnection("jdbc:odbc:Driver={Microsoft Access Driver (*.mdb, *.accdb)};DBQ="+application.getRealPath("WEB-INF/db.accdb"));
8: Statement st = con.createStatement(1004,1008);
9:
10: %>
Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:568)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:455)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:395)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:339)
javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
root cause
javax.servlet.ServletException: java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Could not find file '(unknown)'.
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:916)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:845)
org.apache.jsp.khema.doLogin_jsp._jspService(doLogin_jsp.java:145)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:395)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:339)
javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
root cause
java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Could not find file '(unknown)'.
sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc.java:6957)
sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:7114)
sun.jdbc.odbc.JdbcOdbc.SQLDriverConnect(JdbcOdbc.java:3073)
sun.jdbc.odbc.JdbcOdbcConnection.initialize(JdbcOdbcConnection.java:323)
sun.jdbc.odbc.JdbcOdbcDriver.connect(JdbcOdbcDriver.java:174)
java.sql.DriverManager.getConnection(DriverManager.java:582)
java.sql.DriverManager.getConnection(DriverManager.java:207)
org.apache.jsp.khema.doLogin_jsp._jspService(doLogin_jsp.java:72)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:395)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:339)
javax.servlet.http.HttpServlet.service(HttpServlet.java:727)

For a start make sure that you specified the correct path to the DB file, once you do that do the following steps.
from the Control panel search for Administrative tools then search for Data Sources(ODBC) after that Add Microsoft Access Drivers(*mdb,*accdb).

Related

Upgrading from tomcat6 to tomcat7 giving errors AbstractMethod Error

I have upgrade the tomcat version from tomcat6 to tomcat7 for my web application. On click of a button, AbstractMethod Error is thrown on the page.
Here is the snapshot :
javax.servlet.ServletException: java.lang.AbstractMethodError
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:916)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:845)
com.web.console.jsp.editCDTemplate_jsp._jspService(editCDTemplate_jsp.java:203)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1056)
org.apache.struts.tiles.TilesRequestProcessor.doForward(TilesRequestProcessor.java:261)
org.apache.struts.action.RequestProcessor.processForwardConfig(RequestProcessor.java:388)
org.apache.struts.tiles.TilesRequestProcessor.processForwardConfig(TilesRequestProcessor.java:316)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:231)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1164)
org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:397)
javax.servlet.http.HttpServlet.service(HttpServlet.java:620)
javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
com.web.console.CharsetFilter.doFilter(CharsetFilter.java:16)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
root cause
java.lang.AbstractMethodError
javax.servlet.ServletRequestWrapper.isAsyncStarted(ServletRequestWrapper.java:396)
com.web.console.jsp.editCDTemplate_jsp._jspService(editCDTemplate_jsp.java:166)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1056)
org.apache.struts.tiles.TilesRequestProcessor.doForward(TilesRequestProcessor.java:261)
org.apache.struts.action.RequestProcessor.processForwardConfig(RequestProcessor.java:388)
org.apache.struts.tiles.TilesRequestProcessor.processForwardConfig(TilesRequestProcessor.java:316)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:231)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1164)
org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:397)
javax.servlet.http.HttpServlet.service(HttpServlet.java:620)
javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
com.web.console.CharsetFilter.doFilter(CharsetFilter.java:16)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
The above error occurs on click of button. Only one single button is producing this error.
EDIT
On Pressing the button the following jsp should be displayed but it is throwing the above exception.
CODE SNIPPET
<console:page url="emptyPage.jsp"
title="com.web.template">
<console:menu>
</console:menu>
<console:header>
<%if ( request.getParameter("mode").equals("edit") ) {%>
<bean:message key="com.web.editTemplate"/>
<%} else { %>
<bean:message key="com.web.create"/>
<%}%>
</console:header>
<console:pageBody>
<tr><td><table width="100%"><tr><td>
<%
ServletContext pwgContext = getServletContext().getContext("/pwg");
ivr_005fcallflow_005fframe_jsp.storeAdminSessionIdInContext(pwgContext, session.getId());
WebConsoleSession webConsoleSession = (WebConsoleSession)session.getAttribute(LoginAction.WEB_CONSOLE_SESSION_KEY);
if ( webConsoleSession != null )
ivr_005fcallflow_005fframe_jsp.storeFPSAAdminSessionIdInContext( pwgContext, webConsoleSession.getSessionId() );
RequestDispatcher dispatcher = pwgContext.getRequestDispatcher("/callflow");
InvokeServletTag.FakeRequest subRequest = new InvokeServletTag.FakeRequest(request);
if (request.getParameter("template") != null) {
subRequest.setParameter("callFlowNumber", request.getParameter("template"));
}
InvokeServletTag.FakeResponse subResponse = new InvokeServletTag.FakeResponse();
dispatcher.include(subRequest, subResponse);
subResponse.flushTo(out);
%>
</td></tr></table></td></tr>
<html:errors/>
</console:pageBody>
</console:page>
Can anyone help me on this.
Remove servlet-api, servlet, jsp-api and jasper jars from your build path, You ll see some compilation problems but it ll be taken care by the container. Alternatively you can edit them and point to the new jar files

com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException when making an insert to a database

I'm making a inserting program for database ..
I've simply a textbox to insert an article into my webpage.
When i insert this article:
But while the results are pretty exciting, it's important to note that
this is still a small-scale study and further research is needed to
confirm the link between SERT and SAD, as well as the role that
sunlight plays on serotonin.
The next step will be to find out more about why some people increase
SERT production as the days get shorter, and why some people are
unaffected. It’s estimated SAD affects more than 12 million people
across northern Europe.
Sam Challis, an information manager at British mental health charity
Mind, told the BBC: "We don't yet know enough about how serotonin
levels can be affected by light levels so this is quite an
interesting, albeit small, study. We would welcome more research."
after updating that article into database ..it's throwing an error as:
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 's important to note
that this is still a small-scale study and further researc' at line 1
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
at com.mysql.jdbc.Util.getInstance(Util.java:386)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1054)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4237)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4169)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2617)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2778)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2819)
at com.mysql.jdbc.StatementImpl.executeUpdate(StatementImpl.java:1811)
at com.mysql.jdbc.StatementImpl.executeUpdate(StatementImpl.java:1725)
at org.apache.jsp.controller.rajendra.arora.successfully_jsp._jspService(successfully_jsp.java:71)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:403)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:347)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
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:51)
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:221)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:107)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:504)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:155)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:76)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:934)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:90)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:515)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1012)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:642)
at org.apache.coyote.http11.Http11NioProtocol$Http11ConnectionHandler.process(Http11NioProtocol.java:223)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1597)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1555)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
I've this code to insert into database:
String content=request.getParameter("content");
try{
Class.forName("com.mysql.jdbc.Driver");
Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306/news", "root", "1234");
Statement st=con.createStatement();
int i=st.executeUpdate("insert into main_news(my_news) values('"+content+"')");
}
catch(Exception e){
e.printStackTrace();
}
Surely, Help would be appreciated!
As DaniEll said, that is because your string contains single quotes ('). To prevent this problem you can use PreparedStatement:
PreparedStatement ps = con.prepareStatement
("insert into main_news(my_news) values(?)");
ps.setString(1,content);
ps.executeUpdate();

java.sql.SQLException: ORA-00942: table or view does not exist

when i was trying to read data from Oracle database using the following code i was getting exception
PreparedStatement pst=con.prepareStatement("SELECT * FROM TBLUSER");
pst.executeQuery();
But this table is actually exist in my database when i use this command directly in the command prompt its working fine.And also for one table among the tables in database this code is working fine ,but for other table names its not working properly.So someone please explain why this is happening.
java.sql.SQLException: ORA-00942: table or view does not exist
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:331)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:288)
at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:743)
at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:216)
at oracle.jdbc.driver.T4CPreparedStatement.executeForDescribe(T4CPreparedStatement.java:799)
at oracle.jdbc.driver.OracleStatement.executeMaybeDescribe(OracleStatement.java:1038)
at oracle.jdbc.driver.T4CPreparedStatement.executeMaybeDescribe(T4CPreparedStatement.java:839)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1133)
at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3285)
at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:3329)
at com.symp.ControllerServlet.service(ControllerServlet.java:302)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
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.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:315)
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:745)
Check each of the following:
1) the spelling of the table or view name.
2) that a view is not specified where a table is required.
3) that an existing table or view name exists.
Contact the database administrator if the table needs to be created or if user or application privileges are required to access the table.
Check if you are using the correcte informations :
String url = "jdbc:mysql://localhost:3306/YOUR_SCHEMA";
Driver driver = com.mysql.jdbc.Driver();
String userName = "user";
String password = "pass";
the problem is i am using multiple connections in the program to login to application i have used Oracle connection which is given as class level variable.And the client will be accessed his tables present in MySQL database using MySQL connection which is service method level variable.By mistakenly i have referred oracle connection variable and tried to acess mysql table
I had this error when using persist() in Hibernate and the solution was to execute:
grant all on <schema>.<table> to <user>;
grant all on <schema>.<sequence> to <user>;

JBPM dashboard-builder app wont't start

I deployed dashboard-builder-6.1.0.Final.war app in Tomcat 8.0.11 and JRE 1.8.0_20.
Initially there was ClassNotFoundException which is good, I found required dependencies and gave them to it. In my case were slf4j-api-1.7.7.jar and cdi-api-1.2.jar.
Unfortunately got something even more confusing when try to open JBPM dashboard via http://myhost.com:8080/dashboard-builder/ :
org.apache.jasper.JasperException: An exception occurred processing JSP page /login.jsp at line 162
159:
160: <div id="login-content">
161: <%
162: LocaleManager localeManager = LocaleManager.lookup();
163: Locale currentLocale = localeManager.getCurrentLocale();
164: SessionInitializer.PreferredLocale preferredLocale = SessionInitializer.getPreferredLocale(request);
165: if (preferredLocale != null) currentLocale = preferredLocale.asLocale();
Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:568)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:470)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:405)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:349)
javax.servlet.http.HttpServlet.service(HttpServlet.java:725)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
root cause
java.lang.NullPointerException
org.jboss.dashboard.commons.cdi.CDIBeanLocator.getBeanByName(CDIBeanLocator.java:50)
org.jboss.dashboard.LocaleManager.lookup(LocaleManager.java:37)
org.apache.jsp.login_jsp._jspService(login_jsp.java:214)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:725)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:405)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:349)
javax.servlet.http.HttpServlet.service(HttpServlet.java:725)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
I really don't see a reason for that. Any ideas would be appreciated, thanks!
Are you using the tomcat distribution? Have you followed https://github.com/droolsjbpm/dashboard-builder/blob/master/builder/src/main/tomcat7/README.md ?

Freemarker StringTemplateLoader

I am trying to load some Freemarker templating from the DB using stringLoader and executing them through template.process, but here is the problem, freemarker stuff like <#if... is executing but when I try to execute assign JspTaglibs it breaks.
Here is a simple example:
From the DB I get <#assign bean=JspTaglibs["/WEB-INF/struts-bean.tld]>, which i put in a in StringTemplateLoader. I create configuration, template.. so far everything is working. When I do template.process(data, out), the page reports:
Starting output:FreeMarker template error: The following has evaluated to null or missing: ==> JspTaglibs [in template "temp" at line 1, column 15] Tip: If the failing expression is known to be legally null/missing, either specify a default value with myOptionalVar!myDefault, or use <#if myOptionalVar??>when-present<#else>when-missing. (These only cover the last step of the expression; to cover the whole expression, use parenthessis: (myOptionVar.foo)!myDefault, (myOptionVar.foo)?? The failing instruction (FTL stack trace): ---------- ==> #assign bean = JspTaglibs["/WEB-INF/s... [in template "temp" at line 1, column 1] ---------- Java stack trace (for programmers): ---------- freemarker.core.InvalidReferenceException: [... Exception message was already printed; see it above ...] at freemarker.core.InvalidReferenceException.getInstance(InvalidReferenceException.java:98) at freemarker.core.DynamicKeyName._eval(DynamicKeyName.java:87) at freemarker.core.Expression.eval(Expression.java:111) at freemarker.core.Assignment.accept(Assignment.java:106) at freemarker.core.Environment.visit(Environment.java:265) at freemarker.core.Environment.process(Environment.java:243) at freemarker.template.Template.process(Template.java:277) at org.apache.jsp.test5_jsp._jspService(test5_jsp.java:109) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) at javax.servlet.http.HttpServlet.service(HttpServlet.java:727) at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334) at javax.servlet.http.HttpServlet.service(HttpServlet.java:727) 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:171) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103) 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:1070) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:611) at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.doRun(AprEndpoint.java:2440) at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:2429) at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) at java.lang.Thread.run(Unknown Source)
Scenario that I have is that I have some code stored in the database and I would like to execute it by freemarker during template.process().
Is that even possible, and if it is, what am I doing wrong?
The problem is that JspTaglibs is not a core FreeMarker feature, but something that the FreemarkerServlet puts into the data-model, and something that requires Servlet environment and a HTTP request (as JSP requires that). Out of the box, there's no way to separate this feature from the FreemarkerServlet. However, maybe you can extend it so that you can still use it for your purpose. Most of the magic happens inside createModel, where among others, it adds JspTaglibs to the data-model.
It might also useful to know that FreeMarker (and thus FreemarkerServlet) can load templates directly from the database, if you give it a such TemplateLoader implementation through the FreeMarker Configuration. If all you want is serving templates from the database instead of where Struts traditionally stores them, you just need to provide the proper TemplateLoader.

Categories

Resources