Java expert help me. A NullPointerException !!! I can't solve it.

I have complied 3 files (SerialBean.java;SerialBuffer.java;ReaderSerial.java) as my package successfully, it is named serial. The package extends javax.comm.*; I wanna do some serial work.
Then I maked an application :SerialExample1
--------------------------------------code----------------------------------
----------------------------SerialExmaple1.java-----------------------------
import serial.*;
import java.io.*;
import javax.comm.*;
public class SerialExample1
public static void main(String args[])
SerialBean sB=new SerialBean(1);
sB.Initialize();
sB.WritePort("Hi,Chrono");
sB.ClosePort();
It is good enough to deliver the String "Hi,Chrono".
Then I maked another windows application :SerialExample2
------------------------------------code-------------------------------------
-----------------------------Frame1.java-------------------------------------
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import com.borland.jbcl.layout.*;
import serial.*;
import java.io.*;
import javax.comm.*;
public class Frame1 extends JFrame
private JPanel contentPane;
private XYLayout xYLayout1 = new XYLayout();
private Button button1 = new Button();
private TextField textField1 = new TextField();
private SerialBean sB=new SerialBean(1);
//Construct the frame
public Frame1()
enableEvents(AWTEvent.WINDOW_EVENT_MASK);
try
jbInit();
catch(Exception e)
e.printStackTrace();
//Component initialization
private void jbInit() throws Exception
//setIconImage(Toolkit.getDefaultToolkit().createImage(Frame1.class.getResource("[Your Icon]")));
contentPane = (JPanel) this.getContentPane();
button1.setLabel("button1");
button1.addActionListener(new Frame1_button1_actionAdapter(this));
contentPane.setLayout(xYLayout1);
this.setSize(new Dimension(400, 300));
this.setTitle("Frame Title");
textField1.setText("textField1");
contentPane.add(button1, new XYConstraints(54, 52, -1, -1));
contentPane.add(textField1, new XYConstraints(195, 57, -1, -1));
//Overridden so we can exit when window is closed
protected void processWindowEvent(WindowEvent e)
super.processWindowEvent(e);
if (e.getID() == WindowEvent.WINDOW_CLOSING)
System.exit(0);
void button1_actionPerformed(ActionEvent e)
sB.Initialize();
sB.WritePort("Hi Chrono");
sB.ClosePort();
class Frame1_button1_actionAdapter implements java.awt.event.ActionListener
private Frame1 adaptee;
Frame1_button1_actionAdapter(Frame1 adaptee)
this.adaptee = adaptee;
public void actionPerformed(ActionEvent e)
adaptee.button1_actionPerformed(e);
---------------------------SerialExample2.java--------------------------------
import javax.swing.UIManager;
import java.awt.*;
public class SerialExample2
private boolean packFrame = false;
//Construct the application
public SerialExample2()
Frame1 frame = new Frame1();
//Validate frames that have preset sizes
//Pack frames that have useful preferred size info, e.g. from their layout
if (packFrame)
frame.pack();
else
frame.validate();
//Center the window
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
Dimension frameSize = frame.getSize();
if (frameSize.height > screenSize.height)
frameSize.height = screenSize.height;
if (frameSize.width > screenSize.width)
frameSize.width = screenSize.width;
frame.setLocation((screenSize.width - frameSize.width) / 2, (screenSize.height - frameSize.height) / 2);
frame.setVisible(true);
//Main method
public static void main(String[] args)
try
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
catch(Exception e)
e.printStackTrace();
new SerialExample2();
It is a bad code!!! I compiled them seccessfully but It can't work .The java system gave
some wrong messages
Exception occurred during event dispatching:java.lang.NullPointerException     at serial.SerialBean.WritePort(SerialBean.java:115)     at Frame1.button1_actionPerformed(Frame1.java:66)     at Frame1_button1_actionAdapter.actionPerformed(Frame1.java:82)     at java.awt.Button.processActionEvent(Button.java:329)     at java.awt.Button.processEvent(Button.java:302)     at java.awt.Component.dispatchEventImpl(Component.java:2593)     at java.awt.Component.dispatchEvent(Component.java:2497)     at java.awt.EventQueue.dispatchEvent(EventQueue.java:339)     at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:131)     at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:98)     at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)     at java.awt.EventDispatchThread.run(EventDispatchThread.java:85)-----------------------------------------------------------------------------------
I tried to debug it in Frame1.java:66 and SerialBean.java:115 but I can not find any error.
How to deal with it?
Here are the code about package serial
-----------------------------------code--------------------------------------------
----------------------------SerialBean.java----------------------------------------
package serial;
import java.io.*;
import java.util.*;
import javax.comm.*;
* This bean provides some basic functions to implement full dulplex
* information exchange through the srial port.
public class SerialBean
static String PortName;
CommPortIdentifier portId;
SerialPort serialPort;
static OutputStream out;
static InputStream in;
SerialBuffer SB;
ReadSerial RT;
* Constructor
* @param PortID the ID of the serial to be used. 1 for COM1,
* 2 for COM2, etc.
public SerialBean(int PortID)
PortName = "COM" + PortID;
* This function initialize the serial port for communication. It startss a
* thread which consistently monitors the serial port. Any signal capturred
* from the serial port is stored into a buffer area.
public int Initialize()
int InitSuccess = 1;
int InitFail = -1;
try
portId = CommPortIdentifier.getPortIdentifier(PortName);
try
serialPort = (SerialPort)
portId.open("Serial_Communication", 2000);
} catch (PortInUseException e)
return InitFail;
//Use InputStream in to read from the serial port, and OutputStream
//out to write to the serial port.
try
in = serialPort.getInputStream();
out = serialPort.getOutputStream();
} catch (IOException e)
return InitFail;
//Initialize the communication parameters to 9600, 8, 1, none.
try
serialPort.setSerialPortParams(9600,
SerialPort.DATABITS_8,
SerialPort.STOPBITS_1,
SerialPort.PARITY_NONE);
} catch (UnsupportedCommOperationException e)
return InitFail;
} catch (NoSuchPortException e)
return InitFail;
// when successfully open the serial port, create a new serial buffer,
// then create a thread that consistently accepts incoming signals from
// the serial port. Incoming signals are stored in the serial buffer.
SB = new SerialBuffer();
RT = new ReadSerial(SB, in);
RT.start();
// return success information
return InitSuccess;
* This function returns a string with a certain length from the incomin
* messages.
* @param Length The length of the string to be returned.
public String ReadPort(int Length)
String Msg;
Msg = SB.GetMsg(Length);
return Msg;
* This function sends a message through the serial port.
* @param Msg The string to be sent.
public void WritePort(String Msg)
int c;
try
for (int i = 0; i < Msg.length(); i++)
out.write(Msg.charAt(i));
} catch (IOException e) {}
* This function closes the serial port in use.
public void ClosePort()
RT.stop();
serialPort.close();
----------------------------ReadSerial.java--------------------------------------
package serial;
import java.io.*;
* This class reads message from the specific serial port and save
* the message to the serial buffer.
public class ReadSerial extends Thread
private SerialBuffer ComBuffer;
private InputStream ComPort;
* Constructor
* @param SB The buffer to save the incoming messages.
* @param Port The InputStream from the specific serial port.
public ReadSerial(SerialBuffer SB, InputStream Port)
ComBuffer = SB;
ComPort = Port;
public void run()
int c;
try
while (true)
c = ComPort.read();
ComBuffer.PutChar(c);
} catch (IOException e) {}
------------------------------SerialBuffer.java-------------------------------------
package serial;
public class SerialBuffer
private String Content = "";
private String CurrentMsg, TempContent;
private boolean available = false;
private int LengthNeeded = 1;
* This function returns a string with a certain length from the incomin
* messages.
* @param Length The length of the string to be returned.
public synchronized String GetMsg(int Length)
LengthNeeded = Length;
notifyAll();
if (LengthNeeded > Content.length())
available = false;
while (available == false)
try
wait();
} catch (InterruptedException e) { }
CurrentMsg = Content.substring(0, LengthNeeded);
TempContent = Content.substring(LengthNeeded);
Content = TempContent;
LengthNeeded = 1;
notifyAll();
return CurrentMsg;
* This function stores a character captured from the serial port to the
* buffer area.
* @param t The char value of the character to be stored.
public synchronized void PutChar(int c)
Character d = new Character((char) c);
Content = Content.concat(d.toString());
if (LengthNeeded < Content.length())
available = true;
notifyAll();
Help me !!!

First thing to say is that you really should check if the initialisation was successful in
button1_actionPerformed()You should be checking the return value on the SerialBean Initialize() method. If the initialisation has failed, then the null pointer exception will be thrown because there will be no stream to write to.
I would also recommend rewriting the catches in the SerialBean Initialize() method to dump the stack trace from the caught exception and any additional information that the exception holds for example:
} catch (PortInUseException e) {
    e.printStackTrace();
    return InitFail;
}This will give you a lot more information to work with if it is an initialisation problem.

Similar Messages

  • Can any Java expert help me? Urgent.

    I create a table---CourseDB in adatabase to store the Student ID ( student identification number) and the grades of the courses that they took.
    The structure of the table---CourseDB is:
    StudentID
    GradeofCourse1
    GradeofCourse2
    GradeofCourse3
    GradeofCourseN
    Here GradeofCourse1 means the grade of course 1, that the student obtained. GradeofCourse2, GradeofCourse3, GradeofCourseN have the same meaning.
    I want to use the following query to count the students
    who get g1 in course 1, and g2 in course 2, ......and gn in
    course n.
    Select COUNT(*)
    From CourseDB
    Where GradeofCourse1=g1 AND GradeofCourse2= g2
    ......AND GradeofCourseN=gn
    Here g1, g2,......,gn are grade, the values are: A,B,C,D.
    I want to consider all the possible combination of g1,g2,...,gn.
    The students take all the n courses:Course 1, Course 2,...., Course n, and may get A,B,C, or D in the n courses.
    For example:
    g1=A,g2=B,g3=C,.....,gn=D
    ( This means that the student gets A in Course 1, gets B in Course 2, gets C in Course 3,....., gets D in Course n. Many students may have the same situation. I want to know how many are the students?)
    Or:
    g1=B,g2=C,g3=D,......,gn=A
    To make the problem clear, I give a detail example:
    For example, there are two courses: course 1, course 2.
    I want to know how many stuent get "A" in course 1 and
    get "B" in course 2 at the same time.
    And I want to know all the grade combination of the two courses:
    course 1 course 2
    A A
    A B
    A C
    A D
    B A
    B B
    B C
    B D
    C A
    C B
    C C
    C D
    D A
    D B
    D C
    D D
    So that's 16 total combinations(4^2).
    My question is in the code how I can assign the values(A,B,C,D)
    to g1,g2,g3,.....,gn conveniently.
    The following "nested for loop" can solve the problem ( for example, there are 6 courses):
    for (char class1 = 'A'; class1 <= 'D'; class1++)
    for (char class2 = 'A'; class1 <= 'D'; class2++)
    for (char class3 = 'A'; class1 <= 'D'; class3++)
    for (char class4 = 'A'; class1 <= 'D'; class4++)
    for (char class5 = 'A'; class1 <= 'D'; class5++)
    for (char class6 = 'A'; class1 <= 'D'; class6++)
    select count(*)
    from CourseDB
    where GradeofCourse1=class1 AND GradeofCourse2 = class2 AND GradeofCourse3 = class3
    ....AND GradeofCourse6=class6
    But the problem is that in the "Where GradeofCourse1=class1 AND
    GradeofCourse2= class2 ......AND GradeofCourse6=class6" of the
    Query, the number of courses is not fixed, maybe six, maybe three,
    maybe four, so the depth of "nested for loop" can not be fixed.
    Can any Java expert give me some suggestions?
    Thanks in advance.
    Jack

    Jack,
    When you posted this on the other forum, it was quite a different question, but it has mutated to this point now. I believe what you want to do can be done with what MS Access calls a crosstab query and you can completely leave Java and any other programming language out of it. If you need to know how to do a crosstab query please take it to another forum.

  • Help! Algorithm...can you solve it??????

    does anyone know how to convert this Algorithm to Jave code and if you do show me how and explain why??
    An Algorithm for computing the closure of X with respect to F
    Repeat
    Oldx = X;
    For every Y -->A in F, if Y is a subset of X then add A to X
    Until (oldx = X)
    Please send any solution to [email protected], thanks for your help!!!

    Try the code below, I've not really tested it, just knocked it together.
    I think it works like this:
    If you have a universe with A,B,C,D,E in it.
    Take a set of functional dependencies F with rules like Y->A (i.e. Y functionaly determines A).
    To find the closure of X you work out which other variables can be determined if you know X. So by transitivity if A->D and D->E, then if you know A, then you can work out D and then work out E.
    try playing with the code by changing X and F. The code should work with rules like (A,D)->B. i.e. if you know A and D you can get D.
    Hope this helps :-)
    public class Closure{
         public static void main(String[] args){
              char[] X={'A'};
              char[][][] F = {{{'A'},{'D'}},{{'B'},{'C'}},{{'D'},{'E'}}};
              char[] Y;
              char[] OldX = {};
              char[] A;
              System.out.print("closure of " + X[0] + "is ");
              while(!java.util.Arrays.equals(OldX,X)){
                   OldX = X;
                   for (int i=0; i<F.length;i++){
                        Y=F[0];
                        A=F[i][1];
                        if(contains(X,Y)){
                             X = append(A,X);
              for(int x =0; x<X.length;x++){
                   System.out.print(X[x] );
              System.exit(0);
         static boolean contains(char[] superset, char[] subset){
              boolean contains = true;
              for (int i=0; contains && i < subset.length;i++){
                   contains = false;
                   for(int j=0; j<superset.length;j++){
                        if (superset[j] == subset[i])contains = true;
              return contains;
         static char[] append(char[] set1, char[] set2){
              char[] append = new char[set1.length + set2.length];
              for (int i=0; i < set1.length;i++){
                   append[i] = set1[i];
              for (int i=0; i < set2.length;i++){
                   append[i + set1.length] = set2[i];
              return removeDups(append);
         static char[] removeDups(char[] set){
              java.util.Arrays.sort(set);
              int remCount=0;
              for (int i=1; i < set.length - remCount;){
                   if (set[i] == set[i-1]){
                        for(int j=i;j < set.length - ++remCount;j++){
                             set[j] = set[j+1];
                   }else{
                        i++;
              char[] removeDups = new char[set.length - remCount];
              for(int i = 0; i < removeDups.length;i++){
                   removeDups[i] = set[i];
              return removeDups;

  • Since a few days I get this Error: Java Script "TypeError: eSettings is undefined" How can I solve the problem?

    Before I can open Firefox 4.01 I get a Java Script Error: TypeError: eSettings is undefined

    Clear the cache and the cookies from sites that cause problems.
    * "Clear the Cache": Tools > Options > Advanced > Network > Offline Storage (Cache): "Clear Now"
    * "Remove the Cookies" from sites causing problems: Tools > Options > Privacy > Cookies: "Show Cookies"
    Start Firefox in <u>[[Safe Mode]]</u> to check if one of the extensions is causing the problem (switch to the DEFAULT theme: Firefox (Tools) > Add-ons > Appearance/Themes).
    * Don't make any changes on the Safe mode start window.
    * https://support.mozilla.com/kb/Safe+Mode
    * [[Troubleshooting extensions and themes]]
    If it does work in Safe-mode then disable all extensions and then try to find which is causing it by enabling one at a time until the problem reappears.
    * Use "Disable all add-ons" on the [[Safe mode]] start window to disable all extensions.
    * Close and restart Firefox after each change via "File > Exit" (Mac: "Firefox > Quit"; Linux: "File > Quit")
    In Firefox 4 you can use one of these to start in <u>[[Safe mode]]</u>:
    * Help > Restart with Add-ons Disabled
    * Hold down the Shift key while double clicking the Firefox desktop shortcut (Windows)

  • Hi, since my update to OSX Yosemite, I have problems opening DW and AI CS6. A message with update to old Java SE-6 is displayed? How can I solve this problem? Thanks

    Hi,since my update to OSX Yosemite,I have problems opening DW and AI CS6. A message with update to old Java SE-6 is displayed?Thx

    You need to install Java SE 6 to run those programs. There has been quite a bit of discussion here about that. Something at one of these links should get you going...
    Prompted to install Java SE 6 Runtime | Mac OS 10.9
    Dreamweaver and Java SE 6 Runtime problem on MAC Mountain Lion OSX

  • How I can enable Java ssv helper plugin silently for win7 users with IE9

    here is what happens:
    when I deploy java 7.21 on win7 users, after deployment when users try to Open their IE they get a login screen and apparently it is related to Java ssv helper plugin. it is trying to enable it and needs admin account/password. I am trying to deploy this to about 3000 computers and I dont want all of them start calling helpdesk for this.
    your help is appreciated.

    The following article describes how to create a shared preference file. You can either create preferences that individual users can override, or create locked preferences that individual users cannot override.
    http://kb.mozillazine.org/Lock_Prefs
    (Note: I don't have any personal experience with these files, but another volunteer might post some additional tips and tricks.)

  • Please help!!  Where I can find free Java-applet HTML-Editor???

    I need free Java-applet HTML-Editor. Where I can find it????
    Thanks.

    NetBeans or Forte is supposed to do that now. I've not had an occasion to try to do it in either yet though.

  • My 1st day with JAVA. Help me.

    Hi Java Experts,
    I am new to JAVA, and just subscribed to this forum. Please suggest me some best books and best sites to start with, and which IDE to use for programming.
    Detailed help will be appreciated.
    Rohit.

    ... i keep plugging jEdit from http://www.jedit.org
    it's light weight, free and written in java. has a lot of nice features but is not too complex. netbeans might indeed be nice, but it can be very resource hungry. it depends on what your system can handle.
    i found "Beginning Java Objects: From Concepts to Code"
    by Jacquie Barker absolutely great!
    as far as java intro books go, i ended up going through a bunch that explained some stuff better than others, but never found one that completely 'clicked' for me. by the time i got with them i gave up on the intro stuff and moved on.
    heared that "Learn to Program with Java" by John Smiley is a real good one

  • Java experts on offsetTop and OffsetLeft

    Hi Guys Need ur help ...........
    The web page Html code has <table> tags and if we have to find the largest table among them we need to find the table with the largest height and largest width but height attribute is usually not given with the <table> tag and they say that offsetTop and OffsetLeft can be used to find the largest <table>
    So all java experts in this field plz help me out in this regard.Any small help would be appreciated.........
    Plz help me out guysssssss

    java != javascript

  • Why the same name of process comes out in AIX , in java. please help me.

    Hello.
    I have two questions related to Jvm.
    I've developed Job scheduler program which is doing somthing as the DB schedule is set in the way of Multi
    thread. Currently , I'm in the process of testing this one. It is good , if in the normal case. However, When
    doing Shell, if the application have so a lot to do the Shell, it has a little problem.
    My developing environment is
    OS : AIX 5.3
    JRE : IBM J9 VM (build 2.4, JRE 1.6.0 IBM J9 2.4 AIX ppc-32 jvmap3260sr7-20091214_49398
    (JIT enabled, AOT enabled)
    nofiles(descriptors) 2000
    maxuproc 4096 Maximum number of PROCESSES allowed
    per user True
    In order to execute Shell in My Scheduler program , I tested Runtimeexec() or ProcessBuilder.
    The result of mine in the test , when the executed Shell got over 300 is
         1. The jvm processes that I execute at the first time are shown up , after Shell go to the finish, the
    processes are all in the disappearance again , and at last The processes that I executed at the first time are
    remaining. It's like the process is duplicated process in the maximum of 70.
    When I do shell about 200 to be executed simultaneously, Duplicated jvm about 3 appeared momentarily, then
    disappeared, and also under 120, No duplicated case is found when under 120.
    ps -ef result is below , when shell is excuted
    UID PID PPID C STIME TTY TIME CMD
    jslee 626906 1 0 11, May - 2:20 java -
    DD2_JC_HOME=/source/jslee/JOB -Dfile.encoding=euc-kr jobserver.JobServerMain
    jslee 1421522 626906 0
    19:36:16 - 0:00 java -DD2_JC_HOME=/source/jslee/JOB -Dfile.encoding=euc-kr jobserver.JobServerMain
    ....Skip.....
    jslee 4374620 626906 0 19:34:06 - 0:00 java -DD2_JC_HOME=/source/jslee/JOB -
    Dfile.encoding=euc-kr jobserver.JobServerMain
    (the process list about 60)
    *the first question : Why a lot of duplicated jvm are shown up when in alot of shell to be executed ?
    *the second question : As you can see above , How can I solve out the problem.
    *Is there some option that I can set up when starting Jvm?
    ---Next question---
    My developing environment is
    OS : SunOS 5.8
    JRE : Java(TM) SE Runtime Environment (build 1.6.0_18-b07)
    Java HotSpot(TM) Server
    VM (build 16.0-b13, mixed mode)
    nofiles(descriptors) 256
    As shown obove , the value of descriptors is 256 .
         My scheduler program executed 300 shell at the same time, in result my program was abnormalily
    terminated after doing shell about 180.
    the Exception info is
    java.io.IOException: Cannot run program "sh": error=24, exceeding the number of opened files
         at
    java.lang.ProcessBuilder.start(Unknown Source)
         at java.lang.Runtime.exec(Unknown Source)
         at
    java.lang.Runtime.exec(Unknown Source)
         at java.lang.Runtime.exec(Unknown Source)
    or
    java.net.SocketException: exceeding the number of opened files     at java.net.PlainSocketImpl.socketAccept
    (Native Method)
    &#46608;&#45716;
    java.io.IOException: exceeding the number of opened files     at
    java.io.UnixFileSystem.createFileExclusively(Native Method)
         at java.io.File.checkAndCreate(Unknown
    Source)
         at java.io.File.createTempFile(Unknown Source)
    *question : If I continuously request to open a file that go over system limit, is it possible for JVM to be
    terminated?
    *question : Is there a method that obtains state of System limit in the java library.
    *question : what is the best solution to cope with ?
    Please help me
    =

    struts-config.xml
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.1//EN" "http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd">
    <struts-config>
      <form-beans>
           <form-bean name="registrationForm" type="ndlinh.struts.lab.RegistrationForm" />
      </form-beans>
      <action-mappings>
           <action path="/register"
                   type="ndlinh.struts.lab.RegistrationAction" // action class
                   name="registrationForm" // form bean name
                   validate="false"
                   scope="request"
                   input="registration.jsp" >
                <forward name="success" path="/jsp/success.jsp"  />
                <forward name="failure" path="/jsp/failure.jsp"  />
           </action>
      </action-mappings>
    </struts-config>HTH

  • Help me!! I can't run photoshop cs6 in windows 8

    Help me!! I can't run photoshop cs6 in windows 8

    Could be due to classes not being found or wrong version of java...

  • Expert help needed to connect iPhone / iPad using BlueTooth and Wi-Fi

    We need expert help to connect iPhone / iPad using BlueTooth and Wi-Fi. If you have worked with Apple MFi Program [http://developer.apple.com/programs/mfi], or have expertise/experience in this, please contact me. Thanks! Kevin.

    Hi there.
    I connected to my livebox after about three attempts. You have to pair the livebox by pressing either the number one or two that is on the box. When it is in pair mode it stays that way for ten minutes so it gives you chance to try your wep code that is on the bottom of the box a few times. I can't remember which one was successful but i did try the letters in uppercase and lower and one of them seemed to connect.
    Welcome to discussions by the way.
    Hope this helps JB

  • Need some expert help on this one

    My PPC 10.4.11 mac is running very very slow with plenty of disk space and when I try to verify permission, repair permissions etc. disk utility freezes up to the point where I have to cold shut off the computer. Issues started yesterday when a page in iweb became corrupt causing me to have to completely redesign my index page and then it started freezing up. Do I just need it do an achieve and install or is there something else I can do?

    As your very expert help already mentioned, You must repair the HD.
    If Disk Utility cannot do it then your best bets are DiskWarrior from Alsoft...
    http://www.alsoft.com/DiskWarrior/
    But you need the CD, the download won't work unless you have another Bootable HD.

  • Java mapping help pls

    hi all,
    I've a source structure like this below in PI.
    <MAT>
    <doc type>pdf</doc type
    <subnumber>1234</subnumber>
    <id>45ABC<id>
    <matno>ABCD</matno>
    <filename>transaction1.pdf</filename>
    </MAT>
    target structure would be the same but one more field <filecontent> which is bytearray content such as content=[101, 115, 116, 13, 10, 84, 101, 115, 116, 13, 10, 84, 101, 115, 116, 13, 10, 84, 101, 115, 116, 13, 10, 13, 10, 84, 101, 115, 116, 13, 10, 84, 101, 115, 116, 13, 10, 13, 10, 84, 101, 115, 116, 13, 10, 13, 10, 84, 101, 115, 116, 13, 10, 84, 101, 115, 116, 13, 10]
    <MAT>
    <doc type>pdf</doc type
    <subnumber>1234</subnumber>
    <id>45ABC<id>
    <matno>ABCD</matno>
    <filename>transaction1.pdf</filename>
    <filecontent>bytearraycontent</filecontent
    </MAT>
    And target is HTTP post for posting the above attribute names and values in the body of HTML
    I am writing a java mapping program because I have to read the <filename> tag value from the incoming xml and read the file from PI server location and convert the file content to bytearray and also to map it to target structure for HTTP post. I am requesting help from java experts here in modifying the program according to this requirement. pls help
    package com.usahealth.mapping;
    import java.io.InputStream;
    import java.net.URL;
    import java.net.URLConnection;
    import javax.xml.parsers.DocumentBuilder;
    import javax.xml.parsers.DocumentBuilderFactory;
    import org.w3c.dom.Document;
    import org.w3c.dom.Element;
    import org.w3c.dom.NodeList;
    import com.sap.aii.mapping.api.AbstractTrace;
    import com.sap.aii.mapping.api.AbstractTransformation;
    import com.sap.aii.mapping.api.StreamTransformationException;
    import com.sap.aii.mapping.api.TransformationInput;
    import com.sap.aii.mapping.api.TransformationOutput;
    public class ReadAttrMap extends AbstractTransformation {
      @Override
      public void transform(TransformationInput in, TransformationOutput out)
      throws StreamTransformationException {
      AbstractTrace trace = null;
      try {
      // Initialize Trace
      trace = getTrace();
      // Get Input Message as DOM
      DocumentBuilderFactory docBFactory = DocumentBuilderFactory
      .newInstance();
      docBFactory.setNamespaceAware(true);
      DocumentBuilder docBuilder = docBFactory.newDocumentBuilder();
      Document inDoc = docBuilder.parse(in.getInputPayload()
      .getInputStream());
      inDoc.getDocumentElement().normalize();
      // Read from PayLoad  - here is where I need help to read the filename - convert it to byte array and read other xml tag values and pass  to target structure for HTTP post. I am using HTTP receiver adapter for posting
      } catch (Exception e) {
      trace.addInfo(e.getMessage());
      throw new StreamTransformationException("Mapping Exception: "
      + e.getMessage(), e);
    thx
    mike

    Indrajit, thx again
    So I believe, the java mapping has to be changed to not pass MAT for create element
    // building the target structure   Element target = newdoc.createElement("MAT");  - I have to remove this
    newdoc.appendChild(target);  - have to remove this.   Element doctype = newdoc.createElement(root.getChildNodes().item(1)  will be changed to item(0)
      .getNodeName()); 
    And also to add the logic for  [    ]
    String data = "["; 
    if (fileArray != null) { 
    for (int i = 0; i < fileArray.length; i++) { 
    if data = "[";
    data = data + fileArray[i]; 
    else
    if (i < fileArray.length - 1) { 
    data = data + ","; 
    endif.
    data = data + "]";
    is this right?
    thx indrajit
    -mike

  • Java Access Helper Jar file problem

    I just downloaded Java Access Helper zip file, and unzipped, and run the following command in UNIX
    % java -jar jaccesshelper.jar -install
    I get the following error message, and the installation stopped.
    Exception in thread "main" java.lang.NumberFormatException: Empty version string
    at java.lang.Package.isCompatibleWith(Package.java:206)
    at jaccesshelper.main.JAccessHelperApp.checkJavaVersion(JAccessHelperApp.java:1156)
    at jaccesshelper.main.JAccessHelperApp.instanceMain(JAccessHelperApp.java:159)
    at JAccessHelper.main(JAccessHelper.java:39)
    If I try to run the jar file, I get the same error message.
    Does anyone know how I can fix this?
    Thanks

    Cross-posted, to waste yours and my time...
    http://forum.java.sun.com/thread.jsp?thread=552805&forum=54&message=2704318

Maybe you are looking for

  • Upgrade to ver 1.6 pages not displayed properly in Firefox

    Hi, I upgraded HTML DB to Ver. 1.6 today. The installation was okay, did not raise any errors, but when I use Firefox to log on to HTML DB, the pages are not displayed properly. IE is able to resolve the pages correctly. Do I need to get a plug-in fo

  • Need helps with getting ODI CDC to work

    Hi, I'm new to ODI. I'm trying to get the ODI CDC to work and for now I'm only interested in seeing that the changes are captured correctly. I've set the d/b to archivelog mode and granted all the rights I can think of to the d/b user. I've defined t

  • Opening two PDF's

    I have two monitors and when I open one pdf it opens on my second monitor which is where I want it to open. But when I have one pdf open and want to open a second pdf it opens on my other monitor. I want the pdf's to open on the same monitor just sta

  • Kernel Panic after Software Update to 10.4.3

    What I'm about to say isn't definitive, but it documents my experience and by posting a message here it may help others. Take it for what it's worth ... Last night I accepted upgrade to 10.4.3, restarted the computer, and from that point forward I co

  • HT1977 Purchased audiobooks not showing in itunes account

    I have recently purchased 5 audiobooks in iTunes on my work laptop and they are not showing up on my iPhone nor my iPad.  I'm logged in to my iTunes account on my laptop so, I would assume what I purchase within my account, should show up in my accou