Jar to include to use javax.annotation.* - ejb

I'm a bit confused. I need to compile a project in jDeveloper 11.1.1.6.0. The server side of the project is deployed on the Glassfish server. On the machine of the project's creator everything compiles without any problems.
Using project properties -> Libraries and Classpath I added the libraries such as gf-client.jar, security etc. from $glassfish_home/glassfish/modules and some others (e.g. hibernate3.jar from hibernate dir).
When I try to compile the project I receive the following errors:
package javax.annotation.security does not exist
and
package javax.persistence does not exist.
I suppose that I miss some jars to include. I tried to find which jars (from Glassfish or from JDK) contain javax.annotation.* and javax.persistence.* but I couldn't.
If you have any ideas I would be thankful!

I was having the same problem and was able to solve it by adding a couple of dependencies to the Maven pom.xml file. See this answer for more details.

So I found the source of the problem. The application consists of 2 projects, of which only one (mentioned in the question) uses EJB. I'm not sure if it is the way it should be, but I tried adding ejb-files to another project. And after clean all and rebuild all it compiled like a charm for me. I hope this will help somebody in the future.

Related

Is there a direct way to get a full ejb/servlet application example for glassfish

I have an application that is currently running on JBoss AS but does not work on Glassfish. I'm trying to work through the documentation here but I'm having trouble figuring out things like what the file structure of the application should be and what (if any) additional files are needed. This documentation also refers to examples but to get the examples you need to install Netbeans and access an update tool tied to the glassfish instance installed with Netbeans. When I do this the server won't start, the update tool won't run, and I can't get the examples. Is there an easy way to get these examples (e.g. a simple download)? I've found other examples such as this one, but they are also dependent upon Netbeans.
Is there a simple and complete ejb/servlet example for Glassfish that can be simply downloaded and does not depend upon Netbeans or other IDE?
The obvious example is the Java EE CargoTracker. It was written to show what a "real" application might look like with pure Java EE APIs so should work on both JBoss and GlassFish. You will need Maven installed to build and run it, but there are more complete details in the readme for the project. Note that some of the information is a little out of date (mostly links to java.net which has been sunset in favour of a GitHub site) but the application itself is still a good example of Java EE 7 APIs.
https://github.com/javaee/cargotracker
I found the examples on github here:
https://github.com/javaee/glassfish-samples
To get and build the examples you will need Git and Maven. These examples are small, complete, and concise. The example that was helpful for my particular problem was this example:
glassfish-samples\ws\javaee5\enterprise\servlet-stateless-ear
It demonstrated that I needed to change the structure of my project such that the servlet was in a .war file and not in a .jar file in the lib folder of my project.

TeamCity won't build with NUnit class library

I have a .NET solution set up that has the main ASP MVC project and then a class library project that has had NUnit added to it for unit tests.
When I build the solution in TeamCity the main project builds fine but then when the test project builds I get these errors
error BC30002: Type 'TestFixture' is not defined.
error BC30002: Type 'Test' is not defined.
error BC30389: 'System.Diagnostics.Assert' is not accessible in this context because it is 'Friend'.
I assume it can't find the NUnit.dll or something but the dll is in the solution packages folder. I've tried doing package restore first in case it was that but it still did the same.
Update
Ok, just to test it I added Moq to the project to see if it would pick up the references. It did and worked fine, it seems to be only problem when I try to use NUnit functions. I could disable it from building but surely the NUnit tests won't be picked up in Team City?
Thanks!
Finally fixed the issue and it was my own stupid mistake. Thanks to DevOps for suggesting going through the MSBuild logs, it helped my track down the problem.
The actual DLL wasn't getting checked in to source control because the dev machine that added the test project had a global ignore file to ignore all DLL's. So I thought it was there but it was just the .xml file and I mis read it.
Anyway it now builds and runs the tests.
Thanks for the help everyone

How to / where to find info on JBoss client dependencies? Any documentation?

It may be pretty basic question. But no luck Googling.
I was going through this URL. Because I had an issue accessing EJBs deployed on JBoss. After following this, it worked. Mainly this line.
jboss-ejb3-client.jar, jboss-aop-jdk50-client.jar, jboss-aspect-jdk50-client.jar and jbossall-client.jar -
all these .jar files are found in client folder of JBoss installation directory
But for a newbie of EJBs like me, this is following the steps without understanding the dependencies. So my question, can we find documentation like this somewhere? How do we know the jars we need to copy to client application classpath?
jbossall-client.jar for JBoss 4.X is enough - it contains all needed libraries.
For JBoss 5.X the story is more difficult - you need to reference in your project only jbossall-client.jar, but inside this JAR there are no actual classes, only MANIFEST file, which lists needed dependencies.
So, on JBoss 5, you need to have jbossall-client.jar added to classpath of your client plus all listed JARs lying next to it. Crazy, isnt't it?
JBoss 7 has sane approach. There is bin\client\jboss-client.jar that contains all dependencies needed by clients.

Received a main jar file with other jar files that need to be in the classpath. Whats the best way to include this main jar in my maven project?

So i received a java api from a client and the main code is in main.jar. But the instructions he gave me require me to add these other jars (a.jar, b.jar, etc..) into the classpath whenever I want to use main.jar. These other supporting jars are things like Xerces, jakarta-oro, and a few other publicly available libraries. The problem is i don't know what versions they are, so i'm not sure if there would be issues if i just update the pom.xml file in my app to depend on main.jar and also have dependencies to these other jars as well with the latest versions of them.
Whats the best strategy for using main.jar in my maven application? I'm planning on adding main.jar to our internal maven repository, but what should i do about the xerces, jakarta-oro, and other jars when i dont know what versions they are?
Thanks
If you are lucky the file /META-INF/MANIFEST.MF inside a.jar, b.jar etc. contains an entry "Implementation-Version" or some other useful information which tell you what version they are. If not, you can download the latest release(s) from the project web site and check if they have the same file size as your bundled dependencies.
You may also come to the idea to bundle the dependencies with the main.jar in one big jar, but this may become funny, when you have the dependencies twice in your classpath at some point in the future...
What about just asking the client what version numbers this dependencies have?
If you don't have any information about these third-party libraries, just add them to src/resources/META-INF/lib and commit to SVN. That's the best way, if we're talking about black box approach.

Flex Mojo Maven Compile Question

I am trying to get the flex mojos maven compiler to run my projects.
Anyone with feedback on the below information is appreciated.
I am using this configuration for the maven compiler plugin and for
some reason every time I run the clean install on my SWF project I
still see the following in the compile step for the app.
info.rvin.mojo
flex-compiler-mojo
true
true
-compiler.accessible=false
-compiler.actionscript-file-encoding UTF-8
-compiler.allow-source-path-overlap=false
-compiler.as3=true
-compiler.debug=false
That means I can not connect to my app via the Flex Builder's debug
tool. Any thoughts on how I should properly configure the plugin in
the pom.xml?
Thanks!
adam, we're just starting to build out the chapter on flexmojos in Maven: The Definitive Guide. For starters, use the new plugin groupId, artifactId that is listed in that chapter. velo moved the flexmojos project over to the Sonatype Forge a few months ago, and we're just getting the 3.0 release out.
To anyone out there reading this: remember Maven is a build tool; it only (typically) executes (parts of) your code as a consequence of executing the tests you've implemented.

Resources