Re: ClassCastException:JavaURLContext cannot be cast to class org.xx.xxx
Could you show the PrescientTemplateOriginalPage code ? François > Le 22 févr. 2020 à 02:32, LSomefun a écrit : > > I have been on this issue for atleast 2 weeks now. Trying to use Wicket with > EJB. This occurs when I use @EJb for either a stateless or stateful bean . > > *My code below > The webpage which has the EJB as a variable* > > public class PartnersZipCode extends PrescientTemplateOriginalPage{ > @EJB(name = "ejb/publishZipCodes") > transient private PublishZipCodes partnerInterests; > @EJB > transient private ProspectivePartners marketPlace; > private String sessionZip="sessionZip"; > private String sessionEmail="sessionEmail"; > private String nameFromSession; > private String dbKeys="dbKeys"; > private Vector forkeys; > private Form zipCodeFormOfInterest; > private Label partnerOne; > private Label partnerTwo; > private Label interestedZips; > private Collection listOfZips; >public PartnersZipCode() { >zipCodeFormOfInterest=new Form("zipCodeFormOfInterest"); >partnerOne=new Label("partnerOne"); >partnerTwo=new Label("partnerTwo"); >interestedZips=new Label("interestedZips"); >zipCodeFormOfInterest.add(partnerOne); >zipCodeFormOfInterest.add(partnerTwo); >zipCodeFormOfInterest.add(interestedZips); >add(zipCodeFormOfInterest); >nameFromSession=(String) getSession().getAttribute(sessionEmail); > >forkeys= (Vector) getSession().getAttribute(dbKeys); >partnerInterests.publishZip(nameFromSession,listOfZips=(Collection) > getSession().getAttribute(sessionZip)); > > >} > > > } > > *The EJB Class* > > @ManagedBean > @JMSConnectionFactoryDefinition( >name="java:app/jms/ZipCodesConnectionFactory" > ) > public class PublishZipCodes { > > Message message; > Session session; > JMSProducer messageProducer; > Collection nextZipCode; > > //@Resource(lookup = "java:comp/jms/ZipCodesConnectionFactory") > // ConnectionFactory connectionFactory; > @Resource(lookup = "jms/ZipCodes") > Topic topic; > > @EJB > StartUpSingleton bean; > @Inject > @JMSConnectionFactory(value ="jms/ZipCodesConnectionFactory") > JMSContext connection; > >public PublishZipCodes() { >} > > > > @PostConstruct >public void publish() { > if(connection==null){ > connection=bean.getConnection(); > } > > // messageProducer=connection.createProducer(); >nextZipCode=new ArrayList<>(); >if(nextZipCode.isEmpty()){ > >} > >messageProducer=connection.createProducer(); >message= connection.createTextMessage( > Arrays.deepToString(nextZipCode.toArray()) ); >messageProducer.send(topic,message); >} > > > > > >public void closeConn(){ >connection.close(); >} > >public JMSContext getConnection() { >return connection; >} > >public void setConnection(JMSContext connection) { >this.connection = connection; >} > > > > >public void publishZip(String toString, Collection arrayList) { > nextZipCode=arrayList; > if(messageProducer==null){ >messageProducer=connection.createProducer(); > } > HashMap maptoString=new HashMap(); > maptoString.put(toString,nextZipCode.toArray()); >message= connection.createTextMessage((String) > maptoString.keySet().stream().map(key -> key + "=" + > maptoString.get(key)).collect(Collectors.joining(", ", "{", "}"))); >messageProducer.send(topic,message); >} >} > > > > > *The continuous and frustrating error below* > > java.lang.ClassCastException: class > com.sun.enterprise.naming.impl.JavaURLContext cannot be cast to class > org.prescients.prescientdocwicket.PublishZipCodes > (com.sun.enterprise.naming.impl.JavaURLContext is in unnamed module of > loader org.apache.felix.framework.BundleWiringImpl$BundleClassLoader > @1ff0c0f8; org.prescients.prescientdocwicket.PublishZipCodes is in unnamed > module of loader org.glassfish.web.loader.WebappClassLoader @22507381) > at > org.prescients.prescientdocwicket.Wicket_Proxy_PublishZipCodes$$FastClassByCGLIB$$2031b0b8.invoke() > at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204) > at > org.apache.wicket.proxy.LazyInitProxyFactory$AbstractCGLibInterceptor.intercept(LazyInitProxyFactory.java:364) > at > org.prescients.prescientdocwicket.Wicket_Proxy_PublishZipCodes$$EnhancerByCGLIB$$4a8b3f18.publishZip() > at > org.prescients.prescientdocwicket.PartnersZipCode.(PartnersZipCode.java:56) > at > java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native > Method) > at > java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) > at > java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) > at > java.base/java.lang.reflect.Constructor.newIns
Re: ClassCastException:JavaURLContext cannot be cast to class org.xx.xxx
There is no formComponents in your form. So why do you use a form ? François > Le 22 févr. 2020 à 02:32, LSomefun a écrit : > > I have been on this issue for atleast 2 weeks now. Trying to use Wicket with > EJB. This occurs when I use @EJb for either a stateless or stateful bean . > > *My code below > The webpage which has the EJB as a variable* > > public class PartnersZipCode extends PrescientTemplateOriginalPage{ > @EJB(name = "ejb/publishZipCodes") > transient private PublishZipCodes partnerInterests; > @EJB > transient private ProspectivePartners marketPlace; > private String sessionZip="sessionZip"; > private String sessionEmail="sessionEmail"; > private String nameFromSession; > private String dbKeys="dbKeys"; > private Vector forkeys; > private Form zipCodeFormOfInterest; > private Label partnerOne; > private Label partnerTwo; > private Label interestedZips; > private Collection listOfZips; >public PartnersZipCode() { >zipCodeFormOfInterest=new Form("zipCodeFormOfInterest"); >partnerOne=new Label("partnerOne"); >partnerTwo=new Label("partnerTwo"); >interestedZips=new Label("interestedZips"); >zipCodeFormOfInterest.add(partnerOne); >zipCodeFormOfInterest.add(partnerTwo); >zipCodeFormOfInterest.add(interestedZips); >add(zipCodeFormOfInterest); >nameFromSession=(String) getSession().getAttribute(sessionEmail); > >forkeys= (Vector) getSession().getAttribute(dbKeys); >partnerInterests.publishZip(nameFromSession,listOfZips=(Collection) > getSession().getAttribute(sessionZip)); > > >} > > > } > > *The EJB Class* > > @ManagedBean > @JMSConnectionFactoryDefinition( >name="java:app/jms/ZipCodesConnectionFactory" > ) > public class PublishZipCodes { > > Message message; > Session session; > JMSProducer messageProducer; > Collection nextZipCode; > > //@Resource(lookup = "java:comp/jms/ZipCodesConnectionFactory") > // ConnectionFactory connectionFactory; > @Resource(lookup = "jms/ZipCodes") > Topic topic; > > @EJB > StartUpSingleton bean; > @Inject > @JMSConnectionFactory(value ="jms/ZipCodesConnectionFactory") > JMSContext connection; > >public PublishZipCodes() { >} > > > > @PostConstruct >public void publish() { > if(connection==null){ > connection=bean.getConnection(); > } > > // messageProducer=connection.createProducer(); >nextZipCode=new ArrayList<>(); >if(nextZipCode.isEmpty()){ > >} > >messageProducer=connection.createProducer(); >message= connection.createTextMessage( > Arrays.deepToString(nextZipCode.toArray()) ); >messageProducer.send(topic,message); >} > > > > > >public void closeConn(){ >connection.close(); >} > >public JMSContext getConnection() { >return connection; >} > >public void setConnection(JMSContext connection) { >this.connection = connection; >} > > > > >public void publishZip(String toString, Collection arrayList) { > nextZipCode=arrayList; > if(messageProducer==null){ >messageProducer=connection.createProducer(); > } > HashMap maptoString=new HashMap(); > maptoString.put(toString,nextZipCode.toArray()); >message= connection.createTextMessage((String) > maptoString.keySet().stream().map(key -> key + "=" + > maptoString.get(key)).collect(Collectors.joining(", ", "{", "}"))); >messageProducer.send(topic,message); >} >} > > > > > *The continuous and frustrating error below* > > java.lang.ClassCastException: class > com.sun.enterprise.naming.impl.JavaURLContext cannot be cast to class > org.prescients.prescientdocwicket.PublishZipCodes > (com.sun.enterprise.naming.impl.JavaURLContext is in unnamed module of > loader org.apache.felix.framework.BundleWiringImpl$BundleClassLoader > @1ff0c0f8; org.prescients.prescientdocwicket.PublishZipCodes is in unnamed > module of loader org.glassfish.web.loader.WebappClassLoader @22507381) > at > org.prescients.prescientdocwicket.Wicket_Proxy_PublishZipCodes$$FastClassByCGLIB$$2031b0b8.invoke() > at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204) > at > org.apache.wicket.proxy.LazyInitProxyFactory$AbstractCGLibInterceptor.intercept(LazyInitProxyFactory.java:364) > at > org.prescients.prescientdocwicket.Wicket_Proxy_PublishZipCodes$$EnhancerByCGLIB$$4a8b3f18.publishZip() > at > org.prescients.prescientdocwicket.PartnersZipCode.(PartnersZipCode.java:56) > at > java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native > Method) > at > java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) > at > java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) > at > java.base/java.lang.reflect.Constr