Pessoal
Criei um projeto web com uma servlet e gostaria de abrir este projeto no meu tablet android.
O projeto web é aberto normalmente no browser do pc (com o servidor jetty), mas no tablet dá erro:
UnavaliableException: Servlet Not Initialized
Um detalhe que notei é que apesar de no pom.xml haver o comando para gerar o classes.dex ele não está sendo gerado (colocado no war final)
Será que isto pode estar causando o erro acima?
Pom.xml
[code]<?xml version="1.0"?>
4.0.0
org.example
hello-world
0.1-SNAPSHOT
war
Jetty HelloWorld
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.5</source>
<target>1.5</target>
<verbose>false</verbose>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.1</version>
<executions>
<!-- Convert the compiled classes into a clases.dex. -->
<execution>
<id>generate-dex</id>
<phase>process-classes</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>${android.home}/${android-platform}/tools/dx</executable>
<arguments>
<!--<argument>-JXmx1024M</argument>-->
<argument>--dex</argument>
<argument>--verbose</argument>
<argument>--core-library</argument>
<argument>--output=${project.build.directory}/classes.dex</argument>
<argument>--positions=lines</argument>
<argument>${project.build.directory}/classes/</argument>
</arguments>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>copydex</id>
<phase>process-classes</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<tasks>
<mkdir dir="${project.build.directory}/${project.artifactId}-${project.version}/WEB-INF/lib"/>
<jar basedir="${project.build.directory}"
update="true"
includes="classes.dex"
destfile="${project.build.directory}/${project.artifactId}-${project.version}/WEB-INF/lib/classes.zip"/>
</tasks>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
org.eclipse.jetty
jetty-server
${jettyVersion}
<dependency>
<groupId>com.google.android</groupId>
<artifactId>android</artifactId>
<version>${googleVersion}</version>
</dependency>
[/code]
Servlet:
[code]public class HelloServlet extends HttpServlet {
String proofOfLife = null;
/* ------------------------------------------------------------ */
@Override
public void init(ServletConfig config) throws ServletException {
super .init(config);
//to demonstrate it is possible
Object o = config.getServletContext().getAttribute(
"org.mortbay.ijetty.contentResolver");
android.content.ContentResolver resolver = (android.content.ContentResolver) o;
android.content.Context androidContext = (android.content.Context) config
.getServletContext().getAttribute("org.mortbay.ijetty.context");
proofOfLife = androidContext.getApplicationInfo().packageName;
}
@Override
protected void doGet(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
response.setContentType("text/html");
ServletOutputStream out = response.getOutputStream();
out.println("<html>");
out.println("<h1>Hello From Servlet Land!</h1>");
out.println("Brought to you by: " + proofOfLife);
out.println("</html>");
out.flush();
}
}[/code]