Vivek Raju

Ranch Hand
+ Follow
since Sep 23, 2004
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Vivek Raju

Hi,

I am using Dozer to map old Domain objects to new Domain Objects. I idea is to slowly phase out the old Domain Objects.

I am using dozer-5.3.1.jar dist. The setup and the mapping files and the class mappings look in order.
I get this exception when i run the sample program

<code>
Exception in thread "main" org.dozer.MappingException: java.net.ConnectException: Connection refused: connect
at org.dozer.util.MappingUtils.throwMappingException(MappingUtils.java:88)
at org.dozer.loader.xml.MappingFileReader.read(MappingFileReader.java:65)
at org.dozer.loader.CustomMappingsLoader.loadFromFiles(CustomMappingsLoader.java:103)
at org.dozer.loader.CustomMappingsLoader.load(CustomMappingsLoader.java:57)
at org.dozer.DozerBeanMapper.loadCustomMappings(DozerBeanMapper.java:153)
at org.dozer.DozerBeanMapper.getMappingProcessor(DozerBeanMapper.java:136)
at org.dozer.DozerBeanMapper.map(DozerBeanMapper.java:92)
at com.jpmc.poc.service.DomainObjectMapper.main(DomainObjectMapper.java:32)
Caused by: java.net.ConnectException: Connection refused: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(Unknown Source)
at java.net.PlainSocketImpl.connectToAddress(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at sun.net.NetworkClient.doConnect(Unknown Source)
at sun.net.www.http.HttpClient.openServer(Unknown Source)
at sun.net.www.http.HttpClient.openServer(Unknown Source)
at sun.net.www.http.HttpClient.<init>(Unknown Source)
at sun.net.www.http.HttpClient.New(Unknown Source)
at sun.net.www.http.HttpClient.New(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.connect(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.setupCurrentEntity(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.startEntity(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.startDTDEntity(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDTDScannerImpl.setInputSource(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$DTDDriver.dispatch(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$DTDDriver.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$PrologDriver.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(Unknown Source)
at javax.xml.parsers.DocumentBuilder.parse(Unknown Source)
at org.dozer.loader.xml.MappingFileReader.read(MappingFileReader.java:59)

</code>

Not understanding why it gives me a connection error.

Please help me to understand the issue.


Thanks,

Regards,
Vivek Raju
14 years ago
Hi,

I am using Dozer to map old Domain objects to new Domain Objects. I idea is to slowly phase out the old Domain Objects.

I am using dozer-5.3.1.jar dist. The setup and the mapping files and the class mappings look in order.
I get this exception when i run the sample program

<code>
Exception in thread "main" org.dozer.MappingException: java.net.ConnectException: Connection refused: connect
at org.dozer.util.MappingUtils.throwMappingException(MappingUtils.java:88)
at org.dozer.loader.xml.MappingFileReader.read(MappingFileReader.java:65)
at org.dozer.loader.CustomMappingsLoader.loadFromFiles(CustomMappingsLoader.java:103)
at org.dozer.loader.CustomMappingsLoader.load(CustomMappingsLoader.java:57)
at org.dozer.DozerBeanMapper.loadCustomMappings(DozerBeanMapper.java:153)
at org.dozer.DozerBeanMapper.getMappingProcessor(DozerBeanMapper.java:136)
at org.dozer.DozerBeanMapper.map(DozerBeanMapper.java:92)
at com.jpmc.poc.service.DomainObjectMapper.main(DomainObjectMapper.java:32)
Caused by: java.net.ConnectException: Connection refused: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(Unknown Source)
at java.net.PlainSocketImpl.connectToAddress(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at sun.net.NetworkClient.doConnect(Unknown Source)
at sun.net.www.http.HttpClient.openServer(Unknown Source)
at sun.net.www.http.HttpClient.openServer(Unknown Source)
at sun.net.www.http.HttpClient.<init>(Unknown Source)
at sun.net.www.http.HttpClient.New(Unknown Source)
at sun.net.www.http.HttpClient.New(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.connect(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.setupCurrentEntity(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.startEntity(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.startDTDEntity(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDTDScannerImpl.setInputSource(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$DTDDriver.dispatch(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$DTDDriver.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$PrologDriver.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(Unknown Source)
at javax.xml.parsers.DocumentBuilder.parse(Unknown Source)
at org.dozer.loader.xml.MappingFileReader.read(MappingFileReader.java:59)

</code>

Not understanding why it gives me a connection error.

Please help me to understand the issue.


Thanks,

Regards,
Vivek Raju
Hi all,

I have worked on Hibernate sometime back.
Now i am working on iBatis.

Just wanted to know if iBatis supports something like session.save(), session.update() etc.
In hibernate by pesisting the object using session.save() hibernate internally fires the SQL query.

THanks,

Regards,
S.R.K.Vivek Raju
hi all,

i have a situation here, i have around 6 tabs(all individual jsps displayed as tabs).
The forms of all the six jsp are filled but the data can be submitted for validation onl from the last tab.
Validation can only be performed from all the data(from all 6 tabs) together.

I have implemented this by storing the data of each jsp in session and then submitting all the data from the last tab.
Now after validation, the error messages have to be displayed on individual tab.
I have no idea on how i could get the response onto 6 JSP pages.
Just wanted to know if anyone knows a work around or anything that might help.

Thanks,
Vivek Raju.
16 years ago
JSP
Hi All,

I need to convert an ASCII file to an EBCDIC file (mainframe compatible). The conversion is possible. But I want to maintain the packed decimal requirement also. The mainframe file has COMP-3 fields. i.e computational. Comp-3 fields (packed decimal) are compressed while converting from ASCII to EBCDIC. I tried using oracle �convert�,unix �iconv� and �dd� I don�t know whether they support Comp-3 format or not. Give a solution to convert such that packed decimals are not disturbed in Java.

For example -- '1234' is x'F1F2F3F4' as a string, of length four bytes. The packed decimal representation is x'0123C4', only three bytes long; net saving 1 byte of memory and disk storage.

Thanks,
S.R.K.Vivek Raju
16 years ago
Hi Ulf,

Yes each array contains a complete PDF file.
How could i append them as a file without appending the bytes.

Please give some details.

Thanks,

Regards,
Vivek Raju.
17 years ago
Hi All,

I have to two byte Array. I want to write them to one pdf file.
But the pdf displays only the second byte array content , i know its writing both because i concatenated the byte Arrays and written it as one byte array to the OutputStream.

my code is as follows
<code>
serverData = remoteServiceObject.doRemoteRequestProcess(clientRequest);
System.out.println("server data in tbq reports is" + serverData);
byte[] pdfReportByteArr = (byte[]) (serverData.get(0));
byte[] pdfReportByteArrDetailed = (byte[]) (serverData.get(1));

byte[] completeReport = concatenate(pdfReportByteArr,pdfReportByteArrDetailed);

System.err.println(pdfReportByteArr.length);
System.err.println(pdfReportByteArrDetailed.length);
System.err.println(completeReport.length);

response.setContentLength(completeReport.length);
response.setContentType("application/pdf");
response.setHeader("Expires", "0");
response.setHeader("Cache-Control",
"must-revalidate, post-check=0, pre-check=0");
response.setHeader("Pragma", "public");

ServletOutputStream out = response.getOutputStream();
try {
out.write(completeReport);
out.flush();
out.close();
} catch (Exception e) {
e.printStackTrace();
} finally {
if (out != null) {
try {
out.close();
} catch (Exception e) {
}
}
}

protected byte[] concatenate(byte[] a, byte[] b) {
byte[] complete = new byte[a.length + b.length];
System.arraycopy(a, 0, complete , 0, a.length);
System.arraycopy(b, 0, complete , a.length, b.length);
return complete ;
}
</code>

Any help appreciated.

Thanks,
Regards,
S.R.K.Vivek Raju.
17 years ago
Hi Ulf,

Yeah sure, i would use the code tags from now onwards.
And yes, the Servlet and Applet are running on the same version of JDK.


Thanks,
Regards,
S.R.K.Vivek Raju.
17 years ago
Hi All,

I am actually calling a servlet from an applet to generate a PDF report.

I have to pass certain objects from applet to servlet.
The code on my applet is as follows

Vector vec = new Vector();
vec.add("abc");
vec.add("xyz");
String issueReportUrl="http://localhost/sr/servlet/TBQReports";//getTBQReportPath();
StringBuffer sb = new StringBuffer(issueReportUrl);
try {
URL url = getURL(sb.toString());
URLConnection servletConnection = url.openConnection();
if (servletConnection instanceof HttpURLConnection)
{
((HttpURLConnection)servletConnection).setRequestMethod("POST");
}
else
{
System.out.println("this connection is NOT an HttpUrlConnection connection");
return;
}
servletConnection.setDoInput(true);
servletConnection.setDoOutput(true);
servletConnection.setUseCaches (false);
servletConnection.setDefaultUseCaches (false);
servletConnection.setRequestProperty("Content-Type", "application/octet-stream");
OutputStream os= servletConnection.getOutputStream();
ObjectOutputStream out = new ObjectOutputStream(os);
out.writeObject(vec);
out.flush();
out.close();
parentModule.getAppletContext().showDocument(url, "_blank");
} catch (Exception tr) {
Utility.showMsgBox(Utility.findParentFrame(this), "In actionPerformed" + tr.getMessage(), 1)
}


The code in my servlet is as follows

ObjectInputStream inputFromApplet = null;
PrintWriter out = null;
Vector data = null;
try {
// get an input stream from the applet
inputFromApplet = new ObjectInputStream(new BufferedInputStream(request.getInputStream()));
System.out.println("read Object...");
// read the serialized data from applet
Vector o = (Vector)inputFromApplet.readObject();
if(o != null && (o instanceof Vector))
{
data = (Vector) o;
System.out.println("Got Object"+data.get(0));
inputFromApplet.close();

// send back a confirmation message to the applet
out = new PrintWriter(response.getOutputStream());
response.setContentType("text/plain");
out.println("confirmed " + data.get(0));
out.flush();
out.close();
}
} catch (Exception e) {
e.printStackTrace();
}

When i run the code, i get the following exception

java.io.EOFException
at java.io.ObjectInputStream$PeekInputStream.readFully(ObjectInputStream
.java(Compiled Code))
at java.io.ObjectInputStream$BlockDataInputStream.readShort(ObjectInputS
tream.java:2671)
at java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:767
)
at java.io.ObjectInputStream.<init>(ObjectInputStream.java:286)
at TBQReports.doPost(TBQReports.java:70)
at TBQReports.doGet(TBQReports.java:57)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:696)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:809)
at org.apache.catalina.servlets.InvokerServlet.serveRequest(InvokerServl
et.java:417)
at org.apache.catalina.servlets.InvokerServlet.doGet(InvokerServlet.java
:131)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:696)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:809)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
icationFilterChain.java:198)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
ilterChain.java:144)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperV
alve.java:209)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContex
t.invokeNext(StandardPipeline.java:595)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav
a:432)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:954)

at org.apache.catalina.core.StandardContextValve.invoke(StandardContextV
alve.java:138)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContex
t.invokeNext(StandardPipeline.java:595)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav
a:432)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:954)

at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:
2459)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.j
ava:132)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContex
t.invokeNext(StandardPipeline.java:595)
at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatche
rValve.java:118)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContex
t.invokeNext(StandardPipeline.java:593)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.j
ava:116)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContex
t.invokeNext(StandardPipeline.java:593)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav
a:432)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:954)

at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineVal
ve.java:126)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContex
t.invokeNext(StandardPipeline.java:595)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav
a:432)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:954)

at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:15
2)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java
:869)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.p
rocessConnection(Http11BaseProtocol.java:664)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpo
int.java:527)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFol
lowerWorkerThread.java:80)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadP
ool.java:684)
at java.lang.Thread.run(Thread.java:568)

The line number that it is pointing is
inputFromApplet = new ObjectInputStream(new BufferedInputStream(request.getInputStream())); in my servlet.

I tried flush the data, closing the outputStream. But still couldnt figure out its cause.

Please help.

PS:- The same code works if i pass the values as query string.But the data is large hence i want to pass it as an Object.

Thanks,
Regards,
S.R.K.Vivek Raju
17 years ago
Hi all,

I am doing an RMI call from my Servlet and in the backend i prepare all the data into am ByteArrayOutputStream and add it into a vector and send it back.

It gives my an " java. io.NotSerializableException: java.io.ByteArrayOutput Stream"
I found out that the ByteArrayOutputStream must be serialized before putting into my vector.

I tried browsing on the internet but could'nt get it right.

Please let me know on how to do it.

**********My code in the servlet*******
serverData = remoteServiceObject. doRemoteRequestProcess(clientRequest); System.err.println("serverData>>>>"+serverData.size());
ByteArrayOutputStream pdfReportStream = (ByteArrayOutputStream)serverData.get(0);
***********************************

************MY backend Code****************
public Vector processClientRqst(Vector eClientRequest)
throws Exception {
int methodID = Integer.parseInt (eClientRequest.elementAt(1).toString().trim());
Vector responseData = new Vector();
switch (methodID) {
case SRSConstant.GET_REPORT:
System.err.println("INSIDE DBIS>>>>>>>>>>>");
responseData = getTBQReport(eClientRequest);
break;
}

return (responseData);
}

public Vector getTBQReport(Vector clientData) throws Exception {
String sql;
plantID = clientData.elementAt(2).toString();
issueID = clientData.elementAt(3).toString();
modelYear = clientData.elementAt(4).toString();

Vector serverData = new Vector();

TAVReportGenerator reportGenerator = new TAVReportGenerator(dbConn,srCommMethods);
ByteArrayOutputStream pdfReportStream = reportGenerator.generatePDF(issueID, modelYear, plantID);

serverData.add(pdfReportStream);

return serverData;
}
**************************************

Thanks,

With Regards,
Vivek Raju
17 years ago
Hi,

I think i found the solution.

Thanks a lot
17 years ago
Hi all,

I am new to database, so this could be a silly question.
I want to compare two composite keys.
In one table i have (plt,mdl,ctlid) as composite primary key and in other i have (plt,mdl,ctlid) as composite foriegn key.

I have fetch data from both these tables by equating both the keys.
How would i do that.

Please let me know.

Thanks,
Regards,
Vivek
[ May 17, 2007: Message edited by: S.R.K.Vivek Raju ]
17 years ago
Hi all,

I have to send email with a pdf file as an attachment.
I want to send the attachment without saving the pdf file onto the disk.

I have written code for sending an email attachment could some one help to send the attachment without saving it as a file.

SEE MY CODE BELOW:-
*************************************************************************
import java.io.IOException;
import java.util.Date;
import java.util.Properties;

import javax.activation.DataHandler;
import javax.activation.FileDataSource;
import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.Multipart;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeBodyPart;
import javax.mail.internet.MimeMessage;
import javax.mail.internet.MimeMultipart;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
* Insert the type's description here.
* Creation date: (11/26/2001 6:22:14 PM)
* @author: Administrator
*/
public class SimpleSenderServlet extends HttpServlet {

public void doGet(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException {
this.doService(request, response);
}

public void doPost(
HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException {
this.doService(request, response);
}

public void doService(
HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException {

String recipients[] =
{ "[email protected]"};

String recipientsCC[] = {"[email protected]"};
String from = "[email protected]";
String host = "172.19.31.189";
String filename =
"C:\\Documents and Settings\\vraju.SYNTELDCX\\Desktop\\aqua.jpeg";
String msgText1 = "Sending a file.\n";
String subject = "Sending a file";

Properties props = System.getProperties();
props.put("mail.smtp.host", host);

Session session = Session.getInstance(props, null);

try {

MimeMessage msg = new MimeMessage(session);
msg.setFrom(new InternetAddress(from));
InternetAddress[] addressTo =
new InternetAddress[recipients.length];
for (int i = 0; i < recipients.length; i++) {
addressTo[i] = new InternetAddress(recipients[i]);
}
msg.setRecipients(Message.RecipientType.TO, addressTo);
InternetAddress[] addressCC =
new InternetAddress[recipientsCC.length];
for (int i = 0; i < recipientsCC.length; i++) {
addressCC[i] = new InternetAddress(recipientsCC[i]);
}
msg.setRecipients(Message.RecipientType.CC, addressCC);
msg.setSubject(subject);

MimeBodyPart mbp1 = new MimeBodyPart();
mbp1.setText(msgText1);

MimeBodyPart mbp2 = new MimeBodyPart();

FileDataSource fds = new FileDataSource(filename);
mbp2.setDataHandler(new DataHandler(fds));
mbp2.setFileName(fds.getName());

Multipart mp = new MimeMultipart();
mp.addBodyPart(mbp1);
mp.addBodyPart(mbp2);

msg.setContent(mp);
msg.setSentDate(new Date());

Transport.send(msg);

} catch (MessagingException mex) {
mex.printStackTrace();
Exception ex = null;
if ((ex = mex.getNextException()) != null) {
ex.printStackTrace();
}
}

}
}


*************************************************************************

Thanks in advance

With Regards,
Vivek Raju.
17 years ago
Hi all

I have tried by setting a flag and refreshing the page when the flag is set true, but this does'nt work.I don't want to use the window.setTimeout(); method. I want to refresh only once

I would really appreciate any suggestion on this issue

With Regards
S.R.K.Vivek Raju
That was a good question