Annotation compilation

Does anyone happen to know how an annotation type is compiled into a .class file? I assume it creates an interface that extends Annotation, but how are the defaults and such stored?
Thanks in advance!

Does anyone happen to know how an annotation type is
compiled into a .class file?
I assume it creates an
interface that extends Annotation, but how are the
defaults and such stored? No.
Annotations are attributes - see 4.7 of the JVM spec.

Similar Messages

  • JDK 1.6: Annotation Processing & Compiler Hack

    Hello,
    I am currently using JDK 1.6.0_23
    For one of the requirement, I am going with annotation processing & compiler Hack using Tools.jar available as part of JDK.
    I have refered a PDF - "The Hacker's Guide to javac (PDF) by David Erni and Adrian Kuhn (2008)
    " suggested from page of - http://openjdk.java.net/groups/compiler/
    My requirement is below ->
    Origional Source:
    public void someMethod() {
    }Modified Source:
    public void someMethod() {
       int items = new example.Product().getItems();
    } Below is my code to generate the variable declaration -
    private TreeMaker make; // fetch it from somewhere
    JCNewClass newProduct = make.NewClass(null, List.<JCExpression>nil(), make.Ident(names.fromString("example.Product")), List.<JCExpression>nil(), null);
    JCFieldAccess fieldAccess = make.Select(newProduct, names.fromString("getItems"));
    JCMethodInvocation getTimeMethodInvocation = make.Apply(List.<JCExpression>nil(), fieldAccess, List.<JCExpression>nil());
    expression = getTimeMethodInvocation;
    JCVariableDecl itemsDeclaration = make.VarDef(modifiers,name,varType,expression);
    System.out.println(itemsDeclaration); // this prints int items = new example.Product().getItems(); This itemsDeclaration, I am adding to a List<JCStatement> of JCBlock of JCMethodDecl.
    However modified code does not compile :(
    If I make below changes - Modified does compile
    1)
    JCNewClass newProduct = make.NewClass(null, List.<JCExpression>nil(), make.Ident(names.fromString("Product")), List.<JCExpression>nil(), null);Product insteadof example.Product
    2) Add belwo statement in the origional source code
    import examle.Product; What exactly am I missing here ???
    The AST tree is diffcult to understand with minimum documentation & without much help on the interent.
    I hope this is correct forum, for my query.
    It will be a great help.
    Regards,
    Vikas Parikh

    Hello,
    I couldn't contact them, as the white papaer didn't conatin any email address / contact info.
    I have investigated myself on this & would like to share with you guys, so that any other developer
    do not have to invest precious time like I have done.
    To create a New Class, you require a JCExpression.
    Below would work, if class already has imported Product class.
    make.Ident(names.fromString("Product"))However, if class has not imported the Product class, then there are 2 options -
    1) Create a Ident</pre> from <pre>Symbol (ClassSymbol)
    2) Create a JCField</pre> from <pre>NameI used a later approach.
    Regards,
    Vikas Parikh
    Edited by: 996153 on Mar 31, 2013 11:04 PM

  • Annotation-caused compiler crash

    Hi,
    When attempting to build against a class that uses runtime annotations, javac is crashing with:
    An exception has occurred in the compiler (1.6.0-rc). Please file a bug at the Java Developer Connection (http://java.sun.com/webapps/bugreport) after checking the Bug Parade for duplicates. Include your program and the following diagnostic in your report. Thank you.
    com.sun.tools.javac.code.Symbol$CompletionFailure: class file for test.annotation.TestAnnotation not found
    The test case that generates this error can be found at:
    http://www.cjtucker.com/annotation-bug.tgz
    Synopsis:
    Attempting to build against a class that contains a runtime annotation requires the definition of the annotation to be available to the compiler. If the definition is not available, the compiler crashes.
    Test case:
    The test case attempts to build three classes in three separate packages: a simple RUNTIME scoped annotation, a "core" class, and a "ui" class that builds against the core class. The "ui" class neither knows nor cares about the annotated properties of the "core" class. The annotation class is build in isolation; the core class is built only against the annotation class; the ui class is built only against the core class.
    The test case tarball contains the necessary .java files and directory structure for compilation. The compilation commands are contained in compile.sh.
    The crash can be avoided by including the annotation class in the classpath when building the ui component. The crash has been reproduced in 1.5.0_04, 1.5.0_05, and 1.6.0b61. Other JDKs have not been tested. The crash occurs with both RUNTIME and CLASS scoped annotations, though not with SOURCE scope (as expected: the compiler is correctly stripping annotations in that case). The crash does not occur if the annotation does not take parameters (i.e. is an empty "marker" annotation).
    This raises some additional questions I'd be interested in hearing comment on. What is the expected behavior here? I would expect the annotation class should not be required as a dependency, in the same way I'm not expected to declare a dependency on every class used by a class I interact with. This behavior with annotations seems to breach encapsulation (for example, a client would have to know that my libraries happened to be using a Hibernate persistence layer whether or not this is of interest to them). Perhaps one of the Java gurus here could shed some further light on this?
    Cheers,
    Chris Tucker

    Hi,
    I know this is an old post but I am having the exact same problem with 1.6.0_11 and have not been able to find a solution.
    Any assistance would be much appreciated.
    Thanks.

  • Is it possible to stop compiling process in annotations processing?

    Hi all.
    I'm doing annotations processing with javac.
    Is it possible to stop compilation if an error occurs during annotations processing?
    Thank you!

    francadaval wrote:
    Hi all.
    I'm doing annotations processing with javac.
    Is it possible to stop compilation if an error occurs during annotations processing?If you raise an error with the Messager:
    http://java.sun.com/javase/6/docs/api/javax/annotation/processing/Messager.html
    no class files will be generated. This is the recommended way to start winding things down; from the Processor class:
    "If a processor throws an uncaught exception, the tool may cease other active annotation processors. If a processor raises an error, the current round will run to completion and the subsequent round will indicate an error was raised. Since annotation processors are run in a cooperative environment, a processor should throw an uncaught exception only in situations where no error recovery or reporting is feasible."

  • Help Needed compile, deploy Web Service with Annotations on Web Logic 9.2

    Hi,
    I am new web logic and need some help in compiling, creating deployment file i.e. war, ear on Web Logic 9.2. I have the following sample web service with annotations code code but need help in compiling, creating deployment file (war,ear), creating proxy for testing etc. How to compile and create deployment files in WebLogic 9.2. Any help is really appreciated.
    package sample_ws;
    import java.rmi.RemoteException;
    import javax.jws.*;
    import javax.jws.soap.SOAPBinding;
    import org.w3c.dom.Document;
    @WebService
    @SOAPBinding(style = SOAPBinding.Style.DOCUMENT, use = SOAPBinding.Use.LITERAL,
                 parameterStyle = SOAPBinding.ParameterStyle.BARE)
    public class EchoService {
        public EchoService() {
        @WebMethod(action="echo")
        @WebResult(targetNamespace="http://exa.org", name="echoResult")
        public Document echo(@WebParam(targetNamespace = "http://exa.org",
                                       name = "echoMsg")
            Document doc) throws RemoteException{
            return doc;
    }Thanks

    I am using Oracle Jdeveloper as an IDE and created a war file and deployed on Oracle App. Server it works fine. Now if I deploy the same war on Web Logic it gives me the following error:
    java.lang.IllegalStateException: could not find schema type named {{http}//exa.org}>>echoResult
    Errors were encountered while performing this operation. Here is the code I have:
    package webservice2 ;
    import java.rmi.RemoteException;
    import javax.jws.*;
    import javax.jws.soap.SOAPBinding;
    import org.w3c.dom.Document;
    @WebService
    @SOAPBinding(style = SOAPBinding.Style.DOCUMENT,
                 use = SOAPBinding.Use.LITERAL,
                 parameterStyle = SOAPBinding.ParameterStyle.BARE)
    public class EchoService {
        public EchoService() {
        @WebMethod(action="echo")
        @WebResult(targetNamespace="http://exa.org", name="echoResult")
        public Document echo(@WebParam(targetNamespace = "http://exa.org",
                                       name = "echoMsg")
            Document doc) throws RemoteException{
            return doc;
    }And here is the wsdl file I have:
    <definitions
         name="EchoServiceService"
         targetNamespace="http://webservice2/"
         xmlns="http://schemas.xmlsoap.org/wsdl/"
         xmlns:tns="http://webservice2/"
         xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/"
         xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
         xmlns:ns1="http://exa.org"
         xmlns:xsd="http://www.w3.org/2001/XMLSchema"
         xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
        >
        <types>
            <schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://exa.org" elementFormDefault="qualified"
                 xmlns:tns="http://exa.org" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                 xmlns:soap11-enc="http://schemas.xmlsoap.org/soap/encoding/">
                <element name="echoMsg" nillable="true">
                    <complexType>
                        <sequence>
                            <any/>
                        </sequence>
                    </complexType>
                </element>
                <element name="echoResult" nillable="true">
                    <complexType>
                        <sequence>
                            <any/>
                        </sequence>
                    </complexType>
                </element>
            </schema>
        </types>
        <message name="EchoServicePortType_echo">
            <part name="echoMsg" element="ns1:echoMsg"/>
        </message>
        <message name="EchoServicePortType_echoResponse">
            <part name="echoResult" element="ns1:echoResult"/>
        </message>
        <portType name="EchoService">
            <operation name="echo">
                <input message="tns:EchoServicePortType_echo"/>
                <output message="tns:EchoServicePortType_echoResponse"/>
            </operation>
        </portType>
        <binding name="EchoServiceSoapHttp" type="tns:EchoService">
            <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
            <operation name="echo">
                <soap:operation soapAction="echo"/>
                <input>
                    <soap:body use="literal" parts="echoMsg"/>
                </input>
                <output>
                    <soap:body use="literal" parts="echoResult"/>
                </output>
            </operation>
        </binding>
        <service name="EchoServiceService">
            <port name="EchoServiceSoapHttpPort" binding="tns:EchoServiceSoapHttp">
                <soap:address location="http://localhost:8888/EnableSrc-WebService2-context-root/EchoServiceSoapHttpPort"/>
            </port>
        </service>
    </definitions>Any ideas what might be wrong.

  • Compile build.xml with Ant for web service with annotations

    Hi Friends,
    I have a web service with annotations, using javax.annotation.PostConstruct, and javax.annotation.PreDestroy.
    I have a build.xml to create a EAR for this web service.
    When I run the ant task, the build complete successfully but the .war file cannot be deployed on the WLS server. Taking a closer look, I see that the required files such as, webservices.xml, weblogic.xml, weblogic-webservices.xml, Provision.wsdl files are not generated.
    Following is the build.xml file:
    <?xml version="1.0" encoding="windows-1252" ?>
    <project default="jwsc">
    <property file="build.properties"/>
    <property name="weblogic.jar.classpath"
    value="C:/bea_jDev/wlserver_10.3/server/lib"/>
    <property name="oimclient.jar.classpath"
              value="C:/_data/Project_Dc/OIM_jars" />
         <property name="com.jar.classpath" value="C:/JDeveloper/mywork/Service_Test/lib" />
    <taskdef name="jwsc" classname="weblogic.wsee.tools.anttasks.JwscTask">
    <classpath>
    <path id="weblogic.classpath">
    <pathelement path="WEBLOGIC_HOME"/>
    <fileset dir="${weblogic.jar.classpath}">
    <include name="**/*.jar"/>
    </fileset>
    </path>
    </classpath>
    </taskdef>
    <target name="all" depends="clean,build-service,deploy"></target>
    <target name="build-service">
         <jwsc srcdir="${src.home}" destdir="ear_directory" >
    <classpath>
    <path id="oim.classpath">
    <pathelement path="OIM_HOME"/>
    <fileset dir="${oimclient.jar.classpath}">
    <include name="**/*.jar"/>
    </fileset>
    <fileset dir="${com.jar.classpath}">
    <include name="**/*.jar"/>
    </fileset>
    </path>
    </classpath>
    <jws file="${jws.home}" type="JAXWS" />
    </jwsc>
    </target>
    <target name="deploy">
    <!--add wldeploy task here -->
    </target>
    <target name="clean">
    <delete dir="output" />
    </target>
    </project>
    Can you please point out what else is to be done and where exactly am I going wrong in writing the build.xml file.
    Let me know if some else information is required.

    This is what I get when I run the ant task:
    Buildfile: C:\JDeveloper\mywork\ProvisioningService_Test2\Provision\resource\build.xml
    build-service:
    [jwsc] JWS: processing module /com/fox/provision/webservice/endpoint/impl/ProvisionEndPointImpl
    [jwsc] Parsing source files
    [jwsc] Parsing source files
    [jwsc] 1 JWS files being processed for module /com/.../provision/webservice/endpoint/impl/ProvisionEndPointImpl
    [jwsc] [JAM] Warning: failed to resolve class org.apache.xmlbeans.XmlObject
    [jwsc] [JAM] Warning: failed to resolve class com.bea.xml.XmlObject
    [jwsc] [JAM] Warning: failed to resolve class javax.xml.rpc.holders.Holder
    [jwsc] JWS: C:\..\...\..\...\code\ProvisioningService\src\com\...\provision\webservice\endpoint\impl\..EndPointImpl.java Validated.
    [jwsc] Processing 1 JAX-WS web services...
    [jwsc] warning: Specified AnnotationProcessorFactory, 'com.sun.istack.ws.AnnotationProcessorFactoryImpl', not found on search path.
    warning: No annotation processors found but annotations present.
    2 warnings
    [jwsc] Compiling 2 source files to C:\DOCUME~1\....\LOCALS~1\Temp\_lsgijm
    [jwsc] Building jar: C:\..\...\..\...\code\ProvisioningService\src\com\...\provision\webservice\deploy\ear_directory\com\fox\provision\webservice\endpoint\impl\...EndPointImpl.war
    [jwsc] Created JWS deployment outputFile: C:\..\...\..\...\code\ProvisioningService\src\com\...\provision\webservice\deploy\ear_directory\....\...\provision\webservice\endpoint\impl\..EndPointImpl.war
    [jwsc] [EarFile] Application File : C:\..\...\..\...\code\ProvisioningService\src\com\.....\provision\webservice\deploy\ear_directory\META-INF\application.xml
    [AntUtil.deleteDir] Deleting directory C:\DOCUME~1\....\LOCALS~1\Temp\_lsgijm
    BUILD SUCCESSFUL
    Total time: 7 seconds
    Due to some limitations, I edited the path in the build.xml files.
    Please let me know what can be done. Thanks.
    Edited by: user9112073 on Nov 22, 2011 9:52 PM

  • Selective Ahead of Time Compilation using Annotations

    I'm writing a music composition application.
    Only once compiled by the JIT, does code run at the speed I need to playback and highlight notes as they are played. That is, rendering takes 3 ms and painting takes 1ms. The first few dozen iterations, rendering takes 22 ms and painting 6 ms.
    Interesting, the Hotspot VM has the JVMSPI_IsPrecompilationTarget available for embedded systems.
    Why can't SUN create an annotation to precompile, Ahead-of-Time (AOT), certain methods and all the code called up its object chain? It could be done after class loading and before execution or, an alternate annotation could request that the VM run a low priority thread to compile it. Perhaps with a order priority number. For my application, users often edit scores while CPU cycles sit idle. Ideally, developpers could interact programmatically, receiving a listener event when compilation is done. For my app, if a user presses play and compilation isn't done, the developper could inform the user "preparing for play" and increase the thread priority or at least wait for the "compilation done" event before proceeding. I don't know why SUN hasn't added this to the Java language and VM reference implementation yet. It would make GCJ and Excelsior JET redundant.
    The garbage collector is very well behaved at its low priority and because I use pools of permanent objects, reuse as much as possible. ( http://java.sys-con.com/read/37613.htm )
    -XX:CompileThreshold=# is useless to me.
    Unfortunately, Sun's Java Real Time environment is not available for Mac OS X.

    connections. The VM code (text) is loaded only once in
    mem by the OS. So would the precompiled classes,
    instead of going into the heap of every VM or
    something.Code implemented as native methods will also be in a shared library and will be shared among all VM instances that use that particular shared library implementation. Lots of the classes in the Java 2 Platform already have some/most/all of their implementation in the form of native methods.
    There's no real concept of shared objects for class files, though. In fact a class file, once compiled to machine code by the JIT, may not even result in the same machine code in more than one running VM. The VM needs to work with bytecode for class definitions in order to support class loaders, serialization, JIT compilation, class verification, and maybe other things too.
    I don't think the memory savings would really be that much. Java bytecode is pretty compact and classes are only loaded on-demand anyway.

  • Compile time Annotation Processing

    Is it possible to access the source of the file being analysed at compile time?
    Thanks

    Milesy wrote:
    Is it possible to access the source of the file being analysed at compile time?If you are naughty, you can try to find the file being processed and read it directly, but that is not supported.
    You can use the javac-specific tree API (http://java.sun.com/javase/6/docs/jdk/api/javac/tree/index.html) to map from a javax.lang.model.Element to a AST representing the source for a method or constructor.
    If you want the source for the purposes of modifying it, the annotation processing API is read-only, but much of the effect of mutating the source can be achieved by generating subclasses or the superclass of the class in question. Check the forum archives for details.

  • Odd compiler behavior with annotations

    Hi all,
    I apologize if this is the wrong forum, but the JDev code editor behavior is a significant part of this. I have an annotation type, TestParameters. If I write the following line:
    TestParameters params = (TestParameters) someClass.getAnnotation(TestParameters.class);then the cast is greyed out in the code editor, and code assistance tells me it's unnecessary. Since the signature of getAnnotation is
    <A extends Annotation> A getAnnotation(Class<A>)this is what I'd expect; I really shouldn't need that cast.
    However, if I take the cast out, although nothing is marked red in the code editor, I get a compiler error:
    Error(32,29): incompatible types; found: interface java.lang.annotation.Annotation,
    required: annotation annotation.TestParametersWhat's going on here? I'm 95% sure the code should compile without the cast.
    Thanks much,
    Avrom

    Aha! You're right, what it prints out is not what I'd expected:
    class $Proxy3I was using ojc, but javac gives the same results (including the compiler error: "incompatible types").
    Not entirely sure what's going on here...either the Javadoc for Class.getAnnotation() and the JDev code assistance is both wrong, or something odder is going on.
    Message was edited by:
    Avrom
    ha! Found the issue.
    http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=5104826
    (This was closed by Sun as not a bug.)
    The problem was that someClass was declared as type Class, rather than Class<?>. I guess my understanding of generics wasn't quite up to snuff; I'd been assuming that the declarations
    SomeType myObj;and
    someType<?> myObj;were identical, since you can't access the wildcard in the class containing myObj, but apparently the compiler doesn't see them that way. My bad.

  • Processing annotations without clean/compile?

    I am trying to process all classes that have an @Entity annotation, creating a list of these to be used in another part of the application. Because the annotation processor uses javac, it only seems to work on files that have changed. So, without either cleaning the output dir or touching all input files, the processor will find all @Entity annotated-classes the first time, but only changed ones on future runs. This means I cannot guarantee a complete list every run (without resorting to clean or touch, but that's not an acceptible solution because it is much slower).
    Some questions:
    1. Is the annotation processor only able to work on files that appear changed? This seems like bad design for the processor which is suppose to work with source code (i.e. it shouldn't care whether the class file is out-of-date, it should always process whatever source is there).
    2. Is there a better way to find all classes with a given annotation? Either at compile time or at runtime?

    I'm not a dev, but for what it's worth:
    I ran across almost the same case myself, and I imagine that the correct course is to maintain that list of annotations to be used elsewhere in a separate resource file, which would be generated on the first run and subsequently updated with whatever annotations the processor sees on those runs. My own processor is supposed to (that part is broken for now) use roughly this method for caching metadata gathered from an external source at annotation-processing time, by maintaining an .xml file that contains a "complete picture" of things.
    If there is more to it then I've missed something and I'm very eager to hear what that might be.

  • @SuppressWarnings annotation causing compiler error

    Anyone know why it is illegal to put a @SuppressWarnings annotation as shown in this example? I know this is a retarded example, and that you could just place the annotation on the method instead of inline with the code, so I am not looking for alternatives. I am just curious why it is illegal in the place shown.
    public class SuppressTest {
         public void addFoo(Object bar) {
              List list = (List<String>) bar;
              @SuppressWarnings("unchecked")
              list.add("foo");
    }

    Here is the correct way, to solve this problem. Maybe this makes clear, why the other way is not supported. The @SuppressWarnings affects only the definition of list.
    Anyway - you should be sure, that the cast, that is suppressed, is correct. And you cannot assure it in this special case, because everyone could call addFoo with nearly everything as parameter.
    public class SuppressTest {
        public void addFoo(Object bar) {
         @SuppressWarnings("unchecked")
         List<String> list = (List<String>) bar;
         list.add("foo");
    }Edited by: yawah on 10.12.2009 07:58

  • Questions on the @ServiceClient annotation and Asynchronous webservices

    1. Is their a way to invoke a webservice in an asynchronous manner without using the @ServiceClient annotation? I’ve tried a few things to get access to the async versions of the web methods and each time I get an exception stating “java.rmi.RemoteException: Asynchronous methods can only be invoked from stubs with the ServiceClient annotation”.
    2. Is their anyway to generate a dynamically sized array of service port variables with the @ServiceClient annotation? All the examples that I have seen only have a single port variable annotated with @ServiceClient. I’ve tried creating a class that uses the @ServiceClient annotation, and while it does compile it fails when I try to invoke the services methods. I also found in some documentation a restriction that the @ServiceClient annotation can only be used in the core java (jws) webservice class.
    3. Is their a way to use a single service port variable with the @SeriviceClient annotation to invoke multiple calls to an asynchronous web method if that web method is part of a conversation? When I tried this I found that even though the asynchrounous calls were going out with any problems they were being processed serially on the target services side (I assume due to the conversation).
    The problem I am trying to solve is I need to invoke a stateful webservice in an asynchronous manner multiple times from the same starting service.

    Hi
    That is how I understand that document:
    Locking: Forms, by default, locks a row as soon as the user starts modifying the data. That is pessimistic locking. Apex, on other hand (and optionally forms also) do not lock the record, but before applying any changes checks if the data has changed since the user queried it (what for some reason is called optimistic "locking")
    DB connections: I am not sure why they used the terms synchronous/asynchronous, but the difference is that Forms, by default, keeps an permanent DB connection while the user is using the application, while Apex gets a connection from a connection pool every time a page is requested/submitted.
    Architecture: Forms (in its web version at least) has 3 tiers: the browser, the appserver where the forms service runs and the database. As Apex runs inside the database, there are only 2 tiers: the browser and the database (though you still may need an http server in between which serves static content, I don't think it is considered part of the application in this context). If you are talking about client/server forms, then there are only 2 tiers.
    I hope this helps!
    Luis

  • Custom Annotation :: inject object at runtime

    I would like develop a custom annotation to inject object at runtime. The annotation will work as follows
    1. develop ValidatorClass annotation on type.
    2. If annotated on a type object will be created at runtime and injected to the object. e.g. in class A it will inject validatorimpl object to vald object/
    Please let me know how to implement that.
    package com.debopam.validate
    public interface validator{
    public String validate();
    package com.debopam.validate
    public class validatorimpl implements validator{
    public String validate(){
       return "true";
    pckage com.debopam
    public class A{
    @ValidatorClass(name="com.debopam.validate.validatorimpl")
    validator vald;
    }

    yogeshd,
    It might be that the .class file for the annotation that you are compiling against is the one you have given us the source code for above, but when you run the program, the class file for the annotation is not the same, and is one that was compiled before you added the static field.
    This can happen if your classpath is wrong. (and would explain why the problem only occurs sometimes - because it is only failing when the classpath is wrong).
    If you run the following program with the Fully qualified name of your annotation as the argument, and with the same classpath as you run your program, it can tell you where it is finding the annotation class file. Check that this is the same one that you are compiling to.
    class WhereLoaded {
        public static void main(String[] args) {
            Class theClass=null;
            if(args.length > 0) {
                try {
                    theClass=Class.forName(args[0]);
                } catch (Exception e) {
                    e.printStackTrace();
                    theClass=Object.class;
            } else {
                System.out.println(
                    "The first argument should be a fully qualified class name," +
                    " using java.lang.Object instead"
                theClass=Object.class;
            String name=theClass.getName();
            name=name.substring(name.lastIndexOf(".")+1) + ".class";
            System.out.println(name + " loaded from " + theClass.getResource(name));
    }regards
    Bruce

  • @Resource annotation does not work for XA resource?

    Okay, sounds absurd that it works for everything except XA, but that is all I have to go with for now. We are moving from EJB2.x to EJB3 and I am encountering an issue when using the @Resource annotation for an XA connection factory. See deployment exception at bottom of post.
    First, I deploy my-aqjms-jms.xml which contains two connection factories (sorry, I do not know the equivalent "pre" tag for this board so all formatting is lost):
    <weblogic-jms>
    <foreign-server name="MY-AQJMS-JMS">
    <foreign-connection-factory name="ForeignConnectionFactory-0">
    <local-jndi-name>my/jms/QCF</local-jndi-name>
    <remote-jndi-name>QueueConnectionFactory</remote-jndi-name>
    </foreign-connection-factory>
    <foreign-connection-factory name="ForeignConnectionFactory-1">
    <local-jndi-name>my/jms/XAQCF</local-jndi-name>
    <remote-jndi-name>XAQueueConnectionFactory</remote-jndi-name>
    </foreign-connection-factory>
    <initial-context-factory>oracle.jms.AQjmsInitialContextFactory</initial-context-factory>
    <jndi-property>
    </jndi-property>
    </foreign-server>
    </weblogic-jms>
    Next, I look at my ejb-jar.xml:
    <session>
    <description>My EJB</description>
    <ejb-name>MyEJB</ejb-name>
    <ejb-class>demo.MyEJB</ejb-class>
    <session-type>Stateless</session-type>
    <transaction-type>Container</transaction-type>
    <resource-ref>
    <description>connection factory</description>
    <res-ref-name>jms/myQCF</res-ref-name>
    <res-type>javax.jms.QueueConnectionFactory</res-type>
    <res-auth>Container</res-auth>
    <res-sharing-scope>Shareable</res-sharing-scope>
    </resource-ref>
    <resource-ref>
    <res-ref-name>jms/myXAQCF</res-ref-name>
    <res-type>javax.jms.XAQueueConnectionFactory</res-type>
    <res-auth>Container</res-auth>
    <res-sharing-scope>Shareable</res-sharing-scope>
    </resource-ref>
    </session>
    These are the resource tags I want to move into annotations. (There are matching tags in weblogic-ejb-jar.xml which map "jms/myQCF" to "my/jms/QCF" and same for XAQCF). So, I open demo.MyEJB and add the annotation for the first one:
    @Stateless(name="MyEJB")
    @Resources({
    @Resource(description="connection factory",
    name="jms/myQCF",
    type=javax.jms.QueueConnectionFactory.class,
    authenticationType=Resource.AuthenticationType.CONTAINER,
    shareable=true,
    mappedName = "my/jms/QCF"),
    I remove the resource-ref tag for "jms/myQCF" in ejb-jar and weblogic-ejb-jar.xml but keep the one for "jms/myXAQCF", re-compile, re-package, re-deploy, and test. Everything seems to work fine. So, I open demo.MyEJB and add the annotation for the second connection factory:
    @Resource(description="XA connection factory",
    name="jms/myXAQCF",
    type=javax.jms.XAQueueConnectionFactory.class,
    authenticationType=Resource.AuthenticationType.CONTAINER,
    shareable=true,
    mappedName="my/jms/XAQCF"),
    I also remove the resource-ref tag for "jms/myXAQCF" in both *ejb-jar.xml's.  But now when I try to redeploy, I get the following exception:
    [EJB:011026]The EJB container failed while creating the java:/comp/env namespace for this EJB deployment.
    weblogic.deployment.EnvironmentException: [EJB:010176]The resource-env-ref 'jms/myXAQCF' declared in the ejb-jar.xml descriptor or annotation has no JNDI name mapped to it. The resource-ref must be mapped to a JNDI name using the resource-description element of the weblogic-ejb-jar.xml descriptor or corresponding annotation.
    If I comment the XAQCF annotation it will deploy again. I have since done the same annotation replacement for jms queues and jdbc resources. However, only this one XA connection factory is giving me trouble. Is this an issue in weblogic or is there something I am missing from the annotation?
    Thanks!

    Look like a bug in Appserver. XAResourceWrapper is
    used only for debugging. May be you want to reducethe
    log level to INFO and try it.Yeah, that worked.
    But this is a bug in the app server because a switch
    in the log level shouldn't influence transaction
    behavior.Yes. There is a bug when log level in FINEST. All other log levels should be fine. Please see the bug report at
    http://developer.java.sun.com/developer/bugParade/bugs/4973434.html
    >
    The only big issue I still have is that recovery
    doesn't work. See my other message in this forum. Do
    you have a solution for this?I have asked someone who knows that area well to answer your query.
    - Binod
    >
    -- Andreas

  • Syntax error: annotations are only available if source level is 5.0

    In eclipse, I am trying a hello world JMS tutorial.
    In the code below, it doesn't like the @ sign for some reason... And I don't know how to make it happy....
    It give this error:
    Syntax error: annotations are only available if source level is 5.0
    --------------code------------
    public class MessageSender {
       @Resource(mappedName = "jms/GlassFishBookConnectionFactory")
       private static ConnectionFactory connectionFactory;
    Here is my path if that helps.
    Path=C:\oracle\product\10.2.0\client_1\bin;C:\Program Files (x86)\Java\jre8\bin;c:\glassfish4\glassfish\bin;C:\Program Files (x86)\Java\jdk1.8.0\bin
    Thanks for any leads!
    Jim

    It give this error:
    Syntax error: annotations are only available if source level is 5.0
    That exception is telling you that the java compiler version being used to compile your java source is not 5.0 or later.
    Eclipse uses 'some' version of Java to run itself. And, by default, your java code will use that same version of java unless you configure it to use a different version.
    http://wiki.eclipse.org/Eclipse.ini#Specifying_the_JVM
    One of the most recommended options to use is to specify a specific JVM for Eclipse to run on. Doing this ensures that you are absolutely certain which JVM Eclipse will run in and insulates you from system changes that can alter the "default" JVM for your system. Many a user has been tripped up because they thought they knew what JVM would be used by default, but they thought wrong. eclipse.ini lets you be CERTAIN.
    Check the version of java that eclipse is using. Just because that version of java is not on your path doesn't mean eclipse isn't using it.
    Then repost your question in an eclipse forum.

Maybe you are looking for

  • Pin images in Full Screen Slideshow???

    I am using a full screen slideshow in Muse and it appears that all the images are proportionately resized with fill frame and pinned in the center. This means that if some of my images of people don't have the same general layout, some photos have he

  • Analyzer for Excel-Java heap space error

    When I click on Analyzer for Excel for a report I get the error java.lang.outOfMemoryError:java heap space. Does anyone know how to increase the JVM heap space? Thanks, Krishna.

  • Opening audio attachments

    I tried to listen to my Vonage voicemails through the Vonage website using my iPhone, I clicked on the link to open the file and I get an error from Quicktime saying "Cannot Play Movie. The server is not correctly configured". I also tried saving the

  • HT204088 can we send copy carbon of the billing to another email?

    can we ask to send a copy carbon to another email address, different email, not our email which used as apple id, for every billing they sent after we bought a song from itunes??

  • CE system load test monitoring

    While doing a load testing on CE facing an error with one application in the integrated Portal screen. Can anybody please guide  for what are all to be monitored from the Netweaver of CE and SAP MMC console. By the monitoring need to figure out what