Java Wicket resource issue - java

Im working on a web app where we keep the code and web resources (such as css, image files etc) separated.
I have a file located here:
project root/src/main/webapp/images/icons/16/add.png
And in this location:
project root/src/main/java/se/su/dsv/scipro/icons
I have a class like so:
package se.su.dsv.scipro.icons;
import org.apache.wicket.ResourceReference;
import org.apache.wicket.behavior.AttributeAppender;
import org.apache.wicket.markup.html.image.Image;
import org.apache.wicket.model.Model;
public class ImageIcon extends Image {
private static final long serialVersionUID = 1L;
public static final String ICON_NEW_ADD = "../../../../../../webapp/images/icons/16/add.png";
public ImageIcon(String id, String name, String size, String alt){
super(id, new ResourceReference(ImageIcon.class, name));
if(alt != null){
add(new AttributeAppender("alt", true, new Model<String>(alt), " "));
}
else {
add(new AttributeAppender("alt", true, new Model<String>(name), " "));
}
}
public ImageIcon(String id, String name){
this(id, name, "", null);
}
public ImageIcon(String id, String name, String alt){
this(id, name, "", alt);
}
public static ResourceReference getImage(String imageName, String imageSize){
return new ResourceReference(ImageIcon.class, imageName);
}
}
But when I use this class somewhere in a panel or a page, e.g. like this:
add(new ImageIcon("new_add", ImageIcon.ICON_NEW_ADD));
I get the following exception:
2011 Oct 18 11:11:17,947[ERROR] - RequestCycle - Can't instantiate page using constructor public se.su.dsv.scipro.basepages.DemoPage(org.apache.wicket.PageParameters) and argument
org.apache.wicket.WicketRuntimeException: Can't instantiate page using constructor public se.su.dsv.scipro.basepages.DemoPage(org.apache.wicket.PageParameters) and argument
at org.apache.wicket.session.DefaultPageFactory.createPage(DefaultPageFactory.java:212)
at org.apache.wicket.session.DefaultPageFactory.newPage(DefaultPageFactory.java:65)
at org.apache.wicket.request.target.component.BookmarkablePageRequestTarget.newPage(BookmarkablePageRequestTarget.java:298)
at org.apache.wicket.request.target.component.BookmarkablePageRequestTarget.getPage(BookmarkablePageRequestTarget.java:320)
at org.apache.wicket.request.target.component.BookmarkablePageRequestTarget.processEvents(BookmarkablePageRequestTarget.java:234)
at org.apache.wicket.request.AbstractRequestCycleProcessor.processEvents(AbstractRequestCycleProcessor.java:92)
at org.apache.wicket.RequestCycle.processEventsAndRespond(RequestCycle.java:1250)
at org.apache.wicket.RequestCycle.step(RequestCycle.java:1329)
at org.apache.wicket.RequestCycle.steps(RequestCycle.java:1436)
at org.apache.wicket.RequestCycle.request(RequestCycle.java:545)
at org.apache.wicket.protocol.http.WicketFilter.doGet(WicketFilter.java:486)
at org.apache.wicket.protocol.http.WicketFilter.doFilter(WicketFilter.java:319)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter.doFilterInternal(OpenEntityManagerInViewFilter.java:113)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Thread.java:662)
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at org.apache.wicket.session.DefaultPageFactory.createPage(DefaultPageFactory.java:188)
... 27 more
Caused by: java.lang.IllegalArgumentException: Invalid path ../../../../../../webapp/images/icons/16/add.png
at org.apache.wicket.util.lang.Packages.absolutePath(Packages.java:105)
at org.apache.wicket.util.lang.Packages.absolutePath(Packages.java:44)
at org.apache.wicket.markup.html.PackageResource.<init>(PackageResource.java:504)
at org.apache.wicket.markup.html.PackageResource.newPackageResource(PackageResource.java:448)
at org.apache.wicket.markup.html.PackageResource.get(PackageResource.java:424)
at org.apache.wicket.ResourceReference.newResource(ResourceReference.java:304)
at org.apache.wicket.ResourceReference.bind(ResourceReference.java:151)
at org.apache.wicket.markup.html.image.resource.LocalizedImageResource.bind(LocalizedImageResource.java:180)
at org.apache.wicket.markup.html.image.resource.LocalizedImageResource.setResourceReference(LocalizedImageResource.java:246)
at org.apache.wicket.markup.html.image.Image.setImageResourceReference(Image.java:178)
at org.apache.wicket.markup.html.image.Image.<init>(Image.java:101)
at org.apache.wicket.markup.html.image.Image.<init>(Image.java:77)
at se.su.dsv.scipro.icons.ImageIcon.<init>(ImageIcon.java:83)
at se.su.dsv.scipro.icons.ImageIcon.<init>(ImageIcon.java:93)
at se.su.dsv.scipro.basepages.DemoPage.<init>(DemoPage.java:16)
... 32 more
I guess it is because the image file resides outside any Java package? How can I address this?

Use a ContextRelativeResource. With it, the path to the image will be considered relative to the context root.
For instance, if you'd show this image with the following HTML:
<img src="images/icons/16/add.png">
Use the following:
new Image("add", new ContextRelativeResource("/images/icons/16/add.png")))
You might also find this blog post useful.
There's no ResourceReference version of this variant that I'm aware of, although you can try to integrate the one attached in this JIRA issue: WICKET-790

Related

xCP2.0 Java Service not working - IDfSession is null

I'm currently working on a xCP 2.0 project with Documentum 7.0 and I'm trying to run a Java Service inside a workflow. The Java Service works alright when the function I use does no more than return a "some_string" String. But as soon as I try the actual thing and use documentum specific Objects like:
IDfSession mySession = getSession();
I get these exceptions right here:
java.lang.RuntimeException: Could not invoke the method 'test' from
interface 'class com.gemp1.Test' from BOF module 'gemp1_xCPJava' in
Process Template: 'Peticion de Nuevo Producto v2' - Activity: 'Execute
Java Service'. Workitem: '4a015abd80004959' Workflow: 'Peticion de
Nuevo Producto v2 2014-12-18' - '4d015abd8000411e' Activity: 'Execute
Java Service' - '4c015abd8002e358' Process: 'Peticion de Nuevo
Producto v2' - '4b015abd8002c56c' java.lang.Exception:
java.lang.RuntimeException: Could not invoke the method 'test' from
interface 'class com.gemp1.Test' from BOF module 'gemp1_xCPJava' at
com.documentum.bps.outbound.AbstractService.execute(AbstractService.java:98)
at
com.documentum.bpm.services.BPSIntegrationFramework.executeService(BPSIntegrationFramework.java:260)
at
com.documentum.bpm.services.BPSIntegrationFramework.executeMethod(BPSIntegrationFramework.java:92)
at
com.documentum.bpm.services.BPSIntegrationMethod.executeMethod(BPSIntegrationMethod.java:26)
at
com.documentum.bpm.rtutil.GenericWorkflowMethod.execute(GenericWorkflowMethod.java:129)
at
com.documentum.bpm.rtutil.GenericWorkflowMethod.execute(GenericWorkflowMethod.java:355)
at
com.documentum.bpm.rtutil.GenericWorkflowMethod.execute(GenericWorkflowMethod.java:70)
at com.documentum.mthdservlet.DfMethodRunner.runIt(Unknown Source)
at com.documentum.mthdservlet.AMethodRunner.runAndReturnStatus(Unknown
Source) at com.documentum.mthdservlet.DoMethod.invokeMethod(Unknown
Source) at com.documentum.mthdservlet.DoMethod.doPost(Unknown
Source) at
javax.servlet.http.HttpServlet.service(HttpServlet.java:637) at
javax.servlet.http.HttpServlet.service(HttpServlet.java:717) at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at
org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:235)
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at
org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:190)
at
org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:92)
at
org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.process(SecurityContextEstablishmentValve.java:126)
at
org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:70)
at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at
org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158)
at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:330)
at
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:829)
at
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:598)
at
org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Thread.java:662) Caused by:
java.lang.RuntimeException: Could not invoke the method 'test' from
interface 'class com.gemp1.Test' from BOF module 'gemp1_xCPJava' at
com.documentum.bps.outbound.bof.runtime.BOFClient.invokeMethod(BOFClient.java:121)
at
com.documentum.bps.outbound.bof.runtime.BofModuleService.executeServiceOperation(BofModuleService.java:133)
at
com.documentum.bps.outbound.AbstractService.executeServiceInternal(AbstractService.java:122)
at
com.documentum.bps.outbound.AbstractService.execute(AbstractService.java:79)
... 32 more Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597) at
com.documentum.bps.outbound.bof.runtime.BOFClient.invokeMethod(BOFClient.java:112)
... 35 more Caused by: java.lang.NullPointerException at
com.documentum.fc.client.DfSingleDocbaseModule.getSession(DfSingleDocbaseModule.java:58)
at com.gemp1.Test.test(Test.java:11) ... 40 more
My Java class:
package com.gemp1;
import com.documentum.fc.client.*;
import com.documentum.fc.common.DfException;
public class Test extends DfSingleDocbaseModule {
public String test() {
String result = "Hello12345";
return result;
}
public String[] getUsers() throws DfException {
String docbaseUsers[] = new String[200];
IDfCollection coll = null;
IDfSession mySession = getSession();
String myQuery = "select user_name from dm_user";
IDfQuery myDFQuery = new DfQuery(myQuery);
coll = myDFQuery.execute(mySession, IDfQuery.DF_QUERY);
int i=0;
while (coll.next()) {
docbaseUsers[i] = coll.getString("user_name");
i++;
}
return docbaseUsers;
}
}
And finally my javamodule file:
<?xml version="1.0" encoding="UTF-8"?>
<nsJavaModule:JavaModule xmlns:nsJavaModule="http://xcp.emc.com/javamodule" urn="urn:gemp1:com.emc.xcp.artifact.javamodule.category:Artifacts/Java Modules/xCPJava.javamodule" categoryId="com.emc.xcp.artifact.javamodule.category" name="xCPJava" label="xCPJava" implementationClass="com.gemp1.Test">
<implementationJars contentPath="content/modules/xCPJava.jar"/>
<implementationJars contentPath="content/modules/dfc.jar"/>
</nsJavaModule:JavaModule>
Am I missing something?

Amazon ec2 can't find org.apache.tomcat.dbcp.dbcp.BasicDataSource

I am trying to connect to MySQL service using the following code, but it cannot initialize the database class:
import org.apache.tomcat.dbcp.dbcp.BasicDataSource;
public class Database {
private static final String JDBC_DRIVER = "com.mysql.jdbc.Driver";
private static final BasicDataSource dataSource = new BasicDataSource();
static {
dataSource.setDriverClassName(JDBC_DRIVER);
dataSource.setUrl(ServerConfig.DB_URL);
dataSource.setUsername(ServerConfig.DB_USERNAME);
dataSource.setPassword(ServerConfig.DB_PASSWORD);
}
...
}
Here's the ServerConfig class:
public class ServerConfig {
public static final String DB_URL = "jdbc:mysql://localhost:3306/relay";
public static final String DB_USERNAME = "my_username";
public static final String DB_PASSWORD = "mypassword";
public static final boolean DEBUG = true;
}
Here's the stack trace:
java.lang.NoClassDefFoundError: Could not initialize class com.relayapp.server.database.Database
at com.relayapp.server.model.User.add(User.java:125)
at com.relayapp.server.request.AddUser.processRequest(AddUser.java:51)
at com.relayapp.server.request.RelayRequestServlet.doPost(RelayRequestServlet.java:55)
at com.relayapp.server.request.RelayRequestServlet.doGet(RelayRequestServlet.java:22)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:723)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:861)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:620)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Thread.java:745)
The user credentials seem to be correct, and I can run the mysql command successfully.
What am I doing wrong?
The problem was with the package org.apache.tomcat.dbcp.dbcp.BasicDataSource.
This answer helped fix it. Instead of the /usr/share/java folder, tomcat was in the usr/share/tomcat7 folder, and I ran the command:
sudo wget -O /usr/share/tomcat7/tomcat-dbcp-7.0.57.jar http://search.maven.org/remotecontent?filepath=org/apache/tomcat/tomcat-dbcp/7.0.57/7tomcat-dbcp-7.0.57.jar

NoSuchMethodError Exception for setEntity in ContainerResponseFilter

I am implementing a JAX-RS filter with CXF and I am trying to edit the Entity of the response. My filter's code is shown below
public void filter(ContainerRequestContext requestContext,
ContainerResponseContext responseContext) throws IOException {
String s = (String) responseContext.getEntity();
responseContext.setEntity(s + "an additional message");
}
The problem is that I am getting an NoSuchMethodError when I am running it.
Here is my Exception stack
javax.ws.rs.InternalServerErrorException: java.lang.NoSuchMethodError: javax.ws.rs.container.ContainerResponseContext.setEntity(Ljava/lang/Object;)V
at org.apache.cxf.jaxrs.interceptor.JAXRSOutInterceptor.handleWriteException(JAXRSOutInterceptor.java:385)
at org.apache.cxf.jaxrs.interceptor.JAXRSOutInterceptor.serializeMessage(JAXRSOutInterceptor.java:224)
at org.apache.cxf.jaxrs.interceptor.JAXRSOutInterceptor.processResponse(JAXRSOutInterceptor.java:154)
at org.apache.cxf.jaxrs.interceptor.JAXRSOutInterceptor.handleMessage(JAXRSOutInterceptor.java:85)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:271)
at org.apache.cxf.interceptor.OutgoingChainInterceptor.handleMessage(OutgoingChainInterceptor.java:77)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:271)
at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:121)
at org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:239)
at org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:223)
at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:203)
at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:137)
at org.apache.cxf.transport.servlet.CXFNonSpringServlet.invoke(CXFNonSpringServlet.java:158)
at org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(AbstractHTTPServlet.java:243)
at org.apache.cxf.transport.servlet.AbstractHTTPServlet.doPut(AbstractHTTPServlet.java:180)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:640)
at org.apache.cxf.transport.servlet.AbstractHTTPServlet.service(AbstractHTTPServlet.java:219)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Thread.java:722)
Caused by: java.lang.NoSuchMethodError: javax.ws.rs.container.ContainerResponseContext.setEntity(Ljava/lang/Object;)V
at com.my.oasis.filters.TestResponseFilter.filter(TestResponseFilter.java:20)
at org.apache.cxf.jaxrs.utils.JAXRSUtils.runContainerResponseFilters(JAXRSUtils.java:1675)
at org.apache.cxf.jaxrs.interceptor.JAXRSOutInterceptor.serializeMessage(JAXRSOutInterceptor.java:219)
... 27 more
What am I doing wrong? Is that meaning that the setEntity() method is defined in the API but is not implemented by the CXF Framework?
Thanks
Try implementing a CXF filter instead of direct JAX-RS filter. For that you will have to implement ResponseHandler interface.
Following is dummy code :
package com.question;
import org.apache.cxf.jaxrs.ext.ResponseHandler;
import org.apache.cxf.jaxrs.model.OperationResourceInfo;
import org.apache.cxf.message.Message;
/*
* Filter for Responses
*/
public class CustomOutfilter implements ResponseHandler
{
/*
* #param : arg0
*
* #param : arg1
*
* #param : arg2
*
* #return : Response
*/
#Override
public Response handleResponse(Message arg0, OperationResourceInfo arg1,
Response arg2)
{
//play with arg2 here and return it
return arg2;
}
}

InvocationTargetException - Call Rest service from java Soap webservice using httpClient

I am created soap webservice in my server. And I want to call other service(In another server) from my soap service using httpClient with "POST" method. I used "httpclient-4.2.2.jar" and "httpcore-4.2.2.jar".
Code snippet:
public class User {
public static String addUser(String userEmail, String password) {
final String uri = "http://www.example.com/";
String requestParams = String.format("{\"userEmail\": \"%s\", \"password\": \"%s\"}", userEmail, password);
final HttpClient client = new DefaultHttpClient();
final HttpPost postMethod = new HttpPost(uri);
postMethod.setEntity(new StringEntity(requestParams, "utf-8"));
try {
final HttpResponse response = client.execute(postMethod);
final String responseData = EntityUtils.toString(response.getEntity(), "utf-8");
System.out.println(responseData);
} catch(final Exception e) {
e.printStackTrace();
}
return responseData;
}
}
When I call this menthod from another class using the following code.
User.addUser(userEmail, password);
Stacktrace:
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.struts.actions.DispatchAction.dispatchMethod(DispatchAction.java:269)
at org.apache.struts.actions.DispatchAction.execute(DispatchAction.java:170)
at org.apache.struts.chain.commands.servlet.ExecuteAction.execute(ExecuteAction.java:58)
at org.apache.struts.chain.commands.AbstractExecuteAction.execute(AbstractExecuteAction.java:67)
at org.apache.struts.chain.commands.ActionCommandBase.execute(ActionCommandBase.java:51)
at org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:191)
at org.apache.commons.chain.generic.LookupCommand.execute(LookupCommand.java:305)
at org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:191)
at org.apache.struts.chain.ComposableRequestProcessor.process(ComposableRequestProcessor.java:283)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913)
at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:449)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:693)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:806)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.geronimo.tomcat.valve.DefaultSubjectValve.invoke(DefaultSubjectValve.java:56)
at org.apache.geronimo.tomcat.GeronimoStandardContext$SystemMethodValve.invoke(GeronimoStandardContext.java:406)
at org.apache.geronimo.tomcat.valve.GeronimoBeforeAfterValve.invoke(GeronimoBeforeAfterValve.java:47)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:555)
at org.apache.geronimo.tomcat.valve.ThreadCleanerValve.invoke(ThreadCleanerValve.java:40)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:852)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Thread.java:662)
Caused by: java.lang.VerifyError: Cannot inherit from final class
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)
at java.lang.ClassLoader.defineClass(ClassLoader.java:615)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
at org.apache.geronimo.kernel.classloader.JarFileClassLoader.access$200(JarFileClassLoader.java:52)
at org.apache.geronimo.kernel.classloader.JarFileClassLoader$6.run(JarFileClassLoader.java:308)
at java.security.AccessController.doPrivileged(Native Method)
at org.apache.geronimo.kernel.classloader.JarFileClassLoader.findClass(JarFileClassLoader.java:260)
at org.apache.geronimo.kernel.config.MultiParentClassLoader.loadOptimizedClass(MultiParentClassLoader.java:441)
at org.apache.geronimo.kernel.config.MultiParentClassLoader.loadClass(MultiParentClassLoader.java:281)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
at org.apache.http.impl.client.DefaultHttpClient.createHttpParams(DefaultHttpClient.java:157)
at org.apache.http.impl.client.AbstractHttpClient.getParams(AbstractHttpClient.java:448)
at org.apache.http.impl.client.AbstractHttpClient.createClientConnectionManager(AbstractHttpClient.java:309)
at org.apache.http.impl.client.AbstractHttpClient.getConnectionManager(AbstractHttpClient.java:466)
at org.apache.http.impl.client.AbstractHttpClient.createHttpContext(AbstractHttpClient.java:286)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:851)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:805)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:784)
at com.test.User.addUser(User.java:18)
... 34 more
It throws the "InvocationTargetException". What may be the problem? Can you give your suggestions?
The problem is right there in the stacktrace:
Caused by: java.lang.VerifyError: Cannot inherit from final class
and if you look closer at the lines below, you can see an indication of where it goes wrong (hint: DefaultHttpClient.createHttpParams(DefaultHttpClient.java:157))
To cut to the chase: Loose the final modifiers on uri, client, postMethod, response and responseData. They're unnecessary and/or wrongly used anyway.
On a completely other note, you could add final modifiers to the methods formal arguments userEmail and password, but do read up on final first.
Cheers,

Unable to find resource org.apache.wicket.mfu.delete from WicketStuff: MultiFileUploadField.java

I have been trying to incorporate the MultiFileUpload example from wicketstuff.org but can not find the resource for org.apache.wicket.mfu.delete. The original code can be found at the above link, and I have ommitted my code for now but can include it if it would help. The call to the missing package takes place within the renderHead() method of org.apache.wicket.markup.html.form.upload.MultiFileUploadField.java, which is read-only. I am using wicket-1.3.1.jar. I am calling the renderHead() method from org.apache.wicket.markup.html.IHeaderContributor within my code below.
Any help will be greatly appreciated.
add(new HeaderContributor(new IHeaderContributor() {
#Override
public void renderHead(IHeaderResponse response) {
response.renderOnLoadJavascript("document.getElementById('" + summaryField.getMarkupId() + "').focus()");
}
}));
and next is my call to MultiFileUploadField() where the renderHead() method that appears to be causing the problems resides.
add(new MultiFileUploadField("fileInput", new PropertyModel(this, "uploads"), 5));
and finally this is the stacktrace:
2011-02-15 10:46:25,233 [http-8080-2] DEBUG [info.jtrac.wicket.JtracApplication] - i18n failed for key: 'org.apache.wicket.mfu.delete', Class: class org.apache.wicket.markup.html.form.upload.MultiFileUploadField, Style: null, Exception: org.springframework.context.NoSuchMessageException: No message found under code 'org.apache.wicket.mfu.delete' for locale 'en'.
2011-02-15 10:46:25,233 [http-8080-2] ERROR [org.apache.wicket.RequestCycle] - Exception in rendering component: [MarkupContainer [Component id = _header_0, page = info.jtrac.wicket.ItemFormPage, path = 4:_header_0.HtmlHeaderContainer, isVisible = true, isVersioned = true]]
org.apache.wicket.WicketRuntimeException: Exception in rendering component: [MarkupContainer [Component id = _header_0, page = info.jtrac.wicket.ItemFormPage, path = 4:_header_0.HtmlHeaderContainer, isVisible = true, isVersioned = true]]
at org.apache.wicket.Component.renderComponent(Component.java:2497)
at org.apache.wicket.MarkupContainer.onRender(MarkupContainer.java:1354)
at org.apache.wicket.Component.render(Component.java:2296)
at org.apache.wicket.MarkupContainer.autoAdd(MarkupContainer.java:222)
at org.apache.wicket.markup.resolver.HtmlHeaderResolver.resolve(HtmlHeaderResolver.java:78)
at org.apache.wicket.MarkupContainer.renderNext(MarkupContainer.java:1267)
at org.apache.wicket.MarkupContainer.renderAll(MarkupContainer.java:1370)
at org.apache.wicket.Page.onRender(Page.java:1446)
at org.apache.wicket.Component.render(Component.java:2296)
at org.apache.wicket.Page.renderPage(Page.java:891)
at org.apache.wicket.request.target.component.BookmarkablePageRequestTarget.respond(BookmarkablePageRequestTarget.java:231)
at org.apache.wicket.request.AbstractRequestCycleProcessor.respond(AbstractRequestCycleProcessor.java:103)
at org.apache.wicket.RequestCycle.processEventsAndRespond(RequestCycle.java:1172)
at org.apache.wicket.RequestCycle.step(RequestCycle.java:1241)
at org.apache.wicket.RequestCycle.steps(RequestCycle.java:1316)
at org.apache.wicket.RequestCycle.request(RequestCycle.java:493)
at org.apache.wicket.protocol.http.WicketFilter.doGet(WicketFilter.java:354)
at org.apache.wicket.protocol.http.WicketFilter.doFilter(WicketFilter.java:194)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:198)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:75)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:393)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:859)
at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:579)
at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1555)
at java.lang.Thread.run(Thread.java:662)
Caused by: java.util.MissingResourceException: Unable to find resource: org.apache.wicket.mfu.delete for component: form:fileInput [class=org.apache.wicket.markup.html.form.upload.MultiFileUploadField]
at org.apache.wicket.Localizer.getString(Localizer.java:262)
at org.apache.wicket.Localizer.getString(Localizer.java:112)
at org.apache.wicket.Component.getString(Component.java:1787)
at org.apache.wicket.Component.getString(Component.java:1774)
at org.apache.wicket.markup.html.form.upload.MultiFileUploadField.renderHead(MultiFileUploadField.java:202)
at org.apache.wicket.Component.renderHead(Component.java:2532)
at org.apache.wicket.markup.html.form.FormComponentPanel.renderHead(FormComponentPanel.java:183)
at org.apache.wicket.markup.html.internal.HtmlHeaderContainer$1.component(HtmlHeaderContainer.java:212)
at org.apache.wicket.MarkupContainer.visitChildren(MarkupContainer.java:821)
at org.apache.wicket.MarkupContainer.visitChildren(MarkupContainer.java:836)
at org.apache.wicket.MarkupContainer.visitChildren(MarkupContainer.java:861)
at org.apache.wicket.markup.html.internal.HtmlHeaderContainer.renderHeaderSections(HtmlHeaderContainer.java:203)
at org.apache.wicket.markup.html.internal.HtmlHeaderContainer.onComponentTagBody(HtmlHeaderContainer.java:136)
at org.apache.wicket.Component.renderComponent(Component.java:2459)
... 36 more
According to the error message there is no string defined in a .properties files for the multifileupload field's delete string.
I imagine that you need to define this one in your Application.properties (a properties file with the same name as your Application class, but with extension .properties), using the following syntax:
org.apache.wicket.mfu.delete=remove

Categories

Resources