tags:

views:

41

answers:

1

We have a web application that uses JAXB from inside an applet. Everything works fine, except when the JAXBContext is first created, we see the following logged in the applet console:

Creating JAXBContext...
network: Connecting https://myserver.com/MyApp/CC.ccc with proxy=DIRECT
network: Connecting https://myserver.com/MyApp/CC.ccc with cookie "__utma=69126149.1559268128.1262793475.1265211768.1271711769.3; JSESSIONID=723072c1c4bbc2598e402b3f24a5d12f3324"
network: Cache entry not found [url: https://myserver.com/MyApp/com/comm/servlet/generated/package-info.class, version: null]
network: Connecting https://myserver.com/MyApp/com/comm/servlet/generated/package-info.class with proxy=DIRECT
network: Connecting http://myserver.com:443/ with proxy=DIRECT
network: Connecting https://myserver.com/MyApp/com/comm/servlet/generated/package-info.class with cookie "__utma=69126149.1559268128.1262793475.1265211768.1271711769.3; JSESSIONID=723072c1c4bbc2598e402b3f24a5d12f3324"

This happens a total of 20 times, and slows down our application considerably.

I'm using the "xjc" ant task (com.sun.tools.xjc.XJCTask) to compile our schema into Java in the com/comm/servlet/generated/ package. The code gets generated fine, but there is no package-info.java. If I manually create this file and compile and package the code, the package-info.class is missing from the JAR file.

This is my XJC task:

<target name="generateJAXBSource">
 <taskdef name="xjc" classname="com.sun.tools.xjc.XJCTask">
   <classpath>
     <fileset dir="lib/jaxb" includes="*.jar" />
   </classpath>
 </taskdef>

 <xjc schema="resources/requests/111.xsd" 
  destdir="src" 
  package="com.comm.servlet.generated"/>  
</target>

My XSD looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
 xmlns:xml="http://www.w3.org/XML/1998/namespace"&gt;
 <xs:import namespace="http://www.w3.org/XML/1998/namespace" />

 <xs:element name="InfoResponse">
  <xs:complexType>
   <xs:sequence>
    <xs:element ref="WorkQueueItem" maxOccurs="unbounded" />
   </xs:sequence>
  </xs:complexType>
 </xs:element>

I've been googling all day but can't seem to figure out how to get around this.

I tried the workaround proposed here to make sure package-info.java gets compiled:

... but no luck.

Can I instruct JAXB not to look for package-info.class?

How can I make sure that my manually created package-info.java ends up in the JAR file?

Thanks.

A: 

Your JAXB implementation is looking for package-info.class to process any package level annotations that might be present in your model. There is no standard way to prevent a JAXB implementation from looking for package level annotations.

Adding a package-info class (in the same package as your model classes) seems like a reasonable work around.

Is package-info failing to compile for you (if so what error are you getting)? Or is it just not appearing in your JAR (if so how are you building your JAR)?

Blaise Doughan