Harish Vembu

Ranch Hand
+ Follow
since Jul 19, 2004
Harish likes ...
Java MySQL Database Netbeans IDE
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Harish Vembu


Good explantion . Even though its a pretty older post. I would like to add further .

Always from a server architecture point of view its better to have an Apache Server handling all the HTTP requests and route it to Apache Tomcat server to handle dynamic pages like servlets and JSP's. I have worked with such integration on projects.
Both are from Apache Open source community and complement each other well.
For the curious and more inquisitive readers please refer an excellent article - http://www.it.uom.gr/teaching/applicationsIT_1/lectures/apache/sld016.htm


Thanks & Best Regards

Harish
8 years ago


Thanks for the reply. State pattern seems appropriate. In reference to the attached image on the reference link (Wiki)

There is an interface called State and implementing classes StateA and StateB and there is a Context class which is used for swapping between states .

In terms of UML representation I could understand the Dotted Line (Generalization) relationship between states and interface.

How is the empty diamond symbol (relationship) between Context and State can be explained?.

Is it a Has a relationship ? Aggregation or Composition?? or Something else ?

Please clarify. Sometimes I get more curious


Best Regards

Harish

Thanks All for the replies.

I was of the belief a Decorator pattern would help in this case as it provides alternative to Subclassing and relies on Composition rather than inheritance for such interchangeable behaviour.

If State pattern is applicable. Can anyone provide a high level class diagram (UML representation) of this example under study?

Or other Design pattern like Template method/Strategy would be useful?

Casting subtype to Supertype like below and subsequent deleting it is not desired.

Pilot pilotObj = new Passenger();

Please provide some code snippets.


Thanks in Advance.

Harish



I was posed a question regarding dynamic reuse of class/objects at Runtime

Question:
I have a generic Person class which like a parent class. I have Pilot, Passenger and Flight Attendant class which are derived some properties and behavior from Parent.

During runtime usage sometimes Pilot could become a Passenger and vice versa for some segment of travel by implementing/not implementing /overriding/not overriding flyPlane() method.

How to model such a set of Classes(objects) so that we can interchange as desired.

We do not want to use Inheritance and Composition is the preferred way of achieving it. In other words use "Has A" relationship instead of "Is a" relationship.


Please provide full answer with code snippets. " Has a" relationship seems to be sometimes not straightforward to use in some instances as above.

Also mention what type of "Has a " relationship would be used a) Composition or b) Aggregation and why one over other in this case.


Thanks in Advance.




Dear All,


I am facing an issue of SOAP fault when I run the sample code provided below. I am copying the Java code and the Output for your reference below.


Java application:

_____________________________________________________________________________________________________________________________________________________________________________

import java.net.MalformedURLException;
import java.net.URL;
import javax.xml.namespace.QName;
import javax.xml.soap.MessageFactory;
import javax.xml.soap.SOAPMessage;
import javax.xml.soap.SOAPEnvelope;
import javax.xml.soap.SOAPBody;
import javax.xml.soap.SOAPBodyElement;
import javax.xml.soap.SOAPElement;
import javax.xml.soap.SOAPException;
import javax.xml.ws.Dispatch;
import javax.xml.ws.Service;

/**
* Shows how to add a MIME header, of which SOAPAction is one.
*/
public class AddSoapAction {
private static final String WSDL = "http://www.webservicex.net/stockquote.asmx?wsdl";

private static final String NS = "http://www.webserviceX.NET/";

public static void main(String...arg) {
new AddSoapAction().invoke();

System.out.println("\nAll done.");
}

public AddSoapAction() { }

private void invoke(){
try {
//Prepare service to call
Service service = createService();
QName portQName = new QName(NS, "StockQuoteSoap");
Dispatch<SOAPMessage> dispatch =
service.createDispatch(portQName,
SOAPMessage.class, Service.Mode.MESSAGE);

//Add SOAPAction
/* dispatch.getRequestContext().put(
Dispatch.SOAPACTION_USE_PROPERTY, "Next");
dispatch.getRequestContext().put(
Dispatch.SOAPACTION_URI_PROPERTY,
"http://www.webserviceX.NET/GetQuote");*/

//Prepare Request
SOAPMessage request = createMessage();

//send request and get response
SOAPMessage response = dispatch.invoke(request);

//Write response to console
System.out.println("\nGot Response:\n");
response.writeTo(System.out);
System.out.println("\n");

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

private SOAPMessage createMessage() throws SOAPException {
//Create a SOAPMessage
MessageFactory messageFactory =
MessageFactory.newInstance();
SOAPMessage message = messageFactory.createMessage();

try {
SOAPEnvelope env = message.getSOAPPart().getEnvelope();
SOAPBody body = env.getBody();

//Create a SOAPBodyElement
QName bodyName = new QName("http://www.webserviceX.NET/",
"GetQuote");

SOAPBodyElement bodyEl = body.addBodyElement(bodyName);

//Add our data
QName name = new QName("symbol");
SOAPElement symbol = bodyEl.addChildElement(name);
symbol.addTextNode("JAVA");


System.out.println("\nCreated Request:\n");
message.writeTo(System.out);
System.out.println("\n");

} catch (Exception e) {
System.out.println(e.getMessage());
}

return message;
}

private Service createService() throws MalformedURLException {
URL wsdl = new URL(WSDL);

//Create the Service name
String svcName = "StockQuote";
QName svcQName = new QName(NS, svcName);

//Get a delegate wrapper
Service service = Service.create(wsdl, svcQName);
System.out.println("Created Service: " + service.getServiceName());

return service;
}
}

_________________________________________________________________________________________________________________________________


Output :

Created Service: {http://www.webserviceX.NET/}StockQuote

Created Request:

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"><SOAP-ENV:Header/><SOAP-ENV:Body><GetQuote xmlns="http://www.webserviceX.NET/"><symbol>IBM</symbol></GetQuote></SOAP-ENV:Body></SOAP-ENV:Envelope>


Got Response:

<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><soap:Fault><faultcode>soap:Client</faultcode><faultstring>System.Web.Services.Protocols.SoapException: Server did not recognize the value of HTTP Header SOAPAction: .
at System.Web.Services.Protocols.Soap11ServerProtocolHelper.RouteRequest()
at System.Web.Services.Protocols.SoapServerProtocol.RouteRequest(SoapServerMessage message)
at System.Web.Services.Protocols.SoapServerProtocol.Initialize()
at System.Web.Services.Protocols.ServerProtocolFactory.Create(Type type, HttpContext context, HttpRequest request, HttpResponse response, Boolean& abortProcessing)</faultstring><detail /></soap:Fault></soap:Body></soap:Envelope>


All done.

___________________________________________________________________________________________________________________________________________________________


Can anyone assist me in letting me know as to why its giving SOAP fault ?. Is so how to construct and send a proper SOAP message. The web service hosted on remote server somehow doesn't like the value for SOAP action property : SOAPACTION_USE_PROPERTY, "1"


Any help would be much appreciated .

9 years ago
Dear All,

I have problem in running the below as a Java Application in NetBeans

______________________________________________________________________________________

____________________________________________________________________________________________________________

Error:


INFO: Structured second-level cache entries: disabled
Jan 30, 2011 11:12:07 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Echoing all SQL to stdout
Jan 30, 2011 11:12:07 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Statistics: disabled
Jan 30, 2011 11:12:07 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Deleted entity synthetic identifier rollback: disabled
Jan 30, 2011 11:12:07 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Default entity-mode: pojo
Jan 30, 2011 11:12:07 PM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Named query checking : enabled
Jan 30, 2011 11:12:08 PM org.hibernate.impl.SessionFactoryImpl ><init>
INFO: building session factory
Exception in thread "main" java.lang.NoSuchMethodError: org.objectweb.asm.ClassWriter.<init>(Z)V
at net.sf.cglib.core.DebuggingClassWriter.<init>(DebuggingClassWriter.java:47)
at net.sf.cglib.core.DefaultGeneratorStrategy.getClassWriter(DefaultGeneratorStrategy.java:30)
at net.sf.cglib.core.DefaultGeneratorStrategy.generate(DefaultGeneratorStrategy.java:24)
at net.sf.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:216)
at net.sf.cglib.core.KeyFactory$Generator.create(KeyFactory.java:145)
at net.sf.cglib.core.KeyFactory.create(KeyFactory.java:117)
at net.sf.cglib.core.KeyFactory.create(KeyFactory.java:108)
at net.sf.cglib.core.KeyFactory.create(KeyFactory.java:104)
at net.sf.cglib.proxy.Enhancer.<clinit>(Enhancer.java:69)
at org.hibernate.proxy.pojo.cglib.CGLIBLazyInitializer.getProxyFactory(CGLIBLazyInitializer.java:117)
at org.hibernate.proxy.pojo.cglib.CGLIBProxyFactory.postInstantiate(CGLIBProxyFactory.java:43)
at org.hibernate.tuple.entity.PojoEntityTuplizer.buildProxyFactory(PojoEntityTuplizer.java:162)
at org.hibernate.tuple.entity.AbstractEntityTuplizer.<init>(AbstractEntityTuplizer.java:135)
at org.hibernate.tuple.entity.PojoEntityTuplizer.<init>(PojoEntityTuplizer.java:55)
at org.hibernate.tuple.entity.EntityEntityModeToTuplizerMapping.<init>(EntityEntityModeToTuplizerMapping.java:56)
at org.hibernate.tuple.entity.EntityMetamodel.<init>(EntityMetamodel.java:295)
at org.hibernate.persister.entity.AbstractEntityPersister.<init>(AbstractEntityPersister.java:434)
at org.hibernate.persister.entity.SingleTableEntityPersister.<init>(SingleTableEntityPersister.java:109)
at org.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:55)
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:226)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1294)
at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:859)
at com.mcnz.model.HibernateCrudRunner.main(HibernateCrudRunner.java:22)
Java Result: 1.


_________________________________________________________________________________________________________________________________________________________________

It references GameSummary which is in same package.

Any guidance would be much appreciated.


Thanks & Best Regards



Dear all,

I have a basic question regarding HQL and JPQL.

I might be using EJB 3.x, JPA and Hibernate for next project.

I ran some samples with EJB 3.x JPA with Hibenate as ORM framework.

My question is whether we have to use JPQL or HQL or both in entity classes and hibernate files?. If both are needed why both?

Is that something JPQL can do that HQL cannot do and vice versa. Is one better over other?

Thanks in Advance and Appreciate your inputs.


Best Regards



Hi Ritchie and All,

Sorry to poke my nose here .

For the benefit of users like me and all in general



Probably the above reference was taken from Wikipedia @ [url]http://en.wikipedia.org/wiki/Java_version_history
[/url]

This provides a complete history till the latest.

Thanks & Best Regards

Harish

Learning never stops...
9 years ago

Thanks Rob and Ritchie. Your answers are spot on.

It really helped.

I was also thinking on those lines of system 32 which is causing to always use JDK 6 version.

I prefixed the path environment variable with JDK 1.4 path and it worked.

9 years ago

Though the answers to the original post were given, I am not able to get the desired Java version somehow.


I have installed JDK 1..6 and JDK 1.4 on my windows XP machine on different paths

Here is what I have in my environment variables

PATH : C:\Program Files\PHP\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:
\WINDOWS\system32\WindowsPowerShell\v1.0;C:\j2sdk1.4.2_19\bin;%ANT_HOME%\bin;C:\
Program Files\PHP\php.ini;C:\j2sdk1.4.2_19\bin;C:\ant-1.5.2\bin;

I have the highlighted the one for JDK 1.4 bin directory in path.

I have JAVA_HOME user variable set to C:\jdk1.6.0_23 which I am not using in PATH.

When I use Java -version I always get version 6 regardless of me changing the PATH to respective JDK bin directory.

I am wary of setting CLASSPATH variable in PATH as advised on this forum.


Please clarify. Appropriate reply would be much appreciated.


Thanks & Best Regards

Harish
9 years ago
Hi All,

Thanks for all the congratulatory emails.

All the best and Good Luck.

Bye
[ September 16, 2008: Message edited by: Ulf Dittmer ]
11 years ago
Hi Friends,

At last I passed the Exam with 82 % last Friday because of 3 months of hard preparation, good resources and with God's grace/ Good Luck.

My recommedations for succes in this Exam are as below.

1. Mikolai Study Guide and Notes - Easy to revise

2. Mikolai's Quiz - Final brush up

3. J2EE 1.4 tutorial

4. Basic Specs like WS-I BP 1.0a , J2EE and SOAP,WSDL,UDDI,etc.

Though th Exam is going to be revamped with new specs in early next year . The above resources would be the best bet.

Good Luck and

Three Cheers

Thanks

Harish

SCJP SCJWS
[ September 16, 2008: Message edited by: Ulf Dittmer ]
11 years ago
Hi Krishnakumar,

I am interested to know further. I can arrange to pick up the voucher from you. My only constraint is that to check whether the Exam Voucher is valid to appear for the EXAM even in USA.

Can you check with Prometric on it?. We can discuss about it too.

Expecting your reply

Thanks
11 years ago
Can I use this voucher for any Exam even in US then I am interested. Please let me know ASAP. I inquired about it and as per the information I got Voucher bought in India cannot be used here in US.

Thanks
11 years ago
Hi,

If so hold it for me I am ready to buy it. But before I do, I want to get it confirmed by giving the voucher number here at prometric center in USA.

I think this is the best way to get it confirmed for taking exam.

Will contact you to get it.

Thanks
11 years ago