Help with Errors

Viewpoint
Enthusiast

Help with Errors

I don't know how to fix these errors. I'm not really sure what the first one wants but I'm pretty sure the second one just can't find that location so how do I fix these?

[mkdir] Created dir: C:\Events\build\classes
[javac] Compiling 11 source files to C:\Events\build\classes
[javac] C:\Events\src\java\com\teradata\portlets\events\validators\EditEvent
Validator.java:23: non-static method equals(java.lang.Object) cannot be referenc
ed from a static context
[javac] return EditEventModel.equals(clazz);
[javac] ^
[javac] C:\Events\src\java\com\teradata\portlets\events\validators\EditEvent
Validator.java:68: cannot find symbol
[javac] symbol : variable lang
[javac] location: class com.teradata.portlets.calendar.validators.EditEventV
alidator
[javac] if(obj.getClass() == java.lang.String && ((String)obj).trim().len
gth() <= 0)
[javac] ^
[javac] Note: C:\Events\src\java\com\teradata\portlets\events\controllers\Ev
entsViewController.java uses unchecked or unsafe operations.
[javac] Note: Recompile with -Xlint:unchecked for details.
[javac] 2 errors

Here is the code

package com.teradata.portlets.calendar.validators;

import com.teradata.portlets.calendar.model.EditEventModel;
import java.sql.Timestamp;
import org.springframework.validation.Errors;
import org.springframework.validation.Validator;

public class EditEventValidator
implements Validator
{

public EditEventValidator()
{
}

public boolean supports(Class clazz)
{
return EditEventModel.equals(clazz);
}

public void validate(Object obj, Errors e)
{
EditEventModel editEventModel = (EditEventModel)obj;
if(editEventModel == null)
throw new NullPointerException("encountered null edit event form model");
Integer id = editEventModel.getEventId();
String eventTitle = editEventModel.getEventTitle();
String eventText = editEventModel.getEventText();
String author = editEventModel.getEventAuthorName();
String lastModifiedName = editEventModel.getEventLastModifiedName();
Integer priority = editEventModel.getEventPriority();
Long start = editEventModel.getEventStartTime();
Long end = editEventModel.getEventEndTime();
Long logTime = editEventModel.getEventLogTime();
Long lastModifiedTime = editEventModel.getEventLastModifiedTime();
validateRequiredField("eventId", id, e);
if(id.intValue() != -1)
{
validateRequiredField("eventAuthorName", author, e);
validateRequiredField("eventLastModifiedName", lastModifiedName, e);
validateTimestamp("eventLogTime", logTime, e);
validateTimestamp("eventLastModifiedTime", lastModifiedTime, e);
}
validateRequiredField("eventTitle", eventTitle, e);
validateMaxLength("eventTitle", eventTitle, 128, e);
validateMaxLength("eventText", eventText, 16384, e);
validateRequiredField("eventPriority", priority, e);
validateRequiredField("eventStartTime", start, e);
validateTimestamp("eventStartTime", start, e);
validateRequiredField("eventEndTime", end, e);
validateTimestamp("eventEndTime", end, e);
if(start != null && end != null && start.longValue() > end.longValue())
e.rejectValue("eventStartTime", "errors.startafterend");
}

public void validateRequiredField(String fieldName, Object obj, Errors e)
{
if(obj == null)
{
e.rejectValue(fieldName, "errors.required");
return;
}
if(obj.getClass() == java.lang.String && ((String)obj).trim().length() <= 0)
e.rejectValue(fieldName, "errors.required");
}

public void validateTimestamp(String fieldName, Long time, Errors e)
{
if(time == null)
return;
try
{
Timestamp timestamp = new Timestamp(time.longValue());
if(timestamp == null)
e.rejectValue(fieldName, "errors.invalidtimestamp");
}
catch(Exception ex)
{
e.rejectValue(fieldName, "errors.invalidtimestamp");
}
}

public void validateMaxLength(String fieldName, String string, int maxLength, Errors e)
{
if(string == null)
return;
if(string.length() > maxLength)
e.rejectValue(fieldName, "errors.toolong");
}

public static final int MAX_LENGTH_EVENTTITLE = 128;
public static final int MAX_LENGTH_EVENTTEXT = 16384;
}
17 REPLIES
Teradata Employee

Re: Help with Errors

Validator.java:23: non-static method equals(java.lang.Object) cannot be referenc

ed from a static context

[javac] return EditEventModel.equals(clazz);

[javac]


The equals method cannot be used as a static method. That is, you need to provide an object. Try EditEventModel.class.equals(clazz);


Validator.java:68: cannot find symbol

[javac] symbol : variable lang

[javac] location: class com.teradata.portlets.calendar.validators.EditEventV

alidator

[javac] if(obj.getClass() == java.lang.String && ((String)obj).trim().len

gth() <= 0)


I would try obj.getClass().equals(String.class)
Enthusiast

Re: Help with Errors

Thanks! I'm well on my way to getting this thing running. Do you know where I put these folders? Images, Incudes, js, resources and tooltip? I shuffled all my folders and I have no idea where they go.
Teradata Employee

Re: Help with Errors

These folders go under yourProjectName/web/
Enthusiast

Re: Help with Errors

Ok. I deployed the project but when I try to add the portlet to the portal all I see is the loading bar. Before I had the folders in the right place my portlet was under a different tab but now its Undefined. Maybe the folders are still the problem?
Enthusiast

Re: Help with Errors

Anyone know how to fix this error?

ERROR 05 Jun 2009 08:18:52,738 [com.liferay.portal.kernel.deploy.AutoDeployScann
er] [com.liferay.portal.log.CommonsLogImpl.error(52)] Auto deploy failed to remo
ve EventsPortlet.war
Teradata Employee

Re: Help with Errors

You can just redeploy the portlet and this shouldn't be an issue.

You can also manually undeploy the portlet by going to _$CATALINA\_HOME/webapps_ and _$CATALINA\_HOME_/work_ and removing the files/folders related to your portlet.
Enthusiast

Re: Help with Errors

I redeployed and I still get those errors.
Teradata Employee

Re: Help with Errors

Did you try manually undeploying it?
Enthusiast

Re: Help with Errors

Yeah, I deleted the files for it in those directories. This is what Tomcat is displaying.

ERROR 05 Jun 2009 09:57:00,791 [ContainerBackgroundProcessor[StandardEngine[Cata

lina]]] [org.apache.catalina.core.StandardContext.start(4217)] Error listenerSta

rt

ERROR 05 Jun 2009 09:57:00,791 [ContainerBackgroundProcessor[StandardEngine[Cata

lina]]] [org.apache.catalina.core.StandardContext.start(4244)] Context [/EventsP

ortlet] startup failed due to previous errors


INFO 05 Jun 2009 09:57:00,791 [ContainerBackgroundProcessor[StandardEngine[Cata

lina]]] [com.teradata.anterage.buildinfo.webapp.BuildInfoSessionContextListener.

contextDestroyed(78)] EventsPortlet: Unloading Build --> 2009.06.05 09:56:1

0 | Events Portlet | 03340684@pepwud10038 | build 69 | 1.5.0_19-b02 |

Windows XP 5.1 x86

INFO 05 Jun 2009 09:57:00,807 [ContainerBackgroundProcessor[StandardEngine[Cata

lina]]] [org.apache.catalina.core.ApplicationContext.log(647)] Closing Spring ro

ot WebApplicationContext

INFO 05 Jun 2009 09:57:00,807 [ContainerBackgroundProcessor[StandardEngine[Cata

lina]]] [org.apache.catalina.core.ApplicationContext.log(647)] Shutting down Log

4J

INFO 05 Jun 2009 09:57:00,807 [ContainerBackgroundProcessor[StandardEngine[Cata

lina]]] [com.liferay.portal.deploy.HotDeployPortletListener.invokeUndeploy(374)]

Unregistering portlets for EventsPortlet

INFO 05 Jun 2009 09:57:00,807 [ContainerBackgroundProcessor[StandardEngine[Cata

lina]]] [com.liferay.portal.deploy.HotDeployPortletListener.invokeUndeploy(407)]

Portlets for EventsPortlet unregistered successfully