EncodeHintType Error

558 views
Skip to first unread message

Leonardo José

unread,
Aug 22, 2019, 10:42:30 AM8/22/19
to zxing
Hello people,

I need some help.

gerarQrCode(requisicao, idAluno);

public static void gerarQrCode(Requisicao requisicao, String idAluno)
throws WriterException, IOException, NotFoundException {
String qrCodeData = "http://unigranrio.com.br";
// String filePath = "D:\\qrCode\\" + idAluno + ".png";
// String filePath = requisicao.obterRecursoUrl("/" + requisicao.getOrigem().getNomeMantida() + "/img/qrCode/" + idAluno + ".png";
String filePath = Configuracao.getCaminhoImagem() + "qrCode/" + idAluno + ".png";
String charset = "UTF-8"; // or "ISO-8859-1"
// Map<EncodeHintType, ErrorCorrectionLevel> hintMap = new HashMap<EncodeHintType, ErrorCorrectionLevel>();
Map hintMap = new HashMap();
hintMap.put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.L);

createQRCode(qrCodeData, filePath, charset, hintMap, 200, 200);

}

public static void createQRCode(String qrCodeData, String filePath, String charset, Map hintMap, int qrCodeheight,
int qrCodewidth) throws WriterException, IOException {
BitMatrix matrix = new MultiFormatWriter().encode(new String(qrCodeData.getBytes(charset), charset),
BarcodeFormat.QR_CODE, qrCodewidth, qrCodeheight, hintMap);
MatrixToImageWriter.writeToFile(matrix, filePath.substring(filePath.lastIndexOf('.') + 1), new File(filePath));

}



I'm using zxing-1.7-javase.jar, zxing-core.jar and also put core-2.0-sources.jar
Here in our work we do not use maven because it is an old project and so we have to go downloading libs and doing the import.

When I run java application it works normally, but when I run it on tomcat it arrives at breakpoint hintMap.put (EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.L);
Displays the error

Just every time I run via tomcat, I'm getting the following error:
java.lang.NoClassDefFoundError: com / google / zxing / EncodeHintType
at br.edu.unigranrio.comum.cartirinha.control.CartirinhaStudent.generateQrCode (CarteirinhaAluno.java:699)
at br.edu.unigranrio.comum.cartirinha.control.CartirinhaStudent $ AcaoPrintCartirinhaStudentPDF.run (CarteirinhaAluno.java:646)
at br.edu.unigranrio.casework.control.ControllerController.treatment (UpliftController.java:378)
at br.edu.unigranrio.casework.control.SystemController.treatUpdate (SystemController.java:153)
at br.edu.unigranrio.casework.control.ControllerHttpServlet.tractRequest (ControllerHttpServlet.java:1204)
at br.edu.unigranrio.casework.controle.ControllerHttpServlet.doPost (ControllerHttpServlet.java:1589)
at javax.servlet.http.HttpServlet.service (HttpServlet.java:641)
at javax.servlet.http.HttpServlet.service (HttpServlet.java:722)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter (ApplicationFilterChain.java:304)
at org.apache.catalina.core.ApplicationFilterChain.doFilter (ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke (StandardWrapperValve.java:240)
at org.apache.catalina.core.StandardContextValve.invoke (StandardContextValve.java:164)
at org.apache.catalina.core.StandardHostValve.invoke (StandardHostValve.java:164)
at org.apache.catalina.valves.ErrorReportValve.invoke (ErrorReportValve.java:100)
at org.apache.catalina.valves.AccessLogValve.invoke (AccessLogValve.java:562)
at org.apache.catalina.core.StandardEngineValve.invoke (StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service (CoyoteAdapter.java:394)
at org.apache.coyote.http11.Http11Processor.process (Http11Processor.java:243)
at org.apache.coyote.http11.Http11Protocol $ Http11ConnectionHandler.process (Http11Protocol.java:188)
at org.apache.tomcat.util.net.JIoEndpoint $ SocketProcessor.run (JIoEndpoint.java:302)
at java.util.concurrent.ThreadPoolExecutor.runWorker (Unknown Source)
at java.util.concurrent.ThreadPoolExecutor $ Worker.run (Unknown Source)
at java.lang.Thread.run (Unknown Source)
Caused by: java.lang.ClassNotFoundException: com.google.zxing.EncodeHintType
at org.apache.catalina.loader.WebappClassLoader.loadClass (WebappClassLoader.java:1676)
at org.apache.catalina.loader.WebappClassLoader.loadClass (WebappClassLoader.java:1521)
... more


Follow all my imports:

import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.google.zxing.BarcodeFormat;
import com.google.zxing.EncodeHintType;
import com.google.zxing.MultiFormatWriter;
import com.google.zxing.NotFoundException;
import com.google.zxing.WriterException;
import com.google.zxing.client.j2se.MatrixToImageWriter;
import com.google.zxing.common.BitMatrix;
import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel;

import br.edu.unigranrio.casework.controle.Action;
import br.edu.unigranrio.casework.controle.AliasAction;
import br.edu.unigranrio.casework.controle.Configuration;
import br.edu.unigranrio.casework.control.ControllerUse;
import br.edu.unigranrio.casework.controle.LinkPadrao;
import br.edu.unigranrio.casework.control.Requiring;
import br.edu.unigranrio.casework.control.Form Validator;
import br.edu.unigranrio.casework.modelo.RetornoProcedureJdbc;
import br.edu.unigranrio.casework.visual.GeneratorAjax;
import br.edu.unigranrio.casework.visual.GeneratorJasper;
import br.edu.unigranrio.casework.visual.ViewParameters;
import br.edu.unigranrio.casework.visual.ResponseAjax;
import br.edu.unigranrio.comum.cartirinha.model.ManagerCarteirinhaStudent;
import br.edu.unigranrio.comum.cartirinha.modelo.to.CartirinhaAlunoTO;
import br.edu.unigranrio.comum.carteirinha.modelo.to.RemessaCarteirinhaAlunoTO;
import br.edu.unigranrio.comum.carteirinha.modelo.to.RemessaCarteirinhasTO;
import br.edu.unigranrio.comum.carteirinha.modelo.to.ViasCarteirinhaTO;
import br.edu.unigranrio.comum.carteirinha.visual.ParteCarteirinhaStudent;
import br.edu.unigranrio.comum.carteirinha.visual.ParteCarteirinhaAlunoPorCampus;
import br.edu.unigranrio.comum.carteirinha.visual.ParteCarteirinhaAlunoBy Course;
import br.edu.unigranrio.comum.cartirinha.visual.PageDetailsResign;
import br.edu.unigranrio.comum.cartirinha.visual.PageViewInformationCartirinhaStudent;
import br.edu.unigranrio.comum.carteirinha.visual.PageJustifyViaCarteirinha;
import br.edu.unigranrio.comum.carteirinha.visual.PageRemessaCarteirinhaStudantil;
import br.edu.unigranrio.comum.carteirinha.visual.docs.ExcelRemessaCarteirinhaStudent;



Lachezar Dobrev

unread,
Aug 22, 2019, 12:01:47 PM8/22/19
to Leonardo José, zxing
Did you include the zxing*.jar in the .war file? In WEB-INF/lib…
> --
> You received this message because you are subscribed to the Google Groups "zxing" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to zxing+un...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/zxing/695b7d9e-3d85-4477-b4f2-23db5df1463e%40googlegroups.com.

Leonardo José

unread,
Aug 22, 2019, 12:17:39 PM8/22/19
to zxing
Estou usando esses aqui

zxing-1.7-javase.jar
zxing-core.jar 
core-2.0-sources.jar

see the attachment
> To unsubscribe from this group and stop receiving emails from it, send an email to zx...@googlegroups.com.
Capturar.JPG

Lachezar Dobrev

unread,
Aug 23, 2019, 5:42:50 AM8/23/19
to Leonardo José, zxing
Please keep to English.
I'm by no means a native English speaker, but the list is in English.

I can see an excerpt from a screen-shot to what looks like Eclipse IDE.
The question is: do these .jar files exist in the .war that you
deploy in Tomcat.

Or do you start Tomcat from Eclipse? If that is the case, you need
to mark the .jar files for deployment in the project properties
(Deployment Assembly).

BTW. You don't need the -sources.jar on the class path. You also do
not need to add it to the .war. Instead right-click the zxing-core and
the zxing-javase jars, and select the -sources.jar as the source
attachment.
> To unsubscribe from this group and stop receiving emails from it, send an email to zxing+un...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/zxing/e5cf4817-095f-47ac-8465-d03dbd0e5214%40googlegroups.com.

Leonardo José

unread,
Aug 23, 2019, 7:38:54 AM8/23/19
to zxing
Hello,
So I am starting tomcat locally in my eclipse and I also put both core and javase in my project's build-path and there in the class itself where it doesn't exist, asks to add source ... so I did it all and when I put it to run other than in java application, it presents this error there in the attachment ... saying that java.lang.NoClassDefFoundError: com / google / zxing / EncodeHintType
Since if I give an F3 in this class, it is in the project.

Leonardo José

unread,
Aug 23, 2019, 11:20:39 AM8/23/19
to zxing
Friend got it ... really needed to put in Assembly
Thank you very much

Em sexta-feira, 23 de agosto de 2019 06:42:50 UTC-3, Lachezar Dobrev escreveu:

Sean Owen

unread,
Nov 5, 2019, 8:13:51 AM11/5/19
to zxing
Yep, it means you didn't actually include the library.
You are also using a very very old version.
Reply all
Reply to author
Forward
0 new messages