Dynamically Spring AOP with client-server application in JAVA? - spring

I'm using Eclipse Juno IDE and Tomcat 7.0
I have a server, within the server I have TaxiStation class. Now when an event is occur
in the station I'm logging it with spring AOP.
From the other side I have a client. The client is a Web application. so when the user
want to see if there are taxis in the station (I have vectors that holds the data), he clicks on a button, then the servlet asking from the Server the information and then it's display the required jsp page with the information. If the vectors are empty it works fine, but when
there is even one element I'm getting an exception.
Here is my code:
The server side:
ApplicationContext.xml:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd">
<aop:aspectj-autoproxy>
<aop:include name="Logging"/>
</aop:aspectj-autoproxy>
<bean id="Logging" class="pack.aop.Logging"/>
<bean id="Station" class="pack.bl.Station" scope ="prototype" lazy-init="true"/>
The Server c'tor:
public MyServer()
{
al = new ArrayList<ClientHandler>();
try {
ApplicationContext ctx = new ClassPathXmlApplicationContext("applicationContext.xml");
si = (StationInterface)ctx.getBean("Station",StationInterface.class);
} catch (SecurityException e) {
e.printStackTrace();
}
}
SI is the station interface (I have station class that implements this interface)
ClientHandler
ClientHandler(Socket client)
{
this.socket = client;
try{
to_client = new ObjectOutputStream(socket.getOutputStream());
from_client = new ObjectInputStream(socket.getInputStream());
si.set_server(MyServer.this);
}
catch(IOException ioe)
{
// error when create the streams
return;
}
}
public void run(){
boolean is_running = true;
try
{
data_from_client = (Vector)from_client.readObject();
if (data_from_client.elementAt(0).equals("taxis_waits") &&
data_from_client.elementAt(1).equals("taxis_break"))
{
Object t_b = si.get_taxis_on_break();
Object t_w = si.get_taxis_on_waiting();
to_client.writeObject(t_w);
to_client.writeObject(t_b);
to_client.flush();
}
else if (data_from_client.elementAt(0).equals("all_passengers"))
{
Object x = si.get_passengesrs();
to_client.writeObject(x);
to_client.flush();
}
}
}
NOTE: the methods: get_taxis_on_break(), get_taxis_on_waiting() and get_passengers(),
returning Vector. (of taxi or passenger)
so when the vectors are empty it seems to work fine and the server writing the
data to the servlet, and the servlet read it fine, but when there is an element
I'm getting an exception in the client side (the servlet (WebApplication)):
The Exception:
SEVERE: Servlet.service() for servlet [pack.servlets.servlet2] in context with path
[/TaxiWeb] threw exception
java.io.WriteAbortedException: writing aborted; java.io.NotSerializableException:
org.springframework.aop.aspectj.annotation.InstantiationModelAwarePointcutAdvisorImpl
at java.io.ObjectInputStream.readObject0(Unknown Source)
at java.io.ObjectInputStream.readArray(Unknown Source)
at java.io.ObjectInputStream.readObject0(Unknown Source)
at java.io.ObjectInputStream.defaultReadFields(Unknown Source)
at java.io.ObjectInputStream.readSerialData(Unknown Source)
at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
at java.io.ObjectInputStream.readObject0(Unknown Source)
at java.io.ObjectInputStream.defaultReadFields(Unknown Source)
at java.io.ObjectInputStream.readSerialData(Unknown Source)
at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
at java.io.ObjectInputStream.readObject0(Unknown Source)
at java.io.ObjectInputStream.defaultReadFields(Unknown Source)
at java.io.ObjectInputStream.readSerialData(Unknown Source)
at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
at java.io.ObjectInputStream.readObject0(Unknown Source)
at java.io.ObjectInputStream.defaultReadFields(Unknown Source)
at java.io.ObjectInputStream.readSerialData(Unknown Source)
at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
at java.io.ObjectInputStream.readObject0(Unknown Source)
at java.io.ObjectInputStream.readArray(Unknown Source)
at java.io.ObjectInputStream.readObject0(Unknown Source)
at java.io.ObjectInputStream.defaultReadFields(Unknown Source)
at java.io.ObjectInputStream.readSerialData(Unknown Source)
at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
at java.io.ObjectInputStream.readObject0(Unknown Source)
at java.io.ObjectInputStream.readObject(Unknown Source)
at pack.servlets.servlet2.doPost(servlet2.java:90)
at pack.servlets.servlet2.doGet(servlet2.java:47)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:225)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:927)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1001)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:579)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.io.NotSerializableException:
org.springframework.aop.aspectj.annotation.InstantiationModelAwarePointcutAdvisorImpl
at java.io.ObjectOutputStream.writeObject0(Unknown Source)
at java.io.ObjectOutputStream.writeArray(Unknown Source)
at java.io.ObjectOutputStream.writeObject0(Unknown Source)
at java.io.ObjectOutputStream.defaultWriteFields(Unknown Source)
at java.io.ObjectOutputStream.writeSerialData(Unknown Source)
at java.io.ObjectOutputStream.writeOrdinaryObject(Unknown Source)
at java.io.ObjectOutputStream.writeObject0(Unknown Source)
at java.io.ObjectOutputStream.defaultWriteFields(Unknown Source)
at java.io.ObjectOutputStream.writeSerialData(Unknown Source)
at java.io.ObjectOutputStream.writeOrdinaryObject(Unknown Source)
at java.io.ObjectOutputStream.writeObject0(Unknown Source)
at java.io.ObjectOutputStream.defaultWriteFields(Unknown Source)
at java.io.ObjectOutputStream.writeSerialData(Unknown Source)
at java.io.ObjectOutputStream.writeOrdinaryObject(Unknown Source)
at java.io.ObjectOutputStream.writeObject0(Unknown Source)
at java.io.ObjectOutputStream.defaultWriteFields(Unknown Source)
at java.io.ObjectOutputStream.writeSerialData(Unknown Source)
at java.io.ObjectOutputStream.writeOrdinaryObject(Unknown Source)
at java.io.ObjectOutputStream.writeObject0(Unknown Source)
at java.io.ObjectOutputStream.writeArray(Unknown Source)
at java.io.ObjectOutputStream.writeObject0(Unknown Source)
at java.io.ObjectOutputStream.access$300(Unknown Source)
at java.io.ObjectOutputStream$PutFieldImpl.writeFields(Unknown Source)
at java.io.ObjectOutputStream.writeFields(Unknown Source)
at java.util.Vector.writeObject(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at java.io.ObjectStreamClass.invokeWriteObject(Unknown Source)
at java.io.ObjectOutputStream.writeSerialData(Unknown Source)
at java.io.ObjectOutputStream.writeOrdinaryObject(Unknown Source)
at java.io.ObjectOutputStream.writeObject0(Unknown Source)
at java.io.ObjectOutputStream.writeObject(Unknown Source)
at pack.my_server.MyServer$ClientHandler.run(MyServer.java:186)

your Station Class must implement the java.io.Serializable interface if it is to be serialized.
UPDATED
or you can extend your interface and make it Serializable
public interface SI extends Serializable{
//interface code here
}

Related

The 11th image is never recognized by the reader

I am trying to convert a gif into an Arraylist of buffered images. I had used a piece of code from Convert each animated GIF frame to a separate BufferedImage before, but it returned buffered images where every pixel was the same exact color. Thus, I decided to use this instead:
public ArrayList<BufferedImage> getFrames(File gif) throws IOException {
ArrayList<BufferedImage> frames = new ArrayList<BufferedImage>();
try {
ImageReader reader = ImageIO.getImageReadersByFormatName("gif").next();
ImageInputStream stream = ImageIO.createImageInputStream(gif);
reader.setInput(stream);
int count = reader.getNumImages(true);
System.out.println("count is "+count);
for (int index = 0; index < count; index++) {
System.out.println("index is "+index);
BufferedImage frame = reader.read(index);
frames.add(frame);
}
} catch (IOException ex) {
System.out.println("An I/O problem has occurred");
}
return frames;
}
The output indicates that there is an error on the 10th image:
count is 70
index is 0
index is 1
index is 2
index is 3
index is 4
index is 5
index is 6
index is 7
index is 8
index is 9
index is 10
Exception in thread "AWT-EventQueue-0" java.lang.ArrayIndexOutOfBoundsException: 4096
I'm wondering: why 10? What happens at the 11th image that causes this problem? How do I fix the error so that I can have all 70 frames?
Here is the rest of the errors (with a stacktrack added in):
at com.sun.imageio.plugins.gif.GIFImageReader.read(Unknown Source)
at javax.imageio.ImageReader.read(Unknown Source)
at Pointilismo.getFrames(Pointilismo.java:104)
at Pointilismo.updateimage(Pointilismo.java:116)
at Pointilismo.switchimage(Pointilismo.java:135)
at Pointilismo.actionPerformed(Pointilismo.java:210)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$500(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
I don't have any experience with Image processing but found maybe the cause of your problem:
bug

Using JSF 2.2.9 on Spring+Tomcat causes java.lang.NoClassDefFoundError: javax/enterprise/context/spi/Contextual

I need to use custom html attributes inside JSF components, and for this the only solution that i found is use JSF 2.2, in this way:
<f:passThroughAttribute name="data-toggle" value="modal" />
The problem is that i'm using Spring + Tomcat and i can't change this because i don't have time. Every time that i start my server i got the following error :
Informações: CDI #ViewScoped manager unavailable
java.lang.NoClassDefFoundError: javax/enterprise/context/spi/Contextual
I know this happens because i don't use CDI, but as i said i can't change from Spring to CDI because of time.
How can i solve this problem ? I must use JSF 2.2 (Because custom html attributes) and Spring.
SOLVED:
This problem as solved, i downgrade to JSF 2.2.6 and error stops.
Stack trace:
Fev 01, 2015 4:13:57 PM com.sun.faces.application.view.ViewScopeManager <init>
Informações: CDI #ViewScoped manager unavailable
java.lang.NoClassDefFoundError: javax/enterprise/context/spi/Contextual
at com.sun.faces.application.view.ViewScopeManager.<init>(Unknown Source)
at com.sun.faces.application.view.ViewScopeManager.getInstance(Unknown Source)
at com.sun.faces.application.view.ViewScopeEventListener.processEvent(Unknown Source)
at javax.faces.event.SystemEvent.processListener(Unknown Source)
at javax.faces.event.ComponentSystemEvent.processListener(Unknown Source)
at com.sun.faces.application.ApplicationImpl.processListeners(Unknown Source)
at com.sun.faces.application.ApplicationImpl.invokeListenersFor(Unknown Source)
at com.sun.faces.application.ApplicationImpl.publishEvent(Unknown Source)
at javax.faces.component.UIViewRoot.getViewMap(Unknown Source)
at javax.faces.component.UIViewRoot.getViewMap(Unknown Source)
at com.sun.faces.mgbean.BeanManager$ScopeManager$ViewScopeHandler.handle(Unknown Source)
at com.sun.faces.mgbean.BeanManager$ScopeManager.pushToScope(Unknown Source)
at com.sun.faces.mgbean.BeanManager.createAndPush(Unknown Source)
at com.sun.faces.mgbean.BeanManager.create(Unknown Source)
at com.sun.faces.el.ManagedBeanELResolver.resolveBean(Unknown Source)
at com.sun.faces.el.ManagedBeanELResolver.getValue(Unknown Source)
at com.sun.faces.el.DemuxCompositeELResolver._getValue(Unknown Source)
at com.sun.faces.el.DemuxCompositeELResolver.getValue(Unknown Source)
at org.apache.el.parser.AstIdentifier.getValue(AstIdentifier.java:71)
at org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:189)
at com.sun.faces.facelets.el.TagValueExpression.getValue(Unknown Source)
at javax.faces.component.UIComponentBase$AttributesMap.get(Unknown Source)
at com.sun.faces.el.CompositeComponentAttributesELResolver$ExpressionEvalMap.get(Unknown Source)
at javax.el.MapELResolver.getValue(MapELResolver.java:52)
at com.sun.faces.el.DemuxCompositeELResolver._getValue(Unknown Source)
at com.sun.faces.el.DemuxCompositeELResolver.getValue(Unknown Source)
at org.apache.el.parser.AstValue.getValue(AstValue.java:169)
at org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:189)
at com.sun.faces.facelets.el.ContextualCompositeValueExpression.getValue(Unknown Source)
at com.sun.faces.facelets.el.TagValueExpression.getValue(Unknown Source)
at com.sun.faces.application.ApplicationImpl.createComponentApplyAnnotations(Unknown Source)
at com.sun.faces.application.ApplicationImpl.createComponent(Unknown Source)
at com.sun.faces.facelets.tag.jsf.ComponentTagHandlerDelegateImpl.createComponent(Unknown Source)
at com.sun.faces.facelets.tag.jsf.ComponentTagHandlerDelegateImpl.apply(Unknown Source)
at javax.faces.view.facelets.DelegatingMetaTagHandler.apply(Unknown Source)
at javax.faces.view.facelets.CompositeFaceletHandler.apply(Unknown Source)
at com.sun.faces.facelets.tag.composite.ImplementationHandler.apply(Unknown Source)
at javax.faces.view.facelets.CompositeFaceletHandler.apply(Unknown Source)
at com.sun.faces.facelets.compiler.NamespaceHandler.apply(Unknown Source)
at com.sun.faces.facelets.compiler.EncodingHandler.apply(Unknown Source)
at com.sun.faces.facelets.impl.DefaultFacelet.include(Unknown Source)
at com.sun.faces.facelets.impl.DefaultFacelet.include(Unknown Source)
at com.sun.faces.facelets.impl.DefaultFaceletContext.includeFacelet(Unknown Source)
at com.sun.faces.facelets.tag.jsf.CompositeComponentTagHandler.applyCompositeComponent(Unknown Source)
at com.sun.faces.facelets.tag.jsf.CompositeComponentTagHandler.applyNextHandler(Unknown Source)
at com.sun.faces.facelets.tag.jsf.ComponentTagHandlerDelegateImpl.apply(Unknown Source)
at javax.faces.view.facelets.DelegatingMetaTagHandler.apply(Unknown Source)
at javax.faces.view.facelets.CompositeFaceletHandler.apply(Unknown Source)
at javax.faces.view.facelets.DelegatingMetaTagHandler.applyNextHandler(Unknown Source)
at com.sun.faces.facelets.tag.jsf.ComponentTagHandlerDelegateImpl.apply(Unknown Source)
at javax.faces.view.facelets.DelegatingMetaTagHandler.apply(Unknown Source)
at com.sun.faces.facelets.tag.ui.DefineHandler.applyDefinition(Unknown Source)
at com.sun.faces.facelets.tag.ui.CompositionHandler.apply(Unknown Source)
at com.sun.faces.facelets.impl.DefaultFaceletContext$TemplateManager.apply(Unknown Source)
at com.sun.faces.facelets.impl.DefaultFaceletContext.includeDefinition(Unknown Source)
at com.sun.faces.facelets.tag.ui.InsertHandler.apply(Unknown Source)
at javax.faces.view.facelets.CompositeFaceletHandler.apply(Unknown Source)
at com.sun.faces.facelets.compiler.NamespaceHandler.apply(Unknown Source)
at com.sun.faces.facelets.compiler.EncodingHandler.apply(Unknown Source)
at com.sun.faces.facelets.impl.DefaultFacelet.include(Unknown Source)
at com.sun.faces.facelets.impl.DefaultFacelet.include(Unknown Source)
at com.sun.faces.facelets.impl.DefaultFacelet.include(Unknown Source)
at com.sun.faces.facelets.impl.DefaultFaceletContext.includeFacelet(Unknown Source)
at com.sun.faces.facelets.tag.ui.CompositionHandler.apply(Unknown Source)
at com.sun.faces.facelets.compiler.NamespaceHandler.apply(Unknown Source)
at com.sun.faces.facelets.compiler.EncodingHandler.apply(Unknown Source)
at com.sun.faces.facelets.impl.DefaultFacelet.apply(Unknown Source)
at com.sun.faces.application.view.FaceletViewHandlingStrategy.buildView(Unknown Source)
at com.sun.faces.lifecycle.RenderResponsePhase.execute(Unknown Source)
at com.sun.faces.lifecycle.Phase.doPhase(Unknown Source)
at com.sun.faces.lifecycle.LifecycleImpl.render(Unknown Source)
at javax.faces.webapp.FacesServlet.service(Unknown Source)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.primefaces.webapp.filter.FileUploadFilter.doFilter(FileUploadFilter.java:72)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at br.com.jwebbuild.filter.LoginFilter.doFilter(LoginFilter.java:73)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
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:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:240)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:164)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:462)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:562)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:395)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:250)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:188)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:302)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:744)
Caused by: java.lang.ClassNotFoundException: javax.enterprise.context.spi.Contextual
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1676)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1521)
... 98 more
I have same problem and found your question on google (i use JSF 2.2.9), with the answer from hwellmann, i added these depency on pom.xml of my maven project:
<dependency>
<groupId>javax.enterprise</groupId>
<artifactId>cdi-api</artifactId>
<version>1.2</version>
</dependency>
and problem solved, thanks!
Did you include the cdi-api.jar in your setup?
That doesn't mean you have to use CDI in your application, but the API classes have to be there to satisfy the dependencies of JSF.
Probably you are using the #ViewScoped from javax.faces.bean, it was added in JSF 2.0. Try using the annotation from javax.faces.view, added in JSF 2.2.
use JSF 2.2.8 or change tomcat to Apache TomEE, or configure CDI+JSF-Tomcat.
Best solution using jsf older versions because in the new versions will dependency from CDI

Processing not working

I'm trying to run this code in processing:
This is the simple code..
void setup()
{
size(400,400);
background(255,255,0);
}
void draw()
{
ellipse(mouseX,mouseY,40,40);
fill(0,255,255);
strokeWeight(5);
}
But when i click run button i see no output,but get this:
java.net.SocketException: Permission denied: connect
at java.net.DualStackPlainSocketImpl.connect0(Native Method)
at java.net.DualStackPlainSocketImpl.socketConnect(Unknown Source)
at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)
at java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source)
at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at sun.net.NetworkClient.doConnect(Unknown Source)
at sun.net.www.http.HttpClient.openServer(Unknown Source)
at sun.net.www.http.HttpClient.openServer(Unknown Source)
at sun.net.www.http.HttpClient.<init>(Unknown Source)
at sun.net.www.http.HttpClient.New(Unknown Source)
at sun.net.www.http.HttpClient.New(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.connect(Unknown Source)
at processing.app.contrib.ContributionManager.download(ContributionManager.java:62)
at processing.app.contrib.ContributionListing$2.run(ContributionListing.java:362)
at java.lang.Thread.run(Unknown Source)
java.net.SocketException: Permission denied: connect
at java.net.DualStackPlainSocketImpl.connect0(Native Method)
at java.net.DualStackPlainSocketImpl.socketConnect(Unknown Source)
at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)
at java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source)
at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at sun.net.NetworkClient.doConnect(Unknown Source)
at sun.net.www.http.HttpClient.openServer(Unknown Source)
at sun.net.www.http.HttpClient.openServer(Unknown Source)
at sun.net.www.http.HttpClient.<init>(Unknown Source)
at sun.net.www.http.HttpClient.New(Unknown Source)
at sun.net.www.http.HttpClient.New(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.connect(Unknown Source)
at processing.app.contrib.ContributionManager.download(ContributionManager.java:62)
at processing.app.contrib.ContributionListing$2.run(ContributionListing.java:362)
at java.lang.Thread.run(Unknown Source)
I have downloaded java jdk for windows 7 x64,processing 2.2.1...please help me!
I ran your code with processing 2.2.1 both Java and Javascript mode.. and working ._.
Since I saw that: "java.net.SocketException: Permission denied: connect"
I recommend to Check Firewall, antivirus, install Javascript mode, reboot computer, re-create the sketch, move the sketch directory...
The code is valid.
Do you have any sketches working, or is this the first. If so, I would suggest uninstalling and reinstall. Sounds as though something is missing. Also, processing 3 is now out with debug added.

Add MouseClick Event on ScrollPane in JavaFX

I have created a Scroll Pane (with Anchor Pane) in JavaFX.
On runtime I am creating a rectangle and adding it to the ScrollPane.
I want to add a mouse click event on the scroll pane, in which I can change the contents of the scrollPane on runtime.
I tried doing that but I get this exception when I click on the ScrollPane
Exception in thread "JavaFX Application Thread" java.lang.IllegalArgumentException: argument type mismatch
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at sun.reflect.misc.Trampoline.invoke(Unknown Source)
at sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at sun.reflect.misc.MethodUtil.invoke(Unknown Source)
at javafx.fxml.FXMLLoader$MethodHandler.invoke(Unknown Source)
at javafx.fxml.FXMLLoader$ControllerMethodEventHandler.handle(Unknown Source)
at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(Unknown Source)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(Unknown Source)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(Unknown Source)
at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(Unknown Source)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(Unknown Source)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(Unknown Source)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(Unknown Source)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(Unknown Source)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(Unknown Source)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(Unknown Source)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(Unknown Source)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(Unknown Source)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(Unknown Source)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(Unknown Source)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(Unknown Source)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(Unknown Source)
at com.sun.javafx.event.EventUtil.fireEventImpl(Unknown Source)
at com.sun.javafx.event.EventUtil.fireEvent(Unknown Source)
at javafx.event.Event.fireEvent(Unknown Source)
at javafx.scene.Scene$ClickGenerator.postProcess(Unknown Source)
at javafx.scene.Scene$ClickGenerator.access$7900(Unknown Source)
at javafx.scene.Scene$MouseHandler.process(Unknown Source)
at javafx.scene.Scene$MouseHandler.access$1500(Unknown Source)
at javafx.scene.Scene.impl_processMouseEvent(Unknown Source)
at javafx.scene.Scene$ScenePeerListener.mouseEvent(Unknown Source)
at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(Unknown Source)
at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.tk.quantum.GlassViewEventHandler.handleMouseEvent(Unknown Source)
at com.sun.glass.ui.View.handleMouseEvent(Unknown Source)
at com.sun.glass.ui.View.notifyMouse(Unknown Source)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.lambda$null$141(Unknown Source)
at com.sun.glass.ui.win.WinApplication$$Lambda$37/1109371569.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Here is my JavaFX fxml part,
<ScrollPane fx:id="scrollPane" layoutX="229.0" layoutY="183.0" onMouseClicked="#ChangeImageColor" prefHeight="137.0" prefWidth="143.0">
<content>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="154.0" prefWidth="157.0" />
</content>
</ScrollPane>
And My Java Code,
#FXML
void ChangeImageColor(ActionEvent event)
{
System.out.print("Hit!");
scrollPane.setContent(null);
Rectangle rectangle = new Rectangle(200, 200, Color.BLUEVIOLET);
rectangle.setStroke(Color.BLACK);
rectangle.setStrokeWidth(25);
scrollPane.setContent(rectangle);
}
This is what i am doing on initialization,
Rectangle rectangle = new Rectangle(200, 200, Color.RED);
rectangle.setStroke(Color.BLACK);
rectangle.setStrokeWidth(25);
scrollPane.setContent(rectangle);
The problem you are facing is because of the declaration of the method
#FXML
void ChangeImageColor(ActionEvent event)
Here the parameter should be of type MouseEvent instead of ActionEvent. You can also remove the parameter if you are not sure of the kind of event it is. Try using :
#FXML
void ChangeImageColor()
or
#FXML
void ChangeImageColor(MouseEvent event)
I am not sure why did adding the event in the fxml did not work.
I simply added the event definition in the Java code and it worked perfectly fine.
scrollPane.setOnMouseClicked(new EventHandler<Event>()
{
#Override
public void handle(Event event)
{
//Logic on event occurrence
}
});

Error Connecting to Oracle Database from Pentaho Report Designer

I am new to Pentaho, and I am struggling to set up a new database connection. I am trying to connect to an Oracle 10g database, but whenever I test the connection, I get the below error. It doesn't really seem to list any specific error message so I'm not really sure what to do or where to go from this point.
I placed ojdbc jar's in my tomcat lib folder, but maybe there is another place those should go.
Any help/hints would be greatly appreciated.
Error connecting to database [OFF SSP Cert] : org.pentaho.di.core.exception.KettleDatabaseException:
Error occured while trying to connect to the database
Error connecting to database: (using class oracle.jdbc.driver.OracleDriver)
oracle/dms/instrument/ExecutionContextForJDBC
org.pentaho.di.core.exception.KettleDatabaseException:
Error occured while trying to connect to the database
Error connecting to database: (using class oracle.jdbc.driver.OracleDriver)
oracle/dms/instrument/ExecutionContextForJDBC
org.pentaho.di.core.database.Database.normalConnect(Database.java:366)
org.pentaho.di.core.database.Database.connect(Database.java:315)
org.pentaho.di.core.database.Database.connect(Database.java:277)
org.pentaho.di.core.database.Database.connect(Database.java:267)
org.pentaho.di.core.database.DatabaseFactory.getConnectionTestReport(DatabaseFactory.java:76)
org.pentaho.di.core.database.DatabaseMeta.testConnection(DatabaseMeta.java:2443)
org.pentaho.ui.database.event.DataHandler.testDatabaseConnection(DataHandler.java:510)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
java.lang.reflect.Method.invoke(Unknown Source)
org.pentaho.ui.xul.impl.AbstractXulDomContainer.invoke(AbstractXulDomContainer.java:329)
org.pentaho.ui.xul.swing.tags.SwingButton$OnClickRunnable.run(SwingButton.java:58)
java.awt.event.InvocationEvent.dispatch(Unknown Source)
java.awt.EventQueue.dispatchEvent(Unknown Source)
java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
java.awt.Dialog$1.run(Unknown Source)
java.awt.Dialog$3.run(Unknown Source)
java.security.AccessController.doPrivileged(Native Method)
java.awt.Dialog.show(Unknown Source)
java.awt.Component.show(Unknown Source)
java.awt.Component.setVisible(Unknown Source)
java.awt.Window.setVisible(Unknown Source)
java.awt.Dialog.setVisible(Unknown Source)
org.pentaho.ui.xul.swing.tags.SwingDialog.show(SwingDialog.java:234)
org.pentaho.reporting.ui.datasources.jdbc.ui.XulDatabaseDialog.open(XulDatabaseDialog.java:237)
org.pentaho.reporting.ui.datasources.jdbc.ui.ConnectionPanel$EditDataSourceAction.actionPerformed(ConnectionPanel.java:162)
javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
javax.swing.DefaultButtonModel.setPressed(Unknown Source)
javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
java.awt.AWTEventMulticaster.mouseReleased(Unknown Source)
java.awt.AWTEventMulticaster.mouseReleased(Unknown Source)
java.awt.Component.processMouseEvent(Unknown Source)
javax.swing.JComponent.processMouseEvent(Unknown Source)
java.awt.Component.processEvent(Unknown Source)
java.awt.Container.processEvent(Unknown Source)
java.awt.Component.dispatchEventImpl(Unknown Source)
java.awt.Container.dispatchEventImpl(Unknown Source)
java.awt.Component.dispatchEvent(Unknown Source)
java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
java.awt.Container.dispatchEventImpl(Unknown Source)
java.awt.Window.dispatchEventImpl(Unknown Source)
java.awt.Component.dispatchEvent(Unknown Source)
java.awt.EventQueue.dispatchEvent(Unknown Source)
java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
java.awt.Dialog$1.run(Unknown Source)
java.awt.Dialog$3.run(Unknown Source)
java.security.AccessController.doPrivileged(Native Method)
java.awt.Dialog.show(Unknown Source)
java.awt.Component.show(Unknown Source)
java.awt.Component.setVisible(Unknown Source)
java.awt.Window.setVisible(Unknown Source)
java.awt.Dialog.setVisible(Unknown Source)
org.pentaho.reporting.ui.datasources.jdbc.ui.JdbcDataSourceDialog.performConfiguration(JdbcDataSourceDialog.java:661)
org.pentaho.reporting.ui.datasources.jdbc.JdbcDataSourcePlugin.performEdit(JdbcDataSourcePlugin.java:67)
org.pentaho.reporting.designer.core.actions.report.AddDataFactoryAction.actionPerformed(AddDataFactoryAction.java:79)
Seems you are using some sort of native JDBC driver. Make sure that the native libararies are there and can be read at runtime. You probably have to copy more than one jar into the lib/jdbc directory to make it work.
Your Oracle manual should contain all the details on how to install a JDBC driver.

Resources