how jaxb.index file handled by axis2? - jaxb

I am trying to add jaxb.index files to completely avoid the search for JAXB classes in my web service project and https://www.ibm.com/support/knowledgecenter/SSAW57_8.5.5/com.ibm.websphere.nd.multiplatform.doc/ae/cwbs_tuning_jaxbcontext.html says that " If the package does not contain any JAXB classes, an empty jaxb.index file must be placed in the package". My EAR file contains third party jars and my web service project as utility jar in which I put jaxb.index file properly.
My question is that Does JAXB.newInstance search all classpath in which has third party jars not containing jaxb classes?
If yes it doesn't make sense to put empty jaxb.index to all package of third party jar such as logging. Does it?

Related

create an .aar file without dependencies libs

I'm developing an android library which contains an external 3rd party library (for example: dagger).
I want to publish an .aar file to maven which not contains the dagger library inside. How can I create .aar file that doesn't contain any 3rd party libraries and contains only my code.
Another question, publishing .jar file instead of .aar file can solve this issue but there are any disadvantages is this solution?

Common Classes between portlet

I need to share multiple classes and properties file between portlets.
So I made a portlet Common-portlet, and in the rest of the portlets I made it as required development context in liferay-plugin-package.properties.
In eclipse, I also added the Common-portlet into the rest of the portlet's classpath.
After doing this eclipse shows no error.
But when I run the rest of the portlets it shows:
java.lang.NoClassDefFoundError: com/xxx/xxxxxxx/xxxxx/util/JSONUtil.
Is the approach above correct?
If yes then what I am lacking.
If no then what can be a better approach?
I would suggest create one separate java project and put all the common java file inside it and
extract the same as .jar file put it into tomcat-7.0.40\lib\ext and give a classpath refenerece from this directory or else in eclipse you can add this common project's reference all other portlet.

Jersey 2.5 not reading jaxb.properties

I am trying to get Jersey to use EclipseLink as its context factory, however, the file jaxb.properties is not being read. The docs say the file needs to be in the folder with the domain classes being mapped and I have verified that. I'm certain it is not being read because I have fubar'd the class name
javax.xml.bind.context.factory=org.eclipse.persistence.jaxb.JAXBContextFactoryXXX
No need to use jaxb.properties. Add a dependency to "jersey-media-moxy" using Maven. Jersey will automatically pick up MoxyXmlFeature (contained in the JAR) and then configure and use MoxyContextResolver to build new JAXB instances.
You may need to add an exclusion to the jersey-media-moxy dependency to avoid pulling in an unwanted version of the org.eclipse.persistence.moxy artifact.

Liferay - Share Utils class between 2 different portlets

I'm developing a Liferay application, consisting on 2 different portlets, an both have to make certain operations in common, so I decided to put that operations in static methods in an external Utils class.
I have to externalize that class to avoid duplicating the same code in both portlets, and I want to have the portlets in different WAR files.
I know I can package the Utils class in a JAR file, but we are still developing and we don't want to regenerate the JAR and restart the Tomcat for every change.
Which is the best option and how can I perform it?
If you're using the Liferay SDK, you can use the clients (recently changed to shared) directory to put your common code.
A good example is how deploy-listener-shared is used in conjunction with deploy-listener-hook.
From what it looks like, all the configuration you need to do is to modify your build.xml files that will use the client\shared classes. If you look at build file of deploy-listener-hook you can see all you need to add is the.
For the new SDK:
<property name="import.shared" value="my-utils-shared" />
For the older SDK:
<property name="dependent.clients" value="my-utils-client" />
Hope this helps!
There is another method that involves building a JAR file but it doesn't require a server restart (on Tomcat at least).
Write a build script for your JAR file so it compiles, builds the JAR and finally copies it to the following location:
{tomcat}/webapps/ROOT/WEB-INF/lib
Then in your portlet open the "liferay-plugin-package.properties" (in Liferay Developer Studio / Liferay IDE this should open with a nice GUI).
Then add the name of your JAR to the "portal-dependency-jars" list in this file so in the source it would like (Or just hit the "Add" button in the GUI and select the JARs you want):
portal-dependency-jars=my-custom-lib.jar,my-other-custom-lib.jar
Save the file, and redeploy the portlet, and the JAR will be copied across when the portlet is deployed.
I've used this method for custom JARs, and 3rd party JARs that I've needed to use in my portlets.
For the development phase just package the jar file with both applications.
Unless one application depends on the other somehow it is completely ok.
Another solution is to use JRebel tool. It will allow you to redeploy jar in tomcat without restarting.
Also you may have several portlets in one .war. You may just define them both in portlet.xml.

Lost JSF beginner: Linux, Geronimo and tag library

I use Geronimo with J2EE 5 and Tomcat 6 and I'm trying to create one simple page using JSF. I put the tag library files myfaces_core.tld and myfaces_html.tld in WEB-INF and it works, but just on Windows. Under Linux I got IOException with an unknown reason when I was deploying the WAR. To remove the two tag library files made the deploy possible. But then I got an error when I was opening the page in browser. It was missing the file WEB-INF/myfaces_html.tld, which is specified in the header of JSP file. In examples for MyFaces there is used not MyFaces TLD, but common Sun Java TLD. I have overwritten the URI WEB-INF/myfaces_html.tld to http://java.sun.com/jsf/html ant now I'm getting the error The absolute uri: http://java.sun.com/jsf/html cannot be resolved in either web.xml or the jar files deployed with this application.
I'm lost now. Must I or must I not put the tag library description files into my WAR to use JSF components? These files are already contained in MyFaces JARs in Geronimo Container, aren't? The container must have the same behavior regardless to platform or it needn't? What shall I do to create my simple application really platform independent?
You should not be extracting JAR files of 3rd party tag libraries and placing its loose TLD files in the /WEB-INF folder. The TLD files should be kept in the JAR files where they originate and the JAR files should be untouched and just be dropped in the runtime classpath. Whatever book/tutorial/forum is suggesting otherwise should be blacklisted.
Cleanup your project structure to get rid of those loose TLD files and undo every change related to this, for sure also in the web.xml, if any.
Your /WEB-INF/lib folder should contain just two files in order to get JSF to run on Tomcat 6: one file representing the abstract API and other representing the concrete implementation. As you've apparently chosen to use MyFaces, it'll be those two JAR files (probably with a version number at end of filename, that depends):
myfaces-api.jar
myfaces-impl.jar
Drop them in /WEB-INF/lib folder which is part of the webapp's default runtime classpath. That's all. Next step would be declaring and mapping the FacesServlet in your webapp's web.xml.
Ensure that you're reading the proper book/tutorial.

Resources