> > java.lang.NullPointerException
> > at Turbine.handleException(Turbine.java:507)
> > at Turbine.doGet(Turbine.java:370)
> > at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
> > at javax.servlet.http.HttpServlet.service(HttpServlet.java:865)
> > at
> >
> weblogic.servlet.internal.ServletStubImpl.invokeServlet(Servle
> tStubImpl.java
> > :105)
>
> fixed. sometimes i really hate weblogic's server...

Guess not. Another NPE:

java.lang.NullPointerException
        at Turbine.handleException(Turbine.java:525)
        at Turbine.doGet(Turbine.java:370)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:865)
        at 
weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:105)

I noticed that the reason for this NPE was, that at the line 525, either data was null,
or data.getWriter() retured null. To check this, I made following changes to 
handleException:

     private void handleException(RunData data, Throwable e)
+        throws ServletException
     {
         String mimeType = "text/plain";
         try
         {
             // this is where we capture all exceptions
             // and show the Error Screen
+            if(data == null) {
+                throw new ServletException("RunData is null!");
+            }
                        data.stackTrace = StringUtils.stackTrace(e);
             data.stackTraceException = e;

And indeed, I found "RunData is null!" message in WebLogic's log.
This means that data==null at line 370 of Turbine.java when we are
experiencing this problem. I hope this helps...

> yea...are you using the Turbine connection pool or just
> getting a connection
> with whatever? can i see your JDBCTest code?

JDBCTest uses creates driver instance with Class.forName() and
uses it. The source is at the end of the message.

> > Apache 1.3.9 + JServ 1.1 + MySQL 3.22 OK
> > Tomcat 3.1 + MySQL 3.22 OK
>
> these two are the ones that i really personally only care about.

Mine platform of choice is Tomcat + MySQL. I'm going to use
is whenever possible. But the company I work for is going to
develop real e-bussiness systems very soon, wchich calls
for usage of EJBs, and transactions. WebLogic supports them
relly well, and big names like Bea Systems, or beter yet IBM
are cerainly good for marketing - you shouldn't underesitmate
this factor when you are trying to sell an e-commerce solutions
in a country like Poland.
MySQL is sure a cool database, but it doesn't support transactions,
constraints and triggers. Of course all of these make database server
slower and more resource consuming, but our database engineers
insist that it is impossible to create a reliable and roubust online
system whithout them.
One way or the other, I'm going to work with closed software on
certain projects, and I want to make sure that I'll be able to
integrate Turbine with them.
BTW. My fellow developer just downloaded evalutation version of
IBM WebSphere. Hopefully I'll be able to provide you with results
of testing Turbine on it.

Rafal

---- JDBCTest.java -----------------------------------------------

import java.io.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.sql.*;
import org.apache.regexp.*;

/**
    This simple servlet allows to test your jdbc driver & url string
    The driver you want to test must be in the classpath!
    To be redone under Turbine+WebMacro someday

        @author Tomasz Skutnik [EMAIL PROTECTED]
        @author Rafal Krzewski [EMAIL PROTECTED]
*/
public class JDBCTest extends HttpServlet {
        /**
        do the trick
        */
    public void doGet(HttpServletRequest request, HttpServletResponse response)
        throws IOException, ServletException
    {
                response.setContentType("text/html");
                PrintWriter out = response.getWriter();

                String driver = (String)request.getParameter("driver");
                String url = (String)request.getParameter("url");
                String login = (String)request.getParameter("login");
                String password = (String)request.getParameter("password");
                String table = (String)request.getParameter("table");

                driver = (driver != null) ? driver : "com.sybase.jdbc2.jdbc.SybDriver";
                url = (url != null) ? url : "jdbc:sybase:Tds:forge:4100/turbine";
                login = (login != null) ? login : "turbine";
                password = (password != null) ? password : "turbine";
                table = (table != null) ? table : "Permission";

                out.println(
                        "<h1>Poor man's database explorer</h1><br>" +
                        "<form 
action='"+response.encodeURL(request.getRequestURI())+"' method='post'>" +
                        "Driver: <input type='text' name='driver' size='40' 
value='"+driver+"'><br>" +
                        "URL: <input type='text' name='url' size='40' 
value='"+url+"'><br>" +
                        "login: <input type='text' name='login' size='40' 
value='"+login+"'><br>" +
                        "password: <input type='password' name='password' size='40' 
value='"+password+"'><br>" +
                        "table: <input type='text' name='table' size='40' 
value='"+table+"'><br>" +
                        "<input type='submit'>" +
                        "</form>"
                );

                Driver jdbcDriver = null;
                try {
                        jdbcDriver = (Driver)Class.forName(driver).newInstance();
                } catch (Exception e) {
                        printError(out, "JDBC Driver registration : " + 
e.getMessage());
                }

                Connection connection = null;
                SQLWarning warning = null;

                try {
                        connection = DriverManager.getConnection(url,login,password);
                        warning = connection.getWarnings();
                } catch (ThreadDeath e) {
                        throw e;
                } catch (OutOfMemoryError e) {
                        throw e;
                } catch (Throwable e) {
                        printError(out, "Connecting exception: " + e.getMessage());
                }

                out.println("Connected !<br>");

                while( warning != null) {
                        out.println("SQLState : " + warning.getSQLState() + "<br>");
                        out.println("Message : " + warning.getMessage() + "<br><br>");
                        warning = warning.getNextWarning();
                }

                try {
                        Statement statement = connection.createStatement();
                        ResultSet results = statement.executeQuery(
                                "select * " +
                                "from " + table
                        );

                        ResultSetMetaData metaData = results.getMetaData();

                        out.println("MetaData<br><table cellspacing='0' border='1' 
bordercolor='#000000'>");
                        out.println("<tr bgcolor='#CCCCCC'>");
                        out.println("<td>ColumnName</td>");
                        out.println("<td>TableTable</td>");
                        out.println("<td>ColumnTypeName</td>");
                        out.println("<td>ColumnType</td>");
                        out.println("<td>isNullable</td>");
                        out.println("<td>isAutoIncrement</td>");
                        out.println("<td>isReadOnly</td>");
                        out.println("<td>isSearchable</td>");
                        out.println("<td>Scale</td>");
                        out.println("<td>Precision</td>");
                        out.println("<td>ColumnDisplaySize</td>");
                        out.println("</tr>");
                        for (int i = 1; i <= metaData.getColumnCount(); i++) {
                                try
                                {
                                        out.println("<tr>");
                                        
out.println("<td>"+metaData.getColumnName(i)+"</td>");
                                        out.println("<td>*</td>");
                                        
//out.println("<td>"+metaData.getTableName(i)+"</td>");
                                        
out.println("<td>"+metaData.getColumnTypeName(i)+"</td>");
                                        
out.println("<td>"+metaData.getColumnType(i)+"</td>");
                                        
out.println("<td>"+metaData.isNullable(i)+"</td>");
                                        
out.println("<td>"+metaData.isAutoIncrement(i)+"</td>");
                                        
out.println("<td>"+metaData.isReadOnly(i)+"</td>");
                                        
out.println("<td>"+metaData.isSearchable(i)+"</td>");
                                        
out.println("<td>"+metaData.getScale(i)+"</td>");
                                        
out.println("<td>"+metaData.getPrecision(i)+"</td>");
                                        
out.println("<td>"+metaData.getColumnDisplaySize(i)+"</td>");
                                        out.println("</tr>");
                                } catch (Exception e) {
                                        throw new ServletException ("Error querying 
metadata" + e);
                                }
                        }
                        out.println("</table><br>");

                        out.println("Query result<br><table cellspacing='0' border='1' 
bordercolor='#000000'>");
                        out.println("<tr bgcolor='#CCCCCC'>");
                        for (int i = 1; i <= metaData.getColumnCount(); i++) {
                                out.println("<td>"+metaData.getColumnLabel(i)+"</td>");
                        }
                        out.println("</tr>");

                        while(results.next()) {
                                out.println("<tr>");
                                for (int i = 1; i <= metaData.getColumnCount(); i++) {
                                        Object obj = results.getObject(i);
                                        out.println("<td>"+(obj != null ? 
(obj.toString().equals("") ? "&nbsp;" : obj.toString()) :
"null")+"</td>");
                                }
                                out.println("</tr>");
                        }
                        out.println("</table>");
                        statement.close();
                } catch (Exception e) {
                        printError(out, "Error executing query: " + e);
                }

                try {
                        connection.close();
                        DriverManager.deregisterDriver(jdbcDriver);
                } catch (Exception e) {
                        printError(out, "Error closing connectin: " + e);
                }

                out.println("Disconnected !<br>");
                out.close();
    }

        /**
                We don't distinguish get and post - chains to doGet
        */
        public void doPost(HttpServletRequest request, HttpServletResponse response)
                throws IOException, ServletException
        {
                doGet(request,response);
        }

        /**
                Format the message nicely and send it to the browser
        */
        public void printError( PrintWriter out, String message )
        {
                try     {
                        RE r = new RE("$");
                        out.println("<b>Error</b><br>"+r.subst(message, 
"<br>",RE.MATCH_MULTILINE));
                } catch (RESyntaxException e) {
                }
        }
}



------------------------------------------------------------
To subscribe:        [EMAIL PROTECTED]
To unsubscribe:      [EMAIL PROTECTED]
Problems?:           [EMAIL PROTECTED]

Reply via email to