JAXB map to java.lang.Object.
Hi people,
I need to create objects using the JAXB xjc tool.
There is an element/attribute in my XMLSchema that needs to be maped to java.lang.Object.
I tried to use anySimpleType this way:
<element name="try1" type="anySimpleType" maxOccurs="1" minOccurs="0"/>Also tried this:
<attribute name="try2" type="anySimpleType" use="optional"/>But this way it maps to java.lang.String.
Thanks for any help, references, sugestions.
Att,
TJ.
Ok, try1 is working, I'm sorry.
Thanks.
Similar Messages
-
Mapping xsd:anyType element to Java.lang.Object
Hi,
I am using JAXB to parse a xml and in the XSD we have one element which is of the anyType and returns java.lang.object from JAXB generated classes. The issue is that when the node contains string and we type cast the returned object to string every thing runs fine but when the element contains embeded xml then the object returned can not be type cast to string.
code snippet:
*<xsd:element name="SignatureDefinition" type="xsd:anyType" />*
and the xml I am parsing contains:
*<SignatureDefinition>
<a>name</a>
<b> job</b>
</SignatureDefinition>*
That is the element contains a object which is a well formed xml.
Can any one guide or provide me the pointers.
Thanks
Regards,
DeveshHello Devesh,
The "SignatureDefinition" portion of the XML document should be unmarshalled as a DOM Element.
File file = new File("any.xml");
Root root = (Root) jaxbContext.createUnmarshaller().unmarshal(file);
Element element = (Element) root.getSignatureDefinition();
System.out.println(element.getTextContent());
If "SignatureDefintion" is the root of the XML document, you should get a JAXBElement wrapping a DOM Element.
File file = new File("any.xml");
JAXBElement<Element> root = (JAXBElement<Element>) jaxbContext.createUnmarshaller().unmarshal(file);
System.out.println(root.getValue().getTextContent());
-Blaise -
Sort(java.util.LinkedList java.lang.Object ) doesn't work
Why doesn't this work?
LinkedList<Object> sysPropsKeys = new LinkedList<Object>(System.getProperties().keySet());
Collections.sort(sysPropsKeys);
cannot fnd symbol
symbol : method sort(java.util.LinkedList<java.lang.Object>)
location: class java.util.CollectionsI will admit to not having Java1.5 installed on my machine. Haven't yet had the chance to play with generics, but the above DOES work in 1.4, and SHOULD work in 1.5
Maybe I'm naive but, System.getProperties() returns a Properties object right?
According to the API: http://java.sun.com/j2se/1.5.0/docs/api/java/util/Properties.html: Each key and its corresponding value in the property list is a string.
All the keys SHOULD be strings.
AFAIK string are comparable, and shouldn't throw class cast exceptions
Thus the keys returned from getProperties SHOULD be comparable, and compatible for comparision.
Ok, I can see your point in that some hackers abuse the Properties class by putting non string keys/values into the Properties Map. In that case the code would become more like your above. I'd probably still go with a TreeMap though, rather than a sorted list of keys. Most time you want the keys, you want the values as well. So if the intention is to print out a sorted list of system properties, and their values, keeping it in a map is best.
Just my 2 cents,
evnafets -
Error: initialization error: file java\lang\Object.class not found
when the error listed my classpath's its not the same list that is in my Windows XP environment variable list?
I am on 9.0.3
I am assuming I have to set some varible to my new jdk\bin directory. I reinstalled it. I have set it to use jdk 1.4 using the ojvm tool a while back.Please help!!
I did change the jdev.conf file setting:
SetJavaHome /System/Library/Frameworks/JavaVM.framework/Versions/1.4.2/Home
and I still get this error:
initiallization erro: file java/lang/Object.class not found in classpath
I am usgin Oracle JDeveloper 10g 10.1.2 on a Mac OS X Tiger
Could someone please help?
thanks a bunch!!! -
hi all
ive installed jdk1.4.1 from jdk1.3 .
When i try to compile a java file i get this error.
Error: invalid file 'java/lang/Object.class' (wrong version: 48, expected 45)
anyone has any idea abt this.
im stuck :( pls help.
thanks
JanDid you uninstall 1.3 completely? Completely in the sense both jdk and jre.
You may get this error if you use javac of one version and the rt.jar of another version.
Sudha -
Java/lang/NoClassDefFoundError: java/lang/Object
Hi Experts,
We are installing Java "1.6.0_31.We have updated the environment variables with the correct Java Path but which checking the java -version we are getting the following error.
java -version
Error occurred during initialization of VM
java/lang/NoClassDefFoundError: java/lang/Object
hence the DAC service is not starting giving the following error.
startserver.h: startserver.h: cannot open
OS detected: SunOS
ld.so.1: java: fatal: libjli.so: open failed: No such file or directory
Killed
Following are the environment variable entries.
PATH=/opt/SUNWspro/bin:/../oracle/product/10.2.0/client_1/bin:/.../Informatica/PowerCenter8.6.1/server/bin:/usr/sfw/bin:/...../JAVA631/jdk1.6.0_31/bin/sparcv9:/.../JAVA631/jdk1.6.0_31/lib:/..../JAVA631/jdk1.6.0_31/jre/lib/sparcv9/jli:/...../JAVA631/jdk1.6.0_31/jre/lib/sparcv9:$PATH
export PATH
Need ur support.
ThanksWhere do you run shell script?
What's your Oracle's version?
What's text of your shell script?
By asking 100 questions and keeping 90 of them "unanswered" you throw yourself to the list of "blacklist users"
Kamran Agayev A. (10g OCP)
http://kamranagayev.wordpress.com
[Step by Step install Oracle on Linux and Automate the installation using Shell Script |http://kamranagayev.wordpress.com/2009/05/01/step-by-step-installing-oracle-database-10g-release-2-on-linux-centos-and-automate-the-installation-using-linux-shell-script/]
Edited by: Kamran Agayev A. on May 19, 2009 1:28 PM -
NoClassDefFound java/lang/Object error
Hi all,
I just tried to install JRE 1.4.1 on Win98 and encountered this error when I typed in java -version:
error occurred during initialization of VM
java/lang/NoClassDefFoundError: java/lang/Object
After I installed I added SET CLASSPATH = and the path to my rt.jar and tools.jar to my autoexec.bat, but that didn't seem to work.
Sorry about posting this here if it isn't appropriate, I tried a forum search but kept getting Server Error.
SteveLook at this thread:
http://forum.java.sun.com/thread.jsp?forum=54&thread=106425
Think it is reply 3 or 4, where you have to rename the the java.exe file somewhere in your system path -
Javah error java.lang.Object not found
Hi guys-
I'm trying to run a javah command to generate a .h file... I'm using windows2000 & jdk1.1.8... when I run the command from DOS prompt I keep getting the same eror as java.lang.Object not found: aborting.. I've checked all the classpath and it seems ok ... I have CLASSPATH=..;c:\jdk1.1.8\lib\classes.zip
Can anybody help me with this???
ThanxMaybe try ; right click my computer ,click the advanced tab and select enviroment variables,click on classpath and then edit,check if it's correct.I had the sam problem and that seemed to fix it. :)
-
Weblogic - a web service with java.lang.Object parameter
hi all,
i'm creating a web service with a java.lang.Object parameter.
my question is as follows:
when a client calls the web service, how to i get the soap message object and convert it to soap message string using the parameter?
thanks,
alexHere's some code from one of the Axis samples, this shows the basic process of making a call:
package samples.message;
import org.apache.axis.client.Service;
import org.apache.axis.client.Call;
import org.apache.axis.message.SOAPBodyElement;
import org.apache.axis.utils.Options;
import org.apache.axis.utils.XMLUtils;
import org.w3c.dom.Element;
import java.net.URL;
import java.util.Vector;
public class TestMsg {
public String doit(String[] args) throws Exception {
Options opts = new Options(args);
opts.setDefaultURL("http://localhost:8080/axis/services/MessageService");
Service service = new Service();
Call call = (Call) service.createCall();
call.setTargetEndpointAddress( new URL(opts.getURL()) );
SOAPBodyElement[] input = new SOAPBodyElement[2];
input[0] = new SOAPBodyElement(XMLUtils.StringToElement("urn:foo",
"e1", "Hello"));
input[1] = new SOAPBodyElement(XMLUtils.StringToElement("urn:foo",
"e1", "World"));
Vector elems = (Vector) call.invoke( input );
SOAPBodyElement elem = null ;
Element e = null ;
elem = (SOAPBodyElement) elems.get(0);
e = elem.getAsDOM();
String str = "Res elem[0]=" + XMLUtils.ElementToString(e);
elem = (SOAPBodyElement) elems.get(1);
e = elem.getAsDOM();
str = str + "Res elem[1]=" + XMLUtils.ElementToString(e);
return( str );
public static void main(String[] args) throws Exception {
String res = (new TestMsg()).doit(args);
System.out.println(res); -
Finalizer.register(java.lang.Object)
I need to know th use of Finalizer.register(java.lang.Object) method.
Can someone please help me...Its urgent!!!!
Thank you!!
Message was edited by:
Java_FreakI am instantiating a MQQueue object..... When I run
the memory debugger it says a call is made to the
Finalizer.register method and the FInalizer object is
on heap even after the GC...Why is this a problem? If it is a problem again
1) Consult the bug database
2) Post formatted code that reproduces your problem.
Other than that consult these
http://java.sun.com/developer/technicalArticles/ALT/RefObj/
http://www.javaworld.com/javaworld/javatips/jw-javatip79.html
This is the best and only advice I can give you based on your problem description. -
The first quthor of java.lang.Object
The biggest mystery for me in Java still exists as to who really coded the mother of all classes java.lang.Object.
Here�s what the source of it says in JavaDocs
* Class <code>Object</code> is the root of the class hierarchy.
* Every class has <code>Object</code> as a superclass. All objects,
* including arrays, implement the methods of this class.
* @author unascribed
* @version 1.61, 01/23/03
* @see java.lang.Class
* @since JDK1.0
public class Object {
�
See the annotation @author above, it says �unascribed� which means unknown. Any one who can solve this mystery for me and come up with the real author of this jni implementation class called �Object�
I mean, the first one to code Object class...Please help mecross-post
-
Who is the author of java.lang.Object
The biggest mystery for me in Java still exists as to who really coded the mother of all classes java.lang.Object.
Here�s what the source of it says in JavaDocs
* Class <code>Object</code> is the root of the class hierarchy.
* Every class has <code>Object</code> as a superclass. All objects,
* including arrays, implement the methods of this class.
* @author unascribed
* @version 1.61, 01/23/03
* @see java.lang.Class
* @since JDK1.0
public class Object {
�
See the annotation @author above, it says �unascribed� which means unknown. Any one who can solve this mystery for me and come up with the real author of this jni implementation class called �Object�
I mean the first one to write java.lang.Object. Please help me...Please don't cross-post
-
HELP!! Deploying with DC, missing type java.lang.Object
Hi Folks,
I have a WebDynpro project created with a DC. I have been deploying the project directly from the application node, but I just built the associated DC for the first time, and now I get errors in my source code that I have the missing type java.lang.Object.
I have tried the repair-->project structure and classpath option already. Looks like some basic links are broken.
This is hopefully simple, but I have no Idea what I need to do.
Thanks
Message was edited by:
Todd FisherHi there,
If it's because of broken links, did you try closing the project and opening it again?
Kind regards,
J. -
Java newbie: java.lang.Object[]
Hi: I have a method which returns a java.lang.Object[]. I have tried a number of things. But can't seem to How do I print the contents of the object?
The method I am calling is the following
==============
public java.lang.Object[] getAllUsers() {
if (super.cachedEndpoint == null) {
throw new org.apache.axis.NoEndPointException();
org.apache.axis.client.Call _call = createCall();
call.setOperation(operations[125]);
_call.setUseSOAPAction(true);
_call.setSOAPActionURI("");
call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11CONSTANTS);
_call.setOperationName(new javax.xml.namespace.QName("Urn:ApiService", "getAllUsers"));
setRequestHeaders(_call);
setAttachments(_call);
try { java.lang.Object _resp = _call.invoke(new java.lang.Object[] {});
if (_resp instanceof java.rmi.RemoteException) {
throw (java.rmi.RemoteException)_resp;
else {
extractAttachments(_call);
try {
return (java.lang.Object[]) _resp;
} catch (java.lang.Exception _exception) {
return (java.lang.Object[]) org.apache.axis.utils.JavaUtils.convert(_resp, java.lang.Object[].class);
=============
Thanks
RaviWhere in that code do you claim you are doing that? Post a SSCCE .
edit: Should you really be trying to work with web services if you don't know the basics of Java? -
Java.lang.Object. init ???????
Can anyone tell me why Sun have removed the method java.lang.Object.<init> from their JDK1.3.1?
There is actually no error. I am profiling benchmark programs (Java Grande benchmark suite) for method invocations using Sun's JDK1.3.1 and comparing the results with those previously measured using Kaffe. The method java.lang.Object.<init> appears to be invoked in every benchmark program on Kaffe but does not appear to be invoked in any of the programs when using Sun's VM. I fist thought that HotSpot was inlining this method but when I inspected the actual java class libraries for Sun's VM, the method java.lang.Object.<init> does not seem to be implemented in any of them. This is why I assumed that the method had been removed from Sun's VM.
Have you any ideas?
Thanks in advance.
Anthony.
Maybe you are looking for
-
We just purchased a Samsung 3D HD Smart TV. My B-friend has a Samsung Galaxy 3 (poor thing) which syncs beautifully with the TV. We are also Amazon Prime customers. So another great syncing capability. I own an iphone 5 and an Imac. so we can never c
-
Segmentation fault with xqillia when using purifyplus
Hi friends, I am using BDB , xqilla /xerces interface to perform an xquery.The program works fine,but after building the program along with purifyplus,if i try to run the program a segmentation fault is raised. attached are the code,command used to b
-
Error Creating Work Area in JDeveloper for SCM
In the Repository Object Navigator for 9i SCM, my userID has been granted the the following permissions to a shared work area called pdshare by the owner/build manager: Select Administrate Insert Update Delete Version Compile Update Spec. However, in
-
I have an assignment which requires me to draw a topology of a network. I already able to find out the objects within the network but I still need to know how they (switchs, routers and hubs) are connected to each other (like the route needed to be t
-
For some reason, no users under Server.app has rights to administer the server. I'm still an admin on the server itself though. Is there a way via command line to enable a user to 'administer this server'? Is it just a user group that I can add th