Could AAR archive contain compiled classes? - axis2

is it possible to have compiled classes inside AAR file?
archive.aar
+-META-INF/ (wsdls + service.xml)
+-com/example/GeneratedArtifactFromWSDL.class
My question is, whether other classes in different classes could use those generated classes if archive.aar is on classpath. And second question, is Axis able to handle such archive? Or is my only way to generate 2 archives - aar with wsdls and service.xml and jar with compiled classes?

It's normal to include compiled classes specific to a service in the AAR file for the service. It's done exactly as in your example. When Axis2 runs your service, it provides a classloader that can access the contents of the AAR.
Here is some documentation on the layout of AAR files.

Related

How to use a JAR file in IntelliJ after downloading?

I want to use the import javax.ide in IntelliJ, specifically exploring MetaClass and seeing what it can do. I've downloaded the JAR (198) from https://download.oracle.com/otndocs/jcp/standard_extension_ide-1.0-fr-oth-JSpec/, and I know I'm supposed to somehow add it to dependencies under Project Settings -> Modules -> Dependencies, but I'm not sure what exactly I'm supposed to add from the downloaded folder. The folder containing javax/ide itself is somewhat buried, but I tried adding different levels of directories and none of them worked. The actual folder doesn't even contain java files, it contains a bunch of htmls so I might just be downloading the wrong thing. Thanks for the consideration
I've downloaded the JAR (198) from
It is not a JAR. This is a .zip archive and it does not contain compiled classes in a form of a JAR. It has only source files.
If you are working with a JAR - you need to add such a jar file which contains the needed for your classes into the module's dependencies.
If you do not have the JAR but only have sources - you can create a separate module from these sources and then use it as a module dependency to the module where you want to use these classes.

Deploy struts project in embeded jetty

I'm embedding jetty in my application, the structure of the folder tree is:
|--lib
|--WebRoot
|---WEB-INF
|---lib
what I wonder is---where should I put the struts2 libs(e.g. struts2-core-2.2.3.1.jar, xwork-core-2.2.3.1.jar), and what about the servlet related api(e.g. servlet-api-2.5-6.1.11.jar, jasper-compiler-5.5.15.jar api)?
should I place jars in the top lib folder or in the lib folder inside WEB-INF?
This is really entirely up to how you want to structure your app, if you are embedding you don't have to follow a traditional webapp approach where you have a war file (exploded or not) and its convention of libraries under WEB-INF as in your example with a web.xml, you can skip the idea of a webapp deployer entirely and just build out the handler change yourself and register the servlets in java code, take a look at some of the embedded examples we have:
http://git.eclipse.org/c/jetty/org.eclipse.jetty.project.git/tree/example-jetty-embedded/src/main/java/org/eclipse/jetty/embedded/ManyServletContexts.java
There are other examples in there as well, if you are embedding then unless you need to deploy wars you don't have to muck with that aspect of things. If you do need to deploy wars then you put things where the would be in any normal usage of a servlet container, things for just that war in the WEB-INF/lib and things in the system classloader back in your main primary classpath.

Can Struts 1.x Resource Bundles be placed elsewhere than the classes directory?

This is for Struts 1.x (I'm using 1.3.10).
I've noticed that Struts is unable to pick up resource bundles in the ApplicationResources.properties file if it is not placed somewhere in the default classpath (e.g., com.abc.SomePackage).
For instance, if I put the ApplicationResources.properties file in a custom folder /WEB-INF/strutsResources and configure the struts-config.xml thus:
<message-resources parameter="/WEB-INF/strutsResources/ApplicationResources"/>
I've read that the resources need to be on the classpath so I've also tried adding the /WEB-INF/strutsResources folder to the classpath. It still does not pick up the resource keys.
I've double-checked that the strutsResources folder is actually deployed to the server (I'm using Glassfish v3), so the file is there, it's just not being parsed.
P.S.
If you're wondering why I'm trying to do this, I just wanted to organize my code a little better ("better," IMO). Since the ApplicationResources.properties file is not really a class, I wanted to place it in a resources folder by itself.
I've checked that placing the ApplicationResources file in a package in the src directory works just fine.
Ultimately, the answer is yes. You can play some interesting games by configuring a custom className and/or factory and get messages however you want (including from a database) and so on. This allows you to customize whatever you want*.
I agree the resources aren't a class, but putting them on the classpath is a common practice, and allows resources to be loaded as a resource, e.g., from inside a jar. I'm sympathetic, but I'd leave it as-is.
*Like reversing all the text; a fun prank to play on your co-workers and QA department.
Its best leave it on the classpath.
It's stadard practise to include properties files on the classpath, especially if you're planning on packaging it up in your WAR/EAR. You're keeping it under WEB-INF so you gain no benefit from moving it off the classpath, and you'll just confuse other developers who have to work on the project and you've had to put a hack in to make this work.
If you want to keep your files external to your deployable WAR/EAR then that's a valid reason for not using the classpath. Typically this will require some configuration as part of your deployment to specify where the file is to reside.
For example specify the location using
a JVM argument (e.g. -Dprops.file=/config/myapp.properites)
lookup from a JNDI resource
use a PropertiesFactoryBean if you're using the Spring framework (I
use Spring's ApplicationContext with Struts 1 MVC)
read properties from a database writing your own
ApplicationPropertiesDAO class that initialises itself durnig your
applications bootstrap process (e.g. Spring application contact,
Servlet in web.xml, Listener in web.xml, etc)

What are some Maven project naming conventions for web application module?

When creating a project with the webapp archetype in Maven, they subtly advise not putting any Java source in the webapp project by not including the "src/main/java" folder.
What do you name your Maven projects?
project-webapp for the project that contains the JSP, CSS, Images, etc.
project for the project that contains domain specific entities
? for the project that contains the web application files like Servlets, Listeners, etc.
My first inclination would be to use "webapp" for the project containing the web application files (Servlets/Listeners), however the archetype uses "webapp" to convey the JSP/CSS/Images project and would cause confusion to other developers.
When creating a project with the webapp archetype in Maven, they subtly advise not putting any Java source in the webapp project by not including the "src/main/java" folder.
That's not really true. When you create a project with the maven-archetype-quickstart, you don't get a src/main/resources directory. Would that mean you should not put resources in this project? No.
What do you name your Maven projects?
There is no general rules, nor conventions. Use something that makes sense for your organization and your team. But as I said above, your initial assumption is not true and putting Java code inside a maven war module is a common practice (except for code you want to share between modules).
Not sure if this below link directly answers your question, but it makes sense to refer it
Refer their JIRA task here Document the naming convention for archetypes
As per this, the naming convention can be as below
The Artifact id of the archetype should be of the format -archetype-
Ex: + maven-archetype-quickstart : Which indicates the archetype is from maven and the project is a quick start
Same way you scala-archetype-simple : Which indicates it is from scala and is a simple scala project
Best of luck

Include one Maven assembly inside another?

My project generates 3/4 assemblies, 3 jars and 1 war.[I need to use assemblies itself]
I need to include 2 of these assembly jars into my war.
How can I ensure that before assembly war creation , other 2 jars are created ?
Please respond
You have three choices:
define all the assembly executions in one plugin configuration, and order them as needed.
See this answer for more details.
Define an earlier phase for your jar assemblies so that they have all been packaged before the war is packaged.
Move the jar content into separate projects and specify them as dependencies of the war project so they are packaged automatically. This is the "Maven way" of handling this. It would also allow you to potentially reuse the jars in other wars.
I'd recommend option 3 myself, but the other two should both work.