JWorld@TW the best professional Java site in Taiwan
      註冊 | 登入 | 全文檢索 | 排行榜  

» JWorld@TW » Object Relational Mapping  

按列印兼容模式列印這個話題 列印話題    把這個話題寄給朋友 寄給朋友    訂閱主題
reply to topicthreaded modego to previous topicgo to next topic
本主題所含的標籤
無標籤
作者 java.lang.NullPointerException錯誤
sigmagod





發文: 10
積分: 0
於 2014-11-04 20:35 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
我在MyEclipse撰寫完的程式在Main跑沒問題,但是jar丟回agile server
配置成Tools Menu
但是會一直發生java.lang.NullPointerException
這是怎麼回事?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
public class Pendingreport implements ICustomAction {
    public static String formatDate(Date date) {
    DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    return df.format(date);
  }
    public ActionResult doAction(IAgileSession session, INode actionNode,
      IDataObject affectedObject) {
                       String cName = "Change Requests";
                       int delayTime = 1;
           String li = "0";
                       int rowNum = 1;
                       String reviewerStr = "";
    String reviewerStr2 = "";
    String fl = "$STATUSTYPE.REVIEW";
    String fl1 = "$STATUSTYPE.PENDING";
                Vector lVect_1 = new Vector();
                List data = new ArrayList();
                List data2 = new ArrayList();
               
             try {
      IUser user0 = session.getCurrentUser();
 
      String userr = user0.toString();
      IUser user1 = (IUser) session.getObject(
          UserConstants.CLASS_USER_BASE_CLASS, "10210361");
      String user2 = user1.toString();
      IUser user3 = (IUser) session.getObject(
          UserConstants.CLASS_USER_BASE_CLASS, "10210225");
      String user4 = user3.toString();
 
      if (userr.equals(user2) || userr.equals(user4)) {
 
        IAdmin admin = session.getAdminInstance();
        session.setTimeout(999999999);
 
        HSSFWorkbook hssfworkbook = new HSSFWorkbook();
        HSSFSheet sheet = hssfworkbook.createSheet("sheet1");
 
        HSSFCellStyle style = hssfworkbook.createCellStyle();
        style.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);
        style.setAlignment(HSSFCellStyle.ALIGN_CENTER);
 
        HSSFCellStyle style_right = hssfworkbook.createCellStyle();
        style_right.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);
        style_right.setAlignment(HSSFCellStyle.ALIGN_RIGHT);
 
        HSSFCellStyle style_left = hssfworkbook.createCellStyle();
        style_left.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);
        style_left.setAlignment(HSSFCellStyle.ALIGN_LEFT);
 
        HSSFFont font = hssfworkbook.createFont();
        font.setFontHeight((short) 16);
        font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
 
        style.setFont(font);
 
        HSSFRow row = sheet.createRow(0);
        HSSFCell cell1 = row.createCell(0);
        HSSFCell cell2 = row.createCell(1);
        HSSFCell cell3 = row.createCell(2);
        HSSFCell cell4 = row.createCell(3);
        HSSFCell cell5 = row.createCell(4);
        HSSFCell cell6 = row.createCell(5);
        HSSFCell cell7 = row.createCell(6);
        HSSFCell cell8 = row.createCell(7);
 
        cell1.setCellValue("變更單號");
        cell2.setCellValue("表單建立者");
        cell3.setCellValue("建立時間");
        cell4.setCellValue("持續時間");
        cell5.setCellValue("當前關卡");
        cell6.setCellValue("審核者");
        cell7.setCellValue("審核狀態");
        cell8.setCellValue("當前審核閒置時間");
 
        HSSFSheet sheetReport = hssfworkbook.createSheet("逾期統計");
 
        HSSFRow rowReport = sheetReport.createRow(0);
        HSSFCell cell1Report = rowReport.createCell(0);
        HSSFCell cell2Report = rowReport.createCell(1);
        cell1Report.setCellValue("姓名");
        cell2Report.setCellValue("逾期件數");
 
        FileOutputStream file = new FileOutputStream(
            "Pending Report.xls");
        IQuery query = (IQuery) session.createObject(IQuery.OBJECT_TYPE,
                cName);
        query.setCaseSensitive(false);
        query.setCriteria("[1030] in ('" + fl + "','" + fl1 + "')");
        // query.setCriteria("[1030] in('" + fl + "' , '" + fl1 + "')");
        ITable itable = query.execute();
        ITwoWayIterator itwowayinterator = itable.getTableIterator();
        //System.out.println("");
 
        for (int i = 1; itwowayinterator.hasNext(); i++) {
          IRow irow = (IRow) itwowayinterator.next();
          IChange change = (IChange) session.getObject(
              ChangeConstants.CLASS_CHANGE_BASE_CLASS,
              irow.getValue("number"));
          String changeName = change.getName();
          String originator = change.getValue("originator")
              .toString();
          Date dateOriginated = (Date) change
              .getValue("dateOriginated");
          Date currentDate = new Date();
          long l = currentDate.getTime() - dateOriginated.getTime();
          long day = (1 / (1000 * 60 * 60 * 24));
          ITable workflowTbl = change
              .getTable(ChangeConstants.TABLE_WORKFLOW);
          ITwoWayIterator workflowItr = workflowTbl
              .getTableIterator();
          while (workflowItr.hasNext()) {
            IRow workflowRow = (IRow) workflowItr.next();
            String statusCodeStr = workflowRow.getCell(
                Integer.parseInt("3934")).toString();
            String workflowStatusStr = workflowRow.getCell(
                Integer.parseInt("3878")).toString();
 
            reviewerStr = workflowRow.getCell(
                Integer.parseInt("1110")).toString();
 
            String actionStr = workflowRow.getCell(
                Integer.parseInt("1111")).toString();
            String workflowStr = workflowRow.getCell(
                Integer.parseInt("3935")).toString();
 
            //if (statusCodeStr.equals("Reminder") && !reviewerStr.equals("")
                //&& day > delayTime && actionStr.equals("Awaiting Approval"))
            if (statusCodeStr.equals("Current Process") && !reviewerStr.equals("") && day > delayTime && actionStr.equals("Awaiting Approval")) {
              String date1 = workflowRow.getCell(
                  Integer.parseInt("2000009132")).toString();
              if (!date1.equals(li) && !date1.equals("")) {
                row = sheet.createRow(rowNum);
                cell1 = row.createCell(0);
                cell2 = row.createCell(1);
                cell3 = row.createCell(2);
                cell4 = row.createCell(3);
                cell5 = row.createCell(4);
                cell6 = row.createCell(5);
                cell7 = row.createCell(6);
                cell8 = row.createCell(7);
                cell1.setCellValue(changeName);
                cell2.setCellValue(originator);
                cell3.setCellValue(formatDate(dateOriginated));
                cell4.setCellValue(day);
                cell5.setCellValue(workflowStatusStr);
                cell6.setCellValue(reviewerStr);
                cell7.setCellValue(actionStr);
                cell8.setCellValue(date1);
 
                //System.out.print(changeName + " " + originator
                    //+ " " + formatDate(dateOriginated)
                    //+ " " + day + " ");
                //System.out.print(statusCodeStr + " ");
                //System.out.print(workflowStatusStr + " ");
                //System.out.print(reviewerStr + "");
                //System.out.print(actionStr + " ");
                //System.out.println(workflowStr);
                //data.add(reviewerStr);
                //data2.add(reviewerStr);
                rowNum++;
              }
            }
          }
        }
} else {
        return new ActionResult(ActionResult.STRING, "Pending文件不存在");
      }  
    } catch (APIException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    } catch (FileNotFoundException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    } catch (IOException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
    /*finally {
      session.close();
    }*/
    return new ActionResult(ActionResult.STRING, "Pending Report");
    
  }
 
}


reply to postreply to post
作者 Re:java.lang.NullPointerException錯誤 [Re:sigmagod]
afa510





發文: 179
積分: 0
於 2014-11-05 09:29 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
你何不Google 一下 NullPointerException 到底是甚麼意思?

reply to postreply to post
作者 Re:java.lang.NullPointerException錯誤 [Re:sigmagod]
pclevin





發文: 322
積分: 0
於 2014-11-05 09:40 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
你這樣發文問,沒人看懂的。

請:
1、錯誤訊息 全文 ,
2、程式如果可以就給完整的程式。(如果有人給你一半的程式,你看看你看懂否)
3、使用相關技術,例如:jdk 7.xx 、 poi xxx ...等。

感謝~


reply to postreply to post
我的網誌
http://pclevin.blogspot.com
作者 Re:java.lang.NullPointerException錯誤 [Re:pclevin]
sigmagod





發文: 10
積分: 0
於 2014-11-05 18:23 user profilesend a private message to userreply to postreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
不好意思!
我找到原因了,因為session放錯位置了
謝謝各位!


reply to postreply to post
» JWorld@TW »  Object Relational Mapping

reply to topicthreaded modego to previous topicgo to next topic
  已讀文章
  新的文章
  被刪除的文章
Jump to the top of page

JWorld@TW 本站商標資訊

Powered by Powerful JuteForum® Version Jute 1.5.8