ClassNotFoundException when using JZebra in Weblogic 10.3

725 views
Skip to first unread message

Alfonso Dager

unread,
Jul 26, 2012, 6:33:16 PM7/26/12
to jzebra...@googlegroups.com
We have a web application and are attempting to use the jZebra applet in a JSP page.  When we run the page we get the following error: java.lang.ClassNotFoundException: jzebra.PrintApplet.class
Details:
Running on Weblogic 10.3.2
jzebra.jar located at: {project_home}/WebContent/
HTML to implement: 	
<applet name="jZebra" code="jzebra.PrintApplet.class" archive="./jzebra.jar" width="100" height="100">
    <param name="printer" value="zebra">
</applet>	

Where should the jzebra.jar be located and what is the appropriate way to call it? Do we need additional steps for using in Weblogic.  When clicking on the 'Find Printer' button, that's when the exception is thrown and we get an error that the FindPrinter method cannot be found.
Any quick help would be appreciated.

Tres Finocchiaro

unread,
Jul 26, 2012, 9:39:59 PM7/26/12
to jzebra...@googlegroups.com
Alfonso,
This is generally a pretty simple fix.

Check this location:
archive="./jzebra.jar"

Make sure it is valid.

You may need to adjust it for your needs, such as:
archive="{project_home}/WebContent/jzebra.jar"
or
archive="../WebContent/jzebra.jar"

Basically, if you can create a working download line for the jar, i.e:
 <a href="./jzebra.jar">click to download jar</a>
 the rest should work just fine.  Just make sure that path is correct.

-Tres

--
To unsubscribe from this group, send email to jzebra-users...@googlegroups.com
 
http://code.google.com/p/jzebra



--
- Tres.Fin...@gmail.com

Gary Kapit

unread,
Jul 27, 2012, 10:51:10 AM7/27/12
to jzebra...@googlegroups.com
Hi Tres,

I'm also working on the project with Alfonso. Thanks for your response. We were able to get that part working but have run into a new issue.

We are attempting to use the PrintFIle() function to print a job from a .txt file we're creating. We are getting an error when we call the function (Exeption occured: jzebra.PrintRaw.print() failed.). We assume this error is occurring because the function cannot see the text file to print it. Since we're using WebLogic and are creating the file ad-hoc, we cannot place the file in the same place as the jZebra.jar because it is inside of an .ear file. Our question is where should we be putting the file so that the PrintFile() function can access it?

We've tried placing the file in the following place unsuccessfully:

1) (Project home)
2) (Project home)/TestFolder
3) For testing purposes only, we tried placing the file inside the /WebContent folder inside the .ear (the same place as the jZebra.jar)

Again, thanks for your response and for any further help you can provide.

Gary

Tres Finocchiaro

unread,
Jul 27, 2012, 2:13:02 PM7/27/12
to jzebra...@googlegroups.com
Gary/Alfonso,
  • One problem with java is that it doesn't know relative paths.  This means the applet always needs absolute paths when supplying a file.  There's usually some ways to generate this with JavaScript or the web engine.
  • One awesome thing about java is, it can put your URLs direction into the applet:
    applet.appendFile("http://domain/site/dynamically_create_zpl.php");
  • One thing to remember with java is that it there are a few limitations when using cookies.
Since we're using WebLogic and are creating the file ad-hoc, we cannot place the file in the same place as the jZebra.jar because it is inside of an .ear file
If you can use WebLogic to echo raw text back to the browser in a new webpage I think it would work.

If WebLogic always exports as a web page, you could encode it in base64 in an XML tag and use appendXML(); feature instead.  Either way, you want to get your data to the browser.  If you can read it in Firefox, IE, Chrome, then the applet will be able to read it too!

-Tres

Alfonso's responses missed the mailing list.  I am putty a copy of it below:
Hi Tres,

Thanks for your response. We were able to get that part working but have run into a new issue.
We are attempting to use the PrintFIle() function to print a job from a .txt file we're creating.  We are getting an error when we call the function (Exeption occured: jzebra.PrintRaw.print() failed.). We assume this error is occurring because the function cannot see the text file to print it. Since we're using WebLogic and are creating the file ad-hoc, we cannot place the file in the same place as the jZebra.jar because it is inside of an .ear file.  Our question is where should we be putting the file so that the PrintFile() function can access it?
We've tried placing the file in the following place unsuccessfully:
1) (Project home)
2) (Project home)/TestFolder
3) For testing purposes only, we tried placing the file inside the /WebContent folder inside the .ear (the same place as the jZebra.jar)
Again, thanks for your response and for any further help you can provide.
--
To unsubscribe from this group, send email to jzebra-users...@googlegroups.com
 
http://code.google.com/p/jzebra

Gary Kapit

unread,
Jul 27, 2012, 2:34:37 PM7/27/12
to jzebra...@googlegroups.com
Thanks again, Tres. We started kind of going down that path already. We abandoned the PrintFile and are just using Print(). We're passing it a string. Where you call  applet.append("P1\n"); in your sample we're saying: applet.append(OurStringVariable);

When we press the "Print" button on our webpage nothing happens. No errors. Nothing. We have other buttons there for testing like "Find Printer", "List Printers", "Default Printer" and all of those call your functions correctly and the info is displayed to us on screen. It just seems odd that the "Print" button which calls Print() does absolutely nothing.

Behind our button is this:

<input name="Print" class="buttonPurple" type="button" value="Print" onclick="return print()"/>

And here is our Print() method:

function print() {
          var applet = document.jZebra;
          if (applet != null) {
             // Send characters/raw commands to applet using "append"
             // Hint:  Carriage Return = \r, New Line = \n, Escape Double Quotes= \"
             applet.append(msg);
             
             // Send characters/raw commands to printer
             applet.print();
  }
   
If you have any thoughts we'd love to hear them!! Thanks again.

Gary

On Thursday, July 26, 2012 6:33:16 PM UTC-4, Alfonso Dager wrote:

Tres Finocchiaro

unread,
Jul 27, 2012, 5:09:17 PM7/27/12
to jzebra...@googlegroups.com
Gary,

What happens when you replace the contents of the print() function with alert("Hello"); ?


-Tres

--
To unsubscribe from this group, send email to jzebra-users...@googlegroups.com
 
http://code.google.com/p/jzebra

Tres Finocchiaro

unread,
Jul 27, 2012, 5:17:32 PM7/27/12
to jzebra...@googlegroups.com
Gary,

Also, I don't mean this to sound patronizing, but I use Google Chrome for debugging and it's excellent.  When I "inspect element" it has JavaScript errors at the bottom right without having to install FireBug (Firefox) or try to count the line numbers (Internet Explorer).

It's obviously poor for enterprise testing, but it works really well for JavaScript stuff like this.

-Tres

miamicane99

unread,
Jul 27, 2012, 5:41:37 PM7/27/12
to jzebra...@googlegroups.com

Tres,

We actually tried putting the alert in previously and got nothing which means (I assume) that it's not even getting inside the function for some reason. No idea why.

Tres Finocchiaro

unread,
Jul 27, 2012, 7:05:01 PM7/27/12
to jzebra...@googlegroups.com, jzebra...@googlegroups.com
Can you remove the return statement from your button and just put the alert directly in the HTML?  

onclick="alert('hello');"

-Tres

miamicane99

unread,
Jul 27, 2012, 7:10:31 PM7/27/12
to jzebra...@googlegroups.com

The project is on my work computer so I can't try it right now but I'll try that and get back to you. Thanks again for your help.

Sent from my Nexus 7

Reply all
Reply to author
Forward
0 new messages