|
I have this error when I run my project jsf2.0
Avertissement: StandardWrapperValve[Faces Servlet]: PWC1406: Servlet.service() for servlet Faces Servlet threw exception
java.lang.NullPointerException
at com.sun.enterprise.v3.services.impl.monitor.MonitorableSelectionKeyHandler$CloseHandler.notifyClosed(MonitorableSelectionKeyHandler.java:94)
at com.sun.enterprise.v3.services.impl.monitor.MonitorableSelectionKeyHandler$CloseHandler.remotlyClosed(MonitorableSelectionKeyHandler.java:90)
at com.sun.grizzly.BaseSelectionKeyHandler.notifyRemotlyClose(BaseSelectionKeyHandler.java:233)
at com.sun.grizzly.util.OutputWriter.notifyRemotelyClosed(OutputWriter.java:353)
at com.sun.grizzly.util.OutputWriter.flushChannel(OutputWriter.java:148)
at com.sun.grizzly.util.OutputWriter.flushChannel(OutputWriter.java:76)
at com.sun.grizzly.http.SocketChannelOutputBuffer.flushChannel(SocketChannelOutputBuffer.java:326)
at com.sun.grizzly.http.SocketChannelOutputBuffer.flushBuffer(SocketChannelOutputBuffer.java:398)
at com.sun.grizzly.http.SocketChannelOutputBuffer.endRequest(SocketChannelOutputBuffer.java:389)
at com.sun.grizzly.http.ProcessorTask.action(ProcessorTask.java:1090)
at com.sun.grizzly.tcp.Response.action(Response.java:268)
at com.sun.grizzly.tcp.Response.finish(Response.java:412)
at org.apache.catalina.connector.OutputBuffer.close(OutputBuffer.java:341)
at org.apache.catalina.connector.CoyoteOutputStream.close(CoyoteOutputStream.java:187)
at java.nio.channels.Channels$WritableByteChannelImpl.implCloseChannel(Channels.java:469)
at java.nio.channels.spi.AbstractInterruptibleChannel.close(AbstractInterruptibleChannel.java:115)
at com.sun.faces.application.resource.ResourceHandlerImpl.handleResourceRequest(ResourceHandlerImpl.java:296)
at javax.faces.application.ResourceHandlerWrapper.handleResourceRequest(ResourceHandlerWrapper.java:125)
at org.primefaces.application.PrimeResourceHandler.handleResourceRequest(PrimeResourceHandler.java:85)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:591)
at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1539)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:343)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:217)
at org.primefaces.webapp.filter.FileUploadFilter.doFilter(FileUploadFilter.java:79)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:217)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:279)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595)
at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:98)
at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:91)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:162)
at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:330)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:231)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:174)
at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:828)
at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:725)
at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1019)
at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:225)
at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
at java.lang.Thread.run(Thread.java:722)
do you have an idea
thanks
|
|
|
|
|
You are trying to invoke a method on an object that is referencing nothing.
Use the debug Luke.
Panic, Chaos, Destruction. My work here is done.
Drink. Get drunk. Fall over - P O'H
OK, I will win to day or my name isn't Ethel Crudacre! - DD Ethel Crudacre
I cannot live by bread alone. Bacon and ketchup are needed as well. - Trollslayer
Have a bit more patience with newbies. Of course some of them act dumb - they're often *students*, for heaven's sake - Terry Pratchett
|
|
|
|
|
I have just heard about the 'Designing to Interfaces' concept.
I am required to implement this design methodology very soon, but I am not fully sure how it works.
What I learned so far is this:
Example A
-------------
Here, using a ShapeInterface decouples this Main app from any subshape object (Rectangle, Triangle, etc.).
So if I need to add a Shape type object in the future, I don't have to modify the client code because it's been 'coded to the interface'.
I only have to change the actual implementation in the concrete class itself.
ShapeInterface shape = ShapeFactory.getNewInstance("triangle");
shape.draw();
Example B
-------------
This code is easy to break because this Main app will be tightly coupled to every future shape object I need (if there comes a Rectangle, I will need to change the code to instantiate a Rectangle etc.).
Also, the implementations are different and so I have to apply the appropriate implementation (Rectangle.draw(), Triangle.draw(), etc.)
Triangle triangle = ShapeFactory.getNewInstance("triangle");
triangle.draw();
I understood this concept. Using an interface so that you won't have the change the code that uses the underlying concrete classes. Ok, understandable. I see the advantage.
Here's the concept that [b]I don't understand[/b]:
Example C
-------------
This example illustrates composition instead of inheritance (Object A has an Object B rather than IS-A B).
A can't print directly, it has to delegate to B. Fine, I understand that. What I don't understand is the advantage of this.
Couple of questions:
1) How was it decoupled?
2) Will putting the interface in between A and B decouple their relationship?
3) What if there was no interface between them? Then A would be tightly coupled to B?
4) If B disappears, can I simply replace it with a C class thanks to the interface?
If I don't understand these concepts then I can't move on in my design.
public interface ABInterface {
public void print();
}
public class A implements ABInterface {
private B b;
public A() {
b = new B();
}
public void print() {
b.print();
}
}
public class B implements ABInterface {
public void print(){
System.out.println("Testing B");
}
}
Ok, so that's that. However, I have another big problem:
Say I have a couple of classes that implement a particular interface. Now say that later, there is one method in that interface that I don't need anymore and thus need to delete.
Then it will cause a ripple-effect to the classes that implemented that interface because the implementation won't be correct anymore.
How do I avoid/deal with this?
It's quite a problem..
Any ideas on this?
|
|
|
|
|
Composition allows you to switch the internal implementation of an interface easily. In your example you can easily change A so that it delegates to a new class X instead of B, and the client code won't notice (not even to change a new A() to new X(), or a DI container registration, as with inheritance). You can even write A so that it chooses a different internal implementation class at runtime (for example a file access wrapper which uses a local disk mapper, a memory mapper or a network resource mapper depending on what is passed to a constructor).
Unlike an inherited solution, the class B is totally decoupled from the class which uses A. B can be package-visible, if it's in the same package as A (in .Net it can and probably should be internal).
B won't be decoupled from A as long as A contains a 'new B()' type statement. You can, of course, use the normal interface and DI or factory mechanisms to decouple them, but you have to ask yourself what the purpose of that is, considering that A itself is already little more than a decoupling wrapper class (decoupling B from the outside world).
If you find that a method on an interface isn't used any more, if you're using a decent IDE you can chase down all the implementations in subclasses and remove them as well. Alternatively, if you use @Override annotations, when you remove the interface method, the implementers' methods with @Override will cause a compilation failure (because they're now not overriding anything) and you can go and delete them.
|
|
|
|
|
Well, an IDE shouldn't make up for my design mistakes. I do use @Override annotations (Ant). Going on and deleting each single implementation is not the right way to work. I suppose that if a change in my code (removing a method) causes a waterfall effect (change implementation everywhere) then my code is badly written.
|
|
|
|
|
Discovering that you don't actually need something you thought you did can be a sign of over-design. But we all have to rework and modify our designs as we code – that's fine and a natural part of software development.
|
|
|
|
|
CsTreval wrote: Any ideas on this?
Don't over use it. For that matter don't over use any abstraction concept.
As an example of that one could suppose that because interfaces are "good" and so are factories that every class should have its own interface and its own factory. And that is just wrong.
Also be aware that in terms of management abstraction conceptions via syntax are only self maintaining when there is only one deliverable. So if you have two deliverables (or 20) and you want to remove an interface method from shared code then you are going to need to determine the impact on all of the deliverables.
CsTreval wrote: This example illustrates composition instead of inheritance
You should strive to favor composition over inheritance. Or more specifically do not over use inheritance and specifically be wary of using inheritance solely as a mechanism to facilitate shared behavior (only.)
CsTreval wrote: 1) How was it decoupled?
Answered by other responder.
CsTreval wrote: 2) Will putting the interface in between A and B decouple their relationship?
Yes. However whether it is appropriate or not is a different question.
CsTreval wrote: 3) What if there was no interface between them? Then A would be tightly coupled to B?
Yes. Again though that might not be appropriate. And especially for this specific example since 'print' suggests something that is very specific.
CsTreval wrote: 4) If B disappears, can I simply replace it with a C class thanks to the interface?
Not sure what the question is.
If you delete B and create C then updating A is still going to be easy even if B/C didn't implement ABInterface. For your example the same work would be required with or without the interface.
|
|
|
|
|
hello everyone
could someone please help me to convert this java code to c#, i have been trying for a week and i am getting very frustrating...
public static void printTicket(final Ticket ticket) throws Exception {
Job job = new Job()
{
@Override
public Object run() {
PosPrinter posPrinter = null;
try
{
if(PrintConfig.getReceiptPrinterType() == PrinterType.OS_PRINTER) {
JReportPrintService.printTicket(ticket);
return null;
}
Restaurant restaurant = RestaurantDAO.getInstance().get(Integer.valueOf(1));
posPrinter = new PosPrinter(PrintConfig.getJavaPosReceiptPrinterName(),
PrintConfig.getCashDrawerName());
posPrinter.beginLine(PosPrinter.SIZE_0);
posPrinter.printText("\u001b|cA\u001b|2C" + restaurant.getName());
posPrinter.endLine();
if (restaurant.getAddressLine1() != null) {
printCentered(posPrinter, restaurant.getAddressLine1());
}
if (restaurant.getAddressLine2() != null) {
printCentered(posPrinter, restaurant.getAddressLine2());
}
if (restaurant.getAddressLine3() != null) {
printCentered(posPrinter, restaurant.getAddressLine3());
}
if (restaurant.getTelephone() != null) {
printCentered(posPrinter, restaurant.getTelephone());
}
posPrinter.beginLine(PosPrinter.SIZE_0);
posPrinter.endLine();
posPrinter.beginLine(PosPrinter.SIZE_0);
posPrinter.printText(com.floreantpos.POSConstants.CHK_NO);
posPrinter.printText(String.valueOf(ticket.getId()));
posPrinter.endLine();
posPrinter.beginLine(PosPrinter.SIZE_0);
posPrinter.printText(com.floreantpos.POSConstants.TBL_);
posPrinter.printText(String.valueOf(ticket.getTableNumber()));
posPrinter.endLine();
posPrinter.beginLine(PosPrinter.SIZE_0);
posPrinter.printText(com.floreantpos.POSConstants.GUEST + " #");
posPrinter.printText(String.valueOf(ticket.getNumberOfGuests()));
posPrinter.endLine();
posPrinter.beginLine(PosPrinter.SIZE_0);
posPrinter.printText(com.floreantpos.POSConstants.SRV_);
posPrinter.printText(String.valueOf(ticket.getOwner().getUserId() + "/" +
ticket.getOwner()));
posPrinter.endLine();
posPrinter.beginLine(PosPrinter.SIZE_0);
posPrinter.printText(com.floreantpos.POSConstants.DATE + ": ");
posPrinter.printText(Application.formatDate(new Date()));
posPrinter.endLine();
posPrinter.beginLine(PosPrinter.SIZE_0);
posPrinter.endLine();
posPrinter.beginLine(PosPrinter.SIZE_0);
printFirstColumn(posPrinter, com.floreantpos.POSConstants.QTY,
firstColumnLength);
printSecondColumn(posPrinter, com.floreantpos.POSConstants.ITEM,
firstColumnLength, secondColumnLength, false);
printThirdColumn(posPrinter, com.floreantpos.POSConstants.UPRICE,
thirdColumnLength);
printFourthColumn(posPrinter, com.floreantpos.POSConstants.SUBTOTAL,
fourthColumnLength);
posPrinter.endLine();
posPrinter.beginLine(PosPrinter.SIZE_0);
posPrinter.printText(StringUtils.leftPad("", totalLength, "_"));
posPrinter.endLine();
List<TicketItem> ticketItems = ticket.getTicketItems();
if (ticketItems != null) {
for (TicketItem ticketItem : ticketItems) {
posPrinter.beginLine(PosPrinter.SIZE_0);
printFirstColumn(posPrinter, String.valueOf(ticketItem.getItemCount()),
firstColumnLength);
printSecondColumn(posPrinter, ticketItem.getName(), firstColumnLength,
secondColumnLength, false);
printThirdColumn(posPrinter,
Application.formatNumber(ticketItem.getUnitPrice()),
thirdColumnLength);
printFourthColumn(posPrinter,
Application.formatNumber(ticketItem
.getSubtotalAmountWithoutModifiers()), fourthColumnLength);
posPrinter.endLine();
List<TicketItemModifierGroup> modifierGroups =
ticketItem.getTicketItemModifierGroups();
if (modifierGroups != null) {
for (TicketItemModifierGroup modifierGroup : modifierGroups) {
List<TicketItemModifier> modifiers =
modifierGroup.getTicketItemModifiers();
if (modifiers != null) {
for (TicketItemModifier modifier : modifiers) {
if (modifier.getTotalAmount() == 0) {
continue;
}
boolean extra = false;
String display = " - " + modifier.getName();
if (modifier.getModifierType() ==
TicketItemModifier.EXTRA_MODIFIER) {
display = " - Extra " + display;
extra = true;
}
posPrinter.beginLine(PosPrinter.SIZE_0);
printFirstColumn(posPrinter,
String.valueOf(modifier.getItemCount()), firstColumnLength);
printSecondColumn(posPrinter, display, firstColumnLength,
secondColumnLength, false);
if(extra) {
printThirdColumn(posPrinter, Application.formatNumber
(modifier.getExtraUnitPrice()), thirdColumnLength);
}
else {
printThirdColumn(posPrinter, Application.formatNumber
(modifier.getUnitPrice()), thirdColumnLength);
}
printFourthColumn(posPrinter, Application.formatNumber
(modifier.getTotalAmount()), fourthColumnLength);
posPrinter.endLine();
}
}
}
}
}
}
posPrinter.beginLine(PosPrinter.SIZE_0);
posPrinter.printText(StringUtils.leftPad("", totalLength, "_"));
posPrinter.endLine();
posPrinter.beginLine(PosPrinter.SIZE_0);
posPrinter.printText(StringUtils.leftPad("SUB-TOTAL " + ":", 32));
posPrinter.printText(StringUtils.leftPad(Application.formatNumber(ticket
.getSubtotalAmount()), 10));
posPrinter.endLine();
posPrinter.beginLine(PosPrinter.SIZE_0);
posPrinter.printText(StringUtils.leftPad("TAX " + ":", 32));
posPrinter.printText(StringUtils.leftPad(Application.formatNumber(ticket
.getTaxAmount()), 10));
posPrinter.endLine();
posPrinter.beginLine(PosPrinter.SIZE_0);
posPrinter.printText(StringUtils.leftPad("GRAND TOTAL " + ":", 32));
posPrinter.printText(StringUtils.leftPad(Application.formatNumber(ticket
.getTotalAmount()), 10));
posPrinter.endLine();
posPrinter.beginLine(PosPrinter.SIZE_0);
posPrinter.endLine();
posPrinter.beginLine(PosPrinter.SIZE_0);
posPrinter.printText(StringUtils.leftPad("TIP " + ":", 32));
if (ticket.getGratuity() != null) {
posPrinter.printText(StringUtils.leftPad(Application.formatNumber(ticket
.getGratuity().getAmount()), 10));
}
posPrinter.endLine();
posPrinter.beginLine(PosPrinter.SIZE_0);
posPrinter.printText(StringUtils.leftPad("TOTAL " + ":", 32));
posPrinter.endLine();
printCentered(posPrinter, "THANK YOU!!");
printCentered(posPrinter, "PLEASE COME AGAIN!!!");
posPrinter.printCutPartial();
}
catch(Exception x) {
logger.error("Error while printing ticket", x);
}
finally {
if (posPrinter != null) {
posPrinter.finalize();
}
}
return null;
}
};
Worker.post(job);
}
The problem I'm getting is, when i try to convert from java to c#, for some reason it highlights the code (see the three lines on the source code underlined) and it says (the base type is not defined)
Hence I'm very new to this so any help it would mean a world to me...
thanks in advance
kind regards
lapeci
|
|
|
|
|
C# does not have a Job class or an Object class like Java. You may have to implement your own variation of the Job class and Object class. Good luck on that
@Override is Java specific and C# doesn't use it.
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
Paul Conrad wrote: or an Object class like Java.
What does "like Java" mean?
C# certainly does have an Object class.
|
|
|
|
|
I stand corrected
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
|
|
|
|
|
Do you actually understand what the code you have posted is doing? That is a very important first step before you try to convert it!
|
|
|
|
|
Why not use jni4net? Allows the inter-call between Java or Dot.Net?
http://jni4net.sourceforge.net/
A shady programmer working at a shady company
|
|
|
|
|
I Want to learn JSF 2.0 with using eclipse,hibernate, Spring. If any body can provide me a good video tutorial then i will be highly thankful to him/her. I want to learn from beginning. I am looking for positive answers. my mail id is gaurav.21engg@gmail.com....plzzz send me video tutorial related to JSF 2.0.
Thanks & Regards
Gaurav Sharma
|
|
|
|
|
buy a book, amazon has plenty of them.
There is no better way then to code yourself. A video does not help at all.
|
|
|
|
|
Instead of repeatedly posting questions here for information on Java technologies, you could start at the proper Java site[^] and spend your time much more profitably.
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
|
I am beginner to JAVA and I have the following doGet method, and I need to call to from another method
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException
{
String url = "";
if (Code < 0 )
{
url = "/Error.jsp";
}
else
{
url = "/Error.jsp";
}
RequestDispatcher dispatcher =
getServletContext().getRequestDispatcher(url);
dispatcher.forward(request, response);
}
want to know how to call this method from another method, just like the following.
public int getCode()
{
if (stateName.equals("Aden") || stateName.equals("aden") || stateName.equals("ADEN"))
{
Code = 01;
return (Code);
}
else if (stateName.equals("Mukalla") || stateName.equals("mukalla") || stateName.equals("MUKALLA"))
{
Code = 02;
return (Code);
}
else
{
return doGet(request, response);
}
}
the line
return doGet(request, response);
I want to know the correct way of calling?
|
|
|
|
|
You have already shown the correct way of calling it; what is the problem?
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
Calling directly doGet or doPost methods is not the correct method. The correct method of calling these methods (i'm assuming they are in a Java servlet) is the following:
Assuming you have a JSP page (at, for example, http://localhost/yourproject/yourjsp.jsp ), you can make requests at that page (GET or POST, it doesn't matter for now).
After you have the JSP page, you need to map it in your web.xml file, in your project, like this:
<servlet-mapping>
<servlet-name>YourServlet</servlet-name>
<url-pattern>/yourpage</url-pattern>
</servlet-mapping>
And then, in your servlet, named in this particular example YourServlet.java , have the doGet / doPost methods, which will get called automatically when you make a request to yourpage.jsp . This is the correct way of calling a doGet or doPost method, and it's rarely (if ever) recommended calling them directly (of course, you can have the other servlet method, processRequest , but that will only forward the request to doGet or doPost).
And in your particular example, you can't call return doGet(request, response) . doGet and doPost are void methods (meaning they don't return anything). Worst case, you can call doGet(request, response) but not return.
Full-fledged Java/.NET lover, full-fledged PHP hater.
Full-fledged Google/Microsoft lover, full-fledged Apple hater.
Full-fledged Skype lover, full-fledged YM hater.
|
|
|
|
|
<pre lang="text"><apispec>
<api version="v1" name="findplaces" provider="ibm" />
<request type="json">
<uri path="/findplaces" mapping="/appengine/data/ibm/places">
[CDATA[List places of a city]]
</uri>
<queryparams>
<param name="country" mapping="/appengine/data/ibm/places/place[@country]">
[CDATA[Country is an attribute of place]]
</param>
<param name="city" mapping="/appengine/data/ibm/places/place[@city]">
[CDATA[City is an attribute of place]]
</param>
<param name="limit" mapping="limit">
[CDATA[Number of places to be returned]]
</param>
</queryparams>
</request>
<response type="json" deflimit="10">
<place name="/appengine/data/ibm/places/place[@name]" city="/appengine/data/ibm/places/place[@city]" country="/appengine/data/ibm/places/place[@country]" address="/appengine/data/ibm/places/place[@address]" zip="/appengine/data/ibm/places/place[@zip]">
<location lat="/appengine/data/ibm/places/place/location[@lat]" long="/appengine/data/ibm/places/place/location[@long]" />
</place>
</response>
</apispec></pre>
|
|
|
|
|
Why do you keep repeating this unreadable post? Please read the suggestions you have been given, edit your question and uncheck the option on the page that says "Treat my content as plain text, not as HTML".
|
|
|
|
|
Dear Richard, i m doing same thing which u told me. I am following ur suggestions but i don't know y u r not able to see. I m posting in plain text format.
|
|
|
|
|
As it's unlikely you will take any notice of my previous suggestion I would refer you to Google that has all these hits[^] for Java SAX.
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
do one thing u send me ur mail id and then i will send u that .xml file. plzzzz i need ur help, help me.
|
|
|
|
|