java.lang.SecurityException: sealing violation

Hi,

I got one problem after running one program.

Please anyone can help me?

Thanks,

Regards

Dinesh

java.lang.SecurityException: sealing violation

at java.net.URLClassLoader.defineClass(URLClassLoader.java:234)

at java.net.URLClassLoader.access$100(URLClassLoader.java:56)

at java.net.URLClassLoader$1.run(URLClassLoader.java:195)

at java.security.AccessController.doPrivileged(Native Method)

at java.net.URLClassLoader.findClass(URLClassLoader.java:188)

at java.lang.ClassLoader.loadClass(ClassLoader.java:297)

at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:286)

at java.lang.ClassLoader.loadClass(ClassLoader.java:253)

at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:313)

at java.lang.Class.forName0(Native Method)

at java.lang.Class.forName(Class.java:120)

at MakeDocWithFactory.main(MakeDocWithFactory.java:14)

Process Exit...

[989 byte] By [dinesh_singhal] at [2007-9-26 3:57:04]
# 1

A package can be divided over multiple JAR files. Like com.somename.someclass is present in one file, and com.somename.anotherclass is in another. Even more, the second JAR file could hold both classes. Thus:

JAR-1.jar

com.somename.someclass

JAR-2.jar

com.somename.someclass

com.somename.anotherclass

Obviously, JAR-1.jar above would be an old version that may not be fully compatible with the new version in JAR-2.jar. Now, if JAR-1.jar was used to load someclass and JAR-2.jar to load anotherclass then you may get into trouble.

That's why JAR files (or, more precise: packages inside JAR files) can be sealed. If sealed, then if someclass is loaded from JAR-1.jar, then anotherclass cannot be loaded from JAR-2.jar. JAR-1.jar not providing anotherclass, a security exception is thrown. It would, however, not be a problem if both were loaded from JAR-2.jar. So, in your case: you need to find which class is causing the problem and remove the old version from the classpath, or put it in the classpath after the newer JAR file...

Here's your problem:

at MakeDocWithFactory.main MakeDocWithFactory.java:14)

Show us line 14!

Arjan.

avbentem at 2007-6-29 12:48:33 > top of Java-index,Security,Other Security APIs, Tools, and Issues...
# 2

Hi Arjun,

Here is my java file for your kind reference.

import org.w3c.dom.Document;

import org.w3c.dom.Element;

import org.w3c.dom.Text;

import org.w3c.dom.ProcessingInstruction;

import java.io.PrintWriter;

import com.ibm.xml.parser.TXDocument;

public class MakeDocWithFactory

{

public static void main(String argv[])

{

try

{

Document doc=(Document)Class.forName("com.ibm.xml.parser.TXDocument").newInstance();

Element root=doc.createElement("person");

Element item=doc.createElement("name");

item.appendChild(doc.createTextNode("Jon Doe"));

root.appendChild(item);

root.appendChild(doc.createComment("Processing Instruction"));

root.appendChild(doc.createProcessingInstruction("parser"," ignoreNextLine"));

item=doc.createElement("age");

item.appendChild(doc.createTextNode("35"));

root.appendChild(item);

item=doc.createElement("email");

item.appendChild(doc.createTextNode("a@a.com"));

root.appendChild(item);

item=doc.createElement("url");

item.appendChild(doc.createTextNode("http://www.xyz.com"));

root.appendChild(item);

doc.appendChild(root);

((TXDocument)doc).setVersion("1.0");

((TXDocument)doc).printWithFormat(new PrintWriter(System.out));

}

catch (Exception e)

{

e.printStackTrace();

}

}

}

dinesh_singhal at 2007-6-29 12:48:33 > top of Java-index,Security,Other Security APIs, Tools, and Issues...
# 3

So, I guess line 14 is this:Document doc=(Document)Class.forName

("com.ibm.xml.parser.TXDocument").newInstance();

Somewhere you have two JAR files that both hold classes from the namespace com.ibm.xml.parser. You may try to set the -verbose option to see what classes are loaded from which JAR file (or ZIP file). Like explained earlier: the problem is that some other class from the same package (thus: com.ibm.xml.parser) has been loaded from another JAR file, and that file happened to have been sealed. So, using -verbose, you may see something like

[Loaded java/lang/Thread.class from d:\jdk1.4\lib\classes.zip]

[Loaded java/lang/Object.class from d:\jdk1.4\lib\classes.zip]

...

...

[Loaded com/ibm/xml/parser/something from some-file.jar]

...

[Loaded com/ibm/xml/parser/TXDocument from some-other-file.jar]

I am not using IBM parsers here, so I cannot tell you which JAR files to check. On the file system, you can simply search for files that have TXDocument in their contents. You can view the contents of JAR files like any other ZIP archive, like with WinZip on Windows.

Make sure that I counted correctly and line 14 is the line I mentioned above!

Goodluck,

Arjan.

avbentem at 2007-6-29 12:48:33 > top of Java-index,Security,Other Security APIs, Tools, and Issues...
# 4

Hi Arjun,

Here is the output after trying the -verbose option using following command

java -verbose com.ibm.xml.parser.TXDocument

[Opened D:\JDK1.3\JRE\lib\rt.jar]

[Opened D:\JDK1.3\JRE\lib\i18n.jar]

[Opened D:\JDK1.3\JRE\lib\sunrsasign.jar]

[Loaded java.lang.Object from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.io.Serializable from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.lang.Comparable from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.lang.String from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.lang.Class from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.lang.Cloneable from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.lang.ClassLoader from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.lang.Throwable from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.lang.Error from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.lang.ThreadDeath from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.lang.Exception from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.lang.RuntimeException from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.security.ProtectionDomain from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.security.AccessControlContext from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.lang.ClassNotFoundException from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.lang.LinkageError from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.lang.NoClassDefFoundError from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.lang.ClassCastException from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.lang.ArrayStoreException from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.lang.VirtualMachineError from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.lang.StackOverflowError from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.lang.ref.Reference from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.lang.ref.SoftReference from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.lang.ref.WeakReference from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.lang.ref.FinalReference from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.lang.ref.PhantomReference from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.lang.ref.Finalizer from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.lang.Runnable from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.lang.Thread from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.lang.ThreadGroup from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.util.Dictionary from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.util.Map from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.util.Hashtable from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.util.Properties from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.lang.reflect.AccessibleObject from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.lang.reflect.Member from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.lang.reflect.Method from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.lang.reflect.Constructor from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.lang.Boolean from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.lang.Character from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.lang.Number from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.lang.Float from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.lang.Double from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.lang.Byte from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.lang.Short from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.lang.Integer from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.lang.Long from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.lang.OutOfMemoryError from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.lang.NullPointerException from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.lang.ArithmeticException from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.lang.Shutdown from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.lang.StrictMath from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.io.ObjectStreamField from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.util.Comparator from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.lang.String$CaseInsensitiveComparator from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.lang.System from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.security.AccessController from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.util.Collections from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.util.Random from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.util.Collection from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.util.AbstractCollection from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.util.Set from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.util.AbstractSet from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.util.Collections$EmptySet from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.util.List from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.util.AbstractList from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.util.Collections$EmptyList from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.util.AbstractMap from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.util.Collections$EmptyMap from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.util.Collections$ReverseComparator from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.lang.ThreadLocal from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.lang.InheritableThreadLocal from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.security.Guard from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.security.Permission from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.security.BasicPermission from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.lang.reflect.ReflectPermission from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.lang.ref.Reference$Lock from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.lang.ref.Reference$ReferenceHandler from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.lang.ref.ReferenceQueue from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.lang.ref.ReferenceQueue$Null from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.lang.ref.ReferenceQueue$Lock from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.lang.ref.Finalizer$FinalizerThread from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.util.Enumeration from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.util.Hashtable$EmptyEnumerator from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.util.Iterator from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.util.Hashtable$EmptyIterator from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.io.ObjectStreamClass from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.io.ObjectStreamClass$ObjectStreamClassEntry from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.io.ObjectStreamClass$CompareClassByName from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.io.ObjectStreamClass$CompareMemberByName from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.util.Map$Entry from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.util.Hashtable$Entry from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded sun.misc.Version from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.io.InputStream from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.io.FileInputStream from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.io.FileDescriptor from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.io.OutputStream from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.io.FileOutputStream from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.io.FilterInputStream from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.io.BufferedInputStream from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.io.FilterOutputStream from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.io.PrintStream from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.io.BufferedOutputStream from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.io.Writer from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.io.OutputStreamWriter from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded sun.io.CharToByteConverter from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded sun.io.Converters from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.util.Vector from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.util.Stack from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.security.PrivilegedAction from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded sun.security.action.GetPropertyAction from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded sun.io.CharacterEncoding from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.util.Locale from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.lang.StringBuffer from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded sun.io.CharToByteSingleByte from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded sun.io.CharToByteCp1252 from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.io.BufferedWriter from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.lang.Compiler from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.lang.Compiler$1 from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded sun.misc.Launcher from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.net.URLStreamHandlerFactory from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded sun.misc.Launcher$Factory from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded sun.misc.Launcher$1 from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.security.SecureClassLoader from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.net.URLClassLoader from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded sun.misc.Launcher$ExtClassLoader from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded sun.security.util.Debug from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.util.StringTokenizer from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.io.File from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.io.FileSystem from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.io.Win32FileSystem from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.security.PrivilegedExceptionAction from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded sun.misc.Launcher$2 from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.net.URLStreamHandler from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded sun.net.www.protocol.file.Handler from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.net.URL from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.util.HashSet from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.util.HashMap from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.util.HashMap$EmptyHashIterator from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.util.HashMap$Entry from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded sun.misc.URLClassPath from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.util.ArrayList from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded sun.net.www.protocol.jar.Handler from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded sun.misc.Launcher$AppClassLoader from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded sun.misc.Launcher$3 from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.net.URLClassLoader$1 from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded sun.misc.URLClassPath$2 from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded sun.misc.URLClassPath$Loader from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded sun.misc.URLClassPath$JarLoader from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.util.zip.ZipConstants from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.util.zip.ZipFile from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.util.jar.JarFile from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded sun.security.action.LoadLibraryAction from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.lang.Runtime from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.lang.ClassLoader$4 from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.lang.ClassLoader$NativeLibrary from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded sun.misc.JarIndex from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded sun.misc.ExtensionDependency from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.util.zip.ZipEntry from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.util.jar.JarEntry from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.util.jar.JarFile$JarFileEntry from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.io.DataInput from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.io.DataInputStream from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.util.zip.ZipFile$ZipFileInputStream from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.util.zip.InflaterInputStream from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.util.zip.ZipFile$1 from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.util.zip.Inflater from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.util.jar.Manifest from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.io.ByteArrayInputStream from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.util.jar.Attributes from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.util.jar.Manifest$FastInputStream from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.util.jar.Attributes$Name from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.lang.Math from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.util.jar.JarVerifier from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.io.ByteArrayOutputStream from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.util.EmptyStackException from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.security.PrivilegedActionException from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded sun.net.www.ParseUtil from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded sun.misc.Resource from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded sun.misc.URLClassPath$4 from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.lang.Package from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded sun.security.util.ManifestEntryVerifier from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded sun.misc.CharacterDecoder from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded sun.misc.BASE64Decoder from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.security.CodeSource from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.security.Policy from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.security.Policy$1 from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.security.Security from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.security.Security$1 from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.io.Reader from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.io.BufferedReader from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.io.InputStreamReader from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded sun.io.ByteToCharConverter from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded sun.io.ByteToCharISO8859_1 from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.security.Provider from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded sun.security.provider.Sun from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded sun.security.provider.Sun$1 from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded com.sun.rsajca.Provider from D:\JDK1.3\JRE\lib\sunrsasign.jar]

[Loaded com.sun.rsajca.Provider$1 from D:\JDK1.3\JRE\lib\sunrsasign.jar]

[Loaded sun.security.provider.PolicyFile from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.security.PermissionCollection from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded sun.security.provider.PolicyPermissions from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.net.URLConnection from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded sun.net.www.URLConnection from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded sun.net.www.protocol.file.FileURLConnection from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.net.ContentHandler from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.net.UnknownContentHandler from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded sun.net.www.MessageHeader from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.io.FilePermission from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.io.FilePermission$1 from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.lang.RuntimePermission from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.security.cert.Certificate from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded org.w3c.dom.Node]

[Loaded com.ibm.xml.parser.Visitee]

[Loaded com.ibm.xml.parser.Child]

[Loaded com.ibm.xml.parser.Parent]

[Loaded org.w3c.dom.Document]

[Loaded com.ibm.xml.parser.TXDocument]

[Loaded java.io.IOException from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded com.ibm.xml.parser.Visitor]

[Loaded com.ibm.xml.parser.LibraryException]

[Loaded java.lang.SecurityException from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.lang.Shutdown$Lock from D:\JDK1.3\JRE\lib\rt.jar]

[Loaded java.lang.Shutdown$Lock from D:\JDK1.3\JRE\lib\rt.jar]

Exception in thread "main" java.lang.SecurityException: sealing violation

at java.net.URLClassLoader.defineClass(URLClassLoader.java:234)

at java.net.URLClassLoader.access$100(URLClassLoader.java:56)

at java.net.URLClassLoader$1.run(URLClassLoader.java:195)

at java.security.AccessController.doPrivileged(Native Method)

at java.net.URLClassLoader.findClass(URLClassLoader.java:188)

at java.lang.ClassLoader.loadClass(ClassLoader.java:297)

at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:286)

at java.lang.ClassLoader.loadClass(ClassLoader.java:253)

at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:313)

Now what can i do?

dinesh_singhal at 2007-6-29 12:48:34 > top of Java-index,Security,Other Security APIs, Tools, and Issues...
# 5

[Loaded com.ibm.xml.parser.Visitee]

..

[Loaded com.ibm.xml.parser.Visitor]

[Loaded com.ibm.xml.parser.LibraryException]

Oops, the lines that mention com.ibm.xml.parser do not show any file they were loaded from. This makes me feel that they are loaded from a directory structure (like the IBM classes are not in a JAR or ZIP file, but are simply on the file system, like in a directory com, subdirectory ibm, subdirectory ibm, etc. Such directory cannot be sealed, I guess, so I am lost here.

I think you still need to try to locate this TXDocument.class -- either in a JAR file or on the file system. Maybe this TXDocument is in some sealed JAR, while the other com.ibm.xml.parser classes are present in some directory structure?

Maybe the main question is: how did you install this IBM stuff? The org.w3c.dom.Node is not loaded from an archive either... Did you unzip this stuff somwhere?

So: search for TXDocument.class -- both as a file name and as the contents of files. Maybe (part of) the com.ibm.xml.parser package is present both as plain files and in some JAR or ZIP file?

Arjan.

avbentem at 2007-6-29 12:48:34 > top of Java-index,Security,Other Security APIs, Tools, and Issues...
# 6

Oh, I did not notice that you executed

java -verbose com.ibm.xml.parser.TXDocument

I thought you added the -verbose option to the command that you use to start your own project, which uses MakeDocWithFactory...

Anyway, your command shows that TXDocument is loaded all right, as it shows somewhere in your output! However, TXDocument itself also requires some classes to be loaded. The Sealing Violation occurs when loading these classes.

Best guess: the IBM parser stuff you intalled relies on a different version of the org.w3c.dom stuff than the things that are loaded. However, somewhere in your classpath you also have some JAR file that holds the version the IBM thing expects. So, search for org.w3c.dom things... Was the XML stuff included in the IBM download? How did you install the IBM stuff.

By the way, why using the IBM stuff, and why load it like

Document doc=(Document)Class.forName

("com.ibm.xml.parser.TXDocument").newInstance();

To avoid hardcoding such specific names of implementations, check out JAXP. If IBM does not support JAXP, then switch to Xerces... When downloading Xerces, you do not need to download any JAXP stuff from Sun. You'd get get code like

import javax.xml.parsers.*;

private Document fetchDocument(String sourceUri)

{

DocumentBuilderFactory dFactory =

DocumentBuilderFactory.newInstance();

System.out.println("Using DOM Parser " +

dFactory.getClass().toString() );

dFactory.setNamespaceAware(true);

dFactory.setValidating(true);

dFactory.setIgnoringElementContentWhitespace(true);

DocumentBuilder parser;

Document document = null;

try

{

parser = dFactory.newDocumentBuilder();

System.out..println("Loading source document ["

+ sourceUri + "]");

document = parser.parse(sourceUri);

}

catch(SAXException se)

{

System.out.println(se.toString());

return null;

}

catch(ParserConfigurationException pce)

{

System.out.println(pce.toString());

return null;

}

catch(IOException ioe)

{

System.out.println(ioe.toString());

return null;

}

return document;

}

http://java.sun.com/xml/xml_jaxp.html -- Java API for XML Overview

http://java.sun.com/xml/jaxp-1.1/docs/api -- JAXP 1.1 API

http://java.sun.com/j2se/1.3/docs/guide/extensions -- Java Extension Mechanism

http://xml.apache.org/xerces2-j -- Apache Xerces for Java 2

Arjan.

avbentem at 2007-6-29 12:48:34 > top of Java-index,Security,Other Security APIs, Tools, and Issues...
# 7
Thanks a lot Arjan for giving your valuable time.I am very beginner in java programming.I will try my best to solve this as you have suggested.
dinesh_singhal at 2007-6-29 12:48:34 > top of Java-index,Security,Other Security APIs, Tools, and Issues...
# 8

One never needs to say "sorry" about wading into Java ;-)

Another remark about XML: there is an easier way to process XML in Java, although less standard: JDOM. Here, the DOM is NOT the well-known Document Object Model. So, instead of the IBM XML parser or the Xerces stuff, check out the following links... I know, not "Security General" related...

JDOM: http://www.jdom.org

Get Beta 7 at http://jdom.org/dist/binary

Java World articles by the main designers: http://www.javaworld.com/javaworld/jw-05-2000/jw-0518-jdom_p.html and http://www.javaworld.com/javaworld/jw-07-2000/jw-0728-jdom2_p.html

More introductionaly text with easy-to-read examples and a lot of other links at http://www.ibm.com/developerworks/java/library/j-jdom/

About JDOM and JDK:

http://jcp.org/jsr/detail/102.jsp http://java.sun.com/aboutJava/communityprocess/jsr/jsr_102_jdom.html

Good luck,

a.

avbentem at 2007-6-29 12:48:34 > top of Java-index,Security,Other Security APIs, Tools, and Issues...
# 9
Thank you soooooo... much Arjan,Under your guidance, finally i got solved my problems.Thanks AgainRegardsDinesh
dinesh_singhal at 2007-6-29 12:48:34 > top of Java-index,Security,Other Security APIs, Tools, and Issues...
# 10
> finally i got solved my problems... but you do not want to share the solution with the other readers? Uhuh...a.
avbentem at 2007-6-29 12:48:34 > top of Java-index,Security,Other Security APIs, Tools, and Issues...
# 11

I am sorry, i forgot to write the solution.

Here is the complete solution.

I have downloaded the JDOM components from the http://jdom.org/dist/binary site.

Here is the complete test Program.

import java.io.*;

import org.jdom.output.XMLOutputter;

import org.jdom.Element;

import org.jdom.Document;

import org.jdom.*;

public class MakeDocWithFactory

{

public static void main(String argv[])

{

try

{

Element root=new Element("person");

Element item=new Element("name");

item.setText("Jon Doe");

root.addContent(item);

root.addContent(new Comment("Processing Instruction"));

root.addContent(new ProcessingInstruction("parser"," ignoreNextLine"));

item=new Element("age");

item.setText("35");

root.addContent(item);

item=new Element("email");

item.setText("a@a.com");

root.addContent(item);

item=new Element("url");

item.setText("http://www.xyz.com");

root.addContent(item);

Document doc = new Document(root);

try

{

PrintWriter pw = new PrintWriter(System.out);

XMLOutputter serializer = new XMLOutputter();

serializer.output(doc, pw);

}

catch (IOException e)

{

System.err.println(e);

}

/*try

{

FileOutputStream out = new FileOutputStream("doc.xml");

XMLOutputter serializer = new XMLOutputter();

serializer.output(doc, out);

out.flush();

out.close();

}

catch (IOException e)

{

System.err.println(e);

}*/

}

catch (Exception e)

{

e.printStackTrace();

}

}

}

dinesh_singhal at 2007-6-29 12:48:34 > top of Java-index,Security,Other Security APIs, Tools, and Issues...