GetInitParameter in startup servlet throwing NullPointerException
I understand that if your Init Parameter contains nothing, getInitParameter will
return null. Well, I'm checking for that, and I'm getting the NullPointerException
while I'm trying to check for it?!?! Here's my code:
excerpt from web.xml:
<servlet>
<servlet-name>startupServlet</servlet-name>
<servlet-class>vw.action.startupServlet</servlet-class>
<load-on-startup>1</load-on-startup>
<init-param>
<param-name>applicationPath</param-name>
<param-value>hint_production</param-value>
<description>applicationPath</description>
</init-param>
</servlet>
yes, I have a servlet mapping element
code:
public class startupServlet extends GenericServlet
public void init( ServletConfig config ) throws ServletException {
so("\n\t startupservlet 1 \n\t");
try {
// null is being thrown here, neither line below is output
if ( getInitParameter( "applicationPath" ) == null )
so(" null applicationPath initParameter ");
else
so(" applicationPath initParameter is NOT Null ");
} catch ( NullPointerException npe ) {
so( "\n\t setting blank path \n\t" );
Constants.setPath( "" );
public void service( ServletRequest req, ServletResponse res ) throws ServletException,
java.io.IOException {
public static void so( String output ) {
System.out.println( output );
I forgot to mention that I'm using WLS 6.1 (SP2)
ps how 'bout that domain name? Marketing genius...
"Brian Preston" <[email protected]> wrote:
>
>I understand that if your Init Parameter contains nothing, getInitParameter
>will
>return null. Well, I'm checking for that, and I'm getting the NullPointerException
>while I'm trying to check for it?!?! Here's my code:
>
>excerpt from web.xml:
>
><servlet>
> <servlet-name>startupServlet</servlet-name>
> <servlet-class>vw.action.startupServlet</servlet-class>
> <load-on-startup>1</load-on-startup>
> <init-param>
> <param-name>applicationPath</param-name>
> <param-value>hint_production</param-value>
> <description>applicationPath</description>
> </init-param>
> </servlet>
>
>yes, I have a servlet mapping element
>
>code:
>
>public class startupServlet extends GenericServlet
>{
> public void init( ServletConfig config ) throws ServletException
>{
> so("\n\t startupservlet 1 \n\t");
>
> try {
> // null is being thrown here, neither line below is output
> if ( getInitParameter( "applicationPath" ) == null )
> so(" null applicationPath initParameter ");
> else
> so(" applicationPath initParameter is NOT Null ");
>
>....
>
>} catch ( NullPointerException npe ) {
> so( "\n\t setting blank path \n\t" );
> Constants.setPath( "" );
> }
> }
>
> public void service( ServletRequest req, ServletResponse res ) throws
>ServletException,
>java.io.IOException {
>
> }
>
> public static void so( String output ) {
> System.out.println( output );
> }
>}
Similar Messages
-
Weblogic 7.0 startup servlet problem
I have added a new startup servlet to my existing web application.
While deploying the same, weblogic is throwing the following
exception.
I'm very sure that class (com/lbx/util/LbxProperties) is part of
webapp war file I created. Can somebody please throw some light about
this.
I'm trying to do the .ear file deployment.
Thank you very much
Santhosh.
<Dec 30, 2002 12:04:27 PM PST> <Error> <HTTP> <101216> <Servlet:
"StartupServlet" failed to preload on startup in webapp: "wliWEB"
javax.servlet.ServletException: com/lbx/util/LbxProperties
at weblogic.servlet.internal.ServletStubImpl.createServlet(ServletStubImpl.java:912)
at weblogic.servlet.internal.ServletStubImpl.createInstances(ServletStubImpl.java:833)
at weblogic.servlet.internal.ServletStubImpl.prepareServlet(ServletStubImpl.java:773)
at weblogic.servlet.internal.WebAppServletContext.preloadServlet(WebAppServletContext.java:2763)
at weblogic.servlet.internal.WebAppServletContext.preloadServlets(WebAppServletContext.java:2708)
at weblogic.servlet.internal.WebAppServletContext.preloadResources(WebAppServletContext.java:2681)
at weblogic.servlet.internal.WebAppServletContext.setStarted(WebAppServletContext.java:4746)
at weblogic.servlet.internal.WebAppModule.start(WebAppModule.java:539)
at weblogic.j2ee.J2EEApplicationContainer.start(J2EEApplicationContainer.java:983)
at weblogic.j2ee.J2EEApplicationContainer.activate(J2EEApplicationContainer.java:1017)
at weblogic.management.deploy.slave.SlaveDeployer.processPrepareTask(SlaveDeployer.java:1112)
at weblogic.management.deploy.slave.SlaveDeployer.prepareUpdate(SlaveDeployer.java:732)
at weblogic.drs.internal.SlaveCallbackHandler$1.execute(SlaveCallbackHandler.java:24)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:153)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:134)
>
Hi Santhosh,
Yeah , if its part of the system class path, it should find it. How are u referencing
the file? Try wrapping the code that gets the Resource and see what exception
you get.
-Raj
"Santhosh Kumar" <[email protected]> wrote:
>
>Raj, you are right. I'm trying to load the properties from within the
>that class.
>However, path (external to ear file) where I placed all those properties
>is part
>of system class path. So wl should find those property files, right?
>
>-Santhosh.
>
>"Raj" <[email protected]> wrote:
>>
>>Hi
>>Are you trying to load any property file in your startup servlet? I
>think
>>WL does
>>not extract the file "automatically" from within the war file. You should
>>probably
>>try referencing the file using some other mechanism or try loading it
>>from ur
>>EJB(as EJB JARs are loaded before WARs).
>>
>>-Raj
>>
>>
>>[email protected] (Santhosh Kumar) wrote:
>>>I have added a new startup servlet to my existing web application.
>>>While deploying the same, weblogic is throwing the following
>>>exception.
>>>
>>>I'm very sure that class (com/lbx/util/LbxProperties) is part of
>>>webapp war file I created. Can somebody please throw some light about
>>>this.
>>>
>>>I'm trying to do the .ear file deployment.
>>>
>>>Thank you very much
>>>Santhosh.
>>>
>>><Dec 30, 2002 12:04:27 PM PST> <Error> <HTTP> <101216> <Servlet:
>>>"StartupServlet" failed to preload on startup in webapp: "wliWEB"
>>>javax.servlet.ServletException: com/lbx/util/LbxProperties
>>> at weblogic.servlet.internal.ServletStubImpl.createServlet(ServletStubImpl.java:912)
>>> at weblogic.servlet.internal.ServletStubImpl.createInstances(ServletStubImpl.java:833)
>>> at weblogic.servlet.internal.ServletStubImpl.prepareServlet(ServletStubImpl.java:773)
>>> at weblogic.servlet.internal.WebAppServletContext.preloadServlet(WebAppServletContext.java:2763)
>>> at weblogic.servlet.internal.WebAppServletContext.preloadServlets(WebAppServletContext.java:2708)
>>> at weblogic.servlet.internal.WebAppServletContext.preloadResources(WebAppServletContext.java:2681)
>>> at weblogic.servlet.internal.WebAppServletContext.setStarted(WebAppServletContext.java:4746)
>>> at weblogic.servlet.internal.WebAppModule.start(WebAppModule.java:539)
>>> at weblogic.j2ee.J2EEApplicationContainer.start(J2EEApplicationContainer.java:983)
>>> at weblogic.j2ee.J2EEApplicationContainer.activate(J2EEApplicationContainer.java:1017)
>>> at weblogic.management.deploy.slave.SlaveDeployer.processPrepareTask(SlaveDeployer.java:1112)
>>> at weblogic.management.deploy.slave.SlaveDeployer.prepareUpdate(SlaveDeployer.java:732)
>>> at weblogic.drs.internal.SlaveCallbackHandler$1.execute(SlaveCallbackHandler.java:24)
>>> at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:153)
>>> at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:134)
>>>>
>>
>
-
I have added a new startup servlet to my existing web application.
While deploying the same, weblogic is throwing the following
exception.
I'm very sure that class (com/lbx/util/LbxProperties) is part of
webapp war file I created. Can somebody please throw some light about
this.
I'm trying to do the .ear file deployment.
Thank you very much
Santhosh.
<Dec 30, 2002 12:04:27 PM PST> <Error> <HTTP> <101216> <Servlet:
"StartupServlet" failed to preload on startup in webapp: "wliWEB"
javax.servlet.ServletException: com/lbx/util/LbxProperties
at weblogic.servlet.internal.ServletStubImpl.createServlet(ServletStubImpl.java:912)
at weblogic.servlet.internal.ServletStubImpl.createInstances(ServletStubImpl.java:833)
at weblogic.servlet.internal.ServletStubImpl.prepareServlet(ServletStubImpl.java:773)
at weblogic.servlet.internal.WebAppServletContext.preloadServlet(WebAppServletContext.java:2763)
at weblogic.servlet.internal.WebAppServletContext.preloadServlets(WebAppServletContext.java:2708)
at weblogic.servlet.internal.WebAppServletContext.preloadResources(WebAppServletContext.java:2681)
at weblogic.servlet.internal.WebAppServletContext.setStarted(WebAppServletContext.java:4746)
at weblogic.servlet.internal.WebAppModule.start(WebAppModule.java:539)
at weblogic.j2ee.J2EEApplicationContainer.start(J2EEApplicationContainer.java:983)
at weblogic.j2ee.J2EEApplicationContainer.activate(J2EEApplicationContainer.java:1017)
at weblogic.management.deploy.slave.SlaveDeployer.processPrepareTask(SlaveDeployer.java:1112)
at weblogic.management.deploy.slave.SlaveDeployer.prepareUpdate(SlaveDeployer.java:732)
at weblogic.drs.internal.SlaveCallbackHandler$1.execute(SlaveCallbackHandler.java:24)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:153)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:134)
>
I have added a new startup servlet to my existing web application.
While deploying the same, weblogic is throwing the following
exception.
I'm very sure that class (com/lbx/util/LbxProperties) is part of
webapp war file I created. Can somebody please throw some light about
this.
I'm trying to do the .ear file deployment.
Thank you very much
Santhosh.
<Dec 30, 2002 12:04:27 PM PST> <Error> <HTTP> <101216> <Servlet:
"StartupServlet" failed to preload on startup in webapp: "wliWEB"
javax.servlet.ServletException: com/lbx/util/LbxProperties
at weblogic.servlet.internal.ServletStubImpl.createServlet(ServletStubImpl.java:912)
at weblogic.servlet.internal.ServletStubImpl.createInstances(ServletStubImpl.java:833)
at weblogic.servlet.internal.ServletStubImpl.prepareServlet(ServletStubImpl.java:773)
at weblogic.servlet.internal.WebAppServletContext.preloadServlet(WebAppServletContext.java:2763)
at weblogic.servlet.internal.WebAppServletContext.preloadServlets(WebAppServletContext.java:2708)
at weblogic.servlet.internal.WebAppServletContext.preloadResources(WebAppServletContext.java:2681)
at weblogic.servlet.internal.WebAppServletContext.setStarted(WebAppServletContext.java:4746)
at weblogic.servlet.internal.WebAppModule.start(WebAppModule.java:539)
at weblogic.j2ee.J2EEApplicationContainer.start(J2EEApplicationContainer.java:983)
at weblogic.j2ee.J2EEApplicationContainer.activate(J2EEApplicationContainer.java:1017)
at weblogic.management.deploy.slave.SlaveDeployer.processPrepareTask(SlaveDeployer.java:1112)
at weblogic.management.deploy.slave.SlaveDeployer.prepareUpdate(SlaveDeployer.java:732)
at weblogic.drs.internal.SlaveCallbackHandler$1.execute(SlaveCallbackHandler.java:24)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:153)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:134)
>
-
CreateEntityManagerFactory() throws NullPointerException for ejb jse client
Dear experts!
I am trying to create a java standard edition client, to test outside the weblogic server, my ejb 3 entities, declared as shown in the following persistence.xml.
The java code, and stacktrace follows also. I have read about some relevant bugs in eclipselink back in 2006, or 7 or 8 and mostly unanswered threads :
CreateEntityManagerFactory null pointer exception and
Returned null to createEntityManagerFactory about tomcat and oc4j.
Persistence.createEntityManagerFactory() throw NullPointerException in oc4j
I am using JDeveloper 11g Studio Edition Version 11.1.1.3.0, Build JDEVADF_11.1.1.3.PS2_GENERIC_100408.2356.5660.
Any helping hand available?
Thank you very much in advance!
NA
package chapter12javaseclient;
import actionbazaar.buslogic.BidException;
import actionbazaar.persistence.Bid;
import actionbazaar.persistence.Bidder;
import actionbazaar.persistence.Item;
import java.util.HashMap;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
import org.eclipse.persistence.config.EntityManagerProperties;
public class PlaceBidBeanJavaSE {
private static EntityManagerFactory emf;
private static EntityManager em;
public static void main(String[] args) {
String userId= "idiot";
Long itemId = new Long (1);
Double bidPrice = 2001.50;
try {
if (emf == null){
emf = Persistence.createEntityManagerFactory("actionBazaar");
System.out.println("EntityManagerFactory created!");
getEntityManager();
System.out.println("EntityManager created!");
addBid(userId,itemId,bidPrice);
commitTransaction();
} finally {
// close the EntityManager when done
em.close();
emf.close();
private static void getEntityManager() {
HashMap emProps = new HashMap();
emProps.put(EntityManagerProperties.JDBC_USER, "ab");
emProps.put(EntityManagerProperties.JDBC_PASSWORD, "ab");
System.out.println("Creating entity manager");
em = emf.createEntityManager(emProps);
em.getTransaction().begin();
private static void commitTransaction() {
em.getTransaction().commit();
private static Long addBid(String userId, Long itemId, Double bidPrice) throws BidException {
Item item = em.find(Item.class,itemId);
if (item == null)
throw new BidException("Invalid Item Id");
Bidder bidder = em.find(Bidder.class,userId);
if (bidder == null)
throw new BidException("Invalid Bidder Id");
Bid bid = new Bid();
bid.setItem(item);
bid.setBidBidder(bidder);
bid.setBidPrice(bidPrice);
em.persist(bid);
return bid.getBidId();
<?xml version="1.0" encoding="UTF-8" ?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
version="1.0">
<persistence-unit name="actionBazaar" transaction-type="RESOURCE_LOCAL">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<class>actionbazaar.persistence.Bid</class>
<class>actionbazaar.persistence.Item</class>
<class>actionbazaar.persistence.User</class>
<class>actionbazaar.persistence.Bidder</class>
<exclude-unlisted-classes>false</exclude-unlisted-classes>
<properties>
<property name="eclipselink.target-server" value="WebLogic_10"/>
<property name="eclipselink.target-database" value="Oracle11"/>
<property name="javax.persistence.jdbc.driver"
value="oracle.jdbc.OracleDriver"/>
<property name="javax.persistence.jdbc.password"
value="ab"/>
<property name="javax.persistence.jdbc.url"
value="jdbc:oracle:thin:@hera:1521:orcl"/>
<property name="javax.persistence.jdbc.user" value="ab"/>
<property name="eclipselink.logging.level" value="ALL"/>
</properties>
</persistence-unit>
</persistence>
The log output follows:
C:\Oracle\Middleware\jdev_11gR1\jdk160_18\bin\javaw.exe -client -classpath C:\MyWork\11g\ejb3inaction\.adf;C:\MyWork\11g\ejb3inaction\Chapter12JavaSEClient\classes;C:\MyWork\11g\ejb3inaction\Chapter12\classes;C:\Oracle\Middleware\jdev_11gR1\modules\javax.ejb_3.0.1.jar;C:\Oracle\Middleware\jdev_11gR1\modules\com.oracle.toplink_1.0.0.0_11-1-1-3-0.jar;C:\Oracle\Middleware\jdev_11gR1\modules\org.eclipse.persistence_1.0.0.0_2-0.jar;C:\Oracle\Middleware\jdev_11gR1\modules\com.bea.core.antlr.runtime_2.7.7.jar;C:\Oracle\Middleware\jdev_11gR1\oracle_common\modules\oracle.toplink_11.1.1\javax.persistence_2.0_preview.jar;C:\Oracle\Middleware\jdev_11gR1\oracle_common\modules\oracle.xdk_11.1.0\xmlparserv2.jar;C:\Oracle\Middleware\jdev_11gR1\oracle_common\modules\oracle.xdk_11.1.0\xml.jar;C:\Oracle\Middleware\jdev_11gR1\modules\javax.jsf_1.0.0.0_1-2.jar;C:\Oracle\Middleware\jdev_11gR1\modules\javax.enterprise.deploy_1.2.jar;C:\Oracle\Middleware\jdev_11gR1\modules\javax.interceptor_1.0.jar;C:\Oracle\Middleware\jdev_11gR1\modules\javax.jms_1.1.1.jar;C:\Oracle\Middleware\jdev_11gR1\modules\javax.jsp_1.1.0.0_2-1.jar;C:\Oracle\Middleware\jdev_11gR1\modules\javax.jws_2.0.jar;C:\Oracle\Middleware\jdev_11gR1\modules\javax.activation_1.1.0.0_1-1.jar;C:\Oracle\Middleware\jdev_11gR1\modules\javax.mail_1.1.0.0_1-4-1.jar;C:\Oracle\Middleware\jdev_11gR1\modules\javax.xml.soap_1.3.1.0.jar;C:\Oracle\Middleware\jdev_11gR1\modules\javax.xml.rpc_1.2.1.jar;C:\Oracle\Middleware\jdev_11gR1\modules\javax.xml.ws_2.1.1.jar;C:\Oracle\Middleware\jdev_11gR1\modules\javax.management.j2ee_1.0.jar;C:\Oracle\Middleware\jdev_11gR1\modules\javax.resource_1.5.1.jar;C:\Oracle\Middleware\jdev_11gR1\modules\javax.servlet_1.0.0.0_2-5.jar;C:\Oracle\Middleware\jdev_11gR1\modules\javax.transaction_1.0.0.0_1-1.jar;C:\Oracle\Middleware\jdev_11gR1\modules\javax.xml.stream_1.1.1.0.jar;C:\Oracle\Middleware\jdev_11gR1\modules\javax.security.jacc_1.0.0.0_1-1.jar;C:\Oracle\Middleware\jdev_11gR1\modules\javax.xml.registry_1.0.0.0_1-0.jar;C:\Oracle\Middleware\jdev_11gR1\modules\javax.persistence_1.0.0.0_1-0-2.jar;C:\Oracle\Middleware\jdev_11gR1\wlserver_10.3\server\lib\weblogic.jar;C:\Oracle\Middleware\jdev_11gR1\wlserver_10.3\server\ext\jdbc\oracle\11g\ojdbc6.jar;C:\Oracle\Middleware\jdev_11gR1\oracle_common\modules\oracle.nlsrtl_11.1.0\orai18n-collation.jar;C:\Oracle\Middleware\jdev_11gR1\oracle_common\modules\oracle.nlsrtl_11.1.0\orai18n-lcsd.jar;C:\Oracle\Middleware\jdev_11gR1\oracle_common\modules\oracle.nlsrtl_11.1.0\orai18n-mapping.jar;C:\Oracle\Middleware\jdev_11gR1\oracle_common\modules\oracle.nlsrtl_11.1.0\orai18n-servlet.jar;C:\Oracle\Middleware\jdev_11gR1\oracle_common\modules\oracle.nlsrtl_11.1.0\orai18n-translation.jar;C:\Oracle\Middleware\jdev_11gR1\oracle_common\modules\oracle.nlsrtl_11.1.0\orai18n-utility.jar;C:\Oracle\Middleware\jdev_11gR1\oracle_common\modules\oracle.nlsrtl_11.1.0\orai18n.jar;C:\Oracle\Middleware\jdev_11gR1\oracle_common\modules\oracle.odl_11.1.1\ojdl.jar;C:\Oracle\Middleware\jdev_11gR1\oracle_common\modules\oracle.dms_11.1.1\dms.jar -Djavax.net.ssl.trustStore=C:\Oracle\Middleware\jdev_11gR1\wlserver_10.3\server\lib\DemoTrust.jks chapter12javaseclient.PlaceBidBeanJavaSE
[EL Finest]: 2010-06-25 09:23:10.495--ServerSession(229902)--Thread(Thread[main,5,main])--Begin predeploying Persistence Unit actionBazaar; session file:/C:/MyWork/11g/ejb3inaction/Chapter12JavaSEClient/classes/_actionBazaar; state Initial; factoryCount 0
[EL Finest]: 2010-06-25 09:23:10.518--ServerSession(229902)--Thread(Thread[main,5,main])--property=eclipselink.orm.throw.exceptions; default value=true
[EL Finer]: 2010-06-25 09:23:10.532--ServerSession(229902)--Thread(Thread[main,5,main])--Searching for default mapping file in file:/C:/MyWork/11g/ejb3inaction/Chapter12JavaSEClient/classes/
[EL Finer]: 2010-06-25 09:23:10.537--ServerSession(229902)--Thread(Thread[main,5,main])--Searching for default mapping file in file:/C:/MyWork/11g/ejb3inaction/Chapter12JavaSEClient/classes/
[EL Config]: 2010-06-25 09:23:10.652--ServerSession(229902)--Thread(Thread[main,5,main])--The access type for the persistent class [class actionbazaar.persistence.Item] is set to [PROPERTY].
[EL Config]: 2010-06-25 09:23:10.696--ServerSession(229902)--Thread(Thread[main,5,main])--The target entity (reference) class for the many to many mapping element [method getCategorySet] is being defaulted to: class actionbazaar.persistence.Category.
[EL Config]: 2010-06-25 09:23:10.702--ServerSession(229902)--Thread(Thread[main,5,main])--The target entity (reference) class for the one to many mapping element [method getBids] is being defaulted to: class actionbazaar.persistence.Bid.
[EL Config]: 2010-06-25 09:23:10.71--ServerSession(229902)--Thread(Thread[main,5,main])--The target entity (reference) class for the many to one mapping element [method getSeller] is being defaulted to: class actionbazaar.persistence.Seller.
[EL Config]: 2010-06-25 09:23:10.71--ServerSession(229902)--Thread(Thread[main,5,main])--The access type for the persistent class [class actionbazaar.persistence.User] is set to [PROPERTY].
[EL Config]: 2010-06-25 09:23:10.711--ServerSession(229902)--Thread(Thread[main,5,main])--The target entity (reference) class for the one to many mapping element [method getCategories] is being defaulted to: class actionbazaar.persistence.Category.
[EL Config]: 2010-06-25 09:23:10.716--ServerSession(229902)--Thread(Thread[main,5,main])--The target entity (reference) class for the one to one mapping element [method getBillingInfo] is being defaulted to: class actionbazaar.persistence.BillingInfo.
[EL Config]: 2010-06-25 09:23:10.717--ServerSession(229902)--Thread(Thread[main,5,main])--The target entity (reference) class for the one to one mapping element [method getContactInfo] is being defaulted to: class actionbazaar.persistence.ContactInfo.
[EL Config]: 2010-06-25 09:23:10.718--ServerSession(229902)--Thread(Thread[main,5,main])--The access type for the persistent class [class actionbazaar.persistence.Bidder] is set to [PROPERTY].
[EL Config]: 2010-06-25 09:23:10.72--ServerSession(229902)--Thread(Thread[main,5,main])--The target entity (reference) class for the one to many mapping element [method getBids] is being defaulted to: class actionbazaar.persistence.Bid.
[EL Config]: 2010-06-25 09:23:10.721--ServerSession(229902)--Thread(Thread[main,5,main])--The access type for the persistent class [class actionbazaar.persistence.Bid] is set to [PROPERTY].
[EL Config]: 2010-06-25 09:23:10.721--ServerSession(229902)--Thread(Thread[main,5,main])--The target entity (reference) class for the many to one mapping element [method getBidBidder] is being defaulted to: class actionbazaar.persistence.Bidder.
[EL Config]: 2010-06-25 09:23:10.721--ServerSession(229902)--Thread(Thread[main,5,main])--The target entity (reference) class for the many to one mapping element [method getItem] is being defaulted to: class actionbazaar.persistence.Item.
[EL Config]: 2010-06-25 09:23:10.722--ServerSession(229902)--Thread(Thread[main,5,main])--The alias name for the entity class [class actionbazaar.persistence.Item] is being defaulted to: Item.
[EL Config]: 2010-06-25 09:23:10.746--ServerSession(229902)--Thread(Thread[main,5,main])--The alias name for the entity class [class actionbazaar.persistence.Bidder] is being defaulted to: Bidder.
[EL Config]: 2010-06-25 09:23:10.746--ServerSession(229902)--Thread(Thread[main,5,main])--The alias name for the entity class [class actionbazaar.persistence.User] is being defaulted to: User.
[EL Config]: 2010-06-25 09:23:10.753--ServerSession(229902)--Thread(Thread[main,5,main])--The table name for entity [class actionbazaar.persistence.Bidder] is being defaulted to: USERS.
[EL Config]: 2010-06-25 09:23:10.753--ServerSession(229902)--Thread(Thread[main,5,main])--The discriminator column name for the root inheritance class [class actionbazaar.persistence.Bidder] is being defaulted to: DTYPE.
[EL Config]: 2010-06-25 09:23:10.755--ServerSession(229902)--Thread(Thread[main,5,main])--The primary key column name for the inheritance class [class actionbazaar.persistence.Bidder] is being defaulted to: USER_ID.
[EL Config]: 2010-06-25 09:23:10.755--ServerSession(229902)--Thread(Thread[main,5,main])--The foreign key column name for the inheritance class [class actionbazaar.persistence.Bidder] is being defaulted to: USER_ID.
[EL Config]: 2010-06-25 09:23:10.758--ServerSession(229902)--Thread(Thread[main,5,main])--The alias name for the entity class [class actionbazaar.persistence.Bid] is being defaulted to: Bid.
Exception in thread "main" java.lang.NullPointerException
at chapter12javaseclient.PlaceBidBeanJavaSE.main(PlaceBidBeanJavaSE.java:43)
Process exited with exit code 1.Thank you for your reply!
The client now works correctly. It seems that the line
em = emf.createEntityManager(emProps);//
throws an exception when no argument is given for em = emf.createEntityManager();// emProps missing!
There was also a warning in jdev editor, about the line you mentioned:
<property name="eclipselink.target-server" value="WebLogic 10"/>
Carry on with your good work!
The updated persistence.xml and java source code shown below:
<?xml version="1.0" encoding="UTF-8" ?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
version="1.0">
<persistence-unit name="actionBazaar" transaction-type="RESOURCE_LOCAL">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<class>actionbazaar.persistence.Bid</class>
<class>actionbazaar.persistence.Item</class>
<class>actionbazaar.persistence.User</class>
<class>actionbazaar.persistence.Bidder</class>
<exclude-unlisted-classes>false</exclude-unlisted-classes>
<properties>
<property name="eclipselink.target-database" value="Oracle11"/>
<property name="javax.persistence.jdbc.driver"
value="oracle.jdbc.OracleDriver"/>
<property name="javax.persistence.jdbc.password"
value="29E8BD11B89A62E3862F19C4F84B7DB0"/>
<property name="javax.persistence.jdbc.user" value="ab"/>
<property name="eclipselink.logging.level" value="ALL"/>
<property name="eclipselink.orm.validate.schema" value="true"/>
<property name="javax.persistence.jdbc.url"
value="jdbc:oracle:thin:@hera:1521:orcl"/>
</properties>
</persistence-unit>
</persistence>
package chapter12javaseclient;
import actionbazaar.buslogic.BidException;
import actionbazaar.persistence.Bid;
import actionbazaar.persistence.Bidder;
import actionbazaar.persistence.Item;
import java.util.HashMap;
import java.util.Hashtable;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
import org.eclipse.persistence.config.EntityManagerProperties;
public class PlaceBidBeanJavaSE {
private static EntityManagerFactory emf;
private static EntityManager em;
private static Hashtable emProps = new Hashtable();
public static void main(String[] args) {
String userId= "idiot";
Long itemId = new Long (2);
Double bidPrice = 2002.50;
try {
if (emf == null){
emf = Persistence.createEntityManagerFactory("actionBazaar");
System.out.println("EntityManagerFactory created!");
getEntityManager();
System.out.println("EntityManager created!");
addBid(userId,itemId,bidPrice);
commitTransaction();
} finally {
// close the EntityManager when done
em.close();
emf.close();
private static void getEntityManager() {
try {
System.out.println("Creating entity manager");
em = emf.createEntityManager(emProps);// if argument is missing exception is thrown!
em.getTransaction().begin();
} catch (Exception ne) {
// TODO: Add catch code
ne.printStackTrace();
private static void commitTransaction() {
em.getTransaction().commit();
private static Long addBid(String userId, Long itemId, Double bidPrice) throws BidException {
Item item = em.find(Item.class,itemId);
if (item == null)
throw new BidException("Invalid Item Id");
Bidder bidder = em.find(Bidder.class,userId);
if (bidder == null)
throw new BidException("Invalid Bidder Id");
Bid bid = new Bid();
bid.setItem(item);
bid.setBidBidder(bidder);
bid.setBidPrice(bidPrice);
em.persist(bid);
return bid.getBidId();
NA
[http://nickaiva.blogspot.com/] -
How long load-on-startup servlet stays in weblogic6.1 sp2
does anybody know how long a load-on-startup servlet exists (before
gets destroyed) in weblogic6.1 sp2. What i want is in load-on-startup
servlet, I want to schedule a java.util.Timer and when application
gets undeployed, i want to cancel that timer. if load-on-startup
servlet exists for the whole application life span then i could do
timer.cancel() on the destroy method of load-on-startup servlet.
any suggestion?
thanks in adv,
soumik
You can simply use ServletContextListener instead - that way you do not
have to worry if (or when) WebLogic decides to destroy the servlet.
soumik <[email protected]> wrote:
> does anybody know how long a load-on-startup servlet exists (before
> gets destroyed) in weblogic6.1 sp2. What i want is in load-on-startup
> servlet, I want to schedule a java.util.Timer and when application
> gets undeployed, i want to cancel that timer. if load-on-startup
> servlet exists for the whole application life span then i could do
> timer.cancel() on the destroy method of load-on-startup servlet.
> any suggestion?
> thanks in adv,
> soumik
Dimitri
-
Class not found for Startup servlet
I have deployed a war file under weblogic 7. The application has some startup servlets,
which are failing to load during startup. It returns the following error messages
for each servlet
####<Jan 8, 2003 2:00:25 PM CST> <Error> <HTTP> <abc-web1> <abcAppServer> <Thread-8>
<kernel identity> <> <101249> <[ServletContext(id=3959381,name=abcApps,context-path=/abcApps)]:
Servlet class com.abc.servlets.startup.StartupTSContentDaemonServlet for servlet
StartupTSContentDaemonServlet could not be loaded because the requested class
was not found in the classpath D:\bea\user_projects\abcdomain\abcAppServer\stage\abcApps\abcApps.war;D:\bea\user_projects\abcdomain\.\abcAppServer\.wlnotdelete\abcApps_abcApps_3959381\jarfiles\WEB-INF\lib\servlet2373.jar;D:\bea\user_projects\abcdomain\.\abcAppServer\.wlnotdelete\abcApps_abcApps_3959381\jarfiles\WEB-INF\lib\jbcl2374.jar;D:\bea\user_projects\abcdomain\.\abcAppServer\.wlnotdelete\abcApps_abcApps_3959381\jarfiles\WEB-INF\lib\jaxp2375.jar;D:\bea\user_projects\abcdomain\.\abcAppServer\.wlnotdelete\abcApps_abcApps_3959381\jarfiles\WEB-INF\lib\xerces2376.jar;D:\bea\user_projects\abcdomain\.\abcAppServer\.wlnotdelete\abcApps_abcApps_3959381\jarfiles\WEB-INF\lib\AS4002377.jar;D:\bea\user_projects\abcdomain\.\abcAppServer\.wlnotdelete\abcApps_abcApps_3959381\jarfiles\WEB-INF\lib\decrypt2378.jar;D:\bea\user_projects\abcdomain\.\abcAppServer\.wlnotdelete\abcApps_abcApps_3959381\jarfiles\cls2372.jar.
java.lang.UnsupportedClassVersionError: com/abc/servlets/startup/StartupTSContentDaemonServlet
(Unsupported major.minor version 48.0)>
####<Jan 8, 2003 2:00:25 PM CST> <Error> <HTTP> <abc-web1> <abcAppServer> <Thread-8>
<kernel identity> <> <101216> <Servlet: "StartupTSContentDaemonServlet" failed
to preload on startup in webapp: "abcApps">
javax.servlet.ServletException: [ServletContext(id=3959381,name=abcApps,context-path=/abcApps)]:
Servlet class com.abc.servlets.startup.StartupTSContentDaemonServlet for servlet
StartupTSContentDaemonServlet could not be loaded because the requested class
was not found in the classpath D:\bea\user_projects\abcdomain\abcAppServer\stage\abcApps\abcApps.war;D:\bea\user_projects\abcdomain\.\abcAppServer\.wlnotdelete\abcApps_abcApps_3959381\jarfiles\WEB-INF\lib\servlet2373.jar;D:\bea\user_projects\abcdomain\.\abcAppServer\.wlnotdelete\abcApps_abcApps_3959381\jarfiles\WEB-INF\lib\jbcl2374.jar;D:\bea\user_projects\abcdomain\.\abcAppServer\.wlnotdelete\abcApps_abcApps_3959381\jarfiles\WEB-INF\lib\jaxp2375.jar;D:\bea\user_projects\abcdomain\.\abcAppServer\.wlnotdelete\abcApps_abcApps_3959381\jarfiles\WEB-INF\lib\xerces2376.jar;D:\bea\user_projects\abcdomain\.\abcAppServer\.wlnotdelete\abcApps_abcApps_3959381\jarfiles\WEB-INF\lib\AS4002377.jar;D:\bea\user_projects\abcdomain\.\abcAppServer\.wlnotdelete\abcApps_abcApps_3959381\jarfiles\WEB-INF\lib\decrypt2378.jar;D:\bea\user_projects\abcdomain\.\abcAppServer\.wlnotdelete\abcApps_abcApps_3959381\jarfiles\cls2372.jar.
java.lang.UnsupportedClassVersionError: com/abc/servlets/startup/StartupTSContentDaemonServlet
(Unsupported major.minor version 48.0)
at weblogic.servlet.internal.ServletStubImpl.prepareServlet(ServletStubImpl.java:785)
at weblogic.servlet.internal.WebAppServletContext.preloadServlet(WebAppServletContext.java:2763)
at weblogic.servlet.internal.WebAppServletContext.preloadServlets(WebAppServletContext.java:2708)
at weblogic.servlet.internal.WebAppServletContext.preloadResources(WebAppServletContext.java:2681)
at weblogic.servlet.internal.HttpServer.preloadResources(HttpServer.java:552)
at weblogic.servlet.internal.WebService.preloadResources(WebService.java:476)
at weblogic.t3.srvr.ServletInitRunner$1.run(ServletInitRunner.java:50)
at weblogic.security.service.SecurityServiceManager.runAs(SecurityServiceManager.java:744)
at weblogic.t3.srvr.ServletInitRunner.run(ServletInitRunner.java:46)
at java.lang.Thread.run(Thread.java:479)
When i look into the directories weblogic created after deployment, there is a
cls2372.jar at 1 level above the web-inf folder and it has all the servlets in
the correct package structure i.e. com/abc/servlets/startup
Any idea on why this is happening or what i am doing wrong?also posting to servlet newsgroup.
"Ram" <[email protected]> wrote in message
news:[email protected]...
>
I have deployed a war file under weblogic 7. The application has somestartup servlets,
which are failing to load during startup. It returns the following errormessages
for each servlet
####<Jan 8, 2003 2:00:25 PM CST> <Error> <HTTP> <abc-web1> <abcAppServer><Thread-8>
<kernel identity> <> <101249><[ServletContext(id=3959381,name=abcApps,context-path=/abcApps)]:
Servlet class com.abc.servlets.startup.StartupTSContentDaemonServlet forservlet
StartupTSContentDaemonServlet could not be loaded because the requestedclass
was not found in the classpathD:\bea\user_projects\abcdomain\abcAppServer\stage\abcApps\abcApps.war;D:\bea
\user_projects\abcdomain\.\abcAppServer\.wlnotdelete\abcApps_abcApps_3959381
\jarfiles\WEB-INF\lib\servlet2373.jar;D:\bea\user_projects\abcdomain\.\abcAp
pServer\.wlnotdelete\abcApps_abcApps_3959381\jarfiles\WEB-INF\lib\jbcl2374.j
ar;D:\bea\user_projects\abcdomain\.\abcAppServer\.wlnotdelete\abcApps_abcApp
s_3959381\jarfiles\WEB-INF\lib\jaxp2375.jar;D:\bea\user_projects\abcdomain\.
\abcAppServer\.wlnotdelete\abcApps_abcApps_3959381\jarfiles\WEB-INF\lib\xerc
es2376.jar;D:\bea\user_projects\abcdomain\.\abcAppServer\.wlnotdelete\abcApp
s_abcApps_3959381\jarfiles\WEB-INF\lib\AS4002377.jar;D:\bea\user_projects\ab
cdomain\.\abcAppServer\.wlnotdelete\abcApps_abcApps_3959381\jarfiles\WEB-INF
\lib\decrypt2378.jar;D:\bea\user_projects\abcdomain\.\abcAppServer\.wlnotdel
ete\abcApps_abcApps_3959381\jarfiles\cls2372.jar.
java.lang.UnsupportedClassVersionError:com/abc/servlets/startup/StartupTSContentDaemonServlet
(Unsupported major.minor version 48.0)>
####<Jan 8, 2003 2:00:25 PM CST> <Error> <HTTP> <abc-web1> <abcAppServer><Thread-8>
<kernel identity> <> <101216> <Servlet: "StartupTSContentDaemonServlet"failed
to preload on startup in webapp: "abcApps">
javax.servlet.ServletException:[ServletContext(id=3959381,name=abcApps,context-path=/abcApps)]:
Servlet class com.abc.servlets.startup.StartupTSContentDaemonServlet forservlet
StartupTSContentDaemonServlet could not be loaded because the requestedclass
was not found in the classpathD:\bea\user_projects\abcdomain\abcAppServer\stage\abcApps\abcApps.war;D:\bea
\user_projects\abcdomain\.\abcAppServer\.wlnotdelete\abcApps_abcApps_3959381
\jarfiles\WEB-INF\lib\servlet2373.jar;D:\bea\user_projects\abcdomain\.\abcAp
pServer\.wlnotdelete\abcApps_abcApps_3959381\jarfiles\WEB-INF\lib\jbcl2374.j
ar;D:\bea\user_projects\abcdomain\.\abcAppServer\.wlnotdelete\abcApps_abcApp
s_3959381\jarfiles\WEB-INF\lib\jaxp2375.jar;D:\bea\user_projects\abcdomain\.
\abcAppServer\.wlnotdelete\abcApps_abcApps_3959381\jarfiles\WEB-INF\lib\xerc
es2376.jar;D:\bea\user_projects\abcdomain\.\abcAppServer\.wlnotdelete\abcApp
s_abcApps_3959381\jarfiles\WEB-INF\lib\AS4002377.jar;D:\bea\user_projects\ab
cdomain\.\abcAppServer\.wlnotdelete\abcApps_abcApps_3959381\jarfiles\WEB-INF
\lib\decrypt2378.jar;D:\bea\user_projects\abcdomain\.\abcAppServer\.wlnotdel
ete\abcApps_abcApps_3959381\jarfiles\cls2372.jar.
java.lang.UnsupportedClassVersionError:com/abc/servlets/startup/StartupTSContentDaemonServlet
(Unsupported major.minor version 48.0)
atweblogic.servlet.internal.ServletStubImpl.prepareServlet(ServletStubImpl.jav
a:785)
atweblogic.servlet.internal.WebAppServletContext.preloadServlet(WebAppServletC
ontext.java:2763)
atweblogic.servlet.internal.WebAppServletContext.preloadServlets(WebAppServlet
Context.java:2708)
atweblogic.servlet.internal.WebAppServletContext.preloadResources(WebAppServle
tContext.java:2681)
atweblogic.servlet.internal.HttpServer.preloadResources(HttpServer.java:552)
atweblogic.servlet.internal.WebService.preloadResources(WebService.java:476)
at weblogic.t3.srvr.ServletInitRunner$1.run(ServletInitRunner.java:50)
atweblogic.security.service.SecurityServiceManager.runAs(SecurityServiceManage
r.java:744)
at weblogic.t3.srvr.ServletInitRunner.run(ServletInitRunner.java:46)
at java.lang.Thread.run(Thread.java:479)
When i look into the directories weblogic created after deployment, thereis a
cls2372.jar at 1 level above the web-inf folder and it has all theservlets in
the correct package structure i.e. com/abc/servlets/startup
Any idea on why this is happening or what i am doing wrong? -
Problem setting up startup servlets in iWS 4.x
I have configured iPlanet Web Server(iWS) 4.1 SP9 to use a startup servlet. However, the error log does not show that the servlet has been initialized. Instead, it shows only the following entries:
Loading Simple Session Manager by default. Specify MMapSessionManager in servlets.properties to load persistent session manager
I found in the Knowledgebase that we need to copy the the configuration entry that was created in context.properties file into the servlets.properties file
My question that ...do we need to copy all the contents of the context.properties file or some portion of that file to servlets.properties .
Please suggest asap, I cant take a risk as this is a live server.
Thanks.Hi,
You need not to copy entry file. In your servlets.properties file at the end of the file you can see the parameters settings of servlet which you have been configured as a servlet.
For example the below setting are for "HelloWorldServlet" servlet configuration. You need to copy that line only.
servlet.HelloWorldServlet.classpath=/export/home/41sp9/docs/servlet
servlet.HelloWorldServlet.code=HelloWorldServlet.class
Note: Make sure that before changing(copying)any changes in file take backup of the old file(present).
Regards,
Dakshin.
Developer Technical Support
Sun Microsystems
http://www.sun.com/developers/support. -
Load on startup servlet and references
Weblogic 6.1 SP2
No jars specified in the classpath. A Singleton is located in a utility.jar file
inside a .ear file.
If I create a Singleton from a load on startup servlet, how long will the singleton
be around? I know that if I undeploy the application, the singleton will be destroyed
since the classloader is unloaded. However, if I never undeploy my application,
will the Singleton always be around? Does Weblogic keep a reference alive to
this Singleton forever?
Please provide some more details on this!
Thanks.
Dan
Dan Baumbach wrote:
> So, because the startup servlet has a static reference to the singleton, the servlet
> will never be garbage collected?
Correct.
>
>
> What if there's a class that is not a singleton, but there are static methods.
> How would garbage collection work in this case?
>
A class object is not an instance object. If the class object has been loaded by the
classloader, it will not be unloaded or garbage collected, regardless of whether or not
it has static methods. If an instance of a class is instatiated on the heap, and a
reference to that object is placed in a static member of its associated class object,
also referred to as a class member, then the instance will not be garbage collected.
>
> Thanks.
> Dan
>
> William Kemp <[email protected]> wrote:
> >The jvm will not garbage collect an object that has a static reference
> >to it. Which is how
> >I am assuming you have implemented the singleton.
> >
> >Bill
> >
> >Dan Baumbach wrote:
> >
> >> Weblogic 6.1 SP2
> >> No jars specified in the classpath. A Singleton is located in a utility.jar
> >file
> >> inside a .ear file.
> >>
> >> If I create a Singleton from a load on startup servlet, how long will
> >the singleton
> >> be around? I know that if I undeploy the application, the singleton
> >will be destroyed
> >> since the classloader is unloaded. However, if I never undeploy my
> >application,
> >> will the Singleton always be around? Does Weblogic keep a reference
> >alive to
> >> this Singleton forever?
> >>
> >> Please provide some more details on this!
> >> Thanks.
> >> Dan
> >
-
"load-on-startup" servlet configuration
Dear All,
I am trying to load a servlet "SettingServlet" at the startup of the application, the configuration I am using inside the web.xml file is as following:
<web-app>
<servlet>
<servlet-name>SettingsServlet</servlet-name>
<servlet-class>com.myPack.SettingsServlet</servlet-class>
<init-param>
<param-name>fichierConfig</param-name>
<param-value>D:/tomcat41/webapps/init.conf</param-value>
</init-param>
<load-on-startup>5</load-on-startup>
</servlet>
</web-app>
It seems that the "SettingsServlet" servlet is not started at the startup.Even it's started in the tomcat window I am getting something like
(SEVERE: Parse error at line......column...:Element type ....not declared ..)
and that for the servlet-name, parma-name,servlet-class, init-param...etc
Do I missed something in the configuration?, please tcheck the few lines above. because Simply I got stuck ! ,,,,,Please help me to fix it, I am waiting for you reply guys.
Thanks and Regards,
kifwetTake a look at the header of your web.xml file, the part about:<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd"> And go check the dtd for your version.
Some versions are very picky about the order of parameters.
Hope this helps. -
Private Room throws NullPointerException
Hi,
I have created a private room and it was sucessfull. i am able to see the room without any problem. but when others(non-members) go to their rooms directory, it throws NullPointerException. This problem is only for private rooms only.
we are using SP 17
The exception is
java.lang.NullPointerException
at com.sap.ip.collaboration.roomui.api.util.properties.RoomResourceProperties.getPropertyValueAsString(RoomResourceProperties.java:53)
at com.sap.ip.collaboration.roomui.api.util.properties.RoomResourceProperties.getRoomPrivacy(RoomResourceProperties.java:33)
at com.sap.netweaver.coll.roomui.api.uicommands.UIRequestMembershipCommand.isExecutable(UIRequestMembershipCommand.java:67)
at com.sapportals.wcm.rendering.uicommand.UIGroupCommand.getResourceCommands(UIGroupCommand.java:78)
at ..............
can anyone reply what might be the reason be?
Thank you.
Saravana.
Edited by: Saravana Parthiban Palaniswamy on Feb 4, 2009 1:22 PM
Edited by: Saravana Parthiban Palaniswamy on Feb 4, 2009 1:26 PMHi,
If u goes to room directory in collaboration, there is a tab called Restricted Rooms. End of the room name there is context menu if u click that, it will show the menu there you can see the option called Request Membership. If you click that, corresponding room owner will receive the mail if he/she enabled the mail properties.
If the answer helps your Question, provide the points.
Regards,
Kathiresan R -
Startup servlet problem in weblogic81
Hi
I created one web application in weblogic81 and it contains one servlet and act as startup servlet.When i m trying to get jndi context to connect to DataSource in init method, i m getting the following exception
javax.naming.CommunicationException [Root exception is java.net.ConnectException: t3://16.138.181.88:7501: Dest
ination unreachable; nested exception is:
java.net.ConnectException: Connection refused; No available router to de
stination]
init method
Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
env.put(Context.PROVIDER_URL,"t3://16.138.181.88:7501" );
jndiContext = new InitialContext(env);
web.xml
<servlet>
<servlet-name>MyServlet</servlet-name>
<servlet-class>com.MyServlet</servlet-class>
<load-on-startup>0</load-on-startup>
</servlet>
Please help me out.
Regards
ChandraTo use the /servlet/ notaton you will need to enable the invoker servlet. To do this open the conf/web.xml and search on "invoker". Follow the directions.
An alternative would be to map the servlet to a url and use that url to call the servlet
<servlet>
<servlet-name>TestServlet</servlet-name>
<servlet-class>TestServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>TestServlet</servlet-name>
<url-pattern>/TestServlet</url-pattern>
</servlet-mapping>
now you should be able to access the servlet with /Fortune/TestServlet -
CreateEntityManagerFactory throws NullPointerException for ejb3 jse client
This question has been posted to the Toplink/jpa forum without any reply.
Dear experts!
I am trying to create a java standard edition client, to test outside the weblogic server, my ejb 3 entities, declared as shown in the following persistence.xml.
The java code follows also. I have read about some relevant bugs in eclipselink back in 2006, or 7 or 8 and mostly unanswered threads :
CreateEntityManagerFactory null pointer exception and
Returned null to createEntityManagerFactory about tomcat and oc4j.
Persistence.createEntityManagerFactory() throw NullPointerException in oc4j
I am using JDeveloper 11g Studio Edition Version 11.1.1.3.0, Build JDEVADF_11.1.1.3.PS2_GENERIC_100408.2356.5660.
Any helping hand available?
Thank you very much in advance!
NA
package chapter12javaseclient;
import actionbazaar.buslogic.BidException;
import actionbazaar.persistence.Bid;
import actionbazaar.persistence.Bidder;
import actionbazaar.persistence.Item;
import java.util.HashMap;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
import org.eclipse.persistence.config.EntityManagerProperties;
public class PlaceBidBeanJavaSE {
private static EntityManagerFactory emf;
private static EntityManager em;
public static void main(String[] args) {
String userId= "idiot";
Long itemId = new Long (1);
Double bidPrice = 2001.50;
try {
if (emf == null){
emf = Persistence.createEntityManagerFactory("actionBazaar");
System.out.println("EntityManagerFactory created!");
getEntityManager();
System.out.println("EntityManager created!");
addBid(userId,itemId,bidPrice);
commitTransaction();
} finally {
// close the EntityManager when done
em.close();
emf.close();
private static void getEntityManager() {
HashMap emProps = new HashMap();
emProps.put(EntityManagerProperties.JDBC_USER, "ab");
emProps.put(EntityManagerProperties.JDBC_PASSWORD, "ab");
System.out.println("Creating entity manager");
em = emf.createEntityManager(emProps);
em.getTransaction().begin();
private static void commitTransaction() {
em.getTransaction().commit();
private static Long addBid(String userId, Long itemId, Double bidPrice) throws BidException {
Item item = em.find(Item.class,itemId);
if (item == null)
throw new BidException("Invalid Item Id");
Bidder bidder = em.find(Bidder.class,userId);
if (bidder == null)
throw new BidException("Invalid Bidder Id");
Bid bid = new Bid();
bid.setItem(item);
bid.setBidBidder(bidder);
bid.setBidPrice(bidPrice);
em.persist(bid);
return bid.getBidId();
<?xml version="1.0" encoding="UTF-8" ?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
version="1.0">
<persistence-unit name="actionBazaar" transaction-type="RESOURCE_LOCAL">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<class>actionbazaar.persistence.Bid</class>
<class>actionbazaar.persistence.Item</class>
<class>actionbazaar.persistence.User</class>
<class>actionbazaar.persistence.Bidder</class>
<exclude-unlisted-classes>false</exclude-unlisted-classes>
<properties>
<property name="eclipselink.target-server" value="WebLogic_10"/>
<property name="eclipselink.target-database" value="Oracle11"/>
<property name="javax.persistence.jdbc.driver"
value="oracle.jdbc.OracleDriver"/>
<property name="javax.persistence.jdbc.password"
value="ab"/>
<property name="javax.persistence.jdbc.url"
value="jdbc:oracle:thin:@hera:1521:orcl"/>
<property name="javax.persistence.jdbc.user" value="ab"/>
<property name="eclipselink.logging.level" value="ALL"/>
</properties>
</persistence-unit>
</persistence>A solution might be found here:
Re: createEntityManagerFactory() throws NullPointerException for ejb jse client
Re: createEntityManagerFactory() throws NullPointerException for ejb jse client
NA
[http://nickaiva.blogspot.com/] -
My servlet throws java.lang.NullPointerException when calling service()
i can't determine which part exactly is null and the exception log is:
Jun 28, 2009 1:28:11 AM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet CheckLog threw exception
java.lang.NullPointerException
at LoginSer.processRequest(LoginSer.java:37)
at LoginSer.doPost(LoginSer.java:85)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:368)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Thread.java:619)
and here is the code can anyone help me please:
import java.io.*;
import java.net.*;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import com.microsoft.sqlserver.jdbc.*;
import javax.servlet.*;
import javax.servlet.http.*;
import javax.xml.ws.Dispatch;
public class RegForm extends HttpServlet {
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");
PrintWriter out = response.getWriter();
String fName=request.getParameter("fName");
String lName=request.getParameter("lName");
String addr=request.getParameter("address");
int x=0;
if(!(fName.equals(null) && lName.equals(null) && addr.equals(null))){
try {
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
String url="jdbc:sqlserver://localhost:1433;databaseName=MyDB1;userName=sa;password=iszecson;";
Connection conn=DriverManager.getConnection(url);
Statement st=conn.createStatement();
//System.out.println("----> "+conn.toString());
int rs=st.executeUpdate("insert into Employee (FirstName,LastName,Address) values ('"+fName+"','"+lName+"','"+addr+"')");
x=rs;
} catch (Exception ex) {
ex.printStackTrace();
out.println("<html>");
out.println("<head>");
out.println("<title>Added</title>");
out.println("</head>");
out.println("<body>");
out.println(x+" rows affected");
out.println("</body>");
out.println("</html>");
out.close();
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
}abulseed wrote:
if(!(fName.equals(null) && lName.equals(null) && addr.equals(null))){
Is this line 37?
If so, if any of fName, lName or addr are null you will get a NullPointerException.
This is not how you check whether something is null.
Use '=='. -
Edit locally throws NullPointerException
Hi All,
While doing EditLocally in a Custom Repository Manager,it throws a null pointer Exception.
As per the Repository Manager Implementation
log ,we dont any exception. So as there is no such relevent error realted to repository manager in default.trc file.
RF doesnt pass call to setContent() method of ContentManager.
We failed to do so in Nw04 SPS11 and Nw04 SPS14.
Where as we can able to edit successfully in NW04 SPS09.
Regards
Arati
Following is the stack trace we got in iview of edit locally
Please wait
Your request is being processed
System Error
An exception occurred during the program execution. Below you will find technical information pertaining to this exception that you might want to forward to your system administrator.
Exception Class
Call Stack java.lang.NullPointerException
at com.sapportals.wcm.control.edit.ResourceClientSideEditControl.renderLockedByUser(ResourceClientSideEditControl.java:1029)
at com.sapportals.wcm.control.edit.ResourceClientSideEditControl.renderIsLockedByOther(ResourceClientSideEditControl.java:344)
at com.sapportals.wcm.control.edit.ResourceClientSideEditControl.renderCurrentConditions(ResourceClientSideEditControl.java:302)
at com.sapportals.wcm.control.edit.ResourceClientSideEditControl.render(ResourceClientSideEditControl.java:191)
at com.sapportals.wdf.layout.HorizontalLayout.renderControls(HorizontalLayout.java:42)
at com.sapportals.wdf.stack.Pane.render(Pane.java:155)
at com.sapportals.wdf.stack.PaneStack.render(PaneStack.java:67)
at com.sapportals.wdf.layout.HorizontalLayout.renderPanes(HorizontalLayout.java:73)
at com.sapportals.wdf.stack.Pane.render(Pane.java:158)
at com.sapportals.wdf.stack.PaneStack.render(PaneStack.java:67)
at com.sapportals.wdf.layout.HorizontalLayout.renderPanes(HorizontalLayout.java:73)
at com.sapportals.wdf.stack.Pane.render(Pane.java:158)
at com.sapportals.wdf.stack.PaneStack.render(PaneStack.java:67)
at com.sapportals.wdf.layout.HorizontalLayout.renderPanes(HorizontalLayout.java:73)
at com.sapportals.wdf.stack.Pane.render(Pane.java:158)
at com.sapportals.wdf.stack.PaneStack.render(PaneStack.java:67)
at com.sapportals.wdf.WdfCompositeController.internalRender(WdfCompositeController.java:696)
at com.sapportals.wdf.WdfCompositeController.buildComposition(WdfCompositeController.java:664)
at com.sapportals.htmlb.AbstractCompositeComponent.preRender(AbstractCompositeComponent.java:33)
at com.sapportals.htmlb.Container.preRender(Container.java:118)
at com.sapportals.htmlb.Container.preRender(Container.java:118)
at com.sapportals.htmlb.Container.preRender(Container.java:118)
at com.sapportals.portal.htmlb.PrtContext.render(PrtContext.java:413)
at com.sapportals.htmlb.page.DynPage.doOutput(DynPage.java:237)
at com.sapportals.wcm.portal.component.base.KMControllerDynPage.doOutput(KMControllerDynPage.java:130)
at com.sapportals.htmlb.page.PageProcessor.handleRequest(PageProcessor.java:129)
at com.sapportals.portal.htmlb.page.PageProcessorComponent.doContent(PageProcessorComponent.java:134)
at com.sapportals.wcm.portal.component.base.ControllerComponent.doContent(ControllerComponent.java:73)
at com.sapportals.portal.prt.component.AbstractPortalComponent.doRefresh(AbstractPortalComponent.java:355)
at com.sapportals.portal.prt.component.AbstractPortalComponent.serviceDeprecated(AbstractPortalComponent.java:188)
at com.sapportals.portal.prt.component.AbstractPortalComponent.service(AbstractPortalComponent.java:114)
at com.sapportals.portal.prt.core.PortalRequestManager.callPortalComponent(PortalRequestManager.java:328)
at com.sapportals.portal.prt.core.PortalRequestManager.dispatchRequest(PortalRequestManager.java:136)
at com.sapportals.portal.prt.core.PortalRequestManager.dispatchRequest(PortalRequestManager.java:189)
at com.sapportals.portal.prt.component.PortalComponentResponse.include(PortalComponentResponse.java:215)
at com.sapportals.portal.pb.IviewModeProxy.doContent(IviewModeProxy.java:20)
at com.sapportals.portal.prt.component.AbstractPortalComponent.serviceDeprecated(AbstractPortalComponent.java:209)
at com.sapportals.portal.prt.component.AbstractPortalComponent.service(AbstractPortalComponent.java:114)
at com.sapportals.portal.prt.core.PortalRequestManager.callPortalComponent(PortalRequestManager.java:328)
at com.sapportals.portal.prt.core.PortalRequestManager.dispatchRequest(PortalRequestManager.java:136)
at com.sapportals.portal.prt.core.PortalRequestManager.dispatchRequest(PortalRequestManager.java:189)
at com.sapportals.portal.prt.component.PortalComponentResponse.include(PortalComponentResponse.java:215)
at com.sapportals.portal.prt.pom.PortalNode.service(PortalNode.java:646)
at com.sapportals.portal.prt.core.PortalRequestManager.callPortalComponent(PortalRequestManager.java:328)
at com.sapportals.portal.prt.core.PortalRequestManager.dispatchRequest(PortalRequestManager.java:136)
at com.sapportals.portal.prt.core.PortalRequestManager.dispatchRequest(PortalRequestManager.java:189)
at com.sapportals.portal.prt.core.PortalRequestManager.runRequestCycle(PortalRequestManager.java:753)
at com.sapportals.portal.prt.connection.ServletConnection.handleRequest(ServletConnection.java:240)
at com.sapportals.portal.prt.dispatcher.Dispatcher$doService.run(Dispatcher.java:522)
at java.security.AccessController.doPrivileged(Native Method)
at com.sapportals.portal.prt.dispatcher.Dispatcher.service(Dispatcher.java:405)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at com.sap.engine.services.servlets_jsp.server.servlet.InvokerServlet.service(InvokerServlet.java:156)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.runServlet(HttpHandlerImpl.java:390)
at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.handleRequest(HttpHandlerImpl.java:264)
at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:347)
at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:325)
at com.sap.engine.services.httpserver.server.RequestAnalizer.invokeWebContainer(RequestAnalizer.java:887)
at com.sap.engine.services.httpserver.server.RequestAnalizer.handle(RequestAnalizer.java:241)
at com.sap.engine.services.httpserver.server.Client.handle(Client.java:92)
at com.sap.engine.services.httpserver.server.Processor.request(Processor.java:148)
at com.sap.engine.core.service630.context.cluster.session.ApplicationSessionMessageListener.process(ApplicationSessionMessageListener.java:33)
at com.sap.engine.core.cluster.impl6.session.MessageRunner.run(MessageRunner.java:41)
at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37)
at java.security.AccessController.doPrivileged(Native Method)
at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:95)
at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:160)
Report ErrorSome more behavior of this problem
1)when try to edit locally>file download started and open the file in approprite application>and in the KM iview got the null pointer exception(which usually have check in now, check in later, cancel local editing buttons)
2) When resume local editing...nothing happens. Even doesnt through error in iview
3) when do a lock explicitly to any document- through selection->lock,it puts a check_out_by_me symbol rather than lock_by_me symbol
Please any body help to resolve the issue,
Regards
arati -
Session expired in Servlet, JasperException, NullPointerException
Hi,
I get an exception on line "rd.forward(request,response);" when session is expired and so null as you can see in the stack trace. First time, session is null and I don't get an exception. if my session is not expired, it's going in the "else" block and it's works. However, as soon as my session expires, I get the exception as described in my first sentence and as you can see just bellow.
I really don't understand why and hope someone could help me.
I'm using jdk1.5 with Tomcat 5.5
Thanks in advance
Etienne.
public void doPost(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException
try
HttpSession session = request.getSession(false);
int action = Integer.parseInt(request.getParameter(ATTR_ACTION));
String url = urlLogin;
if(session == null)
session = request.getSession(true);
session.setAttribute(ATTR_ERROR,"true");
session.setAttribute(ATTR_MESSAGE,MESSAGE_SESSION_EXPIRED);
else
// my code
RequestDispatcher rd = request.getRequestDispatcher(url);
rd.forward(request,response);
catch(Exception ex)
ex.printStackTrace();
3 mai 2005 15:27:11 org.apache.catalina.core.ApplicationDispatcher invoke
GRAVE: "Servlet.service()" pour la servlet jsp a lanc� une exception
java.lang.NullPointerException
at org.apache.jsp.webcose_jsp._jspService(org.apache.jsp.webcose_jsp:96)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:99)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:325)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:245)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:673)
at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:464)
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:399)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:302)
at controller.WebcoseController.doPost(WebcoseController.java:2771)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:825)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:738)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:526)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Unknown Source)
3 mai 2005 15:27:11 org.apache.catalina.core.StandardWrapperValve invoke
GRAVE: "Servlet.service()" pour la servlet jsp a g�n�r� une exception
java.lang.NullPointerException
at org.apache.jsp.webcose_jsp._jspService(org.apache.jsp.webcose_jsp:96)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:99)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:325)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:245)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:825)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:738)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:526)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Unknown Source)The error happens in your JSP file that you forwarded the request to, not in the code you posted.
java.lang.NullPointerException
at org.apache.jsp.webcose_jsp._jspService(org.apache.jsp.webcose_jsp:96)
You need to go diagnose the code there and see where you're using an object whose value is null.
Maybe you are looking for
-
Making one of dashboard page default
Hi Experts, Im using OBIEE 10.1.3.3 wherein i have dashboard which contains 4 pages. When i login to this Dashboard i should see 2nd page as default instead of 1st page. I dont want to reorder them by going to dashboard properties and making 2nd page
-
Bridge has been flawless until the last couple days where it now crashes with teh message "You're running low on memory." Then it crashes. More info: For the last few weeks I've been shooting a lot with large RAW files. The problem began when it woul
-
Can I download but wait to install Lion?
I am eligible for the free up-to-date download of Lion. Of course, that expires in under 30 days now. Since I'd like to wait before installing the first release of Lion, can I download it now but wait to install it? Will it just sit in my downloads f
-
Has anyone seen any kind of acknowledgment from Apple that there even is a problem? It is clear from the outcry across this and other boards that this latest version is negatively affecting a considerable amount of users. But I still haven't seen App
-
How do get rid of duplicate ppc apps on launch pad?
How do get rid of duplicate ppc apps on launch pad?