7 Replies Latest reply on Dec 29, 2006 7:13 AM by Torben Frøberg

    Starnge exception

    Torben Frøberg Newbie

      In a servlet (in a method called from the doPost method) I have the following code:

      Class detailClass=Class.forName("dk.frojonck.pingtest.schedule.PingTest");
      I get a strange exception, when this code is executed:

      java.lang.NoClassDefFoundError: org/apache/oro/text/regex/MalformedPatternException
      at java.lang.Class.forName0(Native Method)
      at java.lang.Class.forName(Class.java:164)
      at dk.frojonck.pingtest.servlet.CreatePingTestServlet.createPingTest(CreatePingTestServlet.java:123)

      I do not understand the exception, since it is about some regular expression class, wich I do not use.

      I am using jboss AS version 4.0.5 running on Fedora Core 5.

      Can somebody give me a hit, what os wrong?

      Torben

        • 1. Re: Starnge exception
          Peter Johnson Master

          The problem is related to the parameters the createPingTest method (at line 123) is passing to Class.forName. Could you post the contents of the createPingTest method, and identify line number 123.

          • 2. Re: Starnge exception
            Torben Frøberg Newbie

            Hello Peter,

            Here is the code. I have marked the call til Class.forName with bold.

            private void createPingTest(
            HttpServletRequest req,
            HttpServletResponse resp) throws ServletException, IOException {
            PrintWriter out=resp.getWriter();
            out.println("");
            out.println("Dan test case");
            out.println("");

            try {
            // Build up the job
            String server=req.getParameter("server");
            String emailAdress=req.getParameter("email");
            if (!Configurator.isValidEmailAddress(emailAdress)){
            out.println("Du skal angive en valid adresse.");
            out.println("<a href=\"definerpingjob.jsp\">definer test" );
            out.println("");
            out.close();
            return;
            }
            Integer tid=new Integer(req.getParameter("tid"));
            if (tid==null || tid.intValue()<=0){
            out.println("Antal test skal være st?rre end 0.");
            out.println("<a href=\"definerpingjob.jsp\">definer test" );
            out.println("");
            out.close();
            return;
            }
            Integer frekvens=new Integer(req.getParameter("frekvens"));
            if (frekvens==null || frekvens.intValue()<=0){
            out.println("Tid mellem to test skal være st?rre end 0.");
            out.println("<a href=\"definerpingjob.jsp\">definer test" );
            out.println("");
            out.close();
            return;
            }
            Integer husnr=new Integer(req.getParameter("husnr"));
            if (husnr==null || husnr.intValue()<=0){
            out.println("Husnummer skal bare være et tal");
            out.println("<a href=\"definerpingjob.jsp\">definer test" );
            out.println("");
            out.close();
            return;
            }

            StdSchedulerFactory factory= new StdSchedulerFactory();
            Collection schedCollection= factory.getAllSchedulers();
            Iterator iter=schedCollection.iterator();
            Scheduler schedule=null;
            while (iter.hasNext()){
            schedule=(Scheduler) iter.next();
            }
            // Her defineres jobbet
            Configurator conf=new Configurator();
            Connection con=conf.getConnection();
            PreparedStatement ps=con.prepareStatement("select nextval('job_id')");
            ResultSet rs=ps.executeQuery();
            Integer jobId=null;
            while (rs.next()){
            jobId=new Integer(rs.getInt(1));
            }
            rs.close();
            ps.close();
            Calendar cal=Calendar.getInstance(TimeZone.getTimeZone("UTC"));
            Class detailClass=Class.forName("dk.frojonck.pingtest.schedule.PingTest");
            JobDetail job=new JobDetail(jobId.toString(),"pingtest",
            detailClass);
            JobDataMap dataMap=job.getJobDataMap();
            dataMap.put("server",server);
            dataMap.put("email",emailAdress);
            dataMap.put("antalping",Configurator.getProperty("antalping"));
            dataMap.put("jobid",jobId.toString());
            cal.add(Calendar.SECOND,10);
            Date startTime=cal.getTime();
            cal.add(Calendar.HOUR_OF_DAY,tid.intValue());
            // cal.add(Calendar.MINUTE,tid.intValue());
            Date endTime=cal.getTime();
            SimpleTrigger trigger=new SimpleTrigger(jobId.toString(),"pingtest",
            startTime,endTime,SimpleTrigger.REPEAT_INDEFINITELY,
            ((long) frekvens.intValue())*1000*60);


            schedule.scheduleJob(job,trigger);

            ps=con.prepareStatement("insert into pingtest "+
            "(id, husnr, email,start_time, end_time, antal, interval,pinghost,bruger_id) "+
            "values (?,?,?,?,?,?,?,?,?)"
            );
            ps.setInt(1,jobId.intValue());
            ps.setInt(2,husnr.intValue());
            ps.setString(3,emailAdress);
            ps.setTimestamp(4,new Timestamp(startTime.getTime()),cal);
            ps.setTimestamp(5,new Timestamp(endTime.getTime()),cal);
            ps.setInt(6,Integer.parseInt(Configurator.getProperty("antalping")));
            ps.setInt(7,frekvens.intValue());
            ps.setString(8,server);
            ps.setString(9,req.getRemoteUser());
            ps.execute();
            // con.commit();
            ps.close();
            con.close();
            String messagetext="Du har mulighed for at følge "+
            " resultaterne på siden "+
            " https://www.frojonck.dk/pingtest/resultatgraf.jsp?jobid="+
            jobId.toString();
            out.println(""+messagetext+"");
            WriteMail mail=new WriteMail(Configurator.getProperty("smtphost"));
            mail.setFrom(Configurator.getProperty("from"));
            mail.addTo(emailAdress);
            mail.setSubject("[PINGTEST] testcase er registreret");
            mail.setTextPart(messagetext+
            "\n bruger er ping \n kodeord er xxx");
            mail.sendMessage();

            }
            catch (Exception e){e.printStackTrace();}

            out.println("");
            out.close();

            // TODO Auto-generated method stub
            }

            • 3. Re: Starnge exception
              Peter Johnson Master

              The next question is, which JVM are you using? JBoss usually prints this information out within the first 50 or so lines on the console. Here is what I get:

              14:42:52,281 INFO [ServerInfo] Java VM: Java HotSpot(TM) Server VM 1.5.0_08-b03, Sun Microsystems Inc.

              • 4. Re: Starnge exception
                Torben Frøberg Newbie

                Hello Peter,

                I am using

                00:51:38,401 INFO [ServerInfo] Java version: 1.5.0_06,Sun Microsystems Inc.
                00:51:38,401 INFO [ServerInfo] Java VM: Java HotSpot(TM) Client VM 1.5.0_06-b05,Sun Microsystems Inc.

                Torben

                • 5. Re: Starnge exception
                  Peter Johnson Master

                  I looked at the source for Class.forName, and for the native method, Class.forName0. I actually used the 1.4.2 JVM source, I don't have ready access to the 1.5.0 source, but I think it is relatively the same. I did not see regular expressions in use anywhere. I am now suspecting the PingTest class. Could you post the source?

                  • 6. Re: Starnge exception
                    Torben Frøberg Newbie

                    Hi Peter,

                    You are right . I am using regular expression in this class. And this is probably the casue for the exception.

                    But how do I correct. It is an application I am moving from from an old version of JBOSS (version 3.2 I think) to now 4.0.5.

                    In the old version of JBOSS I had to place the jar file with regular expression in server/default/lib directory to get it to work.

                    Do I now need to placeit in WEB-INF/lib ? I can see JBOSS has changed it way how to load classes?

                    I have not tried it yet, but I will do later today.
                    If it works, thanks for your help, If it does not work, I would appreciate som more hints.

                    Torben

                    • 7. Re: Starnge exception
                      Torben Frøberg Newbie

                      Hi Peter,

                      Thank you for your help. I just need to put regular expression class in the WEB-INF/lib.

                      Torben