Showing posts with label Tomcat. Show all posts
Showing posts with label Tomcat. Show all posts

Tuesday, May 06, 2014

Azure : Deploying a Java web site to Azure

Well, who would ever think that the words "Azure" and "Java" would be used in the same sentence?

I'm not talking about the Azure VM here; rather the Azure web site option.

As Mrs. Beaton would say "First catch your rabbit". For Java, this becomes "First catch your .war file".

You can create a simple Java web site in either Eclipse or NetBeans - whatever floats your boat.

Work through the following documentation:

Get started with Azure web sites and Java

Adding an application to your Java web site on Azure

I used the "Create a Java web site using the Azure configuration UI" option.

OK, but when you display the web site URL, you get the "This Java based application has been successfully created". So where's my index.jsp?

From the dashboard of the Azure web site, you'll see the FTP address. I use FileZilla.

Before you can use this, you have to set the credentials. There's a link under "Quick Glance" called "Reset your deployment credentials". So set them.

Assume your web site is called MyJavaWebSite.

So to get FileZilla to work, you use the FTP URL from the dashboard page, your user name is:

MyJavaWebSite\username

and the password is whatever you chose.

On the LHS menu, navigate to your war file. On the RHS, navigate to:

/site/wwwroot/webapps

Copy the war file over.

Now navigate to the actual Azure web site URL. Still shows the canned screen.

So append  /MyJavaWebSite/index.jsp to the URL.

Bingo.

Enjoy!

Tuesday, November 16, 2010

Metro : Jax WS incompatibilities with Netbeans

Using Netbeans 6.9 and Tomcat 6 with JAX WS via Metro and Java JDK 6 on Windows.

The Tomcat installation is the one that is loaded as part of Netbeans.

When you try and invoke the web service, you get a string of errors e.g.

java.lang.NoSuchMethodError: javax.xml.ws.WebFault.messageName()Ljava/lang/String


The basic problem seems to be that the versions of JAX WS bundled with Netbeans / Java / Tomcat are incompatible.

(Metro provides JAX-WS 2.2 while Java SE includes JAX-WS 2.1. If you want to run Metro applications outside Tomcat, you will need to use the endorsed standards override mechanism. For more details see:

http://java.sun.com/javase/6/docs/technotes/guides/standards/index.html)

There are literally hundreds of articles etc. all over the web about how to fix this problem with tips about installing file x into the endorsed directory, the common/endorsed directory, updating Tomcat, updating Java etc. etc.

I tried a heap of them and none of the ones I tried fixed the problem. This is Google search at it's worst - tons of articles, all different, none of which appeared to work and utter frustration.

To complicate the issue, it you don't back out the failed change, you run the risk that the next change won't work because you didn't start from a known point.

To complicate things further, some of these changes partly work which means that next time you simply get a different error message and you have to start the process all over again.

Eventually, I went back to the source i.e. Metro and JAX WS.

I came across this article:

Creating a WSDL-first web service with Apache CXF or GlassFish Metro

which pointed me to:

Using JAX-WS 2.x / Metro 1.x/2.0 with Java SE 6

So, download Metro 2 - refer Metro 2.0

Ensure Netbeans and Tomcat are shut down.

Sort the zip file by path.

You do not need to extract all the files. You only need:

metro-on-tomcat.xml and all the jar files under /metro/lib and /metro/osgi.

Extract these to a directory.

Ensure you have ant installed.

Open a command prompt and navigate to the directory that you have just extracted the files to.

Type:

...\metro>set CATALINA_HOME=x:\Program Files\Apache Software Foundation\Apache Tomcat 6.0.26

i.e. the path where Tomcat 6 is installed

where ... is the directory that the files were extracted to.

Then run:

ant -f metro-on-tomcat.xml install


which produces:


Buildfile: metro-on-tomcat.xml

catalinahome-test:

init:

uninstall:

update-catalina-props:

test-api:

check-api:

install-api-tomcat5:

install-api-tomcat6:
[mkdir] Created dir: x:\Program Files\Apache Software Foundation\Apache Tomc
at 6.0.26\endorsed
[copy] Copying 2 files to x:\Program Files\Apache Software Foundation\Apach
e Tomcat 6.0.26\endorsed

install-api-tomcat:

install:
[echo] Installing Metro 2.0 FCS for x:\Program Files\Apache Software Founda
tion\Apache Tomcat 6.0.26 ...
[mkdir] Created dir: x:\Program Files\Apache Software Foundation\Apache Tomc
at 6.0.26\shared\lib
[copy] Copying 4 files to x:\Program Files\Apache Software Foundation\Apach
e Tomcat 6.0.26\shared\lib
[echo] ... installation complete.

BUILD SUCCESSFUL


The two files copied to the \endorsed directory are :

jsr173_api.jar and webservices-api.jar


The four files copied to the \shared\lib directory are:

webservices-extra.jar, webservices-extra-api.jar, webservices-rt.jar and webservices-tools.jar


In addition, the script updates catalina.properties in the \conf directory. It changes:

shared.loader=


to

shared.loader=${catalina.home}/shared/lib/*.jar


And that, believe it or not, is that!

Problem solved!

If you want to back the change out, run:

ant -f metro-on-tomcat.xml uninstall


For completeness, if you want to enable JAX-WS 2.2 for all applications running under Java SE 6, you may run the command:

ant install-api


That command will copy the file webservices-api.jar to ${java.home}/lib/endorsed.

(The command needs to be run by a user that has the permissions to copy files into ${java.home}/lib/endorsed.)

Note that I didn't need to do this.

Enjoy!

Thursday, November 11, 2010

Netbeans : Can't login to Tomcat as Admin or Manager

Using Netbeans 6.9 and Tomcat 6 - integrated with Netbeans.

When I go to the Tomcat server home page i.e. http://localhost:8084/

and then click on the Manager link, I am asked to login. But my login is not accepted! WTF?

The usual course of action is to go to the Tomcat installation which is usually something like:

...\Program Files\Apache Software Foundation\Apache Tomcat 6.0.26\conf

and edit the tomcat-users.xml file adding the lines:






but this login is not accepted.

Looked through the logs and noticed:

Using CATALINA_BASE: "...\Tmp\.netbeans\6.9\apache-tomcat-6.0.26_base"
Using CATALINA_HOME: "...\Program Files\Apache Software Foundation\Apache Tomcat 6.0.26"


where the Tmp directory is my Netbeans work directory.

You have to edit the xml file in that directory NOT the one in the "Program Files" tree.

Then found an easier way.

Click on the Server tab in Netbeans, then right click Tomcat and click Properties.

Click the Connection tab.

The credentials in that tab are what you have to use. It's normally ide and some random password which you can change.

Note that the CATALINA_BASE and CATALINA_HOME settings appear in this tab as well.





Enjoy!

Wednesday, June 17, 2009

Eclipse : Debugging web services and servlets

Been playing with this kind of stuff (Eclipse / Tomcat / Axis2 / jsp / servlets) and came across two good links that explain how to do it all!

How to Debug a Web Service?

and

Debugging a servlet with tomcat and Eclipse tutorial.

Enjoy!

Thursday, December 04, 2008

Java : Tomcat / Eclipse and Axis2

I needed to develop a Java web service that ran inside Tomcat and used Axis2 as the web server component.

I use Eclipse as my Java IDE and was looking around for plug-ins that would automate and simplify the whole process.

Came across this excellent tutorial - Developing Web Services Using Apache Axis2 Eclipse Plugins - Part 1

This uses two Eclipse plug-ins:

Apache Axis2 Service Archive Generator Wizard and
Apache Axis2 Code Generator Wizard

which generate the proxies and then wrap everything up for deployment to Tomcat.

I highly recommend working through the tutorial and then using that knowledge to develop and deploy your own.

Enjoy!