getting "SecurityException" while using JAXB generated Java classesfrom different project

Amit Jain

Usenet Archive
Joined
Aug 3, 2007
Messages
123
Reaction score
0
Hi All,
Again help needed :)

I am getting following exception while unmarshalling.
---- Stack Trace Starts ----
java.lang.SecurityException: class "javax.xml.bind.JAXBElement"'s signer information does not match signer information of other classes in the same package at java.lang.ClassLoader.checkCerts(ClassLoader.java:775) at java.lang.ClassLoader.preDefineClass(ClassLoader.java:487) at java.lang.ClassLoader.defineClass(ClassLoader.java:614) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:
124)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:260) 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:306) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268) at java.lang.ClassLoader.loadClass(ClassLoader.java:251) at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319) at com.yashbinary.abc.JaxbImpl.main(JaxbImpl.java:46)
---- Stack Trace Ends ----
After analyzing stack trace its seems problem occur while trying to access classes from different project. But if its a requirement that we need to separte the "generate JAXB Java classes from an XML schema" with those class which are used to traverse the xmls.

I am using to Java project "JAXBDemo" and "JAXB-USE"
1. In first project (JAXBDemo) I Generate JAXB Java classes from an XML schema.
2. In second project (JAXB-USE) I am trying to read
"booking_detail.xml" using JAXB java classes (generated file from first project).

---- build.xml (to generate jaxb classes) ----
<project name="JAXBDemo" default="main" basedir=".">
<taskdef name="xjc" classname="com.sun.tools.xjc.XJCTask"> <classpath> <fileset dir="C:\lib\XML_API\JAXB_Libs" includes="*.jar" /> <fileset dir="C:\jwsdp1.4\jwsdp-shared\lib" includes="*.jar" /> <pathelement location="classes"/> </classpath> </taskdef> <target name="generate"> <xjc target="src" removeOldOutput="yes" package="com.yashbinary.abc"> <schema dir="C:\Workspace\JAXBDemo\xsd" includes="booking_detail.xsd"/> </xjc> </target> <target name="main" depends="generate"></target> </project>

---- Java Code Starts-----

package com.yashbinary.abc;
public class JaxbImpl {
public static void main(String args) {
JAXBContext jaxbContext;
try {
jaxbContext = JAXBContext.newInstance("com.yashbinary.abc"); Unmarshaller unmarshaller = jaxbContext.createUnmarshaller; JAXBElement<CourseBooking> bookingElement = (JAXBElement<CourseBooking>) unmarshaller.unmarshal(new File("C:/Workspace/JAXB-USE/xml/ booking_detail.xml")); }catch( JAXBException je ) { je.printStackTrace; } }

------- Java Code Ends --------

Thank U in Advance...

regards,
Amit Jain
 

Aakansha

Usenet Archive
Joined
Aug 22, 2007
Messages
7
Reaction score
0
Hi All,
I request please guide, I am also facing issue.

I will appreciate your quick response...

regards,
Aakansha
 

Amit Jain

Usenet Archive
Joined
Aug 3, 2007
Messages
123
Reaction score
0
can someone suggest why I am getting Security Exception and how can i resolve it.

Thanks & regards,
Amit J.
 

Andrew Thompson

Usenet Archive
Joined
Jan 16, 2003
Messages
9,476
Reaction score
0
..
After analyzing stack trace its seems problem occur while trying to access classes from different project. But if its a requirement that we need to separte the "generate JAXB Java classes from an XML schema" with those class which are used to traverse the xmls.

It should be OK, so long as both sets of classes
in the same package are digitally signed with the
same certificate.

How are you signing the Jars? Note that if your
answer includes the word 'eclipse' at any point,
I can offer no further help.
 

Amit Jain

Usenet Archive
Joined
Aug 3, 2007
Messages
123
Reaction score
0
Hi Andrew,

Thanks for your reply.

I am using eclipse version 3.4 (Ganymede).
I am trying to run program with-in ecplise. And I didn't use any signed procedure.

-------- .classpath for Project JAXBDemo ----------- <classpath> <classpathentry exported="true" kind="lib" path="C:/jwsdp1.4/jwsdp- shared/lib/relaxngDatatype.jar"/> <classpathentry kind="src" path="src"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> <classpathentry kind="lib" path="C:/jwsdp1.4/jaxb/lib/ dom4j-1.6.1.jar"/> <classpathentry kind="lib" path="C:/jwsdp1.4/jaxb/lib/jaxb-libs.jar"/ <classpathentry kind="lib" path="C:/jwsdp1.4/jaxb/lib/jaxb-xjc.jar"/> <classpathentry kind="output" path="classes"/> </classpath>

-------- .classpath for Project JAXB-USE ----------- <classpath> <classpathentry kind="src" path="src"/> <classpathentry exported="true" kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/ org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jdk1.5"/> <classpathentry exported="true" kind="lib" path="C:/jwsdp1.4/jwsdp- shared/lib/relaxngDatatype.jar"/> <classpathentry exported="true" kind="lib" path="C:/jwsdp1.4/jwsdp- shared/lib/xsdlib.jar"/> <classpathentry exported="true" kind="lib" path="C:/jwsdp1.4/jwsdp- shared/lib/jax-qname.jar"/> <classpathentry exported="true" kind="lib" path="C:/jwsdp1.4/jaxb/lib/ dom4j-1.6.1.jar"/> <classpathentry exported="true" kind="lib" path="C:/jwsdp1.4/jaxb/lib/ jaxb-impl.jar"/> <classpathentry exported="true" kind="lib" path="C:/jwsdp1.4/jaxb/lib/ jaxb-libs.jar"/> <classpathentry exported="true" kind="lib" path="C:/jwsdp1.4/jaxb/lib/ jaxb-xjc.jar"/> <classpathentry kind="lib" path="C:/lib/XML_API/JAXB_Libs/jaxb- api.jar"/> <classpathentry combineaccessrules="false" kind="src" path="/ JAXBDemo"/> <classpathentry kind="output" path="classes"/> </classpath>

Thank in advance

Amit J.
 

Andrew Thompson

Usenet Archive
Joined
Jan 16, 2003
Messages
9,476
Reaction score
0
Hi Andrew,

Thanks for your reply.

No worries.
I am using eclipse version 3.4 (Ganymede).

From the post to which you replied..
"..if your answer includes the word 'eclipse'
at any point, I can offer no further help."

So.. Good luck with that 'eclipse thing'.
 

Amit Jain

Usenet Archive
Joined
Aug 3, 2007
Messages
123
Reaction score
0
From the post to which you replied..
"..if your answer includes the word 'eclipse'
at any point, I can offer no further help."

So..  Good luck with that 'eclipse thing'.

sorry...
I am not doing any signing of jar.

I tried with other prog and it works fine.

----- Test2 defined in project JAXB-Demo --------
public class Test1 {
public String method{
return "Hello World";
}
}

----- Test1 defined in project JAXB-USE --------
public class Test1 {
public static void main(String args) {
Test2 obj = new Test2;
System.out.println(obj.method);
}
}

And here I got output "Hello Wold" on console. No exception. I don't understand why security exception is thrown when doing unmarshalling unmarshaller.unmarshal(new File("C:/Workspace/JAXBDemo/xml/ booking_detail.xml"));

Need your inputs on the same...

Amit J.
 

Andrew Thompson

Usenet Archive
Joined
Jan 16, 2003
Messages
9,476
Reaction score
0
sorry...
I am not doing any signing of jar.

Can you absolutely *guarantee* me that eclipse is
not signing the code?

This is (the tip of the iceberg) of the problems that
noobs have when they use a powerful, automagic IDE and
something goes wrong. They have no idea what is going
on 'under the bonnet', nor how to fix it.

Are you using Ant to build the project? Eclipse
understands Ant build files, and I might consider
having a closer look at the build.xml(1) if you can
build at that way.

(1) Assuming that:
a) Unlike NB auto-generate build files, it is self-
contained in a single file.
b) It is not monstrously long.

BTW. Are you able to inspect the contents of the Jar
files? (The command line and SDK tools can dump a
list of the contents of a Jar).
 

Amit Jain

Usenet Archive
Joined
Aug 3, 2007
Messages
123
Reaction score
0
Can you absolutely *guarantee* me that eclipse is
not signing the code?

I can't guarantee but for the same projects while running "Test1" class mentioned in my previous post working fine.
Are you using Ant to build the project?  Eclipse
understands Ant build files, and I might consider
having a closer look at the build.xml(1) if you can
build at that way.

(1) Assuming that:
a) Unlike NB auto-generate build files, it is self-
contained in a single file.
b) It is not monstrously long.

I am using build.xml only for project JAXBDemo (project which is used to generate classes for XSD).
BTW.  Are you able to inspect the contents of the Jar
files?  (The command line and SDK tools can dump a
list of the contents of a Jar).

How do I achieve this?

Amit J.
 

Amit Jain

Usenet Archive
Joined
Aug 3, 2007
Messages
123
Reaction score
0
BTW.  Are you able to inspect the contents of the Jar
I gone throgh like provide in previous post. What exactly I need to analyze with that tool.
 

Roedy Green

Usenet Archive
Joined
Dec 17, 2000
Messages
18,395
Reaction score
0
I am getting following exception while unmarshalling.
---- Stack Trace Starts ----
java.lang.SecurityException: class "javax.xml.bind.JAXBElement"'s signer information does not match signer information of other classes in the same package

you need to sign all your jars with the same cert. This may mean repackaging some jars.
 

Andrew Thompson

Usenet Archive
Joined
Jan 16, 2003
Messages
9,476
Reaction score
0
I gone throgh like provide in previous post. What exactly I need to analyze with that tool.

The list of files. Maybe if you post them here,
we can tell if they are digitally signed, or signed
in duplicate.

Roedy suggested another method that gets around the
technical problem. But note that for most APIs, it is
in contravention of the usage license, to repackage
Jars.
 

Amit Jain

Usenet Archive
Joined
Aug 3, 2007
Messages
123
Reaction score
0
The list of files.  Maybe if you post them here,
we can tell if they are digitally signed, or signed
in duplicate.

----- library (Jar files) in Project "JAXBDemo" -----
dom4j-1.6.1.jar
jaxb-api.jar
jaxb-impl.jar
jaxb-libs.jar
jaxb-xjc.jar
relaxngDatatype.jar

----- library (Jar files) in Project "JAXB-USE" ----- dom4j-1.6.1.jar jax-qname.jar jaxb-api.jar jaxb-impl.jar jaxb-libs.jar jaxb-xjc.jar relaxngDatatype.jar xsdlib.jar

Amit J.
 

Amit Jain

Usenet Archive
Joined
Aug 3, 2007
Messages
123
Reaction score
0
Hi Andrew\Roedy,

Are you expecting above list of files. Our something is missing. Could you please suggest how can we further investigate this issue.

I will appreciate your reply...

Thanks,
Amit J.
 

Andrew Thompson

Usenet Archive
Joined
Jan 16, 2003
Messages
9,476
Reaction score
0
Hi Andrew\Roedy,

Are you expecting above list of files.
Yes!

...Our something is missing.

Intellingence? Lack of understanding of the
language I am using to communicate? *Common sense?*

FFS YES! You are obviously not capable of understanding the simplest advice in English (the only language I understand), so when in doubt, *post extra information!*
Could you please suggest how can we further investigate this issue.

(to be honest, and blunt) I am at my wits end as to
how to transmit information to you in a way you understand. /Have you considered hiring an English interpreter?/ That it not intended as sarcasm, nor as an insult, but I simply do not know any other way to transmit tech. info. from my head to yours, short of that.
 

Amit Jain

Usenet Archive
Joined
Aug 3, 2007
Messages
123
Reaction score
0
...Our something is missing.
Typo mistake and unfortunately I clicked send button without reviewing the message.

Thanks alot for your valuable input. I realy do needful to enhance my language gap

regrads, Amit J.
 

Amit Jain

Usenet Archive
Joined
Aug 3, 2007
Messages
123
Reaction score
0
Hi All,

Problem resolved...

Thanks to all for there valuable suggestions.

regards, Amit J.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
548,049
Messages
3,104,244
Members
248,133
Latest member
DujonT

Latest Threads

Top