Win a copy of Spring Boot in Practice this week in the Spring forum!

Ashish Shinde

Ranch Hand
+ Follow
since Dec 08, 2002
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
1
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Ashish Shinde

I am trying to use Hibernate packaged in JBoss 5.1. The persistence.xml (JPA 2.0 compliant) has a tag as:
.

However, JBoss does not recognize it during startup and gives an error:


Any idea as to what the resolution might be or what is causing the error?
11 years ago


I am not using EJB3 but JBoss with SOA.
Will this setting still work. My assumption is it will work as there is no relation to EJB3 here.
Please confirm.
Any good tutorial which will help me understand it would be helpful.
11 years ago
I am trying to integrate JBoss AS5 with Hibernate 3 using annotations.
My requirement is to get SessionFactory through a JNDI lookup.
I tried the following link: http://community.jboss.org/wiki/JBossHibernate3

I have completed following steps:
1. Created the *-ds.xml for creating the datasource and binding to JNDI.
2. Created annotated entity class (just one class for one table as start).
3. Created the *-hibernate.xml as follows:

This file has similar structure as hibernate.cfg.xml and placed in the <jboss-as>/default/deploy folder.

The above file throws an error during startup as:
org.jboss.xb.binding.JBossXBException: Failed to parse source: {urn:jboss:hibernate-deployer:1.0}mapping cannot appear in this position.
Expected content of {urn:jboss:hibernate-deployer:1.0}session-factory is unordered_sequence: {urn:jboss:hibernate-deployer:1.0}depends* {urn:jboss:hibernate-deployer:1.0}property*

It seems the <mapping> tag is not accepted under session-factory> and it works if I remove the <mapping> elements.
But the standard hibernate.cfg.xml does accept <mapping> under <session-factory>.

I do not have any *.hbm.xml as I want to use annotations.

Is there anything else I need to take care of or what is the correct way of doing it?
Any pointers or links would be helpful.

11 years ago

Approach to change code did resolve the issue and was able to generate the XML successfully.
However change to xjb would be more cleaner one.

If anybody has any inputs on how to go about it please let me know.
12 years ago
The problem is I dont have control over xsd.
Is there something that can be implemented through bindings file (xjb) ?
12 years ago
Tried changing the xjb and added parameter "-extension" while using xjc.
But it only changed the setAny(Object) method for Batch in Book.xsd to setAny(Element).

The objectFactory still does not have createHeader(new Header()) method which would return me a JAXBElement to be used in new setAny method.
12 years ago
Facing one more issue.
Final xml to generate should have the following format



The Reviewer xsd has a Header complexType as :


The Book.xsd has <Batch> info as follows:

The <Doc>,<Batch> belong to Book.xsd while rest of them, including Header, belong to Reviewer.xsd.
As you can see the <Header> tag occurs at two places. One instance occurs near the root node and other is deep inside.

Have prepared the xjb to generate classes using xjc from both xsd into a single package.
However , when I create the xml structure above and try to marshal, the error thrown is:
unable to marshal type "com.impl.Header" as an element because it is missing an @XmlRootElement annotation]

Is there a way to accomodate this complexType inside the Batch tag?

12 years ago

I have a requirement to count the number of newline characters in a varchar2 field in Oracle.
The catch is if the line starts with characters 'SS' it should be ignored in the count.

E.g.: -


should return the count as 3

Is there a way to do this using regular expression ?
12 years ago

This works as required.
Thank you very much for the solution.
12 years ago

Now facing another issue.
Both xsd have a Type element as follows:
Reviewer.xsd -


Book.xsd


Since TypeCode is defined as element in both xsd's the xjc gives an error as:

[ERROR] A class/interface with the same name "com.impl.TypeCode" is already in use.
Use a class customization to resolve this conflict.
line 14 of file:/C:/work/src/reviewer.005.005.xsd

[ERROR] (Relevant to above error) another "TypeCode" is generated from here.
line 122 of file:/C:/work/src/Book.xsd
Failed to produce code.


Please let me know how i can modify bindings file to implement class customization and make it work?

Thanks in advance


12 years ago
Resolved it.

Removed the xml declaration i.e. 1st line , in bindings file.
12 years ago
Thanks. Tried using this approach. However when the xjc command runs, it gives the following error:

[ERROR] The processing instruction target matching "[xX][mM][lL]" is not allowed
line 1 of file c:\work\src\bindings.xjb


Ran individual xsd files with xjb and they are generating the classes.
Have verified the xsd files and there are no HTML style (<!-- -->) comments
My Reviewer xsd filename is "reviewer.005.005.xsd". Could this be the issue?
12 years ago


The xsd's have been provided and not allowed to modify it.
12 years ago
The link you have given is pretty much what I am trying to implement.
With 2 xsd (Book and reviewer) and 2 object factories (Book and reviewer) how do i marshal one xml which has book as well as reviewer?

In the example link in your post below,
nowhere in BookType schema it refers the Reviewer xsd.
However the final xml depicted has a Reviewer.

I want to achieve the same.
The BookType xsd has <xsd:any namespace="##any" minOccurs="0"/> with no reference to Reviewer xsd.
How will it know that the namespace="##any" will accmodate the reviewer?
12 years ago
The reviewer is similar as specified in your sample.
However, my book.xsd has following element which I am using to embed the Reviewer:
<xsd:complexType name="Comments">
<xsd:sequence>
<xsd:any minOccurs="1" maxOccurs="1" namespace="##any"
processContents="lax" />
</xsd:sequence>
</xsd:complexType>

I was not aware that I can use "import" tag to import an xsd.

How do I use "import" in conjunction with the "##any" namespace in book.xsd ?
12 years ago