Decoder in a Web Service (java)

128 views
Skip to first unread message

Alejandro

unread,
May 11, 2010, 8:18:26 AM5/11/10
to zxing
Hi,

I need a Zxing decoder for my Web Service application.I've tested the
Zxing library in a Desktop application,and i didn' have any
problems,it works right.But when I try to do the same with the WS I
have problems and I can't make a client for send the QR-Code to my
WS.I'm working on Netbeans 6.8 and I've compiled the core and javase
folders and then I add it to the libraries of my WS project.

The propose of my project is to send a photo by the mobile phone of a
QR-Code to the WS,the WS decode the QR-Code and send the answer with
some data else to the client.It's works with a normal photo,I send the
photo and the server receives it.The error if i add the Zxing part
it's the next:


ADVERTENCIA: Servlet web service endpoint 'App' failure
javax.xml.ws.WebServiceException: Unable to create JAXBContext
at
com.sun.xml.ws.model.AbstractSEIModelImpl.createJAXBContext(AbstractSEIModelImpl.java:
166)
at
com.sun.xml.ws.model.AbstractSEIModelImpl.postProcess(AbstractSEIModelImpl.java:
94)
at
com.sun.xml.ws.model.RuntimeModeler.buildRuntimeModel(RuntimeModeler.java:
258)
at
com.sun.xml.ws.server.EndpointFactory.createSEIModel(EndpointFactory.java:
338)
at
com.sun.xml.ws.server.EndpointFactory.createEndpoint(EndpointFactory.java:
201)
at com.sun.xml.ws.api.server.WSEndpoint.create(WSEndpoint.java:
505)
at com.sun.xml.ws.api.server.WSEndpoint.create(WSEndpoint.java:
560)
at
org.glassfish.webservices.JAXWSServlet.registerEndpoint(JAXWSServlet.java:
394)
at
org.glassfish.webservices.JAXWSServlet.doInit(JAXWSServlet.java:262)
at
org.glassfish.webservices.JAXWSServlet.init(JAXWSServlet.java:97)
at
org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:
1428)
at
org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:
1060)
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:
187)
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:
188)
at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:
641)
at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:
97)
at
com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:
85)
at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:
185)
at
org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:
332)
at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:
233)
at
com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:
165)
at
com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:
791)
at
com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:693)
at
com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:954)
at
com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:
170)
at
com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:
135)
at
com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:
102)
at
com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:
88)
at
com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:
76)
at
com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:
53)
at
com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:
57)
at com.sun.grizzly.ContextTask.run(ContextTask.java:69)
at com.sun.grizzly.util.AbstractThreadPool
$Worker.doWork(AbstractThreadPool.java:330)
at com.sun.grizzly.util.AbstractThreadPool
$Worker.run(AbstractThreadPool.java:309)
at java.lang.Thread.run(Thread.java:619)
Caused by: java.security.PrivilegedActionException:
com.sun.xml.bind.v2.runtime.IllegalAnnotationsException: 1 counts of
IllegalAnnotationExceptions
java.lang.StackTraceElement does not have a no-arg default
constructor.
this problem is related to the following location:
at java.lang.StackTraceElement
at public java.lang.StackTraceElement[]
java.lang.Throwable.getStackTrace()
at java.lang.Throwable
at java.lang.Exception
at Zxing.ReaderException
at public Zxing.ReaderException
serverside.jaxws.ReaderExceptionBean.instance
at serverside.jaxws.ReaderExceptionBean
at java.security.AccessController.doPrivileged(Native Method)
at
com.sun.xml.ws.model.AbstractSEIModelImpl.createJAXBContext(AbstractSEIModelImpl.java:
153)
... 34 more
Caused by: com.sun.xml.bind.v2.runtime.IllegalAnnotationsException: 1
counts of IllegalAnnotationExceptions
java.lang.StackTraceElement does not have a no-arg default
constructor.
this problem is related to the following location:
at java.lang.StackTraceElement
at public java.lang.StackTraceElement[]
java.lang.Throwable.getStackTrace()
at java.lang.Throwable
at java.lang.Exception
at Zxing.ReaderException
at public Zxing.ReaderException
serverside.jaxws.ReaderExceptionBean.instance
at serverside.jaxws.ReaderExceptionBean
at com.sun.xml.bind.v2.runtime.IllegalAnnotationsException
$Builder.check(IllegalAnnotationsException.java:102)
at
com.sun.xml.bind.v2.runtime.JAXBContextImpl.getTypeInfoSet(JAXBContextImpl.java:
472)
at
com.sun.xml.bind.v2.runtime.JAXBContextImpl.<init>(JAXBContextImpl.java:
302)
at com.sun.xml.bind.v2.runtime.JAXBContextImpl
$JAXBContextBuilder.build(JAXBContextImpl.java:1140)
at
com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:
154)
at
com.sun.xml.bind.api.JAXBRIContext.newInstance(JAXBRIContext.java:106)
at com.sun.xml.ws.developer.JAXBContextFactory
$1.createJAXBContext(JAXBContextFactory.java:109)
at com.sun.xml.ws.model.AbstractSEIModelImpl
$1.run(AbstractSEIModelImpl.java:161)
at com.sun.xml.ws.model.AbstractSEIModelImpl
$1.run(AbstractSEIModelImpl.java:154)
... 36 more

ADVERTENCIA: StandardWrapperValve[App]: PWC1382: Allocate exception
for servlet App
javax.servlet.ServletException
at
org.glassfish.webservices.JAXWSServlet.doInit(JAXWSServlet.java:269)
at
org.glassfish.webservices.JAXWSServlet.init(JAXWSServlet.java:97)
at
org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:
1428)
at
org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:
1060)
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:
187)
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:
188)
at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:
641)
at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:
97)
at
com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:
85)
at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:
185)
at
org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:
332)
at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:
233)
at
com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:
165)
at
com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:
791)
at
com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:693)
at
com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:954)
at
com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:
170)
at
com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:
135)
at
com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:
102)
at
com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:
88)
at
com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:
76)
at
com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:
53)
at
com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:
57)
at com.sun.grizzly.ContextTask.run(ContextTask.java:69)
at com.sun.grizzly.util.AbstractThreadPool
$Worker.doWork(AbstractThreadPool.java:330)
at com.sun.grizzly.util.AbstractThreadPool
$Worker.run(AbstractThreadPool.java:309)
at java.lang.Thread.run(Thread.java:619)
Caused by: javax.xml.ws.WebServiceException: Unable to create
JAXBContext
at
com.sun.xml.ws.model.AbstractSEIModelImpl.createJAXBContext(AbstractSEIModelImpl.java:
166)
at
com.sun.xml.ws.model.AbstractSEIModelImpl.postProcess(AbstractSEIModelImpl.java:
94)
at
com.sun.xml.ws.model.RuntimeModeler.buildRuntimeModel(RuntimeModeler.java:
258)
at
com.sun.xml.ws.server.EndpointFactory.createSEIModel(EndpointFactory.java:
338)
at
com.sun.xml.ws.server.EndpointFactory.createEndpoint(EndpointFactory.java:
201)
at com.sun.xml.ws.api.server.WSEndpoint.create(WSEndpoint.java:
505)
at com.sun.xml.ws.api.server.WSEndpoint.create(WSEndpoint.java:
560)
at
org.glassfish.webservices.JAXWSServlet.registerEndpoint(JAXWSServlet.java:
394)
at
org.glassfish.webservices.JAXWSServlet.doInit(JAXWSServlet.java:262)
... 26 more
Caused by: java.security.PrivilegedActionException:
com.sun.xml.bind.v2.runtime.IllegalAnnotationsException: 1 counts of
IllegalAnnotationExceptions
java.lang.StackTraceElement does not have a no-arg default
constructor.
this problem is related to the following location:
at java.lang.StackTraceElement
at public java.lang.StackTraceElement[]
java.lang.Throwable.getStackTrace()
at java.lang.Throwable
at java.lang.Exception
at Zxing.ReaderException
at public Zxing.ReaderException
serverside.jaxws.ReaderExceptionBean.instance
at serverside.jaxws.ReaderExceptionBean
at java.security.AccessController.doPrivileged(Native Method)
at
com.sun.xml.ws.model.AbstractSEIModelImpl.createJAXBContext(AbstractSEIModelImpl.java:
153)
... 34 more
Caused by: com.sun.xml.bind.v2.runtime.IllegalAnnotationsException: 1
counts of IllegalAnnotationExceptions
java.lang.StackTraceElement does not have a no-arg default
constructor.
this problem is related to the following location:
at java.lang.StackTraceElement
at public java.lang.StackTraceElement[]
java.lang.Throwable.getStackTrace()
at java.lang.Throwable
at java.lang.Exception
at Zxing.ReaderException
at public Zxing.ReaderException
serverside.jaxws.ReaderExceptionBean.instance
at serverside.jaxws.ReaderExceptionBean
at com.sun.xml.bind.v2.runtime.IllegalAnnotationsException
$Builder.check(IllegalAnnotationsException.java:102)
at
com.sun.xml.bind.v2.runtime.JAXBContextImpl.getTypeInfoSet(JAXBContextImpl.java:
472)
at
com.sun.xml.bind.v2.runtime.JAXBContextImpl.<init>(JAXBContextImpl.java:
302)
at com.sun.xml.bind.v2.runtime.JAXBContextImpl
$JAXBContextBuilder.build(JAXBContextImpl.java:1140)
at
com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:
154)
at
com.sun.xml.bind.api.JAXBRIContext.newInstance(JAXBRIContext.java:106)
at com.sun.xml.ws.developer.JAXBContextFactory
$1.createJAXBContext(JAXBContextFactory.java:109)
at com.sun.xml.ws.model.AbstractSEIModelImpl
$1.run(AbstractSEIModelImpl.java:161)




Thanks a lot,

Alejandro.

Sean Owen

unread,
May 11, 2010, 8:31:27 AM5/11/10
to zxing
That's a heck of an error. It is not really from the library though.
The library is unable to create a stack trace for an exception due to
some bizarre internal error: Throwable.getStackTrace() is trying to
create StackTraceElement objects but think it has a no-arg constructor
when it doesn't.

I don't know why -- bad Java versions? corrupted installation? some
weird byte-code surgery that the WS system is doing on exceptions? but
it's nothing to do with us.

Alejandro

unread,
May 12, 2010, 2:05:24 PM5/12/10
to zxing
Thanks for the reply Sean.

I have the java 1.6 version and I reinstalled Netbeans 6.8 the last
week.The error is something weird,because when I comment the Zxing
code,it works right.So the error is only when I uncomment the code.I
show you the code,maybe I'm doing something wrong and if you see the
code can help me.


package serverside;



/*import com.google.zxing.BinaryBitmap;
import com.google.zxing.LuminanceSource;
import com.google.zxing.ReaderException;
import com.google.zxing.Result;
import com.google.zxing.client.j2se.BufferedImageLuminanceSource;
import com.google.zxing.common.GlobalHistogramBinarizer;
import com.google.zxing.qrcode.QRCodeReader;*/
import java.awt.image.BufferedImage;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import javax.imageio.ImageIO;
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebService;




/**
*
* @author pc
*/
@WebService()
public class App {

/**
* Web service operation
*/
public String s="Foto recibida";
/* QRCodeReader r = new QRCodeReader();
LuminanceSource source;*/
BufferedImage myImage=null;




@WebMethod(operationName = "getInfo")
public String getInfo(@WebParam(name = "photostr")
String photostr) throws IOException{
//TODO write your implementation code here:
System.out.println("llega");
System.out.println(photostr);

//Decode to bytes from a Base64 String
byte[] sent=Base64Coder.decode(photostr);
InputStream rec = new ByteArrayInputStream(sent);
myImage = ImageIO.read(rec);
ImageIO.write(myImage, "png",new File("C:\\Documents and
Settings\\pc\\Mis documentos\\NetBeansProjects\\WebService \
\QRCode_Received.png"));

//Decoding the QR-Code and getting the info.
/*

source = new BufferedImageLuminanceSource(myImage);
BinaryBitmap bitmap = new BinaryBitmap(new
GlobalHistogramBinarizer(source));
Result result=r.decode(bitmap);
System.out.println(result);

*/


return s+result;
}



}


ps:Sorry to insist,but I can´t understand the error..

Thanks a lot.
Regards.

Sean Owen

unread,
May 12, 2010, 2:47:08 PM5/12/10
to zxing
Like I said, it's nothing to do with the library. You'd have to ask
the webservice container provider.
Reply all
Reply to author
Forward
0 new messages