BEA Logo BEA WebLogic Server Release 1.1

  Corporate Info  |  News  |  Solutions  |  Products  |  Partners  |  Services  |  Events  |  Download  |  How To Buy

   Frequently Asked Questions:   Previous topic   |   Next topic   |   Contents   

 

WebLogic Frequently Asked Questions: JDBC and applets

 

Can I use a "native" two-tier driver for a browser applet?

I'm trying to use WebLogic jDriver for Oracle from an applet, but I get errors and my applet doesn't work. I've heard rumors that you can't use two-tier drivers from applets. Why not?

The rumors are correct. Within an unsigned applet, you cannot load native libraries over the wire, access the local file system, or connect to any host except the host from which you loaded the applet. The applet security manager enforces these restrictions on applets as protection against applets being able to do unsavory things to unsuspecting users.

If you are trying to use jDriver for Oracle from an applet, then you are violating the first restriction. Your applet will fail when it attempts to load the native (non-Java layer) library that allows jDriver for Oracle to make calls into the non-Java Oracle client libraries. If you look at the Exception that is generated, you will see that your applet fails in java.lang.System.loadLibrary, because the security manager determined that you were attempting to load a local library and halted the applet.

You can, however, use the WebLogic JTS or Pool driver for JDBC connectivity in applets. When you use one of these WebLogic multi-tier JDBC drivers, you need one copy of WebLogic jDriver for Oracle (or any other two-tier JDBC driver) for the connection between the WebLogic Server and the DBMS.

Just can't get my browser applet to work!

I've tried everything, and I just can't seem to get my browser applet to work! Any suggestions?

If you haven't yet read it, check Using applets with WebLogic. Here are some other troubleshooting tips for applet debugging:

  1. Did you install the WebLogic classes correctly on your HTTP server? (more information) Don't confuse the absolute path of the WebLogic classes on your HTTP server with CODEBASE. CODEBASE is a configured path that originates from the HTTP Document Root.

  2. Is your applet CODEBASE tag in the applet HTML file set correctly? You can test it by copying the contents into the Open or Go To space of a browser window and opening the URL. If your CODEBASE is correct, you should be placed in the classes directory on your website. (more information)

  3. If you are using the WebLogic JTS or Pool driver, are you running the WebLogic Server on the same host as your HTTP server?

  4. If you can run your applet in Appletviewer successfully, it still doesn't mean that everything's perfect. You probably have the WebLogic classes installed on the machine you are using to run the applet, and this means that you might not have installed the classes correctly on your HTTP server, but the applet is finding the necessary WebLogic classes anyway, by looking in your local CLASSPATH.

    To test your applet in the absence of any local WebLogic classes, temporarily rename the WebLogic directory or try your applet (in Appletviewer) from another machine. Another tip: You can check the HTTP server log to determine which classes are being requested.

  5. Once you have passed these tests, try running your applet in a browser, like Netscape Navigator. If you get a security exception with WebLogic JDBC, it is probably because you are trying to serve your applet from a host that's different from the DBMS host. For more details on this problem, check the next question.

Why doesn't my browser applet connect to the database?

I'm using a WebLogic multitier driver in an applet as an interface to a DBMS. If I run the class using the Sun Appletviewer on my local machine, I have no problems. But when I try to run the applet in a Netscape browser, it will not connect. What's wrong?

If Appletviewer works and Netscape does not, it is an indication that you are violating a Netscape security restriction. In this case, the violation is that an applet cannot open a socket to a machine other than the one from which it loaded the applet. To solve this problem, you will have to serve your applet code from the same machine that hosts the DBMS.

Another tip: The IP naming format you use in the applet CODEBASE and the constructor for the T3Client must match. That is, you can't use dot-notation in one place and a domain name in the other.

My applet works with Appletviewer, but not with a browser . . .?

I tried two of the applets in the examples directory of the distribution. I installed the WebLogic classes on my local machine (NT server) and on another machine (a Windows 95 client), and I'm not using any browsers, just trying to run the applets with Appletviewer. The applets work fine when I run Appletviewer from the NT server, but do not work at all from the Windows 95 client.

There are two possible problems: Either your CODEBASE tag is not set properly in the applet HTML file, or you have not loaded the class files properly on your HTTP server.

The reason the applet works on your NT server is this: You have installed the WebLogic distribution on your NT server, and even if the applet cannot successfully load the necessary classes from the HTTP server, it does find them in your local CLASSPATH. But when you try to run it from the Windows 95 client, the applet must load the classes over the wire from the HTTP server, and if you haven't installed them correctly, it will fail.

For more information about installing the WebLogic classes on an HTTP server, check Using WebLogic for applet programming and Setting up the WebLogic code examples.

Why do I get a Netscape security violation when running an example applet?

I notice when I run a WebLogic example applet, I get a Netscape security violation, although the applet seems to work okay otherwise. Why is this?

If an applet is using WebLogic JDBC (which the WebLogic example applets use), Netscape will report a security violation caused by the JDBC DriverManager looking for a property. It doesn't affect the applet. You can ignore the security violation.

I installed the WebLogic example applets, and they work fine with a Netscape browser on my machine. But when I try to view the applet from another machine on the network, I get a security violation. By the way, the applets and the HTML files in the examples are not on my machine. Here is the stack trace:

Applet exception: class examples/applets/PhoneBook2 got
a security violation:
method verification error
java.lang.VerifyError: examples/applets/PhoneBook2
at java.lang.ClassLoader.resolveClass(ClassLoader.java.143)
at netscape.applet.AppletClassLoader.loadClass
(AppletClassLoader.java:127)

etc. Any clues?

Yes. Netscape requires that the WebLogic Server run on the same machine as the HTTP server from which you served the applet.

What's causing ClassFormatErrors with my applet?

I downloaded your distribution and copied the classes to my HTTP server DocumentRoot. I created an applet that I was able to run successfully from my Netscape server. I placed it in the server directory /webz/ns-home/classes/applets/myapp.class and calling it with the following:

  <APPLET
CODEBASE=http://myserver.com/webz/ns-home/classes
CODE=applets.myapp.class>

Then I set my WebLogic Server properties in the weblogic.properties file to listen on port 7001, and I started the WebLogic Server on the HTTP machine so I could use my applet with WebLogic JDBC, like this:

  <APPLET
CODEBASE=t3://myserver.com:7001/webz/ns-home/classes
CODE=applets.myapp.class>

But when I changed the CODEBASE tag to point to the WebLogic Server, I started getting ClassFormatErrors.

There are several problems with your setup. The most obvious have to do with your CODEBASE:

  1. The CODEBASE tag in your applet should point to your HTTP server, not to the WebLogic Server.

  2. The directory path referenced in your CODEBASE tag is not an absolute directory path on the HTTP server; it is a configured path that originates from the HTTP Document Root. You are using the absolute path in your CODEBASE tag. If your class "myapp" is in the "applets" package, then the correct CODEBASE for your setup would be:

      <APPLET
    CODEBASE=http://myserver.com/classes
    CODE=applets.myapp.class>

More help:

If you are getting a ClassFormatError, it signals a problem with your HTTP server configuration. It could be that you haven't loaded the WebLogic or applet classes in the correct directory on the HTTP server, or you are specifying the CODEBASE or the CODE incorrectly in your APPLET tag. (more information)

Remember, too, that if you installed the WebLogic distribution on the machine from which you are running the applet, your applet will first look for the WebLogic classes in your local CLASSPATH, which may obscure the fact that you haven't properly installed the classes for serving from the HTTP server. To test your HTTP configuration properly, you need to temporarily rename the WebLogic classes in your local CLASSPATH or try your applet from another machine.